From 24fe7a4a73f097319bb519b5ca82d40c9854811d Mon Sep 17 00:00:00 2001 From: Jerome Robert Date: Fri, 8 Feb 2019 18:13:42 +0100 Subject: [PATCH] [Amibe] RemeshSkeleton collapse between polyline extremities when RemeshPolyline return only 2 points. Those two points are supposed to already be the extremities of the polyline but sometime they are not. --- .../mesh/amibe/algos3d/EdgesCollapserNG.java | 1 + .../mesh/amibe/algos3d/RemeshSkeleton.java | 22 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/amibe/src/org/jcae/mesh/amibe/algos3d/EdgesCollapserNG.java b/amibe/src/org/jcae/mesh/amibe/algos3d/EdgesCollapserNG.java index 9099d0087..eb44882e4 100644 --- a/amibe/src/org/jcae/mesh/amibe/algos3d/EdgesCollapserNG.java +++ b/amibe/src/org/jcae/mesh/amibe/algos3d/EdgesCollapserNG.java @@ -97,6 +97,7 @@ public EdgesCollapserNG(Mesh mesh) private AbstractHalfEdge getEdge(Vertex v1, Triangle t, Vertex v2) { + assert v1 == t.getV0() || v1 == t.getV1() || v1 == t.getV2(); assert v1 != v2; AbstractHalfEdge e = v1.getIncidentAbstractHalfEdge(t, null); Vertex start = e.destination(); diff --git a/amibe/src/org/jcae/mesh/amibe/algos3d/RemeshSkeleton.java b/amibe/src/org/jcae/mesh/amibe/algos3d/RemeshSkeleton.java index b009fd2b8..423f96718 100644 --- a/amibe/src/org/jcae/mesh/amibe/algos3d/RemeshSkeleton.java +++ b/amibe/src/org/jcae/mesh/amibe/algos3d/RemeshSkeleton.java @@ -127,6 +127,14 @@ public void compute() edgeIndex.add(e); } + if(toInsert.size() == 2) + { + int n = Math.max(1, polyline.size() / 2); + if(toInsert.get(0) != toInsert.get(1)) + edgeCollapser.collapse(polyline.get(0), polyline.get(polyline.size() - 1), polyline.get(n)); + continue main; + } + for(int k = 0; k < toInsert.size(); k++) { Vertex v = toInsert.get(k); @@ -157,17 +165,9 @@ else if(dd <= tolerance) vertexSwapper.swap(v); } } - if(toInsert.size() == 2) - { - int n = Math.max(1, polyline.size() / 2); - if(toInsert.get(0) != toInsert.get(1)) - edgeCollapser.collapse(toInsert.get(0), toInsert.get(1), polyline.get(n)); - } - else - { - for(int k = 0; k < toInsert.size() - 1; k++) - edgeCollapser.collapse(toInsert.get(k), toInsert.get(k+1), null); - } + + for(int k = 0; k < toInsert.size() - 1; k++) + edgeCollapser.collapse(toInsert.get(k), toInsert.get(k+1), null); for(Vertex v:toInsert) v.setMutable(false);