rasdaman API
miterf.hh
Go to the documentation of this file.
1 /*
2 * This file is part of rasdaman community.
3 *
4 * Rasdaman community is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * Rasdaman community is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
31 #ifndef _D_MITERF_
32 #define _D_MITERF_
33 
34 class r_Minterval;
35 
36 
37 #include "raslib/mddtypes.hh"
38 
39 class r_FixedPointNumber
40 {
41 public:
42  inline r_FixedPointNumber();
43  inline r_FixedPointNumber(const double&);
44 
45  inline r_FixedPointNumber& operator=(const r_FixedPointNumber&);
46  inline r_FixedPointNumber& operator=(const double&);
47 
48  // returns intPart_new - intPart_old -- used for tests
49  inline r_Range stepForward(const r_FixedPointNumber&);
50 
51  // returns carry of fracPart
52  inline bool stepForwardFlag(const r_FixedPointNumber&);
53 
54  inline r_Range getIntPart();
55 
56 private:
57  inline void init(const double&);
58 
59  r_Range intPart;
60  r_Range fracPart;
61 
62  static const int FIXPREC;
63  static const r_Range carryPos;
64  static const r_Range fracMask;
65  static const double fixOne;
66 
67  friend std::ostream& operator<<(std::ostream&,r_FixedPointNumber&);
68 };
69 
70 
71 
72 //@ManMemo: Module: {\bf raslib}
73 
74 /*@Doc:
75  r_MiterFloat is used for iterating through parts of
76  multidimensional intervals with arbitrary stepping size using
77  nearest neighbours. It is given the tile, the source domain
78  and the destination domain
79  Apart from that behaviour is exactly as in r_Miter.
80 
81 */
82 
83 class r_MiterFloat
84 {
85 public:
87  inline r_MiterFloat(Tile *sourceTile, r_Minterval& sourceDomain, r_Minterval& destDomain);
88 
90  inline ~r_MiterFloat();
91 
93  inline void reset();
94 
96  inline char* nextCell();
97 
99  inline bool isDone();
100 
101 protected:
102  struct iter_desc
103  {
104  r_FixedPointNumber min;
105  r_FixedPointNumber pos;
106  r_FixedPointNumber step;
107 
108  r_Range countSteps;
109  r_Range maxSteps;
110 
111  r_Range dimStep;
112  r_Range scaleStep;
113  char *cell;
114  };
115 
116  r_Dimension dim;
117  char *currentCell;
118  const char *firstCell;
119 
120  iter_desc *iterDesc;
121 
122  bool done;
123 };
124 
125 
126 #include "miterf.icc"
127 
128 #endif