From ca2212879eb7c663cf3226b1ba376b13c5ff1c0c Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sun, 29 Sep 2019 14:54:24 +0200 Subject: [PATCH] Change some PointNd to Point functions --- libsrc/csg/meshsurf.cpp | 24 +++++++----------- libsrc/csg/meshsurf.hpp | 25 +++++++++--------- libsrc/gprim/geomobjects.hpp | 6 +++++ libsrc/meshing/meshing2.cpp | 28 +++++++++++++-------- libsrc/meshing/meshing2.hpp | 10 ++++---- libsrc/occ/occmeshsurf.cpp | 20 ++++++--------- libsrc/occ/occmeshsurf.hpp | 24 +++++++++--------- libsrc/stlgeom/meshstlsurface.cpp | 14 +++++------ libsrc/stlgeom/meshstlsurface.hpp | 42 +++++++++++++++---------------- 9 files changed, 96 insertions(+), 97 deletions(-) diff --git a/libsrc/csg/meshsurf.cpp b/libsrc/csg/meshsurf.cpp index 54a70af8..b0d6bfaf 100644 --- a/libsrc/csg/meshsurf.cpp +++ b/libsrc/csg/meshsurf.cpp @@ -23,33 +23,27 @@ Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurf, } -void Meshing2Surfaces :: DefineTransformation (const Point3d & p1, const Point3d & p2, +void Meshing2Surfaces :: DefineTransformation (const Point<3> & p1, const Point<3> & p2, const PointGeomInfo * geominfo1, const PointGeomInfo * geominfo2) { ((Surface&)surface).DefineTangentialPlane (p1, p2); } -void Meshing2Surfaces :: TransformToPlain (const Point3d & locpoint, +void Meshing2Surfaces :: TransformToPlain (const Point<3> & locpoint, const MultiPointGeomInfo & geominfo, - Point2d & planepoint, + Point<2> & planepoint, double h, int & zone) { - Point<2> hp; - surface.ToPlane (locpoint, hp, h, zone); - planepoint.X() = hp(0); - planepoint.Y() = hp(1); + surface.ToPlane (locpoint, planepoint, h, zone); } -int Meshing2Surfaces :: TransformFromPlain (Point2d & planepoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h) +int Meshing2Surfaces :: TransformFromPlain (const Point<2> & planepoint, + Point<3> & locpoint, + PointGeomInfo & gi, + double h) { - Point<3> hp; - Point<2> hp2 (planepoint.X(), planepoint.Y()); - surface.FromPlane (hp2, hp, h); - locpoint = hp; + surface.FromPlane (planepoint, locpoint, h); gi.trignum = 1; return 0; } diff --git a/libsrc/csg/meshsurf.hpp b/libsrc/csg/meshsurf.hpp index 3d606793..91a1d5ae 100644 --- a/libsrc/csg/meshsurf.hpp +++ b/libsrc/csg/meshsurf.hpp @@ -21,21 +21,22 @@ namespace netgen protected: /// - virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, - const PointGeomInfo * geominfo1, - const PointGeomInfo * geominfo2); + void DefineTransformation(const Point<3> & p1, + const Point<3> & p2, + const PointGeomInfo * geominfo1, + const PointGeomInfo * geominfo2) override; /// - virtual void TransformToPlain (const Point3d & locpoint, - const MultiPointGeomInfo & geominfo, - Point2d & plainpoint, - double h, int & zone); + void TransformToPlain(const Point<3> & locpoint, + const MultiPointGeomInfo & geominfo, + Point<2> & plainpoint, + double h, int & zone) override; /// - virtual int TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h); + int TransformFromPlain(const Point<2>& plainpoint, + Point<3>& locpoint, + PointGeomInfo & gi, + double h) override; /// - virtual double CalcLocalH (const Point3d & p, double gh) const; + double CalcLocalH(const Point3d & p, double gh) const override; }; diff --git a/libsrc/gprim/geomobjects.hpp b/libsrc/gprim/geomobjects.hpp index 185da070..48142356 100644 --- a/libsrc/gprim/geomobjects.hpp +++ b/libsrc/gprim/geomobjects.hpp @@ -63,6 +63,9 @@ namespace netgen T & operator() (int i) { return x[i]; } const T & operator() (int i) const { return x[i]; } + T& operator[] (int i) { return x[i]; } + const T& operator[] (int i) const { return x[i]; } + operator const T* () const { return x; } void DoArchive(Archive& archive) @@ -120,6 +123,9 @@ namespace netgen T & operator() (int i) { return x[i]; } const T & operator() (int i) const { return x[i]; } + T& operator[] (int i) { return x[i]; } + const T& operator[] (int i) const { return x[i]; } + operator const T* () const { return x; } void DoArchive(Archive& archive) diff --git a/libsrc/meshing/meshing2.cpp b/libsrc/meshing/meshing2.cpp index 67cb1fd3..1ae2f474 100644 --- a/libsrc/meshing/meshing2.cpp +++ b/libsrc/meshing/meshing2.cpp @@ -122,7 +122,7 @@ namespace netgen // static Vec3d ex, ey; // static Point3d globp1; - void Meshing2 :: DefineTransformation (const Point3d & p1, const Point3d & p2, + void Meshing2 :: DefineTransformation (const Point<3> & p1, const Point<3> & p2, const PointGeomInfo * geominfo1, const PointGeomInfo * geominfo2) { @@ -134,28 +134,28 @@ namespace netgen ey.Z() = 0; } - void Meshing2 :: TransformToPlain (const Point3d & locpoint, + void Meshing2 :: TransformToPlain (const Point<3> & locpoint, const MultiPointGeomInfo & geominf, - Point2d & plainpoint, double h, int & zone) + Point<2> & plainpoint, double h, int & zone) { Vec3d p1p (globp1, locpoint); // p1p = locpoint - globp1; p1p /= h; - plainpoint.X() = p1p * ex; - plainpoint.Y() = p1p * ey; + plainpoint[0] = p1p * ex; + plainpoint[1] = p1p * ey; zone = 0; } - int Meshing2 :: TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, + int Meshing2 :: TransformFromPlain (const Point<2> & plainpoint, + Point<3> & locpoint, PointGeomInfo & gi, double h) { Vec3d p1p; gi.trignum = 1; - p1p = plainpoint.X() * ex + plainpoint.Y() * ey; + p1p = plainpoint[0] * ex + plainpoint[1] * ey; p1p *= h; locpoint = globp1 + p1p; return 0; @@ -545,8 +545,12 @@ namespace netgen for (size_t i = 0; i < locpoints.Size(); i++) - TransformToPlain (locpoints[i], mpgeominfo[i], - plainpoints[i], h, plainzones[i]); + { + Point<2> pp; + TransformToPlain (locpoints[i], mpgeominfo[i], + pp, h, plainzones[i]); + plainpoints[i] = pp; + } /* for (int i = 1; i <= locpoints.Size(); i++) @@ -841,9 +845,11 @@ namespace netgen for (int i = oldnp+1; i <= plainpoints.Size(); i++) { + Point<3> locp; int err = - TransformFromPlain (plainpoints.Elem(i), locpoints.Elem(i), + TransformFromPlain (plainpoints.Elem(i), locp, upgeominfo.Elem(i), h); + locpoints.Elem(i) = locp; if (err) { diff --git a/libsrc/meshing/meshing2.hpp b/libsrc/meshing/meshing2.hpp index 47fd5b01..1cf2d52e 100644 --- a/libsrc/meshing/meshing2.hpp +++ b/libsrc/meshing/meshing2.hpp @@ -84,16 +84,16 @@ protected: virtual double CalcLocalH (const Point3d & p, double gh) const; /// - virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, + virtual void DefineTransformation (const Point<3> & p1, const Point<3> & p2, const PointGeomInfo * geominfo1, const PointGeomInfo * geominfo2); /// - virtual void TransformToPlain (const Point3d & locpoint, const MultiPointGeomInfo & geominfo, - Point2d & plainpoint, double h, int & zone); + virtual void TransformToPlain (const Point<3> & locpoint, const MultiPointGeomInfo & geominfo, + Point<2> & plainpoint, double h, int & zone); /// return 0 .. ok /// return >0 .. cannot transform point to true surface - virtual int TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, + virtual int TransformFromPlain (const Point<2>& plainpoint, + Point<3> & locpoint, PointGeomInfo & geominfo, double h); diff --git a/libsrc/occ/occmeshsurf.cpp b/libsrc/occ/occmeshsurf.cpp index fea3324c..cc70b98d 100644 --- a/libsrc/occ/occmeshsurf.cpp +++ b/libsrc/occ/occmeshsurf.cpp @@ -432,33 +432,27 @@ namespace netgen } - void Meshing2OCCSurfaces :: DefineTransformation (const Point3d & p1, const Point3d & p2, + void Meshing2OCCSurfaces :: DefineTransformation (const Point<3> & p1, const Point<3> & p2, const PointGeomInfo * geominfo1, const PointGeomInfo * geominfo2) { ((OCCSurface&)surface).DefineTangentialPlane (p1, *geominfo1, p2, *geominfo2); } - void Meshing2OCCSurfaces :: TransformToPlain (const Point3d & locpoint, + void Meshing2OCCSurfaces :: TransformToPlain (const Point<3>& locpoint, const MultiPointGeomInfo & geominfo, - Point2d & planepoint, + Point<2> & planepoint, double h, int & zone) { - Point<2> hp; - surface.ToPlane (locpoint, geominfo.GetPGI(1), hp, h, zone); - planepoint.X() = hp(0); - planepoint.Y() = hp(1); + surface.ToPlane (locpoint, geominfo.GetPGI(1), planepoint, h, zone); } - int Meshing2OCCSurfaces :: TransformFromPlain (Point2d & planepoint, - Point3d & locpoint, + int Meshing2OCCSurfaces :: TransformFromPlain (const Point<2> & planepoint, + Point<3> & locpoint, PointGeomInfo & gi, double h) { - Point<3> hp; - Point<2> hp2 (planepoint.X(), planepoint.Y()); - surface.FromPlane (hp2, hp, gi, h); - locpoint = hp; + surface.FromPlane (planepoint, locpoint, gi, h); return 0; } diff --git a/libsrc/occ/occmeshsurf.hpp b/libsrc/occ/occmeshsurf.hpp index d10cc41d..79e04e5b 100644 --- a/libsrc/occ/occmeshsurf.hpp +++ b/libsrc/occ/occmeshsurf.hpp @@ -122,22 +122,22 @@ public: protected: /// - virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, - const PointGeomInfo * geominfo1, - const PointGeomInfo * geominfo2); + void DefineTransformation (const Point<3> & p1, const Point<3> & p2, + const PointGeomInfo * geominfo1, + const PointGeomInfo * geominfo2) override; /// - virtual void TransformToPlain (const Point3d & locpoint, - const MultiPointGeomInfo & geominfo, - Point2d & plainpoint, - double h, int & zone); + void TransformToPlain (const Point<3> & locpoint, + const MultiPointGeomInfo & geominfo, + Point<2> & plainpoint, + double h, int & zone) override; /// - virtual int TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h); + int TransformFromPlain (const Point<2> & plainpoint, + Point<3> & locpoint, + PointGeomInfo & gi, + double h) override; /// - virtual double CalcLocalH (const Point3d & p, double gh) const; + double CalcLocalH (const Point3d & p, double gh) const override; }; diff --git a/libsrc/stlgeom/meshstlsurface.cpp b/libsrc/stlgeom/meshstlsurface.cpp index 4eadc1e0..eaf5a8af 100644 --- a/libsrc/stlgeom/meshstlsurface.cpp +++ b/libsrc/stlgeom/meshstlsurface.cpp @@ -884,7 +884,7 @@ MeshingSTLSurface :: MeshingSTLSurface (STLGeometry & ageom, ; } -void MeshingSTLSurface :: DefineTransformation (const Point3d & p1, const Point3d & p2, +void MeshingSTLSurface :: DefineTransformation (const Point<3> & p1, const Point<3> & p2, const PointGeomInfo * geominfo, const PointGeomInfo * geominfo2) { @@ -893,8 +893,8 @@ void MeshingSTLSurface :: DefineTransformation (const Point3d & p1, const Point3 geom.DefineTangentialPlane(p1, p2, transformationtrig); } -void MeshingSTLSurface :: TransformToPlain (const Point3d & locpoint, const MultiPointGeomInfo & gi, - Point2d & plainpoint, double h, int & zone) +void MeshingSTLSurface :: TransformToPlain (const Point<3> & locpoint, const MultiPointGeomInfo & gi, + Point<2> & plainpoint, double h, int & zone) { int trigs[10000]; @@ -910,9 +910,7 @@ void MeshingSTLSurface :: TransformToPlain (const Point3d & locpoint, const Mult // int trig = gi.trignum; // (*testout) << "locpoint = " << locpoint; - Point<2> hp2d; - geom.ToPlane (locpoint, trigs, hp2d, h, zone, 1); - plainpoint = hp2d; + geom.ToPlane (locpoint, trigs, plainpoint, h, zone, 1); // geom.ToPlane (locpoint, NULL, plainpoint, h, zone, 1); /* @@ -1018,8 +1016,8 @@ GetChartBoundary (NgArray & points, -int MeshingSTLSurface :: TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, +int MeshingSTLSurface :: TransformFromPlain (const Point<2> & plainpoint, + Point<3> & locpoint, PointGeomInfo & gi, double h) { diff --git a/libsrc/stlgeom/meshstlsurface.hpp b/libsrc/stlgeom/meshstlsurface.hpp index e7274c6a..89420bde 100644 --- a/libsrc/stlgeom/meshstlsurface.hpp +++ b/libsrc/stlgeom/meshstlsurface.hpp @@ -27,40 +27,40 @@ public: protected: /// - virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, - const PointGeomInfo * geominfo1, - const PointGeomInfo * geominfo2); + void DefineTransformation (const Point<3> & p1, const Point<3> & p2, + const PointGeomInfo * geominfo1, + const PointGeomInfo * geominfo2) override; /// - virtual void TransformToPlain (const Point3d & locpoint, const MultiPointGeomInfo & geominfo, - Point2d & plainpoint, double h, int & zone); + void TransformToPlain (const Point<3> & locpoint, const MultiPointGeomInfo & geominfo, + Point<2> & plainpoint, double h, int & zone) override; /// - virtual int TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h); + int TransformFromPlain (const Point<2>& plainpoint, + Point<3> & locpoint, + PointGeomInfo & gi, + double h) override; /// - virtual int BelongsToActiveChart (const Point3d & p, - const PointGeomInfo & gi); + int BelongsToActiveChart (const Point3d & p, + const PointGeomInfo & gi) override; /// - virtual int ComputePointGeomInfo (const Point3d & p, PointGeomInfo & gi); + int ComputePointGeomInfo (const Point3d & p, PointGeomInfo & gi) override; /// - virtual int ChooseChartPointGeomInfo (const MultiPointGeomInfo & mpgi, - PointGeomInfo & pgi); + int ChooseChartPointGeomInfo (const MultiPointGeomInfo & mpgi, + PointGeomInfo & pgi) override; /// - virtual int IsLineVertexOnChart (const Point3d & p1, const Point3d & p2, - int endpoint, const PointGeomInfo & gi); + int IsLineVertexOnChart (const Point3d & p1, const Point3d & p2, + int endpoint, const PointGeomInfo & gi) override; - virtual void GetChartBoundary (NgArray & points, - NgArray & poitns3d, - NgArray & lines, double h) const; + void GetChartBoundary (NgArray & points, + NgArray & poitns3d, + NgArray & lines, double h) const override; /// - virtual double CalcLocalH (const Point3d & p, double gh) const; + double CalcLocalH (const Point3d & p, double gh) const override; /// - virtual double Area () const; + double Area () const override; };