diff --git a/libsrc/csg/identify.cpp b/libsrc/csg/identify.cpp index a50c3b5d..8e5b8923 100644 --- a/libsrc/csg/identify.cpp +++ b/libsrc/csg/identify.cpp @@ -225,21 +225,30 @@ Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, n2 /= n2.Length(); if ( fabs(n2 * hsp2.v) > 1e-3) continue; - - - Vec<3> v = hsp2.p - hsp1.p; - double vl = v.Length(); - double cl = fabs (v*n1); + if ((trafo(hsp1.v)-hsp2.v).Length2() > 1e-12) + return false; - double val1 = 1 - cl*cl/(vl*vl); - double val2 = (hsp1.v - hsp2.v).Length(); - - if (val1 < 1e-10 && val2 < 1e-6) - return 1; + double d2typ = Dist2(hsp1.p, hsp2.p); + + if (Dist2 (trafo(hsp1.p),hsp2.p) < 1e-18*d2typ) + return true; + + if (Dist2 (hsp1.p, trafo(hsp1.p)) < 1e-18*d2typ) + { // old style without trafo, but normal projection + Vec<3> v = hsp2.p - hsp1.p; + double vl = v.Length(); + double cl = fabs (v*n1); + + double val1 = 1 - cl*cl/(vl*vl); + double val2 = (hsp1.v - hsp2.v).Length(); + + if (val1 < 1e-10 && val2 < 1e-6) + return true; + } } - return 0; + return false; } int PeriodicIdentification :: diff --git a/libsrc/csg/identify.hpp b/libsrc/csg/identify.hpp index 5211d155..96ae5bce 100644 --- a/libsrc/csg/identify.hpp +++ b/libsrc/csg/identify.hpp @@ -86,23 +86,23 @@ namespace netgen const Surface * as1, const Surface * as2, Transformation<3> atrafo = Vec<3>(0,0,0)); - virtual ~PeriodicIdentification (); - virtual void Print (ostream & ost) const; - virtual void GetData (ostream & ost) const; + virtual ~PeriodicIdentification () override; + virtual void Print (ostream & ost) const override; + virtual void GetData (ostream & ost) const override; // virtual void IdentifySpecialPoints (Array & points); virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, const TABLE & specpoint2solid, - const TABLE & specpoint2surface) const; + const TABLE & specpoint2surface) const override; - virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; - virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); - virtual void IdentifyPoints (class Mesh & mesh); - virtual void IdentifyFaces (class Mesh & mesh); + virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const override; + virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1) override; + virtual void IdentifyPoints (class Mesh & mesh) override; + virtual void IdentifyFaces (class Mesh & mesh) override; virtual void BuildSurfaceElements (Array & segs, class Mesh & mesh, - const Surface * surf); + const Surface * surf) override; };