...@@ -311,11 +311,13 @@ private: ...@@ -311,11 +311,13 @@ private:
bool is_inside(const FaceHandle& _fh); bool is_inside(const FaceHandle& _fh);
/// Tests whether the given cell is inside w.r.t. all cut planes /// Tests whether the given cell is inside w.r.t. all cut planes
bool is_inside(const CellHandle& _ch); bool is_inside_tmp(const CellHandle& _ch);
/// Calculates for all cells whether they are inside w.r.t. all cut planes /// Calculates for all cells whether they are inside w.r.t. all cut planes
void calculateCellInsideness(); void calculateCellInsideness();
bool should_render(const CellHandle& _ch);
/// Tests whether the options were changed since the last time building the buffer /// Tests whether the options were changed since the last time building the buffer
bool optionsChanged(); bool optionsChanged();
......
...@@ -576,14 +576,28 @@ bool VolumeMeshBufferManager<VolumeMesh>::is_inside(const FaceHandle& _fh) ...@@ -576,14 +576,28 @@ bool VolumeMeshBufferManager<VolumeMesh>::is_inside(const FaceHandle& _fh)
* @return True iff the cell is inside. * @return True iff the cell is inside.
*/ */
template <class VolumeMesh> template <class VolumeMesh>
bool VolumeMeshBufferManager<VolumeMesh>::is_inside(const CellHandle& _ch) bool VolumeMeshBufferManager<VolumeMesh>::is_inside_tmp(const CellHandle& _ch)
{ {
if (mStatusAttrib[_ch].hidden())
return false;
if (!mCellInsidenessValid) if (!mCellInsidenessValid)
calculateCellInsideness(); calculateCellInsideness();
return mCellInsideness[_ch.idx()]; return mCellInsideness[_ch.idx()];
} }
/**
* @brief Tests whether the given cell should be rendererd.
*/
template <class VolumeMesh>
bool VolumeMeshBufferManager<VolumeMesh>::should_render(const CellHandle& _ch)
{
if (mStatusAttrib[_ch].hidden())
return false;
return is_inside_tmp(_ch);
}
/** /**
* @brief Calculates for all cells whether they are inside w.r.t. all cut planes * @brief Calculates for all cells whether they are inside w.r.t. all cut planes
...@@ -704,12 +718,14 @@ void VolumeMeshBufferManager<VolumeMesh>::countNumOfVertices() ...@@ -704,12 +718,14 @@ void VolumeMeshBufferManager<VolumeMesh>::countNumOfVertices()
{ {
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
if (mStatusAttrib[*c_it].selected() && is_inside(*c_it)) {
if (mStatusAttrib[*c_it].selected() && should_render(*c_it))
{ {
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3; numOfVertices += ((mMesh.valence(mMesh.face_handle(hfs[i])))-2)*3;
} }
}
} }
else if (mPrimitiveMode == PM_FACES) else if (mPrimitiveMode == PM_FACES)
{ {
...@@ -806,7 +822,7 @@ void VolumeMeshBufferManager<VolumeMesh>::countNumOfVertices() ...@@ -806,7 +822,7 @@ void VolumeMeshBufferManager<VolumeMesh>::countNumOfVertices()
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (is_inside(*c_it)) if (should_render(*c_it))
{ {
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
...@@ -873,11 +889,11 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::F ...@@ -873,11 +889,11 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::F
int incidentCells = 0; int incidentCells = 0;
OpenVolumeMesh::HalfFaceHandle hf0 = mMesh.halfface_handle(_fh, 0); OpenVolumeMesh::HalfFaceHandle hf0 = mMesh.halfface_handle(_fh, 0);
if (mMesh.incident_cell(hf0) != CellHandle(-1)) if (mMesh.incident_cell(hf0) != CellHandle(-1))
if (is_inside(mMesh.incident_cell(hf0))) if (should_render(mMesh.incident_cell(hf0)))
incidentCells += 1; incidentCells += 1;
OpenVolumeMesh::HalfFaceHandle hf1 = mMesh.halfface_handle(_fh, 1); OpenVolumeMesh::HalfFaceHandle hf1 = mMesh.halfface_handle(_fh, 1);
if (mMesh.incident_cell(hf1) != CellHandle(-1)) if (mMesh.incident_cell(hf1) != CellHandle(-1))
if (is_inside(mMesh.incident_cell(hf1))) if (should_render(mMesh.incident_cell(hf1)))
incidentCells += 1; incidentCells += 1;
return incidentCells; return incidentCells;
} }
...@@ -896,7 +912,7 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::E ...@@ -896,7 +912,7 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::E
OpenVolumeMesh::HalfEdgeHandle heh = mMesh.halfedge_handle(_eh, 0); OpenVolumeMesh::HalfEdgeHandle heh = mMesh.halfedge_handle(_eh, 0);
for (OpenVolumeMesh::HalfEdgeCellIter hec_it = OpenVolumeMesh::HalfEdgeCellIter(heh,&mMesh); hec_it.valid(); ++hec_it) for (OpenVolumeMesh::HalfEdgeCellIter hec_it = OpenVolumeMesh::HalfEdgeCellIter(heh,&mMesh); hec_it.valid(); ++hec_it)
if (hec_it->idx() != -1) if (hec_it->idx() != -1)
if (is_inside(*hec_it)) if (should_render(*hec_it))
incidentCells++; incidentCells++;
return incidentCells; return incidentCells;
} }
...@@ -914,7 +930,7 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::V ...@@ -914,7 +930,7 @@ int VolumeMeshBufferManager<VolumeMesh>::getNumOfIncidentCells(OpenVolumeMesh::V
int incidentCells = 0; int incidentCells = 0;
for (OpenVolumeMesh::VertexCellIter vc_it = OpenVolumeMesh::VertexCellIter(_vh,&mMesh); vc_it; ++vc_it) for (OpenVolumeMesh::VertexCellIter vc_it = OpenVolumeMesh::VertexCellIter(_vh,&mMesh); vc_it; ++vc_it)
if (vc_it->idx() != -1) if (vc_it->idx() != -1)
if (is_inside(*vc_it)) if (should_render(*vc_it))
incidentCells++; incidentCells++;
return incidentCells; return incidentCells;
} }
...@@ -1061,7 +1077,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff ...@@ -1061,7 +1077,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff
{ {
ACG::Vec3d cog = getCOG(*vc_it); ACG::Vec3d cog = getCOG(*vc_it);
//ACG::Vec3d newPos = p*mScale + cog*(1-mScale); //ACG::Vec3d newPos = p*mScale + cog*(1-mScale);
if (is_inside(*vc_it)) if (should_render(*vc_it))
addPositionToBuffer(p*mScale + cog*(1-mScale), _buffer, pos++); addPositionToBuffer(p*mScale + cog*(1-mScale), _buffer, pos++);
} }
} }
...@@ -1103,7 +1119,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff ...@@ -1103,7 +1119,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff
OpenVolumeMesh::CellHandle ch = mMesh.incident_cell(mMesh.halfface_handle(*f_it,i)); OpenVolumeMesh::CellHandle ch = mMesh.incident_cell(mMesh.halfface_handle(*f_it,i));
if (ch != CellHandle(-1)) if (ch != CellHandle(-1))
{ {
if (!is_inside(ch)) continue; if (!should_render(ch)) continue;
ACG::Vec3d cog = getCOG(ch); ACG::Vec3d cog = getCOG(ch);
for (unsigned int i = 0; i < vertices.size()-2; i++) for (unsigned int i = 0; i < vertices.size()-2; i++)
{ {
...@@ -1145,7 +1161,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff ...@@ -1145,7 +1161,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (mSkipUnselected && !mStatusAttrib[*c_it].selected()) continue; if (mSkipUnselected && !mStatusAttrib[*c_it].selected()) continue;
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
ACG::Vec3d cog = getCOG(*c_it); ACG::Vec3d cog = getCOG(*c_it);
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
...@@ -1191,7 +1207,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff ...@@ -1191,7 +1207,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildVertexBuffer(unsigned char* _buff
{ {
if (hec_it->idx() != -1) if (hec_it->idx() != -1)
{ {
if (!is_inside(*hec_it)) continue; if (!should_render(*hec_it)) continue;
ACG::Vec3d cog = getCOG(*hec_it); ACG::Vec3d cog = getCOG(*hec_it);
addPositionToBuffer(mMesh.vertex(e.from_vertex())*mScale + cog*(1-mScale), _buffer, pos++); addPositionToBuffer(mMesh.vertex(e.from_vertex())*mScale + cog*(1-mScale), _buffer, pos++);
addPositionToBuffer(mMesh.vertex(e.to_vertex()) *mScale + cog*(1-mScale), _buffer, pos++); addPositionToBuffer(mMesh.vertex(e.to_vertex()) *mScale + cog*(1-mScale), _buffer, pos++);
...@@ -1341,7 +1357,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildNormalBuffer(unsigned char* _buff ...@@ -1341,7 +1357,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildNormalBuffer(unsigned char* _buff
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
{ {
...@@ -1363,7 +1379,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildNormalBuffer(unsigned char* _buff ...@@ -1363,7 +1379,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildNormalBuffer(unsigned char* _buff
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
...@@ -1483,7 +1499,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe ...@@ -1483,7 +1499,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
ACG::Vec4f color = mColorAttrib[*c_it]; ACG::Vec4f color = mColorAttrib[*c_it];
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
...@@ -1503,7 +1519,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe ...@@ -1503,7 +1519,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
{ {
...@@ -1523,7 +1539,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe ...@@ -1523,7 +1539,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
{ {
...@@ -1544,7 +1560,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe ...@@ -1544,7 +1560,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildColorBuffer(unsigned char* _buffe
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
{ {
...@@ -1795,7 +1811,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildPickColorBuffer(ACG::GLState& _st ...@@ -1795,7 +1811,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildPickColorBuffer(ACG::GLState& _st
OpenVolumeMesh::CellHandle ch = mMesh.incident_cell(mMesh.halfface_handle(*f_it,i)); OpenVolumeMesh::CellHandle ch = mMesh.incident_cell(mMesh.halfface_handle(*f_it,i));
if (ch != CellHandle(-1)) if (ch != CellHandle(-1))
{ {
if (!is_inside(ch)) continue; if (!should_render(ch)) continue;
for (unsigned int i = 0; i < (numOfVerticesInHalfface-2)*3; i++) for (unsigned int i = 0; i < (numOfVerticesInHalfface-2)*3; i++)
addColorToBuffer(color, _buffer, pos++); addColorToBuffer(color, _buffer, pos++);
} }
...@@ -1807,7 +1823,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildPickColorBuffer(ACG::GLState& _st ...@@ -1807,7 +1823,7 @@ void VolumeMeshBufferManager<VolumeMesh>::buildPickColorBuffer(ACG::GLState& _st
OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end()); OpenVolumeMesh::CellIter c_begin(mMesh.cells_begin()), c_end(mMesh.cells_end());
for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it) for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it)
{ {
if (!is_inside(*c_it)) continue; if (!should_render(*c_it)) continue;
ACG::Vec4uc color = _state.pick_get_name_color(c_it->idx()+_offset); ACG::Vec4uc color = _state.pick_get_name_color(c_it->idx()+_offset);
std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces(); std::vector<HalfFaceHandle> hfs = mMesh.cell(*c_it).halffaces();
for (unsigned int i = 0; i < hfs.size(); ++i) for (unsigned int i = 0; i < hfs.size(); ++i)
......
Subproject commit 919e020da5b4b61a674a3e4c29b4c658a5c03b52 Subproject commit 38009a60d5f428f5c3781746d4f90ef2ef4cba13