9 #ifndef ISOEX_SCALARGRIDT_HH
10 #define ISOEX_SCALARGRIDT_HH
15 #include <OpenMesh/Core/IO/BinaryHelper.hh>
16 #include <OpenMesh/Core/Geometry/VectorT.hh>
18 #include "RegularGrid.hh"
19 #include "../Implicits/Implicit.hh"
38 template <
typename Scalar>
44 typedef std::vector<Scalar> Values;
48 const Vec3& _x_axis = Vec3( 1, 0, 0 ),
49 const Vec3& _y_axis = Vec3( 0, 1, 0 ),
50 const Vec3& _z_axis = Vec3( 0, 0, 1 ),
51 unsigned int _x_res = 1,
52 unsigned int _y_res = 1,
53 unsigned int _z_res = 1 )
55 initialize( _origin, _x_axis, _y_axis, _z_axis, _x_res, _y_res, _z_res );
71 _x_res, _y_res, _z_res );
72 values_.resize( n_points_, 0.0 );
77 virtual real scalar_distance(
PointIdx _pidx )
const
79 return values_[_pidx];
82 virtual bool is_inside(
PointIdx _pidx )
const
84 return values_[_pidx] < 0.0;
96 void sample(
const Implicit& _implicit );
99 virtual bool read(
const char* _filename );
100 virtual bool write(
const char* _filename );
101 virtual bool read( FILE* _in );
102 virtual bool write( FILE* _out );
105 Scalar&
operator()(
unsigned int x,
unsigned int y,
unsigned int z )
107 return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
110 Scalar
operator()(
unsigned int x,
unsigned int y,
unsigned int z )
const
112 return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
115 Scalar& value(
unsigned int x,
unsigned int y,
unsigned int z )
117 return ( *
this )( x, y, z );
120 Scalar value(
unsigned int x,
unsigned int y,
unsigned int z )
const
122 return ( *
this )( x, y, z );
131 Scalar
lerp_local( Scalar _x, Scalar _y, Scalar _z );
134 Scalar
lerp_world( Scalar _x, Scalar _y, Scalar _z );
140 std::vector< Vec3 > &_intersections );
146 std::vector< Vec3 > &_intersections );
157 #if defined(INCLUDE_TEMPLATES) && !defined(ISOEX_SCALARGRIDT_C)
158 #define ISOEX_SCALARGRIDT_TEMPLATES
159 #include "ScalarGridT.cc"
162 #endif // ISOEX_SCALARGRIDT_HH defined
virtual ~ScalarGridT()
Destructor.
Definition: ScalarGridT.hh:59
virtual bool directed_distance(const Vec3 &, const Vec3 &, Vec3 &, Vec3 &, real &) const
See IsoEx::Implicit::directed_distance()
Definition: ScalarGridT.hh:87
Scalar & operator()(unsigned int x, unsigned int y, unsigned int z)
data access
Definition: ScalarGridT.hh:105
Scalar value_range(int x, int y, int z) const
get scalar value, returns 0.0 if position is not in range
Definition: ScalarGridT.cc:134
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
void get_isosurface_intersections_world(const Vec3 &_o, const Vec3 &_d, Scalar _iso, std::vector< Vec3 > &_intersections)
get intersections with isosurface in world coordinates
Definition: ScalarGridT.cc:209
Scalar lerp_world(Scalar _x, Scalar _y, Scalar _z)
funciton to lineary interploate a scalar value at a world point
Definition: ScalarGridT.cc:197
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: ScalarGridT.hh:62
Scalar lerp_local(Scalar _x, Scalar _y, Scalar _z)
function to lineary interpolate a scalar value at a local point
Definition: ScalarGridT.cc:151
Definition: Implicit.hh:57
A type for volume images, or 3D textures.
ScalarGridT(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=1, unsigned int _y_res=1, unsigned int _z_res=1)
Default constructor.
Definition: ScalarGridT.hh:47
Grid< Vec3 >::PointIdx PointIdx
The grid points can be referred to by PointIdx.
Definition: RegularGridT.hh:68
void get_isosurface_intersections_local(const Vec3 &_o, const Vec3 &_d, Scalar _iso, std::vector< Vec3 > &_intersections)
get intersections with isosurface in local coordinates
Definition: ScalarGridT.cc:229
Definition: RegularGridT.hh:56
Definition: ScalarGridT.hh:39