IsoEx
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
VectorFieldT.hh
1 //=============================================================================
2 //
3 // CLASS VectorFieldT
4 //
5 // Author: Dominik Sibbing <sibbing@cs.rwth-aachen.de>
6 //
7 // Version: $Revision: 1$
8 // Date: $Date: 2008$
9 //
10 //=============================================================================
11 
12 
13 #ifndef ACG_VECTORFIELDT_HH
14 #define ACG_VECTORFIELDT_HH
15 
16 
17 //== INCLUDES =================================================================
18 
19 #include <OpenMesh/Core/Geometry/VectorT.hh>
20 
21 #include "RegularGrid.hh"
22 
23 //== FORWARDDECLARATIONS ======================================================
24 
25 //== NAMESPACES ===============================================================
26 
27 namespace IsoEx
28 {
29 
30 //== CLASS DEFINITION =========================================================
31 
32 
33 
34 
42 template <typename Scalar, int Dim>
43 class VectorFieldT : public RegularGrid
44 {
45 public:
46 
47  typedef OpenMesh::VectorT<Scalar, Dim> Vector;
48 
50  VectorFieldT( const Vec3& _origin = Vec3( 0, 0, 0 ),
51  const Vec3& _x_axis = Vec3( 1, 0, 0 ),
52  const Vec3& _y_axis = Vec3( 0, 1, 0 ),
53  const Vec3& _z_axis = Vec3( 0, 0, 1 ),
54  unsigned int _x_res = 10,
55  unsigned int _y_res = 10,
56  unsigned int _z_res = 10 )
57  {
58  initialize( _origin, _x_axis, _y_axis, _z_axis, _x_res, _y_res, _z_res );
59  }
60 
63 
64 
66  void initialize( const Vec3& _origin,
67  const Vec3& _x_axis,
68  const Vec3& _y_axis,
69  const Vec3& _z_axis,
70  unsigned int _x_res,
71  unsigned int _y_res,
72  unsigned int _z_res )
73  {
74  RegularGrid::initialize( _origin, _x_axis, _y_axis, _z_axis,
75  _x_res, _y_res, _z_res );
76  Vector vec;
77  for ( int i = 0; i < vec.dim(); ++i ) vec[i] = 0.0;
78  values_.resize( _x_res*_y_res*_z_res, vec );
79  }
80 
81 
82  virtual real scalar_distance( PointIdx /*_pidx*/ ) const
83  {
84  return 0.0;
85  }
86 
87  virtual bool is_inside( PointIdx /*_pidx*/ ) const
88  {
89  return false;
90  }
91 
92  virtual bool directed_distance( const Vec3& /*_p0*/,
93  const Vec3& /*_p1*/,
94  Vec3& /*_point*/,
95  Vec3& /*_normal*/,
96  real& /*_distance*/ ) const
97  {
98  return false;
99  }
100 
101 
103  Vector& operator()( unsigned int x, unsigned int y, unsigned int z )
104  {
105  return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
106  }
107 
108  Vector operator()( unsigned int x, unsigned int y, unsigned int z ) const
109  {
110  return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
111  }
112 
113  Vector& value( unsigned int x, unsigned int y, unsigned int z )
114  {
115  return ( *this )( x, y, z );
116  }
117 
118  Vector value( unsigned int x, unsigned int y, unsigned int z ) const
119  {
120  return ( *this )( x, y, z );
121  }
122 
123 
125  Vector value_range( int x, int y, int z ) const;
126 
128  Vector lerp_local( Scalar _x, Scalar _y, Scalar _z );
129 
131  Vector lerp_world( Scalar _x, Scalar _y, Scalar _z );
132 
133 private:
134 
136  std::vector< Vector > values_;
137 };
138 
139 
140 //=============================================================================
141 } // namespace IsoEx
142 //=============================================================================
143 #if defined(INCLUDE_TEMPLATES) && !defined(ACG_VECTORFIELDT_C)
144 #define ACG_VECTORFIELDT_TEMPLATES
145 #include "VectorFieldT.cc"
146 #endif
147 //=============================================================================
148 #endif // ACG_VECTORFIELDT_HH defined
149 //=============================================================================
150 
virtual bool directed_distance(const Vec3 &, const Vec3 &, Vec3 &, Vec3 &, real &) const
See IsoEx::Implicit::directed_distance()
Definition: VectorFieldT.hh:92
Vector lerp_world(Scalar _x, Scalar _y, Scalar _z)
funciton to lineary interploate a vector at a world point
Definition: VectorFieldT.cc:91
Vector lerp_local(Scalar _x, Scalar _y, Scalar _z)
function to lineary interpolate a vector at a local point
Definition: VectorFieldT.cc:46
void initialize(const Vec3 &_origin, const Vec3 &_x_axis, const Vec3 &_y_axis, const Vec3 &_z_axis, unsigned int _x_res, unsigned int _y_res, unsigned int _z_res)
function to initialize the grid
Definition: VectorFieldT.hh:66
~VectorFieldT()
Destructor.
Definition: VectorFieldT.hh:62
void initialize(const Vec3 &_origin, const Vec3 &_x_axis, const Vec3 &_y_axis, const Vec3 &_z_axis, unsigned int _x_res, unsigned int _y_res, unsigned int _z_res)
function to initialize the grid
Definition: RegularGridT.cc:49
Vector value_range(int x, int y, int z) const
get scalar value, returns zero vector if position is not in range
Definition: VectorFieldT.cc:25
A type for volume images, or 3D textures.
Grid< Vec3 >::PointIdx PointIdx
The grid points can be referred to by PointIdx.
Definition: RegularGridT.hh:68
Vector & operator()(unsigned int x, unsigned int y, unsigned int z)
data access
Definition: VectorFieldT.hh:103
VectorFieldT(const Vec3 &_origin=Vec3(0, 0, 0), const Vec3 &_x_axis=Vec3(1, 0, 0), const Vec3 &_y_axis=Vec3(0, 1, 0), const Vec3 &_z_axis=Vec3(0, 0, 1), unsigned int _x_res=10, unsigned int _y_res=10, unsigned int _z_res=10)
Default constructor.
Definition: VectorFieldT.hh:50
Definition: RegularGridT.hh:56
Definition: VectorFieldT.hh:43