Commit b1f19282 authored by Isaak Lim's avatar Isaak Lim
Browse files

added a topology check flag for add_cell with VertexHandles, which is set to false by default

git-svn-id: http://www.openvolumemesh.org/svnrepo/OpenVolumeMesh/trunk@238 66977474-1d4b-4f09-8fe9-267525286df2
parent f81019db
...@@ -264,7 +264,7 @@ bool HexahedralMeshTopologyKernel::check_halfface_ordering(const std::vector<Hal ...@@ -264,7 +264,7 @@ bool HexahedralMeshTopologyKernel::check_halfface_ordering(const std::vector<Hal
//======================================================================================== //========================================================================================
CellHandle CellHandle
HexahedralMeshTopologyKernel::add_cell(const std::vector<VertexHandle>& _vertices) { HexahedralMeshTopologyKernel::add_cell(const std::vector<VertexHandle>& _vertices, bool _topologyCheck) {
assert(_vertices.size() == 8); assert(_vertices.size() == 8);
...@@ -375,10 +375,41 @@ HexahedralMeshTopologyKernel::add_cell(const std::vector<VertexHandle>& _vertice ...@@ -375,10 +375,41 @@ HexahedralMeshTopologyKernel::add_cell(const std::vector<VertexHandle>& _vertice
assert(hf0.is_valid()); assert(hf1.is_valid()); assert(hf2.is_valid()); assert(hf0.is_valid()); assert(hf1.is_valid()); assert(hf2.is_valid());
assert(hf3.is_valid()); assert(hf4.is_valid()); assert(hf5.is_valid()); assert(hf3.is_valid()); assert(hf4.is_valid()); assert(hf5.is_valid());
std::vector<HalfFaceHandle> hfs; std::vector<HalfFaceHandle> hfs;
hfs.push_back(hf0); hfs.push_back(hf1); hfs.push_back(hf2); hfs.push_back(hf0); hfs.push_back(hf1); hfs.push_back(hf2);
hfs.push_back(hf3); hfs.push_back(hf4); hfs.push_back(hf5); hfs.push_back(hf3); hfs.push_back(hf4); hfs.push_back(hf5);
if (_topologyCheck) {
/*
* Test if all halffaces are connected and form a two-manifold
* => Cell is closed
*
* This test is simple: The number of involved half-edges has to be
* exactly twice the number of involved edges.
*/
std::set<HalfEdgeHandle> incidentHalfedges;
std::set<EdgeHandle> incidentEdges;
for(std::vector<HalfFaceHandle>::const_iterator it = hfs.begin(),
end = hfs.end(); it != end; ++it) {
OpenVolumeMeshFace hface = halfface(*it);
for(std::vector<HalfEdgeHandle>::const_iterator he_it = hface.halfedges().begin(),
he_end = hface.halfedges().end(); he_it != he_end; ++he_it) {
incidentHalfedges.insert(*he_it);
incidentEdges.insert(edge_handle(*he_it));
}
}
if(incidentHalfedges.size() != (incidentEdges.size() * 2u)) {
std::cerr << "The specified halffaces are not connected!" << std::endl;
return InvalidCellHandle;
}
// The halffaces are now guaranteed to form a two-manifold
}
return TopologyKernel::add_cell(hfs,false); return TopologyKernel::add_cell(hfs,false);
} }
......
...@@ -133,10 +133,11 @@ public: ...@@ -133,10 +133,11 @@ public:
* 0-------1 * 0-------1
* *
* @param _vertices A list of vertices in the correct order * @param _vertices A list of vertices in the correct order
* @param _topologyCheck Flag if a topology check should be performed before adding the cell
* *
* @return The new hexahedron's cell handle * @return The new hexahedron's cell handle
*/ */
CellHandle add_cell(const std::vector<VertexHandle>& _vertices); CellHandle add_cell(const std::vector<VertexHandle>& _vertices, bool _topologyCheck = false);
// ======================= Specialized Iterators ============================= // ======================= Specialized Iterators =============================
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment