32 #ifndef MarchingCubes_INCLUDE_ONCE 33 #define MarchingCubes_INCLUDE_ONCE 55 Cube(): mMin(0), mMax(0) {}
57 bool includes(
float v)
const {
return v >= mMin && v <= mMax; }
67 void setup(
float* data,
bool use_directly,
bool copy_data,
const fvec3& bottom_left,
const fvec3& top_right,
const ivec3& slices);
76 const float*
values()
const {
return mValues; }
80 const float&
value(
int i)
const {
return mValues[i]; }
82 float&
value(
int i) {
return mValues[i]; }
84 const float&
value(
int x,
int y,
int z)
const {
return mValues[x + mSlices.x()*y + mSlices.x()*mSlices.y()*z]; }
86 float&
value(
int x,
int y,
int z) {
return mValues[x + mSlices.x()*y + mSlices.x()*mSlices.y()*z]; }
89 void normalHQ(
fvec3& normal,
const fvec3& v,
float dx,
float dy,
float dz);
92 void normalLQ(
fvec3& normal,
const fvec3& v,
float dx,
float dy,
float dz);
95 float sampleSmooth(
float x,
float y,
float z)
const;
98 float sampleNearest(
float x,
float y,
float z)
const;
100 fvec3 coordinate(
int x,
int y,
int z)
const {
return mBottomLeft +
fvec3(
float(mCellSize.x()*x),
float(mCellSize.y()*y),
float(mCellSize.z()*z)); }
110 float computeMinimum()
const;
112 float computeMaximum()
const;
114 float computeAverage()
const;
122 const Volume::Cube&
cube(
int x,
int y,
int z)
const 127 return mCubes[ x + y*(slices().
x()-1) + z*(slices().
x()-1)*(slices().
y()-1) ];
139 void setupInternalData();
169 VL_DEBUG_SET_OBJECT_NAME()
178 VL_DEBUG_SET_OBJECT_NAME()
179 mThreshold = threshold;
187 VL_DEBUG_SET_OBJECT_NAME()
189 mThreshold = threshold;
206 int vert0()
const {
return mVert0; }
209 int vertC()
const {
return mVertC; }
228 void run(
bool generate_colors);
235 void updateColor(
const fvec3& color,
int volume_index);
236 void updateColor(
const fvec4& color,
int volume_index);
237 void updateAlpha(
float alpha,
int volume_index);
250 #if defined(VL_OPENGL) 257 void computeEdges(
Volume*,
float threshold);
258 void processCube(
int x,
int y,
int z,
Volume* vol,
float threshold);
261 std::vector<fvec3> mVerts;
262 std::vector<fvec3> mNorms;
263 std::vector<fvec4> mColors;
265 #if defined(VL_OPENGL) 266 typedef unsigned int IndexType;
268 typedef unsigned short IndexType;
270 std::vector<IndexType> mIndices;
274 Edge(): mX(-1), mY(-1), mZ(-1) {}
277 std::vector<Edge> mEdges;
278 std::vector<usvec3> mCubes;
280 bool mHighQualityNormals;
283 static const int mTriangleConnectionTable[256][16];
284 static const int mCubeEdgeFlags[256];
Defines the volume data to be used with a MarchingCube object.
ref< DrawElementsUShort > mDrawElements
Vector3< float > fvec3
A 3 components vector with float precision.
fvec3 coordinate(int x, int y, int z) const
const float & value(int x, int y, int z) const
void setVolume(Volume *vol)
const Volume::Cube & cube(int x, int y, int z) const
void setDataDirty()
Notifies that the data of a Volume has changed and that the internal acceleration structures should b...
Collection< VolumeInfo > * volumeInfo()
Defines the volume parameters to be used with a MarchingCube and Volume object.
std::vector< float > mInternalValues
ref< ArrayFloat4 > mColorArray
const Collection< VolumeInfo > * volumeInfo() const
float & value(int x, int y, int z)
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
const float & value(int i) const
bool dataIsDirty() const
Returns true if the internal data hasn't been updated since the last call to setDataDirty() or setup(...
An efficient implementation of the Marching Cubes algorithm.
Visualization Library main namespace.
ref< ArrayFloat3 > mVertsArray
const ivec3 & slices() const
ref< ArrayFloat3 > mNormsArray
const float * values() const
The base class for all the reference counted objects.
void setColor(const fvec4 &col)
void setThreshold(float t)
const T_Scalar & y() const
bool highQualityNormals() const
Select hight quality normals for best rendering quality, select low quality normals for best performa...
const Volume * volume() const
const fvec3 & cellSize() const
Returns the x/y/z size of a cell.
VolumeInfo(Volume *vol, float threshold, const fvec4 &color)
It's basically an std::vector for Objects that is itself an Object so it can be reference counted and...
void setHighQualityNormals(bool hq)
Select hight quality normals for best rendering quality, select low quality normals for best performa...
const fvec4 & color() const
const fvec3 & topRight() const
const T_Scalar & x() const
VolumeInfo(Volume *vol, float threshold)
The ref<> class is used to reference-count an Object.
std::vector< Cube > mCubes
const fvec3 & bottomLeft() const