Developer Documentation
|
This class creates buffers that can be used to render open volume meshs. More...
#include <ObjectTypes/VolumeMeshObject/VolumeMeshBufferManager.hh>
Classes | |
class | Plane |
Public Member Functions | |
VolumeMeshBufferManager (const VolumeMesh &mesh_, OpenVolumeMesh::StatusAttrib &statusAttrib_, OpenVolumeMesh::ColorAttrib< ACG::Vec4f > &colorAttrib_, OpenVolumeMesh::NormalAttrib< VolumeMesh > &normalAttrib_, OpenVolumeMesh::TexCoordAttrib< ACG::Vec2f > &texcoordAttrib_) | |
void | setScale (double _scale) |
Sets the scale used to shrink cells. | |
double | getScale () const |
Return the scale used to shrink cells. | |
unsigned char | getStride () |
Returns the vertex stride. | |
unsigned char | getColorOffset () |
Returns the color's offset within the buffer. | |
unsigned char | getNormalOffset () |
Returns the normal's offset within the buffer. | |
unsigned char | getTexCoordOffset () |
Returns the texcoord's offset within the buffer. | |
const ACG::VertexDeclaration * | getVertexDeclaration () |
Returns a VertexDeclaration for the vertices stored in the buffer. | |
GLuint | getBuffer () |
Returns the name of the buffer. More... | |
GLuint | getPickBuffer (ACG::GLState &_state, unsigned int _offset) |
Returns the name of the pick buffer. More... | |
void | invalidate () |
Invalidates the buffer. | |
void | invalidateGeometry () |
Invalidates geometry. | |
void | invalidateColors () |
Invalidates colors. | |
void | invalidateNormals () |
Invalidates normals. | |
void | invalidateTexCoords () |
Invalidates texture coordinates. | |
void | free () |
Deletes the buffers on the GPU. More... | |
unsigned int | getNumOfVertices () |
Returns the number of vertices stored in the buffer. | |
void | setDefaultColor (ACG::Vec4f _defaultColor) |
Sets the default color. More... | |
void | setOptionsFromDrawMode (ACG::SceneGraph::DrawModes::DrawMode _drawMode) |
Configures the buffer manager's options from a DrawMode. More... | |
void | disableColors () |
Disables colors. | |
void | enablePerCellColors () |
Enables per cell colors. | |
void | enablePerFaceColors () |
Enables per face colors. | |
void | enablePerHalffaceColors () |
Enables per halfface colors. | |
void | enablePerEdgeColors () |
Enables per edge colors. | |
void | enablePerHalfedgeColors () |
Enables per halfedge colors. | |
void | enablePerVertexColors () |
Enables per vertex colors. | |
void | enablePickColors () |
Enables picking colors. | |
void | disableNormals () |
Disables normals. | |
void | enablePerFaceNormals () |
Enables per face normals. | |
void | enablePerHalffaceNormals () |
Enables per halfface normals. | |
void | enablePerVertexNormals () |
Enables per vertex normals. | |
void | disablePrimitives () |
Disables primitives (nothing will be drawn) | |
void | enableCellPrimitives () |
Enables cell primitives. | |
void | enableFacePrimitives () |
Enables face primitives. | |
void | enableFaceOnCellPrimitives () |
Enables face primitives which are drawn on the cells. | |
void | enableHalffacePrimitives () |
Enables halfface primitves. | |
void | enableHalffaceOnCellPrimitives () |
Enables halfface primitives which are drawn on the cells. | |
void | enableEdgePrimitives () |
Enables edge primitves. | |
void | enableIrregularEdgePrimitives () |
Enables edge primitives for irregular edges. | |
void | enableEdgeOnCellPrimitives () |
Enables edge primitives which are drawn on the cells. | |
void | enableHalfedgePrimitives () |
Enables per halfedge primitives. | |
void | enableVertexPrimitives () |
Enables vertex primitives. | |
void | enableVertexOnCellPrimitives () |
Enables vertex primitives that are drawn on the cells. | |
void | disableTextures () |
Disables textures. | |
void | enableTextureSingle () |
Enables textures. | |
bool | selectionOnly () |
Checks whether only selected primitives should be added to the buffer. | |
void | setSelectionOnly (bool _selectionOnly) |
Set whether only selected primitves should be added to the buffer. | |
void | clearCutPlanes () |
Removes all cut planes. More... | |
void | addCutPlane (const typename VolumeMeshBufferManager< VolumeMesh >::Plane &_p) |
Adds a cut plane. More... | |
void | addCutPlane (const ACG::Vec3d &_p, const ACG::Vec3d &_n, const ACG::Vec3d &_xsize, const ACG::Vec3d &_ysize) |
Adds a cut plane. More... | |
void | setBoundaryOnly (bool _boundaryOnly) |
Sets whether only the boundary primitves should be rendered. | |
Private Types | |
typedef OpenVolumeMesh::VertexHandle | VertexHandle |
typedef OpenVolumeMesh::EdgeHandle | EdgeHandle |
typedef OpenVolumeMesh::HalfEdgeHandle | HalfEdgeHandle |
typedef OpenVolumeMesh::FaceHandle | FaceHandle |
typedef OpenVolumeMesh::HalfFaceHandle | HalfFaceHandle |
typedef OpenVolumeMesh::CellHandle | CellHandle |
typedef VolumeMesh::PointT | Vertex |
typedef OpenVolumeMesh::OpenVolumeMeshEdge | Edge |
typedef OpenVolumeMesh::OpenVolumeMeshFace | Face |
typedef OpenVolumeMesh::OpenVolumeMeshCell | Cell |
Private Member Functions | |
bool | is_inside (const ACG::Vec3d &_p) |
Tests whether the given point is inside w.r.t. all cut planes. More... | |
bool | is_inside (const VertexHandle &_vh) |
Tests whether the given vertex is inside w.r.t. all cut planes. More... | |
bool | is_inside (const HalfEdgeHandle &_heh) |
Tests whether the given halfedge is inside w.r.t. all cut planes. More... | |
bool | is_inside (const EdgeHandle &_eh) |
Tests whether the given edge is inside w.r.t. all cut planes. More... | |
bool | is_inside (const HalfFaceHandle &_hfh) |
Tests whether the given halfface is inside w.r.t. all cut planes. More... | |
bool | is_inside (const FaceHandle &_fh) |
Tests whether the given face is inside w.r.t. all cut planes. More... | |
bool | is_inside (const CellHandle &_ch) |
Tests whether the given cell is inside w.r.t. all cut planes. More... | |
void | calculateCellInsideness () |
Calculates for all cells whether they are inside w.r.t. all cut planes. More... | |
bool | optionsChanged () |
Tests whether the options were changed since the last time building the buffer. More... | |
void | saveOptions () |
State that the current buffer was built with the current options. More... | |
void | addFloatToBuffer (float _value, unsigned char *&_buffer) |
Adds a float to the buffer. More... | |
void | addUCharToBuffer (unsigned char _value, unsigned char *&_buffer) |
Adds an unsigned char to the buffer. More... | |
void | addPositionToBuffer (ACG::Vec3d _position, unsigned char *_buffer, unsigned int _offset) |
Adds a position to the buffer. More... | |
void | addColorToBuffer (ACG::Vec4uc _color, unsigned char *_buffer, unsigned int _offset) |
Adds a color to the buffer. More... | |
void | addColorToBuffer (ACG::Vec4f _color, unsigned char *_buffer, unsigned int _offset) |
Adds a color to the buffer. More... | |
void | addNormalToBuffer (ACG::Vec3d _normal, unsigned char *_buffer, unsigned int _offset) |
Adds a normal to the buffer. More... | |
void | addTexCoordToBuffer (ACG::Vec2f _texCoord, unsigned char *_buffer, unsigned int _offset) |
Adds a texture coordnate to the buffer. More... | |
void | calculateVertexDeclaration () |
Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer. More... | |
void | buildVertexBuffer (unsigned char *_buffer) |
Adds all vertices to the buffer. More... | |
void | buildNormalBuffer (unsigned char *_buffer) |
Adds all normals to the buffer. More... | |
void | buildColorBuffer (unsigned char *_buffer) |
Adds all colors to the buffer. More... | |
void | buildTexCoordBuffer (unsigned char *_buffer) |
Adds texture coordinates to the buffer. More... | |
void | buildPickColorBuffer (ACG::GLState &_state, unsigned int _offset, unsigned char *_buffer) |
Adds all picking colors to the buffer. More... | |
ACG::Vec4f | getValenceColorCode (unsigned int _valence, bool _inner) const |
Returns a color code for irregular edges. More... | |
void | countNumOfVertices () |
Counts the number of vertices that need to be stored in the buffer. More... | |
int | getNumOfIncidentCells (OpenVolumeMesh::FaceHandle _fh) |
Returns the number of cells that are incident to the given face and also inside w.r.t. all cut planes. More... | |
int | getNumOfIncidentCells (OpenVolumeMesh::EdgeHandle _eh) |
Returns the number of cells that are incident to the given edge and also inside w.r.t. all cut planes. More... | |
int | getNumOfIncidentCells (OpenVolumeMesh::VertexHandle _vh) |
Returns the number of cells that are incident to the given vertex and also inside w.r.t. all cut planes. More... | |
ACG::Vec3d | getCOG (OpenVolumeMesh::CellHandle _ch) |
Returns the center of gravity of the given cell. More... | |
void | calculateCOGs () |
Calculates the center of gravity for all cells. More... | |
bool | positionsNeedRebuild () |
Checks whether positions need to be rebuild. More... | |
bool | colorsNeedRebuild () |
Checks whether colors need to be rebuild. More... | |
bool | texCoordsNeedRebuild () |
Checks whether texture coordinates need to be rebuild. More... | |
bool | normalsNeedRebuild () |
Checks whether normals need to be rebuild. More... | |
Private Attributes | |
ACG::Vec4f | mDefaultColor |
const VolumeMesh & | mMesh |
OpenVolumeMesh::StatusAttrib & | mStatusAttrib |
OpenVolumeMesh::ColorAttrib< ACG::Vec4f > & | mColorAttrib |
OpenVolumeMesh::NormalAttrib< VolumeMesh > & | mNormalAttrib |
OpenVolumeMesh::TexCoordAttrib< ACG::Vec2f > & | mTexcoordAttrib |
int | mNumOfVertices |
int | mCurrentNumOfVertices |
unsigned int | mVertexSize |
ACG::VertexDeclaration | mVertexDeclaration |
int | mColorOffset |
int | mNormalOffset |
double | mScale |
GLuint | mBuffer |
unsigned int | mCurrentPickOffset |
unsigned int | mGlobalPickOffset |
bool | mInvalidated |
bool | mGeometryChanged |
bool | mNormalsChanged |
bool | mColorsChanged |
bool | mTexCoordsChanged |
VolumeMeshDrawModesContainer | mDrawModes |
PrimitiveMode | mPrimitiveMode |
NormalMode | mNormalMode |
ColorMode | mColorMode |
bool | mSkipUnselected |
bool | mShowIrregularInnerEdges |
bool | mShowIrregularOuterValence2Edges |
bool | mSkipRegularEdges |
bool | mBoundaryOnly |
PrimitiveMode | mCurrentPrimitiveMode |
NormalMode | mCurrentNormalMode |
ColorMode | mCurrentColorMode |
bool | mCurrentSkipUnselected |
bool | mCurrentShowIrregularInnerEdges |
bool | mCurrentShowIrregularOuterValence2Edges |
bool | mCurrentSkipRegularEdges |
bool | mCurrentBoundaryOnly |
unsigned char | mCurrentVertexSize |
unsigned char | mCurrentNormalOffset |
unsigned char | mCurrentColorOffset |
std::vector< Plane > | cut_planes_ |
std::vector< ACG::Vec3d > | mCogs |
bool | mCogsValid |
std::vector< bool > | mCellInsideness |
bool | mCellInsidenessValid |
TexCoordMode | mTexCoordMode |
TexCoordMode | mCurrentTexCoordMode |
unsigned char | mTexCoordOffset |
unsigned char | mCurrentTexCoordOffset |
This class creates buffers that can be used to render open volume meshs.
Definition at line 69 of file VolumeMeshBufferManager.hh.
|
private |
Adds a color to the buffer.
This method should be called after the size of a vertex and the color offset within a vertex was calculated using calculateVertexDeclaration()
_color | The color that should be inserted |
_buffer | A pointer to the start of the buffer |
_offset | The offset (in number of vertices) to the place the color should be inserted |
Definition at line 179 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds a color to the buffer.
The color is added as unsigned character between 0 and 255 for _color between 0.0f and 1.0f
This method should be called after the size of a vertex and the color offset within a vertex was calculated using calculateVertexDeclaration()
_color | The color that should be inserted |
_buffer | A pointer to the start of the buffer |
_offset | The offset (in number of vertices) to the place the color should inserted |
Definition at line 201 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::addCutPlane | ( | const typename VolumeMeshBufferManager< VolumeMesh >::Plane & | _p | ) |
Adds a cut plane.
After adding the cut plane the buffer is invalidated so it is rebuild the next time someone wants to use it.
_p | The plane that is added. |
Definition at line 439 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::addCutPlane | ( | const ACG::Vec3d & | _p, |
const ACG::Vec3d & | _n, | ||
const ACG::Vec3d & | _xsize, | ||
const ACG::Vec3d & | _ysize | ||
) |
Adds a cut plane.
After adding the cut plane the buffer is invalidated so it is rebuild the next time someone wants to use it.
_p | The position of the plane. |
_n | The normal of the plane. |
_xsize | The x-direction of the plane scaled by 1.0/width |
_ysize | The y-direction of the plane scaled by 1.0/height |
Definition at line 457 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds a float to the buffer.
The given value will be inserted at the location the pointer points to. After execution the pointer will point to the element after the inserted one.
_value | The value that should be inserted |
_buffer | A pointer to the place the value should be inserted to |
Definition at line 121 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds a normal to the buffer.
This method should be called after the size of a vertex and the normal offset within a vertex was calculated using calculateVertexDeclaration()
_normal | The normal that should be inserted |
_buffer | A pointer to the start of the buffer |
_offset | The offset (in number of vertices) to the place the normal should inserted |
Definition at line 221 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds a position to the buffer.
This method should be called after the size of a vertex was calculated using calculateVertexDeclaration()
_position | The position that should be inserted |
_buffer | A pointer to the start of the buffer |
_offset | The offset (in number of vertices) to the place the position should be inserted |
Definition at line 160 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds a texture coordnate to the buffer.
This method should be called after the size of a vertex and the normal offset within a vertex was calculated using calculateVertexDeclaration()
_texCoord | The texture coordinate that should be inserted |
_buffer | A pointer to the start of the buffer |
_offset | The offset (in number of vertices) to the place the texture coordinate should inserted |
Definition at line 240 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds an unsigned char to the buffer.
The given value will be inserted at the location the pointer points to. After execution the pointer will point to the element after the inserted one.
_value | The value that should be inserted |
_buffer | A pointer to the place the value should be inserted to |
Definition at line 143 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds all colors to the buffer.
_buffer | Pointer to the start of the buffer |
Definition at line 1398 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds all normals to the buffer.
_buffer | Pointer to the start of the buffer |
Definition at line 1260 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds all picking colors to the buffer.
_state | The current state which provides the picking colors. |
_offset | An offset that is added to the primitive's idx when asking for a picking color. This is necessary when different types of primitives are picked simultaneously. The number of other primives |
_buffer | Pointer to the start of the buffer |
Definition at line 1724 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds texture coordinates to the buffer.
_buffer | Pointer to the start of the buffer |
Definition at line 1662 of file VolumeMeshBufferManagerT.cc.
|
private |
Adds all vertices to the buffer.
_buffer | Pointer to the start of the buffer |
Definition at line 1046 of file VolumeMeshBufferManagerT.cc.
|
private |
Calculates for all cells whether they are inside w.r.t. all cut planes.
The insideness is stored so it can be reused until the geometry or cut planes change to improve performance.
Definition at line 600 of file VolumeMeshBufferManagerT.cc.
|
private |
Calculates the center of gravity for all cells.
The centers of gravity are stored in the property mCogProperty points to. Make sure this points to a correct property before calling this method.
Definition at line 951 of file VolumeMeshBufferManagerT.cc.
|
private |
Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer.
Depending on the current options this method calculates an appropriate VertexDeclaration which can be used for rendering. Also it calculates the vertex stride and the offsets for colors and normals.
Definition at line 256 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::clearCutPlanes | ( | ) |
Removes all cut planes.
After removing the cut planes the buffer is invalidated so it is rebuild the next time someone wants to use it.
Definition at line 424 of file VolumeMeshBufferManagerT.cc.
|
private |
Checks whether colors need to be rebuild.
Definition at line 997 of file VolumeMeshBufferManagerT.cc.
|
private |
Counts the number of vertices that need to be stored in the buffer.
The number of vertices is stored in mNumOfVertices
Definition at line 702 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::free | ( | ) |
Deletes the buffers on the GPU.
This also invalidates the buffer
Definition at line 2037 of file VolumeMeshBufferManagerT.cc.
GLuint VolumeMeshBufferManager< VolumeMesh >::getBuffer | ( | ) |
Returns the name of the buffer.
This method also builds the buffer when necessary.
Definition at line 1840 of file VolumeMeshBufferManagerT.cc.
|
private |
Returns the center of gravity of the given cell.
_ch | A handle of the cell of interest |
Definition at line 935 of file VolumeMeshBufferManagerT.cc.
|
private |
Returns the number of cells that are incident to the given face and also inside w.r.t. all cut planes.
_fh | A Handle of the face of interest |
Definition at line 876 of file VolumeMeshBufferManagerT.cc.
|
private |
Returns the number of cells that are incident to the given edge and also inside w.r.t. all cut planes.
_eh | A handle of the edge of interest |
Definition at line 898 of file VolumeMeshBufferManagerT.cc.
|
private |
Returns the number of cells that are incident to the given vertex and also inside w.r.t. all cut planes.
_vh | A handle of the vertex of interest |
Definition at line 917 of file VolumeMeshBufferManagerT.cc.
GLuint VolumeMeshBufferManager< VolumeMesh >::getPickBuffer | ( | ACG::GLState & | _state, |
unsigned int | _offset | ||
) |
Returns the name of the pick buffer.
_state | The state that provides the picking colors |
_offset | The offset for the picking colors |
Definition at line 1912 of file VolumeMeshBufferManagerT.cc.
|
private |
Returns a color code for irregular edges.
_valence | Number of incident cells |
_inner | False if the edge is a boundary edge, True if not |
Definition at line 680 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given point is inside w.r.t. all cut planes.
_p | The position to be tested. |
Definition at line 470 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given vertex is inside w.r.t. all cut planes.
A vertex is considered inside iff its positions is inside.
_vh | A Handle to the vertex that should be tested. |
Definition at line 497 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given halfedge is inside w.r.t. all cut planes.
A halfedge is considered inside iff both from- and to-vertex are inside.
_heh | A Handle to the halfedge that should be tested. |
Definition at line 513 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given edge is inside w.r.t. all cut planes.
An edge is considered inside iff both from- and to-vertex are inside.
_eh | A Handle to the edge that should be tested. |
Definition at line 530 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given halfface is inside w.r.t. all cut planes.
A halfface is considered inside iff all its incident vertices are inside.
_hfh | A Handle to the halfface that should be tested. |
Definition at line 547 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given face is inside w.r.t. all cut planes.
A face is considered inside iff all its incident vertices are inside.
_fh | A Handle to the face that should be tested. |
Definition at line 566 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the given cell is inside w.r.t. all cut planes.
A cell is considered inside iff the positions of all its incident vertices moved towards the cell's center of gravity depending on the current scaling parameter are inside.
_ch | A Handle to the cell that should be tested. |
Definition at line 584 of file VolumeMeshBufferManagerT.cc.
|
private |
Checks whether normals need to be rebuild.
Definition at line 1030 of file VolumeMeshBufferManagerT.cc.
|
private |
Tests whether the options were changed since the last time building the buffer.
For this method to work saveOptions() should be called immidiately after building the buffer
Definition at line 636 of file VolumeMeshBufferManagerT.cc.
|
private |
Checks whether positions need to be rebuild.
Definition at line 983 of file VolumeMeshBufferManagerT.cc.
|
private |
State that the current buffer was built with the current options.
This method should be called immidiately after building the buffer
Definition at line 654 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::setDefaultColor | ( | ACG::Vec4f | _defaultColor | ) |
Sets the default color.
The default color is only used for regular edges when drawn together with irregular edges.
_defaultColor | The default color |
Definition at line 318 of file VolumeMeshBufferManagerT.cc.
void VolumeMeshBufferManager< VolumeMesh >::setOptionsFromDrawMode | ( | ACG::SceneGraph::DrawModes::DrawMode | _drawMode | ) |
Configures the buffer manager's options from a DrawMode.
This method extracts from the given draw mode which primitve mode, color mode and normal mode should be used and which irregular edges should be shown.
_drawMode | The DrawMode for which the options should be set |
Definition at line 336 of file VolumeMeshBufferManagerT.cc.
|
private |
Checks whether texture coordinates need to be rebuild.
Definition at line 1015 of file VolumeMeshBufferManagerT.cc.