50 #ifndef VOLUME_MESH_BUFFER_MANAGER_HH
51 #define VOLUME_MESH_BUFFER_MANAGER_HH
53 #include <ACG/GL/GLState.hh>
54 #include <ACG/Scenegraph/DrawModes.hh>
55 #include <ACG/Scenegraph/BaseNode.hh>
56 #include <ACG/GL/VertexDeclaration.hh>
58 #include "VolumeMeshDrawModesContainer.hh"
60 #include <OpenVolumeMesh/Attribs/StatusAttrib.hh>
61 #include <OpenVolumeMesh/Attribs/NormalAttrib.hh>
62 #include <OpenVolumeMesh/Attribs/ColorAttrib.hh>
63 #include <OpenVolumeMesh/Attribs/TexCoordAttrib.hh>
68 template<
class VolumeMesh>
79 typedef typename VolumeMesh::PointT Vertex;
93 PM_HALFFACES_ON_CELLS,
131 position(_p), normal(_n), xdirection(_x), ydirection(_y) {
324 bool is_inside(
const HalfEdgeHandle& _heh);
330 bool is_inside(
const HalfFaceHandle& _hfh);
429 const VolumeMesh& mMesh;
436 int mCurrentNumOfVertices;
438 unsigned int mVertexSize;
449 unsigned int mCurrentPickOffset;
452 unsigned int mGlobalPickOffset;
455 bool mGeometryChanged;
456 bool mNormalsChanged;
458 bool mTexCoordsChanged;
464 PrimitiveMode mPrimitiveMode;
465 NormalMode mNormalMode;
466 ColorMode mColorMode;
468 bool mSkipUnselected;
469 bool mShowIrregularInnerEdges;
470 bool mShowIrregularOuterValence2Edges;
471 bool mSkipRegularEdges;
474 PrimitiveMode mCurrentPrimitiveMode;
475 NormalMode mCurrentNormalMode;
476 ColorMode mCurrentColorMode;
478 bool mCurrentSkipUnselected;
479 bool mCurrentShowIrregularInnerEdges;
480 bool mCurrentShowIrregularOuterValence2Edges;
481 bool mCurrentSkipRegularEdges;
482 bool mCurrentBoundaryOnly;
484 unsigned char mCurrentVertexSize;
485 unsigned char mCurrentNormalOffset;
486 unsigned char mCurrentColorOffset;
488 std::vector<Plane> cut_planes_;
490 std::vector<ACG::Vec3d> mCogs;
492 std::vector<bool> mCellInsideness;
493 bool mCellInsidenessValid;
495 TexCoordMode mTexCoordMode;
496 TexCoordMode mCurrentTexCoordMode;
497 unsigned char mTexCoordOffset;
498 unsigned char mCurrentTexCoordOffset;
503 #if defined(INCLUDE_TEMPLATES) && !defined(VOLUMEMESHBUFFERMANAGERT_CC)
504 #include "VolumeMeshBufferManagerT.cc"
508 #endif // VOLUME_MESH_BUFFER_MANAGER_HH
ACG::Vec4f getValenceColorCode(unsigned int _valence, bool _inner) const
Returns a color code for irregular edges.
void setBoundaryOnly(bool _boundaryOnly)
Sets whether only the boundary primitves should be rendered.
void enableIrregularEdgePrimitives()
Enables edge primitives for irregular edges.
void setOptionsFromDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Configures the buffer manager's options from a DrawMode.
void calculateCOGs()
Calculates the center of gravity for all cells.
void enableEdgeOnCellPrimitives()
Enables edge primitives which are drawn on the cells.
void enablePerHalffaceNormals()
Enables per halfface normals.
void enablePerVertexNormals()
Enables per vertex normals.
void invalidate()
Invalidates the buffer.
void clearCutPlanes()
Removes all cut planes.
const ACG::VertexDeclaration * getVertexDeclaration()
Returns a VertexDeclaration for the vertices stored in the buffer.
void enableVertexPrimitives()
Enables vertex primitives.
void invalidateColors()
Invalidates colors.
void invalidateNormals()
Invalidates normals.
void buildColorBuffer(unsigned char *_buffer)
Adds all colors to the buffer.
bool texCoordsNeedRebuild()
Checks whether texture coordinates need to be rebuild.
void setScale(double _scale)
Sets the scale used to shrink cells.
void free()
Deletes the buffers on the GPU.
void addPositionToBuffer(ACG::Vec3d _position, unsigned char *_buffer, unsigned int _offset)
Adds a position to the buffer.
void disablePrimitives()
Disables primitives (nothing will be drawn)
void enableEdgePrimitives()
Enables edge primitves.
void addUCharToBuffer(unsigned char _value, unsigned char *&_buffer)
Adds an unsigned char to the buffer.
bool positionsNeedRebuild()
Checks whether positions need to be rebuild.
void enablePerFaceNormals()
Enables per face normals.
This class creates buffers that can be used to render open volume meshs.
void addCutPlane(const typename VolumeMeshBufferManager< VolumeMesh >::Plane &_p)
Adds a cut plane.
GLuint getBuffer()
Returns the name of the buffer.
void enablePickColors()
Enables picking colors.
void enablePerFaceColors()
Enables per face colors.
void enableCellPrimitives()
Enables cell primitives.
void enableFacePrimitives()
Enables face primitives.
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.
void buildPickColorBuffer(ACG::GLState &_state, unsigned int _offset, unsigned char *_buffer)
Adds all picking colors to the buffer.
void setDefaultColor(ACG::Vec4f _defaultColor)
Sets the default color.
void enableVertexOnCellPrimitives()
Enables vertex primitives that are drawn on the cells.
void enableHalfedgePrimitives()
Enables per halfedge primitives.
GLuint getPickBuffer(ACG::GLState &_state, unsigned int _offset)
Returns the name of the pick buffer.
unsigned char getTexCoordOffset()
Returns the texcoord's offset within the buffer.
void enablePerVertexColors()
Enables per vertex colors.
void calculateVertexDeclaration()
Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer...
void addNormalToBuffer(ACG::Vec3d _normal, unsigned char *_buffer, unsigned int _offset)
Adds a normal to the buffer.
void enablePerCellColors()
Enables per cell colors.
void addColorToBuffer(ACG::Vec4uc _color, unsigned char *_buffer, unsigned int _offset)
Adds a color to the buffer.
void buildVertexBuffer(unsigned char *_buffer)
Adds all vertices to the buffer.
void saveOptions()
State that the current buffer was built with the current options.
void enablePerHalffaceColors()
Enables per halfface colors.
void countNumOfVertices()
Counts the number of vertices that need to be stored in the buffer.
void calculateCellInsideness()
Calculates for all cells whether they are inside w.r.t. all cut planes.
bool optionsChanged()
Tests whether the options were changed since the last time building the buffer.
void enableHalffacePrimitives()
Enables halfface primitves.
void buildTexCoordBuffer(unsigned char *_buffer)
Adds texture coordinates to the buffer.
void addTexCoordToBuffer(ACG::Vec2f _texCoord, unsigned char *_buffer, unsigned int _offset)
Adds a texture coordnate to the buffer.
unsigned char getStride()
Returns the vertex stride.
void disableTextures()
Disables textures.
unsigned int getNumOfVertices()
Returns the number of vertices stored in the buffer.
unsigned char getColorOffset()
Returns the color's offset within the buffer.
void setSelectionOnly(bool _selectionOnly)
Set whether only selected primitves should be added to the buffer.
Class to define the vertex input layout.
void invalidateTexCoords()
Invalidates texture coordinates.
void enableHalffaceOnCellPrimitives()
Enables halfface primitives which are drawn on the cells.
void addFloatToBuffer(float _value, unsigned char *&_buffer)
Adds a float to the buffer.
void invalidateGeometry()
Invalidates geometry.
void enablePerHalfedgeColors()
Enables per halfedge colors.
bool selectionOnly()
Checks whether only selected primitives should be added to the buffer.
void disableColors()
Disables colors.
bool colorsNeedRebuild()
Checks whether colors need to be rebuild.
void disableNormals()
Disables normals.
void enableFaceOnCellPrimitives()
Enables face primitives which are drawn on the cells.
void enablePerEdgeColors()
Enables per edge colors.
bool normalsNeedRebuild()
Checks whether normals need to be rebuild.
void enableTextureSingle()
Enables textures.
double getScale() const
Return the scale used to shrink cells.
bool is_inside(const ACG::Vec3d &_p)
Tests whether the given point is inside w.r.t. all cut planes.
unsigned char getNormalOffset()
Returns the normal's offset within the buffer.
This class provides easy access to DrawModes supported by OpenVolumeMesh.
void buildNormalBuffer(unsigned char *_buffer)
Adds all normals to the buffer.
ACG::Vec3d getCOG(OpenVolumeMesh::CellHandle _ch)
Returns the center of gravity of the given cell.