From c180b37ea81d8bd559e19f12faf1c5d41b05a1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Sun, 22 Sep 2019 13:15:53 +0200 Subject: [PATCH] more STL*Id --- libsrc/stlgeom/stlgeom.cpp | 2 +- libsrc/stlgeom/stlgeomchart.cpp | 40 +++++++++++++++++++++++++++------ libsrc/stlgeom/stlgeommesh.cpp | 4 ++-- libsrc/stlgeom/stlline.cpp | 3 ++- libsrc/stlgeom/stltool.hpp | 4 ++-- libsrc/stlgeom/stltopology.cpp | 2 +- libsrc/stlgeom/stltopology.hpp | 34 +++++++++++++++------------- 7 files changed, 60 insertions(+), 29 deletions(-) diff --git a/libsrc/stlgeom/stlgeom.cpp b/libsrc/stlgeom/stlgeom.cpp index 74050258..34ef9d8a 100644 --- a/libsrc/stlgeom/stlgeom.cpp +++ b/libsrc/stlgeom/stlgeom.cpp @@ -1609,7 +1609,7 @@ void STLGeometry :: NeighbourAnglesOfSelectedTrig() PrintMessage(1,"Angle to triangle ", st, ":"); for (i = 1; i <= NONeighbourTrigs(st); i++) { - PrintMessage(1," triangle ", NeighbourTrig(st,i), ": angle = ", + PrintMessage(1," triangle ", int(NeighbourTrig(st,i)), ": angle = ", 180./M_PI*GetAngle(st, NeighbourTrig(st,i)), "°", ", calculated = ", 180./M_PI*Angle(GetTriangle(st).GeomNormal(points), GetTriangle(NeighbourTrig(st,i)).GeomNormal(points)), "°"); diff --git a/libsrc/stlgeom/stlgeomchart.cpp b/libsrc/stlgeom/stlgeomchart.cpp index c7e3ac99..ae92d017 100644 --- a/libsrc/stlgeom/stlgeomchart.cpp +++ b/libsrc/stlgeom/stlgeomchart.cpp @@ -259,7 +259,33 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons if (!accepted) break; } - + + /* + // new check 2019-09-22 + if (accepted) + { + auto & trig = GetTriangle(nt); + Point<3> p0 = GetPoint(trig[0]); + Point<3> p1 = GetPoint(trig[1]); + Point<3> p2 = GetPoint(trig[2]); + Point<3> p01 = Center(p0,p1); + Point<3> p02 = Center(p0,p2); + Point<3> p12 = Center(p1,p2); + Point<3> p012 = Center(p0,p1,p2); + p01 += 1e-5 * (p012-p01); + p02 += 1e-5 * (p012-p02); + p12 += 1e-5 * (p012-p12); + bool test1 = chartbound.TestSegChartNV(p01,p012,sn); + bool test2 = chartbound.TestSegChartNV(p02,p012,sn); + bool test3 = chartbound.TestSegChartNV(p12,p012,sn); + if (!test1 || !test2 || !test3) + { + cout << "more stringent" << endl; + accepted = false; + } + } + */ + if (accepted) { @@ -274,13 +300,13 @@ void STLGeometry :: MakeAtlas(Mesh & mesh, const MeshingParameters& mparam, cons for (int k = 1; k <= 3; k++) { - if (innerpointstochart[GetTriangle(nt).PNum(k)] - != chartnum) + STLPointId pi = GetTriangle(nt).PNum(k); + if (innerpointstochart[pi] != chartnum) { - innerpointstochart[GetTriangle(nt).PNum(k)] = chartnum; - pointstochart[GetTriangle(nt).PNum(k)] = chartnum; - chartpoints.Append(GetTriangle(nt).PNum(k)); - innerchartpoints.Append(GetTriangle(nt).PNum(k)); + innerpointstochart[pi] = chartnum; + pointstochart[pi] = chartnum; + chartpoints.Append(pi); + innerchartpoints.Append(pi); } } } diff --git a/libsrc/stlgeom/stlgeommesh.cpp b/libsrc/stlgeom/stlgeommesh.cpp index d92c9f85..fc497039 100644 --- a/libsrc/stlgeom/stlgeommesh.cpp +++ b/libsrc/stlgeom/stlgeommesh.cpp @@ -541,7 +541,7 @@ int STLGeometry :: Project(Point<3> & p3d) const { Point<3> p, pf; - int i, j; + int j; int fi = 0; int cnt = 0; int different = 0; @@ -563,7 +563,7 @@ int STLGeometry :: Project(Point<3> & p3d) const for (j = 1; j <= nt; j++) { - i = chart.GetTrig1(j); + STLTrigId i = chart.GetTrig1(j); const Point<3> & c = GetTriangle(i).center; /* diff --git a/libsrc/stlgeom/stlline.cpp b/libsrc/stlgeom/stlline.cpp index 3b89ed34..0f4a5369 100644 --- a/libsrc/stlgeom/stlline.cpp +++ b/libsrc/stlgeom/stlline.cpp @@ -493,7 +493,8 @@ void STLEdgeDataList :: BuildClusterWithEdge(int ep1, int ep2, NgArray& int j, i, k; int oldend; int newend = 1; - int pnew, ennew(0); + STLPointId pnew; + int ennew(0); int changed = 1; while (changed) diff --git a/libsrc/stlgeom/stltool.hpp b/libsrc/stlgeom/stltool.hpp index 5e746632..c2a6a493 100644 --- a/libsrc/stlgeom/stltool.hpp +++ b/libsrc/stlgeom/stltool.hpp @@ -165,8 +165,8 @@ public: int operator== (const STLBoundarySeg & s2) const { return i1 == s2.i1 && i2 == s2.i2; } void Swap (); - int I1() const { return i1; } - int I2() const { return i2; } + STLPointId I1() const { return i1; } + STLPointId I2() const { return i2; } const Point<3> & P1() const { return p1; } const Point<3> & P2() const { return p2; } const Point<2> & P2D1() const { return p2d1; } diff --git a/libsrc/stlgeom/stltopology.cpp b/libsrc/stlgeom/stltopology.cpp index 9fca6a24..98798d49 100644 --- a/libsrc/stlgeom/stltopology.cpp +++ b/libsrc/stlgeom/stltopology.cpp @@ -829,7 +829,7 @@ void STLTopology :: FindNeighbourTrigs() PrintError("TRIG ",i," has ",NONeighbourTrigs(i)," neighbours!!!!"); for (int kk=1; kk <= NONeighbourTrigs(i); kk++) { - PrintMessage(5,"neighbour-trig",kk," = ",NeighbourTrig(i,kk)); + PrintMessage(5,"neighbour-trig",kk," = ",int(NeighbourTrig(i,kk))); } }; } diff --git a/libsrc/stlgeom/stltopology.hpp b/libsrc/stlgeom/stltopology.hpp index e07f3762..3e98535d 100644 --- a/libsrc/stlgeom/stltopology.hpp +++ b/libsrc/stlgeom/stltopology.hpp @@ -29,9 +29,10 @@ public: STLPointId & operator= (const STLPointId & ai) { i = ai.i; return *this; } STLPointId & operator= (int ai) { i = ai; return *this; } constexpr operator int () const { return i; } - STLPointId operator++ (int) { return i++; } - STLPointId operator-- (int) { return i--; } - STLPointId & operator++ () { i++; return *this; } + STLPointId operator++ (int) { return STLPointId(i++); } + STLPointId operator-- (int) { return STLPointId(i--); } + STLPointId & operator++ () { ++i; return *this; } + STLPointId & operator-- () { --i; return *this; } void DoArchive(Archive& ar) { ar & i; } }; @@ -47,10 +48,13 @@ public: STLTrigId & operator= (const STLTrigId & ai) { i = ai.i; return *this; } STLTrigId & operator= (int ai) { i = ai; return *this; } constexpr operator int () const { return i; } - STLTrigId operator++ (int) { return i++; } - STLTrigId operator-- (int) { return i--; } - STLTrigId & operator++ () { i++; return *this; } - + + STLTrigId operator++ (int) { return STLTrigId(i++); } + STLTrigId operator-- (int) { return STLTrigId(i--); } + STLTrigId & operator++ () { ++i; return *this; } + STLTrigId & operator-- () { --i; return *this; } + + int operator- (STLTrigId i2) const { return i-i2.i; } }; inline void SetInvalid (STLTrigId & id) { id = 0; } @@ -334,9 +338,9 @@ public: int GetNP() const { return points.Size(); } int AddPoint(const Point<3> & p) { points.Append(p); return points.Size(); } - const Point<3> & GetPoint(int nr) const { return points[nr]; } // .Get(nr); } + const Point<3> & GetPoint(STLPointId nr) const { return points[nr]; } // .Get(nr); } int GetPointNum (const Point<3> & p); - void SetPoint(int nr, const Point<3> & p) { points[nr] = p; } // { points.Elem(nr) = p; } + void SetPoint(STLPointId nr, const Point<3> & p) { points[nr] = p; } // { points.Elem(nr) = p; } auto & GetPoints() const { return points; } const Point<3> & operator[] (STLPointId i) const { return points[i]; } @@ -347,8 +351,8 @@ public: int GetNT() const { return trias.Size(); } void AddTriangle(const STLTriangle& t); - const STLTriangle & GetTriangle (int nr) const { return trias[nr]; } // .Get(nr); } - STLTriangle & GetTriangle (int nr) { return trias[nr]; } // .Elem(nr); } + const STLTriangle & GetTriangle (STLTrigId nr) const { return trias[nr]; } // .Get(nr); } + STLTriangle & GetTriangle (STLTrigId nr) { return trias[nr]; } // .Elem(nr); } const STLTriangle & operator[] (STLTrigId i) const { return trias[i]; } STLTriangle & operator[] (STLTrigId i) { return trias[i]; } @@ -381,13 +385,13 @@ public: // Table will be constructed, if topology is not ok /// neighbourtrigs for surfacetrigs - TABLE neighbourtrigs; + TABLE neighbourtrigs; /// get nr-th neighbour Triangle for triangle trig - int NONeighbourTrigs(int trig) const { return neighbourtrigs.EntrySize(trig); } - int NeighbourTrig(int trig, int nr) const { return neighbourtrigs.Get(trig,nr); } + int NONeighbourTrigs(STLTrigId trig) const { return neighbourtrigs.EntrySize(int(trig)); } + STLTrigId NeighbourTrig(STLTrigId trig, int nr) const { return neighbourtrigs.Get(int(trig),nr); } int NeighbourTrigSorted(int trig, int nr) const; - void AddNeighbourTrig(int i, int nt) { neighbourtrigs.Add1(i, nt); } + void AddNeighbourTrig(STLTrigId i, STLTrigId nt) { neighbourtrigs.Add1(int(i), nt); }