Edge orientation coherence
Sort edges in output of IntersectionPlaneMesh() to remove duplicate vertex and maintain orientation coherence in the edges. Before this change, the vertex list contains duplicates and the edge list is not sorted, so there is no easy way to build the polylines of the cut. Calling RemoveDuplicateVertex() will produce a edge list with no coherence, like this example: ``` edge [0 1] goes from [0.12843863 0.38690682 0.1] to [0.13383933 0.3839188 0.1] edge [2 3] goes from [0.14307424 0.38100217 0.1] to [0.13592989 0.38318165 0.1] edge [3 1] goes from [0.13592989 0.38318165 0.1] to [0.13383933 0.3839188 0.1] ``` The output is correct, but somehow confusing because edges in the polyline(s) are not in order. After the proposed change, the output will be: ``` edge [0 1] goes from [0.12843863 0.38690682 0.1] to [0.13383933 0.3839188 0.1] edge [1 3] goes from [0.13383933 0.3839188 0.1] to [0.13592989 0.38318165 0.1] edge [3 2] goes from [0.13592989 0.38318165 0.1] to [0.14307424 0.38100217 0.1] ```
This commit is contained in:
parent
38c3a410b1
commit
97a521fd23
|
@ -195,6 +195,26 @@ bool IntersectionPlaneMesh(TriMeshType & m,
|
|||
}
|
||||
tri::Allocator<TriMeshType> :: template DeletePerVertexAttribute < ScalarType >(m,qH);
|
||||
|
||||
//Clean-up: Remove duplicate vertex
|
||||
tri::Clean<EdgeMeshType>::RemoveDuplicateVertex(em);
|
||||
|
||||
//Clean-up: Sort edges ensuring orientation coherence
|
||||
for(size_t j=1; j < em.edge.size(); j++)
|
||||
{
|
||||
auto &n=em.edge[j-1].V(1);
|
||||
for(size_t i=j; i< em.edge.size(); i++)
|
||||
{
|
||||
auto & ei=em.edge[i];
|
||||
if (ei.V(1) == n)
|
||||
std::swap(ei.V(0), ei.V(1));
|
||||
if (ei.V(0) == n)
|
||||
{
|
||||
std::swap(em.edge[j], em.edge[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue