From d1ebdf35d826caf1396ec076d144ddac53d6468f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Tue, 5 Apr 2016 09:51:12 +0200 Subject: [PATCH] fix for close-surface identification (fixes edge xxx-yyy multiple times in surface mesh --- libsrc/csg/identify.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libsrc/csg/identify.cpp b/libsrc/csg/identify.cpp index e3086a3b..9ebb985a 100644 --- a/libsrc/csg/identify.cpp +++ b/libsrc/csg/identify.cpp @@ -1245,13 +1245,20 @@ BuildSurfaceElements (Array & segs, (mesh.GetIdentifications().Get (s2[0], s1[1], nr) && mesh.GetIdentifications().Get (s2[1], s1[0], nr))) { + Vec<3> ns = surf->GetNormalVector (mesh[s1[0]]); + + Vec<3> t1 = mesh[s1[1]] - mesh[s1[0]]; + Vec<3> t2 = mesh[s2[1]] - mesh[s2[0]]; + Vec<3> nst1 = Cross(t1, ns); + Vec<3> nst2 = Cross(t2, ns); + Vec<3> dvec = Center(mesh[s1[0]], mesh[s1[1]])-Center(mesh[s2[0]], mesh[s2[1]]); + if (nst1 * dvec < 0) continue; + Element2d el(s1[0], s1[1], s2[0], s2[1]); Vec<3> n = Cross (mesh[el[1]] - mesh[el[0]], mesh[el[3]] - mesh[el[0]]); - Vec<3> ns = surf->GetNormalVector (mesh[el[0]]); - if (n * ns < 0) { Swap (el.PNum(1), el.PNum(2));