IsoEx
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
Grid.hh
1 /*===========================================================================*\
2  * *
3  * IsoEx *
4  * Copyright (C) 2002 by Computer Graphics Group, RWTH Aachen *
5  * www.rwth-graphics.de *
6  * *
7  *---------------------------------------------------------------------------*
8  * *
9  * License *
10  * *
11  * This library is free software; you can redistribute it and/or modify it *
12  * under the terms of the GNU Library General Public License as published *
13  * by the Free Software Foundation, version 2. *
14  * *
15  * This library is distributed in the hope that it will be useful, but *
16  * WITHOUT ANY WARRANTY; without even the implied warranty of *
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
18  * Library General Public License for more details. *
19  * *
20  * You should have received a copy of the GNU Library General Public *
21  * License along with this library; if not, write to the Free Software *
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
23  * *
24 \*===========================================================================*/
25 
26 //=============================================================================
27 //
28 // CLASS Grid
29 //
30 //=============================================================================
31 
32 
33 #ifndef ISOEX_GRIDBASE_HH
34 #define ISOEX_GRIDBASE_HH
35 
36 
37 //== INCLUDES =================================================================
38 
39 #include <OpenMesh/Core/Geometry/VectorT.hh>
40 #include <vector>
41 
42 #include <IsoEx/Config/IsoExDefines.hh>
43 
44 //== NAMESPACES ===============================================================
45 
46 namespace IsoEx {
47 
48 //== CLASS DEFINITION =========================================================
49 
50 
57 template< class VectorType >
58 class ISOEXDLLEXPORT Grid
59 {
60 public:
61 
62  //-------------------------------------------------------------- public types
63 
64  typedef VectorType Vec3;
65  typedef typename VectorType::value_type real;
66 
67 
69  typedef unsigned int CubeIdx;
70 
72  typedef unsigned int PointIdx;
73 
74 
80  {
81  public:
85  CubeIterator(unsigned int _idx) : idx_(_idx) {}
87  CubeIdx& operator*() { return idx_; }
89  CubeIdx* operator->() { return &idx_; }
91  bool operator==(const CubeIterator& _rhs) const { return idx_==_rhs.idx_;}
93  bool operator!=(const CubeIterator& _rhs) const { return !(*this==_rhs); }
95  CubeIterator& operator++() { ++idx_; return *this; }
96  private:
97  unsigned int idx_;
98  };
99 
100 
101 
102  //------------------------------------------------------------ public methods
103 
104 
106  Grid() {}
108  virtual ~Grid() {}
109 
110 
111 
113 
114 
116  CubeIterator begin() const { return CubeIterator(0); }
117 
119  CubeIterator end() const { return CubeIterator(n_cubes()); }
120 
122 
123 
124  //------------------------------------------------ abstract virtual interface
125 
126 
128 
129 
131  virtual unsigned int n_cubes() const = 0;
132 
134  virtual unsigned int n_points() const = 0;
135 
137  virtual PointIdx point_idx(CubeIdx _idx, unsigned char _corner) const = 0;
138 
140  virtual Vec3 point(PointIdx _idx) const = 0;
141 
143  virtual bool is_inside(PointIdx _pidx) const = 0;
144 
146  virtual real scalar_distance(PointIdx _pidx) const = 0;
147 
149  virtual bool directed_distance(const Vec3& _p0,
150  const Vec3& _p1,
151  Vec3& _point,
152  Vec3& _normal,
153  real& _distance) const = 0;
155 };
156 
157 
158 //=============================================================================
159 } // namespace IsoEx
160 //=============================================================================
161 #endif // ISOEX_GRIDBASE_HH defined
162 //=============================================================================
CubeIterator end() const
Returns end iterator for the grid's cubes.
Definition: Grid.hh:119
CubeIterator begin() const
Returns begin iterator for the grid's cubes.
Definition: Grid.hh:116
unsigned int PointIdx
The grid points can be referred to by PointIdx.
Definition: Grid.hh:72
CubeIterator(unsigned int _idx)
Definition: Grid.hh:85
Grid()
Default constructor.
Definition: Grid.hh:106
virtual ~Grid()
Destructor.
Definition: Grid.hh:108
CubeIterator & operator++()
Pre-increment.
Definition: Grid.hh:95
Definition: Grid.hh:79
bool operator!=(const CubeIterator &_rhs) const
Comparison.
Definition: Grid.hh:93
bool operator==(const CubeIterator &_rhs) const
Comparison.
Definition: Grid.hh:91
CubeIdx & operator*()
Get cube index from iterator.
Definition: Grid.hh:87
A type for volume images, or 3D textures.
unsigned int CubeIdx
CubeIdx can be used to refer to cubes.
Definition: Grid.hh:69
CubeIdx * operator->()
Get cube index from iterator.
Definition: Grid.hh:89
Definition: Grid.hh:58