43#define VOLUMEMESHBUFFERMANAGERT_CC
45#include "VolumeMeshBufferManager.hh"
47template <
class VolumeMesh>
53 mDefaultColor(
ACG::
Vec4f(0.0,0.0,0.0,1.0)),
55 mStatusAttrib(statusAttrib_),
56 mColorAttrib(colorAttrib_),
57 mNormalAttrib(normalAttrib_),
58 mTexcoordAttrib(texcoordAttrib_),
60 mCurrentNumOfVertices(-1),
67 mCurrentPickOffset(-1),
70 mGeometryChanged(true),
71 mNormalsChanged(true),
73 mTexCoordsChanged(true),
75 mPrimitiveMode(PM_NONE),
77 mColorMode(CM_NO_COLORS),
78 mSkipUnselected(false),
79 mShowIrregularInnerEdges(false),
80 mShowIrregularOuterValence2Edges(false),
81 mSkipRegularEdges(false),
83 mCurrentPrimitiveMode(PM_NONE),
84 mCurrentNormalMode(NM_NONE),
85 mCurrentColorMode(CM_NO_COLORS),
86 mCurrentSkipUnselected(false),
87 mCurrentShowIrregularInnerEdges(false),
88 mCurrentShowIrregularOuterValence2Edges(false),
89 mCurrentSkipRegularEdges(false),
90 mCurrentBoundaryOnly(false),
91 mCurrentVertexSize(0),
92 mCurrentNormalOffset(0),
93 mCurrentColorOffset(0),
95 mCellInsidenessValid(),
96 mTexCoordMode(TCM_NONE),
97 mCurrentTexCoordMode(TCM_NONE),
99 mCurrentTexCoordOffset(0)
113template <
class VolumeMesh>
117 unsigned char *v = (
unsigned char *) &_value;
135template <
class VolumeMesh>
152template <
class VolumeMesh>
155 unsigned char* buffer = _buffer + _offset*mVertexSize;
156 addFloatToBuffer(_position[0], buffer);
157 addFloatToBuffer(_position[1], buffer);
158 addFloatToBuffer(_position[2], buffer);
171template <
class VolumeMesh>
174 unsigned char* buffer = _buffer + _offset*mVertexSize + mColorOffset;
175 addUCharToBuffer(_color[0], buffer);
176 addUCharToBuffer(_color[1], buffer);
177 addUCharToBuffer(_color[2], buffer);
178 addUCharToBuffer(_color[3], buffer);
193template <
class VolumeMesh>
196 unsigned char* buffer = _buffer + _offset*mVertexSize + mColorOffset;
197 addUCharToBuffer(_color[0]*255, buffer);
198 addUCharToBuffer(_color[1]*255, buffer);
199 addUCharToBuffer(_color[2]*255, buffer);
200 addUCharToBuffer(_color[3]*255, buffer);
213template <
class VolumeMesh>
216 unsigned char* buffer = _buffer + _offset*mVertexSize + mNormalOffset;
217 addFloatToBuffer(_normal[0], buffer);
218 addFloatToBuffer(_normal[1], buffer);
219 addFloatToBuffer(_normal[2], buffer);
232template <
class VolumeMesh>
235 unsigned char* buffer = _buffer + _offset*mVertexSize + mTexCoordOffset;
236 addFloatToBuffer(_texCoord[0], buffer);
237 addFloatToBuffer(_texCoord[1], buffer);
248template <
class VolumeMesh>
251 unsigned int currentOffset = 0;
252 mVertexDeclaration.clear();
257 if (mPrimitiveMode != PM_NONE)
259 mVertexDeclaration.addElement(GL_FLOAT, 3,
ACG::VERTEX_USAGE_POSITION,
reinterpret_cast<GLuint*
>(currentOffset),0, 0, mBuffer);
260 currentOffset += 3*
sizeof(float);
263 if (mNormalMode != NM_NONE)
265 mNormalOffset = currentOffset;
266 mVertexDeclaration.addElement(GL_FLOAT, 3,
ACG::VERTEX_USAGE_NORMAL,
reinterpret_cast<GLuint*
>(currentOffset),0, 0, mBuffer);
267 currentOffset += 3*
sizeof(float);
270 if ((mColorMode != CM_NO_COLORS) || mShowIrregularInnerEdges || mShowIrregularOuterValence2Edges)
272 mColorOffset = currentOffset;
273 mVertexDeclaration.addElement(GL_UNSIGNED_BYTE, 4,
ACG::VERTEX_USAGE_COLOR,
reinterpret_cast<GLuint*
>(currentOffset),0, 0, mBuffer);
274 currentOffset += 4*
sizeof(char);
277 if ((mTexCoordMode != TCM_NONE))
279 mTexCoordOffset = currentOffset;
280 unsigned char numOfCoords = 0;
281 if (mTexCoordMode == TCM_SINGLE_2D)
283 mVertexDeclaration.addElement(GL_FLOAT, numOfCoords,
ACG::VERTEX_USAGE_TEXCOORD,
reinterpret_cast<GLuint*
>(currentOffset),0, 0, mBuffer);
284 currentOffset += numOfCoords *
sizeof(float);
287 mVertexSize = currentOffset;
295template <
class VolumeMesh>
298 if (mNumOfVertices == -1)
299 countNumOfVertices();
300 return mNumOfVertices;
310template <
class VolumeMesh>
313 if (mDefaultColor != _defaultColor)
316 mDefaultColor = _defaultColor;
328template <
class VolumeMesh>
332 if (_drawMode & (mDrawModes.cellsColoredPerCell))
333 enablePerCellColors();
334 else if (_drawMode & (mDrawModes.cellsColoredPerFace | mDrawModes.facesColoredPerFace | mDrawModes.facesColoredPerFaceFlatShaded))
335 enablePerFaceColors();
336 else if (_drawMode & (mDrawModes.cellsColoredPerHalfface | mDrawModes.halffacesColoredPerHalfface))
337 enablePerHalffaceColors();
338 else if (_drawMode & ( mDrawModes.edgesColoredPerEdge ))
339 enablePerEdgeColors();
340 else if (_drawMode & (mDrawModes.halfedgesColoredPerHalfedge))
341 enablePerHalfedgeColors();
342 else if (_drawMode & (mDrawModes.cellsColoredPerVertex | mDrawModes.facesColoredPerVertex |
343 mDrawModes.halffacesColoredPerVertex | mDrawModes.edgesColoredPerEdge |
344 mDrawModes.verticesColored))
345 enablePerVertexColors();
350 if (_drawMode & (mDrawModes.cellsFlatShaded | mDrawModes.halffacesFlatShaded))
351 enablePerHalffaceNormals();
352 else if (_drawMode & (mDrawModes.facesFlatShaded | mDrawModes.facesTexturedShaded | mDrawModes.facesColoredPerFaceFlatShaded))
353 enablePerFaceNormals();
354 else if (_drawMode & (mDrawModes.cellsSmoothShaded | mDrawModes.facesSmoothShaded | mDrawModes.halffacesSmoothShaded |
355 mDrawModes.cellsPhongShaded | mDrawModes.facesPhongShaded | mDrawModes.halffacesPhongShaded |
356 mDrawModes.cellsColoredPerCell | mDrawModes.cellsColoredPerFace | mDrawModes.cellsColoredPerHalfface |
357 mDrawModes.facesColoredPerFace | mDrawModes.cellsColoredPerVertex | mDrawModes.cellsTransparent))
358 enablePerVertexNormals();
362 if (_drawMode & (mDrawModes.irregularInnerEdges))
363 mShowIrregularInnerEdges =
true;
365 mShowIrregularInnerEdges =
false;
367 if (_drawMode & (mDrawModes.irregularOuterEdges))
368 mShowIrregularOuterValence2Edges =
true;
370 mShowIrregularOuterValence2Edges =
false;
372 if (!mShowIrregularInnerEdges && !mShowIrregularOuterValence2Edges)
373 mSkipRegularEdges =
false;
375 mSkipRegularEdges =
true;
379 if (_drawMode & (mDrawModes.facesTextured | mDrawModes.facesTexturedShaded))
380 mTexCoordMode = TCM_SINGLE_2D;
382 mTexCoordMode = TCM_NONE;
385 if (_drawMode & (mDrawModes.cellBasedDrawModes))
386 mPrimitiveMode = PM_CELLS;
387 else if (_drawMode & (mDrawModes.facesOnCells))
388 mPrimitiveMode = PM_FACES_ON_CELLS;
389 else if (_drawMode & (mDrawModes.faceBasedDrawModes | mDrawModes.hiddenLineBackgroundFaces))
390 mPrimitiveMode = PM_FACES;
391 else if (_drawMode & (mDrawModes.halffaceBasedDrawModes))
392 mPrimitiveMode = PM_HALFFACES;
393 else if (_drawMode & (mDrawModes.edgesOnCells))
394 mPrimitiveMode = PM_EDGES_ON_CELLS;
395 else if (_drawMode & ((mDrawModes.edgeBasedDrawModes) & ~(mDrawModes.irregularInnerEdges | mDrawModes.irregularOuterEdges)))
396 mPrimitiveMode = PM_EDGES;
397 else if (_drawMode & (mDrawModes.irregularInnerEdges | mDrawModes.irregularOuterEdges))
398 mPrimitiveMode = PM_IRREGULAR_EDGES;
399 else if (_drawMode & (mDrawModes.halfedgeBasedDrawModes))
400 mPrimitiveMode = PM_HALFEDGES;
401 else if (_drawMode & (mDrawModes.verticesOnCells))
402 mPrimitiveMode = PM_VERTICES_ON_CELLS;
403 else if (_drawMode & (mDrawModes.vertexBasedDrawModes))
404 mPrimitiveMode = PM_VERTICES;
406 mPrimitiveMode = PM_NONE;
418template <
class VolumeMesh>
422 invalidateGeometry();
423 mCellInsidenessValid =
false;
433template <
class VolumeMesh>
436 cut_planes_.push_back(_p);
437 invalidateGeometry();
438 mCellInsidenessValid =
false;
451template <
class VolumeMesh>
464template <
class VolumeMesh>
467 for(
typename std::vector<Plane>::iterator it = cut_planes_.begin(); it != cut_planes_.end(); ++it) {
471 double pn = (pl | it->normal);
472 double px = (pl | it->xDirection);
473 double py = (pl | it->yDirection);
475 if (pn < 0.0 && px > -0.5 && px < 0.5 && py > -0.5 && py < 0.5)
491template <
class VolumeMesh>
494 if ( cut_planes_.empty() )
return true;
495 return is_inside(mMesh.vertex(_vh));
507template <
class VolumeMesh>
510 if ( cut_planes_.empty() )
return true;
511 Edge e(mMesh.halfedge(_heh));
512 return is_inside(mMesh.vertex(e.from_vertex())) && is_inside(mMesh.vertex(e.to_vertex()));
524template <
class VolumeMesh>
527 if ( cut_planes_.empty() )
return true;
528 Edge e(mMesh.edge(_eh));
529 return is_inside(mMesh.vertex(e.from_vertex())) && is_inside(mMesh.vertex(e.to_vertex()));
541template <
class VolumeMesh>
544 if ( cut_planes_.empty() )
return true;
546 if (!is_inside(*hfv_it))
return false;
560template <
class VolumeMesh>
563 if ( cut_planes_.empty() )
return true;
564 return is_inside(mMesh.halfface_handle(_fh,0));
578template <
class VolumeMesh>
581 if (mStatusAttrib[_ch].hidden())
584 if (!mCellInsidenessValid)
585 calculateCellInsideness();
587 return mCellInsideness[_ch.idx()];
590template <
class VolumeMesh>
593 if (mStatusAttrib[_vh].hidden())
595 return is_inside(_vh);
598template <
class VolumeMesh>
601 if (mStatusAttrib[_heh].hidden())
603 return is_inside(_heh);
606template <
class VolumeMesh>
609 if (mStatusAttrib[_eh].hidden())
611 return is_inside(_eh);
614template <
class VolumeMesh>
617 if (mStatusAttrib[_hfh].hidden())
619 return is_inside(_hfh);
622template <
class VolumeMesh>
625 if (mStatusAttrib[_fh].hidden())
627 return is_inside(_fh);
630template <
class VolumeMesh>
633 if (mStatusAttrib[_ch].hidden())
635 return is_inside(_ch);
645template <
class VolumeMesh>
648 if (mCellInsideness.size() != mMesh.n_cells())
649 mCellInsideness.resize(mMesh.n_cells());
651 for (
unsigned int i = 0; i < mMesh.n_cells(); i++)
656 if ( cut_planes_.empty() )
663 ACG::Vec3d vertexPos = mScale * mMesh.vertex(*cv_it) + (1-mScale) * cog;
664 if (!is_inside(vertexPos)) inside =
false;
667 mCellInsideness[i] = inside;
670 mCellInsidenessValid =
true;
681template <
class VolumeMesh>
684 return mCurrentPrimitiveMode != mPrimitiveMode ||
685 mCurrentNormalMode != mNormalMode ||
686 mCurrentColorMode != mColorMode ||
687 mCurrentSkipUnselected != mSkipUnselected ||
688 mCurrentShowIrregularInnerEdges != mShowIrregularInnerEdges ||
689 mCurrentShowIrregularOuterValence2Edges != mShowIrregularOuterValence2Edges ||
690 mCurrentSkipRegularEdges != mSkipRegularEdges ||
691 mCurrentBoundaryOnly != mBoundaryOnly;
699template <
class VolumeMesh>
702 mCurrentPrimitiveMode = mPrimitiveMode;
703 mCurrentNormalMode = mNormalMode;
704 mCurrentColorMode = mColorMode;
705 mCurrentSkipUnselected = mSkipUnselected;
706 mCurrentShowIrregularInnerEdges = mShowIrregularInnerEdges;
707 mCurrentShowIrregularOuterValence2Edges = mShowIrregularOuterValence2Edges;
708 mCurrentSkipRegularEdges = mSkipRegularEdges;
709 mCurrentBoundaryOnly = mBoundaryOnly;
710 mCurrentVertexSize = mVertexSize;
711 mCurrentNormalOffset = mNormalOffset;
712 mCurrentColorOffset = mColorOffset;
713 mCurrentNumOfVertices = mNumOfVertices;
725template <
class VolumeMesh>
728 if(_inner && _valence == 3) {
730 }
else if(_inner && _valence == 5) {
732 }
else if(!_inner && _valence > 3) {
734 }
else if(!_inner && _valence == 2) {
736 }
else if(_inner && _valence > 5) {
747template <
class VolumeMesh>
750 unsigned int numOfVertices = 0;
754 if (mPrimitiveMode == PM_CELLS)
759 if (mStatusAttrib[*c_it].selected() && should_render(*c_it))
761 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
762 for (
unsigned int i = 0; i < hfs.size(); ++i)
763 numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3;
767 else if (mPrimitiveMode == PM_FACES)
771 if (mStatusAttrib[*f_it].selected() && should_render(*f_it) && (!mBoundaryOnly || mMesh.is_boundary(*f_it)))
772 numOfVertices += ((mMesh.valence(*f_it))-2)*3;
774 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
778 if (mStatusAttrib[*f_it].selected())
779 numOfVertices += ((mMesh.valence(*f_it))-2)*3*getNumOfIncidentCells(*f_it);
781 else if (mPrimitiveMode == PM_HALFFACES)
785 if (mStatusAttrib[*hf_it].selected() && should_render(*hf_it) && (!mBoundaryOnly || mMesh.is_boundary(*hf_it)))
786 numOfVertices += ((mMesh.valence(mMesh.face_handle(*hf_it)))-2)*3;
788 else if (mPrimitiveMode == PM_EDGES)
792 if (mStatusAttrib[*e_it].selected() && should_render(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
795 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
799 if (mStatusAttrib[*e_it].selected())
800 numOfVertices += 2*getNumOfIncidentCells(*e_it);
802 else if (mPrimitiveMode == PM_HALFEDGES)
806 if (mStatusAttrib[*he_it].selected() && should_render(*he_it) && (!mBoundaryOnly || mMesh.is_boundary(*he_it)))
809 else if (mPrimitiveMode == PM_VERTICES)
813 if (mStatusAttrib[*v_it].selected() && should_render(*v_it) && (!mBoundaryOnly || mMesh.is_boundary(*v_it)))
816 else if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
820 if (mStatusAttrib[*v_it].selected())
821 numOfVertices += getNumOfIncidentCells(*v_it);
826 if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
828 for (
unsigned int i = 0; i < mMesh.n_vertices(); i++)
829 numOfVertices += getNumOfIncidentCells(
VertexHandle(i));
831 else if (mPrimitiveMode == PM_VERTICES)
833 for (
unsigned int i = 0; i < mMesh.n_vertices(); i++)
837 else if (mPrimitiveMode == PM_FACES)
841 if (should_render(*f_it) && (!mBoundaryOnly || mMesh.is_boundary(*f_it)))
842 numOfVertices += ((mMesh.valence(*f_it))-2)*3;
844 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
848 numOfVertices += ((mMesh.valence(*f_it))-2)*3*getNumOfIncidentCells(*f_it);
850 else if (mPrimitiveMode == PM_HALFFACES)
854 if (should_render(*hf_it) && (!mBoundaryOnly || mMesh.is_boundary(*hf_it)))
855 numOfVertices += ((mMesh.valence(mMesh.face_handle(*hf_it)))-2)*3;
857 else if (mPrimitiveMode == PM_CELLS)
862 if (should_render(*c_it))
864 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
865 for (
unsigned int i = 0; i < hfs.size(); ++i)
866 numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3;
870 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
873 numOfVertices += 2*getNumOfIncidentCells(*e_it);
875 else if ( mPrimitiveMode == PM_EDGES )
878 if (should_render(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
881 else if ( mPrimitiveMode == PM_IRREGULAR_EDGES )
884 if (should_render(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
886 bool boundary = mMesh.is_boundary(*e_it);
887 unsigned int valence = mMesh.valence(*e_it);
890 if(( boundary && valence == 3) || (!boundary && valence == 4))
continue;
892 if ((!(mShowIrregularOuterValence2Edges)) && ( boundary && valence == 2))
continue;
894 if ((!(mShowIrregularInnerEdges)) && (( !boundary && valence != 4) ||
895 ( boundary && valence < 2) ||
896 ( boundary && valence > 3)))
continue;
901 else if ( mPrimitiveMode == PM_HALFEDGES )
904 if (should_render(*he_it) && (!mBoundaryOnly || mMesh.is_boundary(*he_it)))
913 mNumOfVertices = numOfVertices;
923template <
class VolumeMesh>
926 int incidentCells = 0;
928 if (mMesh.incident_cell(hf0) !=
CellHandle(-1))
929 if (should_render(mMesh.incident_cell(hf0)))
932 if (mMesh.incident_cell(hf1) !=
CellHandle(-1))
933 if (should_render(mMesh.incident_cell(hf1)))
935 return incidentCells;
945template <
class VolumeMesh>
948 int incidentCells = 0;
951 if (hec_it->idx() != -1)
952 if (should_render(*hec_it))
954 return incidentCells;
964template <
class VolumeMesh>
967 int incidentCells = 0;
969 if (vc_it->idx() != -1)
970 if (should_render(*vc_it))
972 return incidentCells;
982template <
class VolumeMesh>
988 return mCogs[_ch.idx()];
998template <
class VolumeMesh>
1001 if (mCogs.size() != mMesh.n_cells())
1002 mCogs.resize(mMesh.n_cells());
1008 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1011 for (
unsigned int i = 0; i < hfs.size(); ++i)
1014 cog += mMesh.vertex(*hfv_it);
1017 cog = 1.0/count * cog;
1019 mCogs[c_it->idx()] = cog;
1030template <
class VolumeMesh>
1033 return (mGeometryChanged) ||
1034 (mVertexSize != mCurrentVertexSize) ||
1035 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1036 (mNumOfVertices != mCurrentNumOfVertices);
1044template <
class VolumeMesh>
1047 return (mColorsChanged) ||
1048 (mVertexSize != mCurrentVertexSize) ||
1049 (mNumOfVertices != mCurrentNumOfVertices) ||
1050 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1051 (mColorOffset != mCurrentColorOffset) ||
1052 (mColorMode != mCurrentColorMode) ||
1053 (mShowIrregularInnerEdges != mCurrentShowIrregularInnerEdges) ||
1054 (mShowIrregularOuterValence2Edges != mCurrentShowIrregularOuterValence2Edges);
1062template <
class VolumeMesh>
1065 return (mTexCoordsChanged) ||
1066 (mVertexSize != mCurrentVertexSize) ||
1067 (mNumOfVertices != mCurrentNumOfVertices) ||
1068 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1069 (mTexCoordOffset!= mCurrentTexCoordOffset);
1077template <
class VolumeMesh>
1080 return (mNormalsChanged) ||
1081 (mVertexSize != mCurrentVertexSize) ||
1082 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1083 (mNormalOffset != mCurrentNormalOffset) ||
1084 (mNormalMode != mCurrentNormalMode) ||
1085 (mNumOfVertices != mCurrentNumOfVertices);
1093template <
class VolumeMesh>
1096 unsigned int pos = 0;
1098 if (mPrimitiveMode == PM_VERTICES)
1100 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1101 if (mSkipUnselected && !mStatusAttrib[
VertexHandle(i)].selected())
continue;
1103 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1105 addPositionToBuffer(p, _buffer, pos++);
1108 else if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
1110 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1111 if (mSkipUnselected && !mStatusAttrib[
VertexHandle(i)].selected())
continue;
1117 if (should_render(*vc_it))
1118 addPositionToBuffer(p*mScale + cog*(1-mScale), _buffer, pos++);
1122 else if (mPrimitiveMode == PM_FACES)
1124 std::vector<ACG::Vec3d> vertices;
1128 if (mSkipUnselected && !mStatusAttrib[*f_it].selected())
continue;
1129 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1130 if (!should_render(*f_it))
continue;
1133 vertices.push_back(mMesh.vertex(*hfv_it));
1135 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1137 addPositionToBuffer(vertices[0], _buffer, pos++);
1138 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1139 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1143 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
1145 std::vector<ACG::Vec3d> vertices;
1149 if (mSkipUnselected && !mStatusAttrib[*f_it].selected())
continue;
1152 vertices.push_back(mMesh.vertex(*hfv_it));
1154 for (
int i = 0; i < 2; i++)
1159 if (!should_render(ch))
continue;
1161 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1164 addPositionToBuffer(vertices[0]*mScale + cog*(1-mScale), _buffer, pos++);
1165 addPositionToBuffer(vertices[i+1]*mScale + cog*(1-mScale), _buffer, pos++);
1166 addPositionToBuffer(vertices[i+2]*mScale + cog*(1-mScale), _buffer, pos++);
1173 else if (mPrimitiveMode == PM_HALFFACES)
1175 std::vector<ACG::Vec3d> vertices;
1179 if (mSkipUnselected && !mStatusAttrib[*hf_it].selected())
continue;
1180 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1181 if (!should_render(*hf_it))
continue;
1184 vertices.push_back(mMesh.vertex(*hfv_it));
1186 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1188 addPositionToBuffer(vertices[0], _buffer, pos++);
1189 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1190 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1194 else if (mPrimitiveMode == PM_CELLS)
1196 std::vector<ACG::Vec3d> vertices;
1200 if (mSkipUnselected && !mStatusAttrib[*c_it].selected())
continue;
1201 if (!should_render(*c_it))
continue;
1202 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1204 for (
unsigned int i = 0; i < hfs.size(); ++i)
1208 vertices.push_back(mScale*mMesh.vertex(*hfv_it)+(1-mScale)*cog);
1210 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1212 addPositionToBuffer(vertices[0], _buffer, pos++);
1213 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1214 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1220 else if (mPrimitiveMode == PM_EDGES)
1225 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1226 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1227 if (!should_render(*e_it))
continue;
1229 Edge e(mMesh.edge(*e_it));
1230 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1231 addPositionToBuffer(mMesh.vertex(e.to_vertex()), _buffer, pos++);
1234 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
1239 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1241 Edge e(mMesh.edge(*e_it));
1245 if (hec_it->idx() != -1)
1247 if (!should_render(*hec_it))
continue;
1249 addPositionToBuffer(mMesh.vertex(e.from_vertex())*mScale + cog*(1-mScale), _buffer, pos++);
1250 addPositionToBuffer(mMesh.vertex(e.to_vertex()) *mScale + cog*(1-mScale), _buffer, pos++);
1255 else if (mPrimitiveMode == PM_IRREGULAR_EDGES)
1260 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1261 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1262 if (!should_render(*e_it))
continue;
1264 bool boundary = mMesh.is_boundary(*e_it);
1265 unsigned int valence = mMesh.valence(*e_it);
1267 if(( boundary && valence == 3) ||
1268 (!boundary && valence == 4))
continue;
1270 if ((!mShowIrregularOuterValence2Edges) && ( boundary && valence == 2))
continue;
1272 if ((!mShowIrregularInnerEdges) && (( !boundary && valence != 4) ||
1273 ( boundary && valence < 2) ||
1274 ( boundary && valence > 3)))
continue;
1276 Edge e(mMesh.edge(*e_it));
1277 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1278 addPositionToBuffer(mMesh.vertex(e.to_vertex()), _buffer, pos++);
1281 else if (mPrimitiveMode == PM_HALFEDGES)
1286 if (mSkipUnselected && !mStatusAttrib[*he_it].selected())
continue;
1287 if (mBoundaryOnly && !mMesh.is_boundary(*he_it))
continue;
1288 if (!should_render(*he_it))
continue;
1290 double lambda = 0.4;
1291 Edge e(mMesh.halfedge(*he_it));
1292 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1293 addPositionToBuffer((1-lambda)*mMesh.vertex(e.from_vertex()) + lambda*mMesh.vertex(e.to_vertex()), _buffer, pos++);
1307template <
class VolumeMesh>
1310 if (mNormalMode == NM_NONE)
return;
1312 unsigned int pos = 0;
1314 if ((mPrimitiveMode == PM_FACES) && (mNormalMode == NM_FACE))
1319 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1320 if (!should_render(*f_it))
continue;
1322 unsigned int numOfVerticesInFace = mMesh.valence(*f_it);
1324 for (
unsigned int i = 0; i < numOfVerticesInFace - 2; i++)
1326 addNormalToBuffer(normal, _buffer, pos++);
1327 addNormalToBuffer(normal, _buffer, pos++);
1328 addNormalToBuffer(normal, _buffer, pos++);
1332 else if ((mPrimitiveMode == PM_FACES) && (mNormalMode == NM_VERTEX))
1334 std::vector<ACG::Vec3d> normals;
1338 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1339 if (!should_render(*f_it))
continue;
1342 normals.push_back(mNormalAttrib[*hfv_it]);
1344 for (
unsigned int i = 0; i < normals.size()-2; i++)
1346 addNormalToBuffer(normals[0], _buffer, pos++);
1347 addNormalToBuffer(normals[i+1], _buffer, pos++);
1348 addNormalToBuffer(normals[i+2], _buffer, pos++);
1352 else if ((mPrimitiveMode == PM_HALFFACES) && (mNormalMode == NM_HALFFACE))
1357 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1358 if (!should_render(*hf_it))
continue;
1360 unsigned int numOfVerticesInCell = 0;
1362 ++numOfVerticesInCell;
1364 for (
unsigned int i = 0; i < numOfVerticesInCell- 2; i++)
1366 addNormalToBuffer(normal, _buffer, pos++);
1367 addNormalToBuffer(normal, _buffer, pos++);
1368 addNormalToBuffer(normal, _buffer, pos++);
1372 else if ((mPrimitiveMode == PM_HALFFACES) && (mNormalMode == NM_VERTEX))
1374 std::vector<ACG::Vec3d> normals;
1378 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1379 if (!should_render(*hf_it))
continue;
1382 normals.push_back(mNormalAttrib[*hfv_it]);
1384 for (
unsigned int i = 0; i < normals.size()-2; i++)
1386 addNormalToBuffer(normals[0], _buffer, pos++);
1387 addNormalToBuffer(normals[i+1], _buffer, pos++);
1388 addNormalToBuffer(normals[i+2], _buffer, pos++);
1392 else if ((mPrimitiveMode == PM_CELLS) && (mNormalMode == NM_HALFFACE))
1397 if (!should_render(*c_it))
continue;
1398 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1399 for (
unsigned int i = 0; i < hfs.size(); ++i)
1401 ACG::Vec3d normal = -1.0*mNormalAttrib[hfs[i]];
1402 unsigned int numOfVerticesInFace = mMesh.valence(mMesh.face_handle(hfs[i]));
1404 for (
unsigned int i = 0; i < numOfVerticesInFace-2; i++)
1406 addNormalToBuffer(normal, _buffer, pos++);
1407 addNormalToBuffer(normal, _buffer, pos++);
1408 addNormalToBuffer(normal, _buffer, pos++);
1413 else if ((mPrimitiveMode == PM_CELLS) && (mNormalMode == NM_VERTEX))
1415 std::vector<ACG::Vec3d> normals;
1419 if (!should_render(*c_it))
continue;
1420 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1422 for (
unsigned int i = 0; i < hfs.size(); ++i)
1426 normals.push_back(mNormalAttrib[*hfv_it]);
1428 for (
unsigned int i = 0; i < normals.size()-2; i++)
1430 addNormalToBuffer(normals[0], _buffer, pos++);
1431 addNormalToBuffer(normals[i+1], _buffer, pos++);
1432 addNormalToBuffer(normals[i+2], _buffer, pos++);
1445template <
class VolumeMesh>
1448 unsigned int pos = 0;
1450 if ((mPrimitiveMode == PM_VERTICES) && (mColorMode == CM_VERTEX))
1452 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i)
1454 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1457 addColorToBuffer(color, _buffer, pos++);
1460 else if ((mPrimitiveMode == PM_FACES) && (mColorMode == CM_VERTEX))
1462 std::vector<ACG::Vec4f> colors;
1466 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1467 if (!should_render(*f_it))
continue;
1471 colors.push_back(mColorAttrib[*hfv_it]);
1473 for (
unsigned int i = 0; i < (colors.
size()-2); i++)
1475 addColorToBuffer(colors[0], _buffer, pos++);
1476 addColorToBuffer(colors[i+1], _buffer, pos++);
1477 addColorToBuffer(colors[i+2], _buffer, pos++);
1481 else if ((mPrimitiveMode == PM_FACES) && (mColorMode == CM_FACE))
1486 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1487 if (!should_render(*f_it))
continue;
1490 unsigned int numOfVerticesInFace = mMesh.valence(*f_it);
1491 unsigned int numOfDrawnTriangles = numOfVerticesInFace-2;
1493 for (
unsigned int i = 0; i < numOfDrawnTriangles*3; i++)
1494 addColorToBuffer(color, _buffer, pos++);
1497 else if ((mPrimitiveMode == PM_HALFFACES) && (mColorMode == CM_HALFFACE))
1502 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1503 if (!should_render(*hf_it))
continue;
1506 unsigned int numOfVerticesInFace = mMesh.valence(mMesh.face_handle(*hf_it));
1507 unsigned int numOfDrawnTriangles = numOfVerticesInFace-2;
1509 for (
unsigned int i = 0; i < numOfDrawnTriangles*3; i++)
1510 addColorToBuffer(color, _buffer, pos++);
1513 else if ((mPrimitiveMode == PM_HALFFACES) && (mColorMode == CM_VERTEX))
1515 std::vector<ACG::Vec4f> colors;
1519 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1520 if (!should_render(*hf_it))
continue;
1524 colors.push_back(mColorAttrib[*hfv_it]);
1526 for (
unsigned int i = 0; i < (colors.
size()-2); i++)
1528 addColorToBuffer(colors[0], _buffer, pos++);
1529 addColorToBuffer(colors[i+1], _buffer, pos++);
1530 addColorToBuffer(colors[i+2], _buffer, pos++);
1534 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_CELL))
1539 if (!should_render(*c_it))
continue;
1541 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1542 for (
unsigned int i = 0; i < hfs.size(); ++i)
1544 unsigned int numOfVerticesInHalfface = 0;
1546 ++numOfVerticesInHalfface;
1548 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1549 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1550 addColorToBuffer(color, _buffer, pos++);
1554 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_HALFFACE))
1559 if (!should_render(*c_it))
continue;
1560 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1561 for (
unsigned int i = 0; i < hfs.size(); ++i)
1564 unsigned int numOfVerticesInHalfface = 0;
1566 ++numOfVerticesInHalfface;
1568 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1569 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1570 addColorToBuffer(color, _buffer, pos++);
1574 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_FACE))
1579 if (!should_render(*c_it))
continue;
1580 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1581 for (
unsigned int i = 0; i < hfs.size(); ++i)
1583 ACG::Vec4f color = mColorAttrib[mMesh.face_handle(hfs[i])];
1584 unsigned int numOfVerticesInHalfface = 0;
1586 ++numOfVerticesInHalfface;
1588 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1589 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1590 addColorToBuffer(color, _buffer, pos++);
1594 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_VERTEX))
1596 std::vector<ACG::Vec4f> colors;
1600 if (!should_render(*c_it))
continue;
1601 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1602 for (
unsigned int i = 0; i < hfs.size(); ++i)
1606 colors.push_back(mColorAttrib[*hfv_it]);
1608 for (
unsigned int i = 0; i < colors.
size()-2; i++)
1610 addColorToBuffer(colors[0], _buffer, pos++);
1611 addColorToBuffer(colors[i+1], _buffer, pos++);
1612 addColorToBuffer(colors[i+2], _buffer, pos++);
1617 else if ((mPrimitiveMode == PM_EDGES) && (mColorMode == CM_EDGE))
1622 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1623 if (!should_render(*e_it))
continue;
1625 addColorToBuffer(color, _buffer, pos++);
1626 addColorToBuffer(color, _buffer, pos++);
1629 else if ((mPrimitiveMode == PM_EDGES) && (mShowIrregularInnerEdges || mShowIrregularOuterValence2Edges))
1634 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1635 if (!should_render(*e_it))
continue;
1637 bool boundary = mMesh.is_boundary(*e_it);
1638 unsigned int valence = mMesh.valence(*e_it);
1640 bool isIrregularInner = ( boundary && valence < 2) || ( boundary && valence > 3) || (!boundary && valence != 4);
1641 bool isIrregularOuterValence2 = ( boundary && valence == 2);
1645 if (isIrregularInner && mShowIrregularInnerEdges)
1646 color = getValenceColorCode(valence, !boundary);
1647 else if (isIrregularOuterValence2 && mShowIrregularOuterValence2Edges)
1648 color = getValenceColorCode(valence, !boundary);
1650 color = mDefaultColor;
1652 addColorToBuffer(color, _buffer, pos++);
1653 addColorToBuffer(color, _buffer, pos++);
1656 else if ( mPrimitiveMode == PM_IRREGULAR_EDGES )
1661 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1662 if (!should_render(*e_it))
continue;
1664 bool boundary = mMesh.is_boundary(*e_it);
1665 unsigned int valence = mMesh.valence(*e_it);
1667 bool isRegular = ( boundary && valence == 3) || (!boundary && valence == 4);
1668 bool isIrregularInner = ( boundary && valence < 2) || ( boundary && valence > 3) || (!boundary && valence != 4);
1669 bool isIrregularOuterValence2 = ( boundary && valence == 2);
1671 if (isRegular)
continue;
1672 if (isIrregularInner && !mShowIrregularInnerEdges)
continue;
1673 if (isIrregularOuterValence2 && !mShowIrregularOuterValence2Edges)
continue;
1677 if (isIrregularInner && mShowIrregularInnerEdges)
1678 color = getValenceColorCode(valence, !boundary);
1679 else if (isIrregularOuterValence2 && mShowIrregularOuterValence2Edges)
1680 color = getValenceColorCode(valence, !boundary);
1682 color = mDefaultColor;
1684 addColorToBuffer(color, _buffer, pos++);
1685 addColorToBuffer(color, _buffer, pos++);
1688 else if ((mPrimitiveMode == PM_HALFEDGES) && (mColorMode == CM_HALFEDGE))
1693 if (mBoundaryOnly && !mMesh.is_boundary(*he_it))
continue;
1694 if (!should_render(*he_it))
continue;
1697 addColorToBuffer(color, _buffer, pos++);
1698 addColorToBuffer(color, _buffer, pos++);
1709template <
class VolumeMesh>
1713 unsigned int pos = 0;
1715 if (mTexCoordMode == TCM_NONE)
1718 if (mPrimitiveMode == PM_FACES)
1720 std::vector<ACG::Vec2f> texCoords;
1724 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1725 if (!should_render(*f_it))
continue;
1729 texCoords.push_back(mTexcoordAttrib[*hfv_it]);
1731 for (
unsigned int i = 0; i < (texCoords.size()-2); i++)
1733 addTexCoordToBuffer(texCoords[0], _buffer, pos++);
1734 addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
1735 addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
1739 else if (mPrimitiveMode == PM_HALFFACES)
1741 std::vector<ACG::Vec2f> texCoords;
1745 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1746 if (!should_render(*hf_it))
continue;
1750 texCoords.push_back(mTexcoordAttrib[*hfv_it]);
1752 for (
unsigned int i = 0; i < (texCoords.size()-2); i++)
1754 addTexCoordToBuffer(texCoords[0], _buffer, pos++);
1755 addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
1756 addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
1771template <
class VolumeMesh>
1774 unsigned int pos = 0;
1776 if (mPrimitiveMode == PM_VERTICES)
1778 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i)
1780 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1783 addColorToBuffer(color, _buffer, pos++);
1786 if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
1788 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1790 unsigned int numOfIncidentCells = getNumOfIncidentCells(
VertexHandle(i));
1791 for (
unsigned int j = 0; j < numOfIncidentCells; j++)
1792 addColorToBuffer(color, _buffer, pos++);
1795 else if (mPrimitiveMode == PM_EDGES)
1800 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1801 if (!should_render(*e_it))
continue;
1803 addColorToBuffer(color, _buffer, pos++);
1804 addColorToBuffer(color, _buffer, pos++);
1807 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
1813 unsigned int numOfIncidentCells = getNumOfIncidentCells(*e_it);
1814 for (
unsigned int i = 0; i < numOfIncidentCells*2;i++)
1815 addColorToBuffer(color, _buffer, pos++);
1818 else if (mPrimitiveMode == PM_FACES)
1823 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1824 if (!should_render(*f_it))
continue;
1827 unsigned int numOfVertices = 0;
1831 for (
unsigned int i = 0; i < (numOfVertices-2)*3; i++)
1832 addColorToBuffer(color, _buffer, pos++);
1835 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
1842 unsigned int numOfVerticesInHalfface = 0;
1844 ++numOfVerticesInHalfface;
1846 for (
int i = 0; i < 2; i++)
1851 if (!should_render(ch))
continue;
1852 for (
unsigned int i = 0; i < (numOfVerticesInHalfface-2)*3; i++)
1853 addColorToBuffer(color, _buffer, pos++);
1858 else if (mPrimitiveMode == PM_CELLS)
1863 if (!should_render(*c_it))
continue;
1865 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1866 for (
unsigned int i = 0; i < hfs.size(); ++i)
1868 unsigned int numOfVerticesInHalfface = 0;
1870 ++numOfVerticesInHalfface;
1872 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1873 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1874 addColorToBuffer(color, _buffer, pos++);
1887template <
class VolumeMesh>
1890 if ((mBuffer == 0) || optionsChanged() || mInvalidated)
1896 calculateVertexDeclaration();
1898 if (optionsChanged())
1899 mNumOfVertices = -1;
1901 unsigned int numOfVertices = getNumOfVertices();
1903 bool needs_rebuild = positionsNeedRebuild()
1904 || normalsNeedRebuild()
1905 || colorsNeedRebuild()
1906 || texCoordsNeedRebuild();
1908 if (getNumOfVertices() > 0 && needs_rebuild)
1910 unsigned int bufferSize = mVertexSize * numOfVertices;
1916 GL_ARRAY_BUFFER, GL_WRITE_ONLY);
1920 std::cerr <<
"VolumeMeshBufferManager::getBuffer(): error mapping buffer" << std::endl;
1924 buildVertexBuffer(buffer);
1925 buildNormalBuffer(buffer);
1926 buildColorBuffer(buffer);
1927 buildTexCoordBuffer(buffer);
1934 mInvalidated =
false;
1935 mGeometryChanged =
false;
1936 mColorsChanged =
false;
1937 mNormalsChanged =
false;
1938 mTexCoordsChanged =
false;
1953template <
class VolumeMesh>
1956 if (_offset != mCurrentPickOffset || _state.
pick_current_index() != mGlobalPickOffset)
1962 if ((mBuffer == 0) || optionsChanged() || mInvalidated)
1967 calculateVertexDeclaration();
1969 if (optionsChanged())
1970 mNumOfVertices = -1;
1972 unsigned int numOfVertices = getNumOfVertices();
1974 if (getNumOfVertices() > 0 && (positionsNeedRebuild() || colorsNeedRebuild()))
1976 unsigned int bufferSize = mVertexSize * numOfVertices;
1984 std::cerr <<
"VolumeMeshBufferManager::getPickBuffer(): error while mapping buffer" << std::endl;
1988 buildVertexBuffer(buffer);
1989 buildPickColorBuffer(_state, _offset, buffer);
1995 mCurrentPickOffset = _offset;
1997 mInvalidated =
false;
1998 mGeometryChanged =
false;
1999 mColorsChanged =
false;
2000 mTexCoordsChanged =
false;
2010template <
class VolumeMesh>
2013 invalidateGeometry();
2014 invalidateNormals();
2021template <
class VolumeMesh>
2024 mInvalidated =
true;
2025 mNumOfVertices = -1;
2026 mGeometryChanged =
true;
2027 mColorsChanged =
true;
2028 mTexCoordsChanged =
true;
2029 mNormalsChanged =
true;
2031 mCellInsidenessValid =
false;
2037template <
class VolumeMesh>
2040 mInvalidated =
true;
2041 mColorsChanged =
true;
2047template <
class VolumeMesh>
2050 mInvalidated =
true;
2051 mNormalsChanged =
true;
2057template <
class VolumeMesh>
2060 mInvalidated =
true;
2061 mTexCoordsChanged =
true;
2069template <
class VolumeMesh>
static GLboolean unmapBuffer(GLenum target)
Vec4uc pick_get_name_color(size_t _idx)
static void genBuffers(GLsizei n, GLuint *buffers)
size_t pick_current_index() const
Returns the current color picking index (can be used for caching)
static void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
static void deleteBuffers(GLsizei n, const GLuint *buffers)
static GLvoid * mapBuffer(GLenum target, GLenum access)
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
static constexpr size_t size()
returns dimension of the vector
This class creates buffers that can be used to render open volume meshs.
void buildNormalBuffer(unsigned char *_buffer)
Adds all normals to the buffer.
void free()
Deletes the buffers on the GPU.
bool texCoordsNeedRebuild()
Checks whether texture coordinates need to be rebuild.
void saveOptions()
State that the current buffer was built with the current options.
void setDefaultColor(ACG::Vec4f _defaultColor)
Sets the default color.
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.
bool positionsNeedRebuild()
Checks whether positions need to be rebuild.
void addPositionToBuffer(ACG::Vec3d _position, unsigned char *_buffer, unsigned int _offset)
Adds a position to the buffer.
bool normalsNeedRebuild()
Checks whether normals need to be rebuild.
void calculateVertexDeclaration()
Constructs a VertexDeclaration, the size and the offsets for the vertices stored in the buffer.
int getNumOfIncidentCells(OpenVolumeMesh::FaceHandle _fh)
Returns the number of cells that are incident to the given face and also inside w....
void buildPickColorBuffer(ACG::GLState &_state, unsigned int _offset, unsigned char *_buffer)
Adds all picking colors to the buffer.
ACG::Vec3d getCOG(OpenVolumeMesh::CellHandle _ch)
Returns the center of gravity of the given cell.
unsigned int getNumOfVertices()
Returns the number of vertices stored in the buffer.
void addCutPlane(const ACG::Geometry::Plane &_p)
Adds a cut plane.
void clearCutPlanes()
Removes all cut planes.
void invalidateColors()
Invalidates colors.
GLuint getBuffer()
Returns the name of the buffer.
void buildTexCoordBuffer(unsigned char *_buffer)
Adds texture coordinates to the buffer.
bool colorsNeedRebuild()
Checks whether colors need to be rebuild.
void addNormalToBuffer(ACG::Vec3d _normal, unsigned char *_buffer, unsigned int _offset)
Adds a normal to the buffer.
void invalidateNormals()
Invalidates normals.
void invalidate()
Invalidates the buffer.
void invalidateTexCoords()
Invalidates texture coordinates.
void addFloatToBuffer(float _value, unsigned char *&_buffer)
Adds a float to the buffer.
void addColorToBuffer(ACG::Vec4uc _color, unsigned char *_buffer, unsigned int _offset)
Adds a color to the buffer.
void calculateCOGs()
Calculates the center of gravity for all cells.
void countNumOfVertices()
Counts the number of vertices that need to be stored in the buffer.
void buildColorBuffer(unsigned char *_buffer)
Adds all colors to the buffer.
void addTexCoordToBuffer(ACG::Vec2f _texCoord, unsigned char *_buffer, unsigned int _offset)
Adds a texture coordnate to the buffer.
void setOptionsFromDrawMode(ACG::SceneGraph::DrawModes::DrawMode _drawMode)
Configures the buffer manager's options from a DrawMode.
GLuint getPickBuffer(ACG::GLState &_state, unsigned int _offset)
Returns the name of the pick buffer.
bool is_inside(const ACG::Vec3d &_p)
Tests whether the given point is inside w.r.t. all cut planes.
void invalidateGeometry()
Invalidates geometry.
ACG::Vec4f getValenceColorCode(unsigned int _valence, bool _inner) const
Returns a color code for irregular edges.
void buildVertexBuffer(unsigned char *_buffer)
Adds all vertices to the buffer.
void addUCharToBuffer(unsigned char _value, unsigned char *&_buffer)
Adds an unsigned char to the buffer.
Namespace providing different geometric functions concerning angles.
VectorT< float, 4 > Vec4f
@ VERTEX_USAGE_NORMAL
"inNormal"
@ VERTEX_USAGE_COLOR
"inColor"
@ VERTEX_USAGE_POSITION
"inPosition"
@ VERTEX_USAGE_TEXCOORD
"inTexCoord"
VectorT< double, 3 > Vec3d