50 #define VOLUMEMESHBUFFERMANAGERT_CC
52 #include "VolumeMeshBufferManager.hh"
54 template <
class VolumeMesh>
60 mDefaultColor(
ACG::
Vec4f(0.0,0.0,0.0,1.0)),
62 mStatusAttrib(statusAttrib_),
63 mColorAttrib(colorAttrib_),
64 mNormalAttrib(normalAttrib_),
65 mTexcoordAttrib(texcoordAttrib_),
67 mCurrentNumOfVertices(-1),
74 mCurrentPickOffset(-1),
77 mGeometryChanged(true),
78 mNormalsChanged(true),
80 mTexCoordsChanged(true),
82 mPrimitiveMode(PM_NONE),
84 mColorMode(CM_NO_COLORS),
85 mSkipUnselected(false),
86 mShowIrregularInnerEdges(false),
87 mShowIrregularOuterValence2Edges(false),
88 mSkipRegularEdges(false),
90 mCurrentPrimitiveMode(PM_NONE),
91 mCurrentNormalMode(NM_NONE),
92 mCurrentColorMode(CM_NO_COLORS),
93 mCurrentSkipUnselected(false),
94 mCurrentShowIrregularInnerEdges(false),
95 mCurrentShowIrregularOuterValence2Edges(false),
96 mCurrentSkipRegularEdges(false),
97 mCurrentBoundaryOnly(false),
98 mCurrentVertexSize(0),
99 mCurrentNormalOffset(0),
100 mCurrentColorOffset(0),
102 mCellInsidenessValid(),
103 mTexCoordMode(TCM_NONE),
104 mCurrentTexCoordMode(TCM_NONE),
106 mCurrentTexCoordOffset(0)
120 template <
class VolumeMesh>
124 unsigned char *v = (
unsigned char *) &_value;
142 template <
class VolumeMesh>
159 template <
class VolumeMesh>
162 unsigned char* buffer = _buffer + _offset*mVertexSize;
163 addFloatToBuffer(_position[0], buffer);
164 addFloatToBuffer(_position[1], buffer);
165 addFloatToBuffer(_position[2], buffer);
178 template <
class VolumeMesh>
181 unsigned char* buffer = _buffer + _offset*mVertexSize + mColorOffset;
182 addUCharToBuffer(_color[0], buffer);
183 addUCharToBuffer(_color[1], buffer);
184 addUCharToBuffer(_color[2], buffer);
185 addUCharToBuffer(_color[3], buffer);
200 template <
class VolumeMesh>
203 unsigned char* buffer = _buffer + _offset*mVertexSize + mColorOffset;
204 addUCharToBuffer(_color[0]*255, buffer);
205 addUCharToBuffer(_color[1]*255, buffer);
206 addUCharToBuffer(_color[2]*255, buffer);
207 addUCharToBuffer(_color[3]*255, buffer);
220 template <
class VolumeMesh>
223 unsigned char* buffer = _buffer + _offset*mVertexSize + mNormalOffset;
224 addFloatToBuffer(_normal[0], buffer);
225 addFloatToBuffer(_normal[1], buffer);
226 addFloatToBuffer(_normal[2], buffer);
239 template <
class VolumeMesh>
242 unsigned char* buffer = _buffer + _offset*mVertexSize + mTexCoordOffset;
243 addFloatToBuffer(_texCoord[0], buffer);
244 addFloatToBuffer(_texCoord[1], buffer);
255 template <
class VolumeMesh>
258 unsigned int currentOffset = 0;
259 mVertexDeclaration.clear();
264 if (mPrimitiveMode != PM_NONE)
267 currentOffset += 3*
sizeof(float);
270 if (mNormalMode != NM_NONE)
272 mNormalOffset = currentOffset;
274 currentOffset += 3*
sizeof(float);
277 if ((mColorMode != CM_NO_COLORS) || mShowIrregularInnerEdges || mShowIrregularOuterValence2Edges)
279 mColorOffset = currentOffset;
280 mVertexDeclaration.addElement(GL_UNSIGNED_BYTE, 4,
ACG::VERTEX_USAGE_COLOR, reinterpret_cast<GLuint*>(currentOffset));
281 currentOffset += 4*
sizeof(char);
284 if ((mTexCoordMode != TCM_NONE))
286 mTexCoordOffset = currentOffset;
287 unsigned char numOfCoords = 0;
288 if (mTexCoordMode == TCM_SINGLE_2D)
291 currentOffset += numOfCoords *
sizeof(float);
294 mVertexSize = currentOffset;
302 template <
class VolumeMesh>
305 if (mNumOfVertices == -1)
306 countNumOfVertices();
307 return mNumOfVertices;
317 template <
class VolumeMesh>
320 if (mDefaultColor != _defaultColor)
323 mDefaultColor = _defaultColor;
335 template <
class VolumeMesh>
339 if (_drawMode & (mDrawModes.cellsColoredPerCell))
340 enablePerCellColors();
341 else if (_drawMode & (mDrawModes.cellsColoredPerFace | mDrawModes.facesColoredPerFace))
342 enablePerFaceColors();
343 else if (_drawMode & (mDrawModes.cellsColoredPerHalfface | mDrawModes.halffacesColoredPerHalfface))
344 enablePerHalffaceColors();
345 else if (_drawMode & ( mDrawModes.edgesColoredPerEdge ))
346 enablePerEdgeColors();
347 else if (_drawMode & (mDrawModes.halfedgesColoredPerHalfedge))
348 enablePerHalfedgeColors();
349 else if (_drawMode & (mDrawModes.cellsColoredPerVertex | mDrawModes.facesColoredPerVertex |
350 mDrawModes.halffacesColoredPerVertex | mDrawModes.edgesColoredPerEdge |
351 mDrawModes.verticesColored))
352 enablePerVertexColors();
357 if (_drawMode & (mDrawModes.cellsFlatShaded | mDrawModes.halffacesFlatShaded))
358 enablePerHalffaceNormals();
359 else if (_drawMode & (mDrawModes.facesFlatShaded | mDrawModes.facesTexturedShaded))
360 enablePerFaceNormals();
361 else if (_drawMode & (mDrawModes.cellsSmoothShaded | mDrawModes.facesSmoothShaded | mDrawModes.halffacesSmoothShaded |
362 mDrawModes.cellsPhongShaded | mDrawModes.facesPhongShaded | mDrawModes.halffacesPhongShaded))
363 enablePerVertexNormals();
367 if (_drawMode & (mDrawModes.irregularInnerEdges))
368 mShowIrregularInnerEdges =
true;
370 mShowIrregularInnerEdges =
false;
372 if (_drawMode & (mDrawModes.irregularOuterEdges))
373 mShowIrregularOuterValence2Edges =
true;
375 mShowIrregularOuterValence2Edges =
false;
377 if (!mShowIrregularInnerEdges && !mShowIrregularOuterValence2Edges)
378 mSkipRegularEdges =
false;
380 mSkipRegularEdges =
true;
384 if (_drawMode & (mDrawModes.facesTextured | mDrawModes.facesTexturedShaded))
385 mTexCoordMode = TCM_SINGLE_2D;
387 mTexCoordMode = TCM_NONE;
390 if (_drawMode & (mDrawModes.cellBasedDrawModes))
391 mPrimitiveMode = PM_CELLS;
392 else if (_drawMode & (mDrawModes.facesOnCells))
393 mPrimitiveMode = PM_FACES_ON_CELLS;
394 else if (_drawMode & (mDrawModes.faceBasedDrawModes | mDrawModes.hiddenLineBackgroundFaces))
395 mPrimitiveMode = PM_FACES;
396 else if (_drawMode & (mDrawModes.halffaceBasedDrawModes))
397 mPrimitiveMode = PM_HALFFACES;
398 else if (_drawMode & (mDrawModes.edgesOnCells))
399 mPrimitiveMode = PM_EDGES_ON_CELLS;
400 else if (_drawMode & ((mDrawModes.edgeBasedDrawModes) & ~(mDrawModes.irregularInnerEdges | mDrawModes.irregularOuterEdges)))
401 mPrimitiveMode = PM_EDGES;
402 else if (_drawMode & (mDrawModes.irregularInnerEdges | mDrawModes.irregularOuterEdges))
403 mPrimitiveMode = PM_IRREGULAR_EDGES;
404 else if (_drawMode & (mDrawModes.halfedgeBasedDrawModes))
405 mPrimitiveMode = PM_HALFEDGES;
406 else if (_drawMode & (mDrawModes.verticesOnCells))
407 mPrimitiveMode = PM_VERTICES_ON_CELLS;
408 else if (_drawMode & (mDrawModes.vertexBasedDrawModes))
409 mPrimitiveMode = PM_VERTICES;
411 mPrimitiveMode = PM_NONE;
423 template <
class VolumeMesh>
427 invalidateGeometry();
428 mCellInsidenessValid =
false;
438 template <
class VolumeMesh>
441 cut_planes_.push_back(_p);
442 invalidateGeometry();
443 mCellInsidenessValid =
false;
456 template <
class VolumeMesh>
459 addCutPlane(
Plane(_p, _n, _xsize, _ysize));
469 template <
class VolumeMesh>
472 for(
typename std::vector<Plane>::iterator it = cut_planes_.begin(); it != cut_planes_.end(); ++it) {
476 double pn = (pl | it->normal);
477 double px = (pl | it->xdirection);
478 double py = (pl | it->ydirection);
480 if (pn < 0.0 && px > -0.5 && px < 0.5 && py > -0.5 && py < 0.5)
496 template <
class VolumeMesh>
499 if ( cut_planes_.empty() )
return true;
500 return is_inside(mMesh.vertex(_vh));
512 template <
class VolumeMesh>
515 if ( cut_planes_.empty() )
return true;
516 Edge e(mMesh.halfedge(_heh));
517 return is_inside(mMesh.vertex(e.from_vertex())) && is_inside(mMesh.vertex(e.to_vertex()));
529 template <
class VolumeMesh>
532 if ( cut_planes_.empty() )
return true;
533 Edge e(mMesh.edge(_eh));
534 return is_inside(mMesh.vertex(e.from_vertex())) && is_inside(mMesh.vertex(e.to_vertex()));
546 template <
class VolumeMesh>
549 if ( cut_planes_.empty() )
return true;
551 if (!is_inside(*hfv_it))
return false;
565 template <
class VolumeMesh>
568 if ( cut_planes_.empty() )
return true;
569 return is_inside(mMesh.halfface_handle(_fh,0));
583 template <
class VolumeMesh>
586 if (!mCellInsidenessValid)
587 calculateCellInsideness();
589 return mCellInsideness[_ch.idx()];
599 template <
class VolumeMesh>
602 if (mCellInsideness.size() != mMesh.n_cells())
603 mCellInsideness.resize(mMesh.n_cells());
605 for (
unsigned int i = 0; i < mMesh.n_cells(); i++)
610 if ( cut_planes_.empty() )
617 ACG::Vec3d vertexPos = mScale * mMesh.vertex(*cv_it) + (1-mScale) * cog;
618 if (!is_inside(vertexPos)) inside =
false;
621 mCellInsideness[i] = inside;
624 mCellInsidenessValid =
true;
635 template <
class VolumeMesh>
638 return mCurrentPrimitiveMode != mPrimitiveMode ||
639 mCurrentNormalMode != mNormalMode ||
640 mCurrentColorMode != mColorMode ||
641 mCurrentSkipUnselected != mSkipUnselected ||
642 mCurrentShowIrregularInnerEdges != mShowIrregularInnerEdges ||
643 mCurrentShowIrregularOuterValence2Edges != mShowIrregularOuterValence2Edges ||
644 mCurrentSkipRegularEdges != mSkipRegularEdges ||
645 mCurrentBoundaryOnly != mBoundaryOnly;
653 template <
class VolumeMesh>
656 mCurrentPrimitiveMode = mPrimitiveMode;
657 mCurrentNormalMode = mNormalMode;
658 mCurrentColorMode = mColorMode;
659 mCurrentSkipUnselected = mSkipUnselected;
660 mCurrentShowIrregularInnerEdges = mShowIrregularInnerEdges;
661 mCurrentShowIrregularOuterValence2Edges = mShowIrregularOuterValence2Edges;
662 mCurrentSkipRegularEdges = mSkipRegularEdges;
663 mCurrentBoundaryOnly = mBoundaryOnly;
664 mCurrentVertexSize = mVertexSize;
665 mCurrentNormalOffset = mNormalOffset;
666 mCurrentColorOffset = mColorOffset;
667 mCurrentNumOfVertices = mNumOfVertices;
679 template <
class VolumeMesh>
682 if(_inner && _valence == 3) {
684 }
else if(_inner && _valence == 5) {
686 }
else if(!_inner && _valence > 3) {
688 }
else if(!_inner && _valence == 2) {
690 }
else if(_inner && _valence > 5) {
701 template <
class VolumeMesh>
704 unsigned int numOfVertices = 0;
708 if (mPrimitiveMode == PM_CELLS)
712 if (mStatusAttrib[*c_it].selected() && is_inside(*c_it))
714 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
715 for (
unsigned int i = 0; i < hfs.size(); ++i)
716 numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3;
719 else if (mPrimitiveMode == PM_FACES)
723 if (mStatusAttrib[*f_it].selected() && is_inside(*f_it) && (!mBoundaryOnly || mMesh.is_boundary(*f_it)))
724 numOfVertices += ((mMesh.valence(*f_it))-2)*3;
726 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
730 if (mStatusAttrib[*f_it].selected())
731 numOfVertices += ((mMesh.valence(*f_it))-2)*3*getNumOfIncidentCells(*f_it);
733 else if (mPrimitiveMode == PM_HALFFACES)
737 if (mStatusAttrib[*hf_it].selected() && is_inside(*hf_it) && (!mBoundaryOnly || mMesh.is_boundary(*hf_it)))
738 numOfVertices += ((mMesh.valence(mMesh.face_handle(*hf_it)))-2)*3;
740 else if (mPrimitiveMode == PM_EDGES)
744 if (mStatusAttrib[*e_it].selected() && is_inside(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
747 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
751 if (mStatusAttrib[*e_it].selected())
752 numOfVertices += 2*getNumOfIncidentCells(*e_it);
754 else if (mPrimitiveMode == PM_HALFEDGES)
758 if (mStatusAttrib[*he_it].selected() && is_inside(*he_it) && (!mBoundaryOnly || mMesh.is_boundary(*he_it)))
761 else if (mPrimitiveMode == PM_VERTICES)
765 if (mStatusAttrib[*v_it].selected() && is_inside(*v_it) && (!mBoundaryOnly || mMesh.is_boundary(*v_it)))
768 else if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
772 if (mStatusAttrib[*v_it].selected())
773 numOfVertices += getNumOfIncidentCells(*v_it);
778 if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
780 for (
unsigned int i = 0; i < mMesh.n_vertices(); i++)
781 numOfVertices += getNumOfIncidentCells(
VertexHandle(i));
783 else if (mPrimitiveMode == PM_VERTICES)
785 for (
unsigned int i = 0; i < mMesh.n_vertices(); i++)
789 else if (mPrimitiveMode == PM_FACES)
793 if (is_inside(*f_it) && (!mBoundaryOnly || mMesh.is_boundary(*f_it)))
794 numOfVertices += ((mMesh.valence(*f_it))-2)*3;
796 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
800 numOfVertices += ((mMesh.valence(*f_it))-2)*3*getNumOfIncidentCells(*f_it);
802 else if (mPrimitiveMode == PM_HALFFACES)
806 if (is_inside(*hf_it) && (!mBoundaryOnly || mMesh.is_boundary(*hf_it)))
807 numOfVertices += ((mMesh.valence(mMesh.face_handle(*hf_it)))-2)*3;
809 else if (mPrimitiveMode == PM_CELLS)
814 if (is_inside(*c_it))
816 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
817 for (
unsigned int i = 0; i < hfs.size(); ++i)
818 numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3;
822 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
825 numOfVertices += 2*getNumOfIncidentCells(*e_it);
827 else if ( mPrimitiveMode == PM_EDGES )
830 if (is_inside(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
833 else if ( mPrimitiveMode == PM_IRREGULAR_EDGES )
836 if (is_inside(*e_it) && (!mBoundaryOnly || mMesh.is_boundary(*e_it)))
838 bool boundary = mMesh.is_boundary(*e_it);
839 unsigned int valence = mMesh.valence(*e_it);
842 if(( boundary && valence == 3) || (!boundary && valence == 4))
continue;
844 if ((!(mShowIrregularOuterValence2Edges)) && ( boundary && valence == 2))
continue;
846 if ((!(mShowIrregularInnerEdges)) && (( !boundary && valence != 4) ||
847 ( boundary && valence < 2) ||
848 ( boundary && valence > 3)))
continue;
853 else if ( mPrimitiveMode == PM_HALFEDGES )
856 if (is_inside(*he_it) && (!mBoundaryOnly || mMesh.is_boundary(*he_it)))
865 mNumOfVertices = numOfVertices;
875 template <
class VolumeMesh>
878 int incidentCells = 0;
880 if (mMesh.incident_cell(hf0) !=
CellHandle(-1))
881 if (is_inside(mMesh.incident_cell(hf0)))
884 if (mMesh.incident_cell(hf1) !=
CellHandle(-1))
885 if (is_inside(mMesh.incident_cell(hf1)))
887 return incidentCells;
897 template <
class VolumeMesh>
900 int incidentCells = 0;
903 if (hec_it->idx() != -1)
904 if (is_inside(*hec_it))
906 return incidentCells;
916 template <
class VolumeMesh>
919 int incidentCells = 0;
921 if (vc_it->idx() != -1)
922 if (is_inside(*vc_it))
924 return incidentCells;
934 template <
class VolumeMesh>
940 return mCogs[_ch.idx()];
950 template <
class VolumeMesh>
953 if (mCogs.size() != mMesh.n_cells())
954 mCogs.resize(mMesh.n_cells());
960 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
963 for (
unsigned int i = 0; i < hfs.size(); ++i)
966 cog += mMesh.vertex(*hfv_it);
969 cog = 1.0/count * cog;
971 mCogs[c_it->idx()] = cog;
982 template <
class VolumeMesh>
985 return (mGeometryChanged) ||
986 (mVertexSize != mCurrentVertexSize) ||
987 (mPrimitiveMode != mCurrentPrimitiveMode) ||
988 (mNumOfVertices != mCurrentNumOfVertices);
996 template <
class VolumeMesh>
999 return (mColorsChanged) ||
1000 (mVertexSize != mCurrentVertexSize) ||
1001 (mNumOfVertices != mCurrentNumOfVertices) ||
1002 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1003 (mColorOffset != mCurrentColorOffset) ||
1004 (mColorMode != mCurrentColorMode) ||
1005 (mShowIrregularInnerEdges != mCurrentShowIrregularInnerEdges) ||
1006 (mShowIrregularOuterValence2Edges != mCurrentShowIrregularOuterValence2Edges);
1014 template <
class VolumeMesh>
1017 return (mTexCoordsChanged) ||
1018 (mVertexSize != mCurrentVertexSize) ||
1019 (mNumOfVertices != mCurrentNumOfVertices) ||
1020 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1021 (mTexCoordOffset!= mCurrentTexCoordOffset);
1029 template <
class VolumeMesh>
1032 return (mNormalsChanged) ||
1033 (mVertexSize != mCurrentVertexSize) ||
1034 (mPrimitiveMode != mCurrentPrimitiveMode) ||
1035 (mNormalOffset != mCurrentNormalOffset) ||
1036 (mNormalMode != mCurrentNormalMode) ||
1037 (mNumOfVertices != mCurrentNumOfVertices);
1045 template <
class VolumeMesh>
1048 unsigned int pos = 0;
1050 if (mPrimitiveMode == PM_VERTICES)
1052 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1053 if (mSkipUnselected && !mStatusAttrib[
VertexHandle(i)].selected())
continue;
1055 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1057 addPositionToBuffer(p, _buffer, pos++);
1060 else if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
1062 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1063 if (mSkipUnselected && !mStatusAttrib[
VertexHandle(i)].selected())
continue;
1069 if (is_inside(*vc_it))
1070 addPositionToBuffer(p*mScale + cog*(1-mScale), _buffer, pos++);
1074 else if (mPrimitiveMode == PM_FACES)
1076 std::vector<ACG::Vec3d> vertices;
1080 if (mSkipUnselected && !mStatusAttrib[*f_it].selected())
continue;
1081 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1082 if (!is_inside(*f_it))
continue;
1085 vertices.push_back(mMesh.vertex(*hfv_it));
1087 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1089 addPositionToBuffer(vertices[0], _buffer, pos++);
1090 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1091 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1095 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
1097 std::vector<ACG::Vec3d> vertices;
1101 if (mSkipUnselected && !mStatusAttrib[*f_it].selected())
continue;
1104 vertices.push_back(mMesh.vertex(*hfv_it));
1106 for (
int i = 0; i < 2; i++)
1111 if (!is_inside(ch))
continue;
1113 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1116 addPositionToBuffer(vertices[0]*mScale + cog*(1-mScale), _buffer, pos++);
1117 addPositionToBuffer(vertices[i+1]*mScale + cog*(1-mScale), _buffer, pos++);
1118 addPositionToBuffer(vertices[i+2]*mScale + cog*(1-mScale), _buffer, pos++);
1125 else if (mPrimitiveMode == PM_HALFFACES)
1127 std::vector<ACG::Vec3d> vertices;
1131 if (mSkipUnselected && !mStatusAttrib[*hf_it].selected())
continue;
1132 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1133 if (!is_inside(*hf_it))
continue;
1136 vertices.push_back(mMesh.vertex(*hfv_it));
1138 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1140 addPositionToBuffer(vertices[0], _buffer, pos++);
1141 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1142 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1146 else if (mPrimitiveMode == PM_CELLS)
1148 std::vector<ACG::Vec3d> vertices;
1152 if (mSkipUnselected && !mStatusAttrib[*c_it].selected())
continue;
1153 if (!is_inside(*c_it))
continue;
1154 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1156 for (
unsigned int i = 0; i < hfs.size(); ++i)
1160 vertices.push_back(mScale*mMesh.vertex(*hfv_it)+(1-mScale)*cog);
1162 for (
unsigned int i = 0; i < vertices.size()-2; i++)
1164 addPositionToBuffer(vertices[0], _buffer, pos++);
1165 addPositionToBuffer(vertices[i+1], _buffer, pos++);
1166 addPositionToBuffer(vertices[i+2], _buffer, pos++);
1172 else if (mPrimitiveMode == PM_EDGES)
1177 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1178 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1179 if (!is_inside(*e_it))
continue;
1181 Edge e(mMesh.edge(*e_it));
1182 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1183 addPositionToBuffer(mMesh.vertex(e.to_vertex()), _buffer, pos++);
1186 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
1191 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1193 Edge e(mMesh.edge(*e_it));
1197 if (hec_it->idx() != -1)
1199 if (!is_inside(*hec_it))
continue;
1201 addPositionToBuffer(mMesh.vertex(e.from_vertex())*mScale + cog*(1-mScale), _buffer, pos++);
1202 addPositionToBuffer(mMesh.vertex(e.to_vertex()) *mScale + cog*(1-mScale), _buffer, pos++);
1207 else if (mPrimitiveMode == PM_IRREGULAR_EDGES)
1212 if (mSkipUnselected && !mStatusAttrib[*e_it].selected())
continue;
1213 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1214 if (!is_inside(*e_it))
continue;
1216 bool boundary = mMesh.is_boundary(*e_it);
1217 unsigned int valence = mMesh.valence(*e_it);
1219 if(( boundary && valence == 3) ||
1220 (!boundary && valence == 4))
continue;
1222 if ((!mShowIrregularOuterValence2Edges) && ( boundary && valence == 2))
continue;
1224 if ((!mShowIrregularInnerEdges) && (( !boundary && valence != 4) ||
1225 ( boundary && valence < 2) ||
1226 ( boundary && valence > 3)))
continue;
1228 Edge e(mMesh.edge(*e_it));
1229 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1230 addPositionToBuffer(mMesh.vertex(e.to_vertex()), _buffer, pos++);
1233 else if (mPrimitiveMode == PM_HALFEDGES)
1238 if (mSkipUnselected && !mStatusAttrib[*he_it].selected())
continue;
1239 if (mBoundaryOnly && !mMesh.is_boundary(*he_it))
continue;
1240 if (!is_inside(*he_it))
continue;
1242 double lambda = 0.4;
1243 Edge e(mMesh.halfedge(*he_it));
1244 addPositionToBuffer(mMesh.vertex(e.from_vertex()), _buffer, pos++);
1245 addPositionToBuffer((1-lambda)*mMesh.vertex(e.from_vertex()) + lambda*mMesh.vertex(e.to_vertex()), _buffer, pos++);
1259 template <
class VolumeMesh>
1262 if (mNormalMode == NM_NONE)
return;
1264 unsigned int pos = 0;
1266 if ((mPrimitiveMode == PM_FACES) && (mNormalMode == NM_FACE))
1271 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1272 if (!is_inside(*f_it))
continue;
1274 unsigned int numOfVerticesInFace = mMesh.valence(*f_it);
1276 for (
unsigned int i = 0; i < numOfVerticesInFace - 2; i++)
1278 addNormalToBuffer(normal, _buffer, pos++);
1279 addNormalToBuffer(normal, _buffer, pos++);
1280 addNormalToBuffer(normal, _buffer, pos++);
1284 else if ((mPrimitiveMode == PM_FACES) && (mNormalMode == NM_VERTEX))
1286 std::vector<ACG::Vec3d> normals;
1290 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1291 if (!is_inside(*f_it))
continue;
1294 normals.push_back(mNormalAttrib[*hfv_it]);
1296 for (
unsigned int i = 0; i < normals.size()-2; i++)
1298 addNormalToBuffer(normals[0], _buffer, pos++);
1299 addNormalToBuffer(normals[i+1], _buffer, pos++);
1300 addNormalToBuffer(normals[i+2], _buffer, pos++);
1304 else if ((mPrimitiveMode == PM_HALFFACES) && (mNormalMode == NM_HALFFACE))
1309 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1310 if (!is_inside(*hf_it))
continue;
1312 unsigned int numOfVerticesInCell = 0;
1314 ++numOfVerticesInCell;
1316 for (
unsigned int i = 0; i < numOfVerticesInCell- 2; i++)
1318 addNormalToBuffer(normal, _buffer, pos++);
1319 addNormalToBuffer(normal, _buffer, pos++);
1320 addNormalToBuffer(normal, _buffer, pos++);
1324 else if ((mPrimitiveMode == PM_HALFFACES) && (mNormalMode == NM_VERTEX))
1326 std::vector<ACG::Vec3d> normals;
1330 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1331 if (!is_inside(*hf_it))
continue;
1334 normals.push_back(mNormalAttrib[*hfv_it]);
1336 for (
unsigned int i = 0; i < normals.size()-2; i++)
1338 addNormalToBuffer(normals[0], _buffer, pos++);
1339 addNormalToBuffer(normals[i+1], _buffer, pos++);
1340 addNormalToBuffer(normals[i+2], _buffer, pos++);
1344 else if ((mPrimitiveMode == PM_CELLS) && (mNormalMode == NM_HALFFACE))
1349 if (!is_inside(*c_it))
continue;
1350 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1351 for (
unsigned int i = 0; i < hfs.size(); ++i)
1353 ACG::Vec3d normal = -1.0*mNormalAttrib[hfs[i]];
1354 unsigned int numOfVerticesInFace = mMesh.valence(mMesh.face_handle(hfs[i]));
1356 for (
unsigned int i = 0; i < numOfVerticesInFace-2; i++)
1358 addNormalToBuffer(normal, _buffer, pos++);
1359 addNormalToBuffer(normal, _buffer, pos++);
1360 addNormalToBuffer(normal, _buffer, pos++);
1365 else if ((mPrimitiveMode == PM_CELLS) && (mNormalMode == NM_VERTEX))
1367 std::vector<ACG::Vec3d> normals;
1371 if (!is_inside(*c_it))
continue;
1372 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1374 for (
unsigned int i = 0; i < hfs.size(); ++i)
1378 normals.push_back(mNormalAttrib[*hfv_it]);
1380 for (
unsigned int i = 0; i < normals.size()-2; i++)
1382 addNormalToBuffer(normals[0], _buffer, pos++);
1383 addNormalToBuffer(normals[i+1], _buffer, pos++);
1384 addNormalToBuffer(normals[i+2], _buffer, pos++);
1397 template <
class VolumeMesh>
1400 unsigned int pos = 0;
1402 if ((mPrimitiveMode == PM_VERTICES) && (mColorMode == CM_VERTEX))
1404 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i)
1406 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1409 addColorToBuffer(color, _buffer, pos++);
1412 else if ((mPrimitiveMode == PM_FACES) && (mColorMode == CM_VERTEX))
1414 std::vector<ACG::Vec4f> colors;
1418 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1419 if (!is_inside(*f_it))
continue;
1423 colors.push_back(mColorAttrib[*hfv_it]);
1425 for (
unsigned int i = 0; i < (colors.size()-2); i++)
1427 addColorToBuffer(colors[0], _buffer, pos++);
1428 addColorToBuffer(colors[i+1], _buffer, pos++);
1429 addColorToBuffer(colors[i+2], _buffer, pos++);
1433 else if ((mPrimitiveMode == PM_FACES) && (mColorMode == CM_FACE))
1438 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1439 if (!is_inside(*f_it))
continue;
1442 unsigned int numOfVerticesInFace = mMesh.valence(*f_it);
1443 unsigned int numOfDrawnTriangles = numOfVerticesInFace-2;
1445 for (
unsigned int i = 0; i < numOfDrawnTriangles*3; i++)
1446 addColorToBuffer(color, _buffer, pos++);
1449 else if ((mPrimitiveMode == PM_HALFFACES) && (mColorMode == CM_HALFFACE))
1454 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1455 if (!is_inside(*hf_it))
continue;
1458 unsigned int numOfVerticesInFace = mMesh.valence(mMesh.face_handle(*hf_it));
1459 unsigned int numOfDrawnTriangles = numOfVerticesInFace-2;
1461 for (
unsigned int i = 0; i < numOfDrawnTriangles*3; i++)
1462 addColorToBuffer(color, _buffer, pos++);
1465 else if ((mPrimitiveMode == PM_HALFFACES) && (mColorMode == CM_VERTEX))
1467 std::vector<ACG::Vec4f> colors;
1471 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1472 if (!is_inside(*hf_it))
continue;
1476 colors.push_back(mColorAttrib[*hfv_it]);
1478 for (
unsigned int i = 0; i < (colors.size()-2); i++)
1480 addColorToBuffer(colors[0], _buffer, pos++);
1481 addColorToBuffer(colors[i+1], _buffer, pos++);
1482 addColorToBuffer(colors[i+2], _buffer, pos++);
1486 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_CELL))
1491 if (!is_inside(*c_it))
continue;
1493 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1494 for (
unsigned int i = 0; i < hfs.size(); ++i)
1496 unsigned int numOfVerticesInHalfface = 0;
1498 ++numOfVerticesInHalfface;
1500 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1501 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1502 addColorToBuffer(color, _buffer, pos++);
1506 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_HALFFACE))
1511 if (!is_inside(*c_it))
continue;
1512 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1513 for (
unsigned int i = 0; i < hfs.size(); ++i)
1516 unsigned int numOfVerticesInHalfface = 0;
1518 ++numOfVerticesInHalfface;
1520 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1521 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1522 addColorToBuffer(color, _buffer, pos++);
1526 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_FACE))
1531 if (!is_inside(*c_it))
continue;
1532 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1533 for (
unsigned int i = 0; i < hfs.size(); ++i)
1535 ACG::Vec4f color = mColorAttrib[mMesh.face_handle(hfs[i])];
1536 unsigned int numOfVerticesInHalfface = 0;
1538 ++numOfVerticesInHalfface;
1540 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1541 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1542 addColorToBuffer(color, _buffer, pos++);
1546 else if ((mPrimitiveMode == PM_CELLS) && (mColorMode == CM_VERTEX))
1548 std::vector<ACG::Vec4f> colors;
1552 if (!is_inside(*c_it))
continue;
1553 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1554 for (
unsigned int i = 0; i < hfs.size(); ++i)
1558 colors.push_back(mColorAttrib[*hfv_it]);
1560 for (
unsigned int i = 0; i < colors.size()-2; i++)
1562 addColorToBuffer(colors[0], _buffer, pos++);
1563 addColorToBuffer(colors[i+1], _buffer, pos++);
1564 addColorToBuffer(colors[i+2], _buffer, pos++);
1569 else if ((mPrimitiveMode == PM_EDGES) && (mColorMode == CM_EDGE))
1574 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1575 if (!is_inside(*e_it))
continue;
1577 addColorToBuffer(color, _buffer, pos++);
1578 addColorToBuffer(color, _buffer, pos++);
1581 else if ((mPrimitiveMode == PM_EDGES) && (mShowIrregularInnerEdges || mShowIrregularOuterValence2Edges))
1586 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1587 if (!is_inside(*e_it))
continue;
1589 bool boundary = mMesh.is_boundary(*e_it);
1590 unsigned int valence = mMesh.valence(*e_it);
1592 bool isIrregularInner = ( boundary && valence < 2) || ( boundary && valence > 3) || (!boundary && valence != 4);
1593 bool isIrregularOuterValence2 = ( boundary && valence == 2);
1597 if (isIrregularInner && mShowIrregularInnerEdges)
1598 color = getValenceColorCode(valence, !boundary);
1599 else if (isIrregularOuterValence2 && mShowIrregularOuterValence2Edges)
1600 color = getValenceColorCode(valence, !boundary);
1602 color = mDefaultColor;
1604 addColorToBuffer(color, _buffer, pos++);
1605 addColorToBuffer(color, _buffer, pos++);
1608 else if ( mPrimitiveMode == PM_IRREGULAR_EDGES )
1613 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1614 if (!is_inside(*e_it))
continue;
1616 bool boundary = mMesh.is_boundary(*e_it);
1617 unsigned int valence = mMesh.valence(*e_it);
1619 bool isRegular = ( boundary && valence == 3) || (!boundary && valence == 4);
1620 bool isIrregularInner = ( boundary && valence < 2) || ( boundary && valence > 3) || (!boundary && valence != 4);
1621 bool isIrregularOuterValence2 = ( boundary && valence == 2);
1623 if (isRegular)
continue;
1624 if (isIrregularInner && !mShowIrregularInnerEdges)
continue;
1625 if (isIrregularOuterValence2 && !mShowIrregularOuterValence2Edges)
continue;
1629 if (isIrregularInner && mShowIrregularInnerEdges)
1630 color = getValenceColorCode(valence, !boundary);
1631 else if (isIrregularOuterValence2 && mShowIrregularOuterValence2Edges)
1632 color = getValenceColorCode(valence, !boundary);
1634 color = mDefaultColor;
1636 addColorToBuffer(color, _buffer, pos++);
1637 addColorToBuffer(color, _buffer, pos++);
1640 else if ((mPrimitiveMode == PM_HALFEDGES) && (mColorMode == CM_HALFEDGE))
1645 if (mBoundaryOnly && !mMesh.is_boundary(*he_it))
continue;
1646 if (!is_inside(*he_it))
continue;
1649 addColorToBuffer(color, _buffer, pos++);
1650 addColorToBuffer(color, _buffer, pos++);
1661 template <
class VolumeMesh>
1665 unsigned int pos = 0;
1667 if (mTexCoordMode == TCM_NONE)
1670 if (mPrimitiveMode == PM_FACES)
1672 std::vector<ACG::Vec2f> texCoords;
1676 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1677 if (!is_inside(*f_it))
continue;
1681 texCoords.push_back(mTexcoordAttrib[*hfv_it]);
1683 for (
unsigned int i = 0; i < (texCoords.size()-2); i++)
1685 addTexCoordToBuffer(texCoords[0], _buffer, pos++);
1686 addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
1687 addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
1691 else if (mPrimitiveMode == PM_HALFFACES)
1693 std::vector<ACG::Vec2f> texCoords;
1697 if (mBoundaryOnly && !mMesh.is_boundary(*hf_it))
continue;
1698 if (!is_inside(*hf_it))
continue;
1702 texCoords.push_back(mTexcoordAttrib[*hfv_it]);
1704 for (
unsigned int i = 0; i < (texCoords.size()-2); i++)
1706 addTexCoordToBuffer(texCoords[0], _buffer, pos++);
1707 addTexCoordToBuffer(texCoords[i+1], _buffer, pos++);
1708 addTexCoordToBuffer(texCoords[i+2], _buffer, pos++);
1723 template <
class VolumeMesh>
1726 unsigned int pos = 0;
1728 if (mPrimitiveMode == PM_VERTICES)
1730 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i)
1732 if (mBoundaryOnly && !mMesh.is_boundary(
VertexHandle(i)))
continue;
1735 addColorToBuffer(color, _buffer, pos++);
1738 if (mPrimitiveMode == PM_VERTICES_ON_CELLS)
1740 for (
unsigned int i = 0; i < mMesh.n_vertices(); ++i) {
1742 unsigned int numOfIncidentCells = getNumOfIncidentCells(
VertexHandle(i));
1743 for (
unsigned int j = 0; j < numOfIncidentCells; j++)
1744 addColorToBuffer(color, _buffer, pos++);
1747 else if (mPrimitiveMode == PM_EDGES)
1752 if (mBoundaryOnly && !mMesh.is_boundary(*e_it))
continue;
1753 if (!is_inside(*e_it))
continue;
1755 addColorToBuffer(color, _buffer, pos++);
1756 addColorToBuffer(color, _buffer, pos++);
1759 else if (mPrimitiveMode == PM_EDGES_ON_CELLS)
1765 unsigned int numOfIncidentCells = getNumOfIncidentCells(*e_it);
1766 for (
unsigned int i = 0; i < numOfIncidentCells*2;i++)
1767 addColorToBuffer(color, _buffer, pos++);
1770 else if (mPrimitiveMode == PM_FACES)
1775 if (mBoundaryOnly && !mMesh.is_boundary(*f_it))
continue;
1776 if (!is_inside(*f_it))
continue;
1779 unsigned int numOfVertices = 0;
1783 for (
unsigned int i = 0; i < (numOfVertices-2)*3; i++)
1784 addColorToBuffer(color, _buffer, pos++);
1787 else if (mPrimitiveMode == PM_FACES_ON_CELLS)
1794 unsigned int numOfVerticesInHalfface = 0;
1796 ++numOfVerticesInHalfface;
1798 for (
int i = 0; i < 2; i++)
1803 if (!is_inside(ch))
continue;
1804 for (
unsigned int i = 0; i < (numOfVerticesInHalfface-2)*3; i++)
1805 addColorToBuffer(color, _buffer, pos++);
1810 else if (mPrimitiveMode == PM_CELLS)
1815 if (!is_inside(*c_it))
continue;
1817 std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
1818 for (
unsigned int i = 0; i < hfs.size(); ++i)
1820 unsigned int numOfVerticesInHalfface = 0;
1822 ++numOfVerticesInHalfface;
1824 unsigned int numOfDrawnFaces = numOfVerticesInHalfface-2;
1825 for (
unsigned int i = 0; i < numOfDrawnFaces*3; i++)
1826 addColorToBuffer(color, _buffer, pos++);
1839 template <
class VolumeMesh>
1842 if ((mBuffer == 0) || optionsChanged() || mInvalidated)
1848 calculateVertexDeclaration();
1850 if (optionsChanged())
1851 mNumOfVertices = -1;
1853 unsigned int numOfVertices = getNumOfVertices();
1855 if (getNumOfVertices() > 0)
1858 unsigned int bufferSize = mVertexSize * numOfVertices;
1864 GL_ARRAY_BUFFER, GL_READ_WRITE);
1869 if (positionsNeedRebuild())
1870 buildVertexBuffer(buffer);
1871 if (normalsNeedRebuild())
1872 buildNormalBuffer(buffer);
1873 if (colorsNeedRebuild())
1874 buildColorBuffer(buffer);
1875 if (texCoordsNeedRebuild())
1876 buildTexCoordBuffer(buffer);
1886 std::cerr <<
"error while mapping buffer" << std::endl;
1892 mInvalidated =
false;
1893 mGeometryChanged =
false;
1894 mColorsChanged =
false;
1895 mNormalsChanged =
false;
1896 mTexCoordsChanged =
false;
1911 template <
class VolumeMesh>
1914 if (_offset != mCurrentPickOffset || _state.
pick_current_index() != mGlobalPickOffset)
1920 if ((mBuffer == 0) || optionsChanged() || mInvalidated)
1925 calculateVertexDeclaration();
1927 if (optionsChanged())
1928 mNumOfVertices = -1;
1930 unsigned int numOfVertices = getNumOfVertices();
1932 if (getNumOfVertices() > 0)
1935 unsigned int bufferSize = mVertexSize * numOfVertices;
1945 if (positionsNeedRebuild())
1946 buildVertexBuffer(buffer);
1947 if (colorsNeedRebuild())
1948 buildPickColorBuffer(_state, _offset, buffer);
1957 std::cerr <<
"error while mapping buffer" << std::endl;
1962 mCurrentPickOffset = _offset;
1964 mInvalidated =
false;
1965 mGeometryChanged =
false;
1966 mColorsChanged =
false;
1967 mTexCoordsChanged =
false;
1977 template <
class VolumeMesh>
1980 invalidateGeometry();
1981 invalidateNormals();
1988 template <
class VolumeMesh>
1991 mInvalidated =
true;
1992 mNumOfVertices = -1;
1993 mGeometryChanged =
true;
1994 mColorsChanged =
true;
1995 mTexCoordsChanged =
true;
1996 mNormalsChanged =
true;
1998 mCellInsidenessValid =
false;
2004 template <
class VolumeMesh>
2007 mInvalidated =
true;
2008 mColorsChanged =
true;
2014 template <
class VolumeMesh>
2017 mInvalidated =
true;
2018 mNormalsChanged =
true;
2024 template <
class VolumeMesh>
2027 mInvalidated =
true;
2028 mTexCoordsChanged =
true;
2036 template <
class VolumeMesh>
ACG::Vec4f getValenceColorCode(unsigned int _valence, bool _inner) const
Returns a color code 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.
Namespace providing different geometric functions concerning angles.
static void bindBuffer(GLenum _target, GLuint _buffer)
replaces glBindBuffer, supports locking
void invalidate()
Invalidates the buffer.
void clearCutPlanes()
Removes all cut planes.
void invalidateColors()
Invalidates colors.
void invalidateNormals()
Invalidates normals.
void buildColorBuffer(unsigned char *_buffer)
Adds all colors to the buffer.
Vec4uc pick_get_name_color(unsigned int _idx)
bool texCoordsNeedRebuild()
Checks whether texture coordinates need to be rebuild.
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.
VectorT< float, 4 > Vec4f
static GLboolean unmapBuffer(GLenum target)
void addUCharToBuffer(unsigned char _value, unsigned char *&_buffer)
Adds an unsigned char to the buffer.
VectorT< double, 3 > Vec3d
bool positionsNeedRebuild()
Checks whether positions need to be rebuild.
static GLvoid * mapBuffer(GLenum target, GLenum access)
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.
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.
GLuint getPickBuffer(ACG::GLState &_state, unsigned int _offset)
Returns the name of the pick buffer.
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 addColorToBuffer(ACG::Vec4uc _color, unsigned char *_buffer, unsigned int _offset)
Adds a color to the buffer.
unsigned int pick_current_index() const
Returns the current color picking index (can be used for caching)
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 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 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 int getNumOfVertices()
Returns the number of vertices stored in the buffer.
void invalidateTexCoords()
Invalidates texture coordinates.
static void deleteBuffers(GLsizei n, const GLuint *buffers)
static void bufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)
void addFloatToBuffer(float _value, unsigned char *&_buffer)
Adds a float to the buffer.
void invalidateGeometry()
Invalidates geometry.
static void genBuffers(GLsizei n, GLuint *buffers)
bool colorsNeedRebuild()
Checks whether colors need to be rebuild.
bool normalsNeedRebuild()
Checks whether normals need to be rebuild.
bool is_inside(const ACG::Vec3d &_p)
Tests whether the given point is inside w.r.t. all cut planes.
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.