Commit 78cd75fa authored by Max Lyon's avatar Max Lyon

fix bug in adding a hex cell with valence 2 edge

parent cbfed7a2
Pipeline #746 passed with stage
......@@ -2133,6 +2133,51 @@ HalfFaceHandle TopologyKernel::halfface(const std::vector<VertexHandle>& _vs) co
return halfface(hes);
}
HalfFaceHandle TopologyKernel::halfface_extensive(const std::vector<VertexHandle>& _vs) const
{
//TODO: schöner machen
assert(_vs.size() > 2);
VertexHandle v0 = _vs[0];
VertexHandle v1 = _vs[1];
assert(v0.is_valid() && v1.is_valid());
HalfEdgeHandle he0 = halfedge(v0, v1);
if(!he0.is_valid()) return InvalidHalfFaceHandle;
for(HalfEdgeHalfFaceIter hehf_it = hehf_iter(he0); hehf_it.valid(); ++hehf_it)
{
std::vector<HalfEdgeHandle> hes = halfface(*hehf_it).halfedges();
if (hes.size() != _vs.size())
continue;
int offset = 0;
for (unsigned int i = 0; i < hes.size(); ++i)
if (hes[i] == he0)
offset = i;
bool all_vertices_found = true;
for (unsigned int i = 0; i < hes.size(); ++i)
{
HalfEdgeHandle heh = hes[(i+offset)%hes.size()];
if (halfedge(heh).from_vertex() != _vs[i])
{
all_vertices_found = false;
break;
}
}
if (all_vertices_found)
return *hehf_it;
}
return InvalidHalfFaceHandle;
}
//========================================================================================
HalfFaceHandle TopologyKernel::halfface(const std::vector<HalfEdgeHandle>& _hes) const {
......
......@@ -412,6 +412,11 @@ public:
/// \note Only the first three vertices are checked
HalfFaceHandle halfface(const std::vector<VertexHandle>& _vs) const;
/// Get half-face from list of incident vertices (in connected order)
///
/// \note All vertices are checked
HalfFaceHandle halfface_extensive(const std::vector<VertexHandle>& _vs) const;
/// Get half-face from list of incident half-edges
///
/// \note Only the first two half-edges are checked
......
......@@ -307,40 +307,46 @@ HexahedralMeshTopologyKernel::add_cell(const std::vector<VertexHandle>& _vertice
std::vector<VertexHandle> vs;
// Half-face XF
vs.push_back(_vertices[3]);
vs.push_back(_vertices[2]);
vs.push_back(_vertices[1]);
vs.push_back(_vertices[0]);
hf0 = TopologyKernel::halfface(vs); vs.clear();
hf0 = TopologyKernel::halfface_extensive(vs); vs.clear();
// Half-face XB
vs.push_back(_vertices[7]);
vs.push_back(_vertices[6]);
vs.push_back(_vertices[5]);
vs.push_back(_vertices[4]);
hf1 = TopologyKernel::halfface(vs); vs.clear();
hf1 = TopologyKernel::halfface_extensive(vs); vs.clear();
// Half-face YF
vs.push_back(_vertices[1]);
vs.push_back(_vertices[2]);
vs.push_back(_vertices[6]);
hf2 = TopologyKernel::halfface(vs); vs.clear();
vs.push_back(_vertices[7]);
hf2 = TopologyKernel::halfface_extensive(vs); vs.clear();
// Half-face YB
vs.push_back(_vertices[4]);
vs.push_back(_vertices[5]);
vs.push_back(_vertices[3]);
vs.push_back(_vertices[0]);
hf3 = TopologyKernel::halfface(vs); vs.clear();
hf3 = TopologyKernel::halfface_extensive(vs); vs.clear();
// Half-face ZF
vs.push_back(_vertices[1]);
vs.push_back(_vertices[7]);
vs.push_back(_vertices[4]);
vs.push_back(_vertices[0]);
hf4 = TopologyKernel::halfface(vs); vs.clear();
hf4 = TopologyKernel::halfface_extensive(vs); vs.clear();
// Half-face ZB
vs.push_back(_vertices[2]);
vs.push_back(_vertices[3]);
vs.push_back(_vertices[5]);
vs.push_back(_vertices[6]);
hf5 = TopologyKernel::halfface(vs);
hf5 = TopologyKernel::halfface_extensive(vs);
if(!hf0.is_valid()) {
......
Markdown is supported
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