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++);
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++);
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++);
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++);