From 975d2203508d878eae810089d0a5ca631240f4d5 Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Mon, 7 Sep 2009 11:50:13 +0000 Subject: [PATCH] namespaces, layers for 2D geometry --- libsrc/csg/algprim.hpp | 785 +++++++++++++++--------------- libsrc/csg/brick.hpp | 152 +++--- libsrc/csg/csg.hpp | 17 +- libsrc/csg/csgeom.hpp | 587 +++++++++++----------- libsrc/csg/csgparser.hpp | 14 +- libsrc/csg/curve2d.hpp | 76 +-- libsrc/csg/edgeflw.hpp | 134 ++--- libsrc/csg/explicitcurve2d.hpp | 160 +++--- libsrc/csg/extrusion.hpp | 207 ++++---- libsrc/csg/gencyl.hpp | 88 ++-- libsrc/csg/identify.hpp | 352 +++++++------- libsrc/csg/manifold.hpp | 27 +- libsrc/csg/meshsurf.hpp | 122 ++--- libsrc/csg/polyhedra.hpp | 159 +++--- libsrc/csg/revolution.hpp | 228 ++++----- libsrc/csg/singularref.hpp | 126 ++--- libsrc/csg/solid.hpp | 371 +++++++------- libsrc/csg/specpoin.hpp | 305 ++++++------ libsrc/csg/spline3d.hpp | 151 +++--- libsrc/csg/surface.hpp | 584 +++++++++++----------- libsrc/csg/triapprox.hpp | 72 +-- libsrc/geom2d/genmesh2d.cpp | 25 +- libsrc/geom2d/geom2dmesh.hpp | 51 +- libsrc/geom2d/geometry2d.hpp | 5 +- libsrc/geom2d/spline.hpp | 35 +- libsrc/geom2d/splinegeometry.cpp | 13 +- libsrc/geom2d/splinegeometry.hpp | 205 ++++---- libsrc/include/nginterface_v2.hpp | 12 +- ng/nginterface_v2.cpp | 10 +- 29 files changed, 2608 insertions(+), 2465 deletions(-) diff --git a/libsrc/csg/algprim.hpp b/libsrc/csg/algprim.hpp index 4c56edd7..9a6e66fa 100644 --- a/libsrc/csg/algprim.hpp +++ b/libsrc/csg/algprim.hpp @@ -3,348 +3,351 @@ /**************************************************************************/ -/* File: algprim.hh */ +/* File: algprim.hpp */ /* Author: Joachim Schoeberl */ /* Date: 1. Dez. 95 */ /**************************************************************************/ -/* +namespace netgen +{ -Quadric Surfaces (Plane, Sphere, Cylinder) + /* + + Quadric Surfaces (Plane, Sphere, Cylinder) -*/ - - -/** - A quadric surface. - surface defined by - cxx x^2 + cyy y^2 + czz z^2 + cxy x y + cxz x z + cyz y z + - cx x + cy y + cz z + c1 = 0. - **/ -class QuadraticSurface : public OneSurfacePrimitive -{ -protected: - double cxx, cyy, czz, cxy, cxz, cyz, cx, cy, cz, c1; - -public: - virtual double CalcFunctionValue (const Point<3> & point) const; - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - /* - virtual int RootInBox (const Box<3> & box) - const { return 0; } - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) - const { return DOES_INTERSECT; } -*/ - virtual double HesseNorm () const { return cxx + cyy + czz; } - - virtual Point<3> GetSurfacePoint () const; - - - virtual void Print (ostream & ist) const; - virtual void Read (istream & ist); - void PrintCoeff (ostream & ost) const; -}; - - -/// A Plane (i.e., the plane and everything behind it). -class Plane : public QuadraticSurface -{ - /// a point in the plane - Point<3> p; - /// outward normal vector - Vec<3> n; - - double eps_base; - -public: - /// - Plane (const Point<3> & ap, Vec<3> an); - - virtual void GetPrimitiveData (const char *& classname, - Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - static Primitive * CreateDefault (); - - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); - - - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - - /// - virtual void DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2); - /// - virtual void ToPlane (const Point<3> & p3d, - Point<2> & pplane, double h, - int & zone) const; - /// - virtual void FromPlane (const Point<2> & pplane, - Point<3> & p3d, - double h) const; - /// - virtual void Project (Point<3> & p) const; - - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - - /// - inline virtual double CalcFunctionValue (const Point<3> & p3d) const - {return cx * p3d(0) + cy * p3d(1) + cz * p3d(2) + c1;} - /// - virtual void CalcGradient (const Point<3> & point, - Vec<3> & grad) const; - /// - virtual void CalcHesse (const Point<3> & point, - Mat<3> & hesse) const; - /// - virtual double HesseNorm () const; - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void GetTriangleApproximation - (TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const; - -}; - -// typedef Plane Plane; - - -/// -class Sphere : public QuadraticSurface -{ - /// - Point<3> c; - /// - double r; -public: - /// - Sphere (const Point<3> & ac, double ar); - - virtual void GetPrimitiveData (const char *& classname, - Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - static Primitive * CreateDefault (); - - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); - - - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - - /// - virtual void DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2); - /// - virtual void ToPlane (const Point<3> & p3d, - Point<2> & pplane, double h, - int & zone) const; - /// - virtual void FromPlane (const Point<2> & pplane, - Point<3> & p, double h) const; - /// - virtual void Project (Point<3> & p) const; - - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; - /// - virtual Point<3> GetSurfacePoint () const; - /// - const Point<3> & Center () const { return c; } - /// - double Radius () const { return r; } - - /// - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; -}; - - -/// -class Cylinder : public QuadraticSurface -{ - /// - Point<3> a, b; - /// - double r; - /// - Vec<3> vab; - -public: - Cylinder (const Point<3> & aa, const Point<3> & ab, double ar); - Cylinder (Array & coeffs); - - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - static Primitive * CreateDefault (); - - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); - - /// - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - /// - virtual void DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2); - /// - virtual void ToPlane (const Point<3> & p, - Point<2> & pplane, - double h, - int & zone) const; - /// - virtual void FromPlane (const Point<2> & pplane, - Point<3> & p, - double h) const; - /// - virtual void Project (Point<3> & p) const; - - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; -}; - - - - - -/// -class EllipticCylinder : public QuadraticSurface -{ -private: - /// - Point<3> a; - /// - Vec<3> vl, vs; - /// - Vec<3> vab, t0vec, t1vec; - /// - double vabl, t0, t1; -public: - /// - EllipticCylinder (const Point<3> & aa, - const Vec<3> & avl, const Vec<3> & avs); - - /* - static Primitive * CreateDefault (); - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); */ - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; - /// - virtual Point<3> GetSurfacePoint () const; - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; + + /** + A quadric surface. + surface defined by + cxx x^2 + cyy y^2 + czz z^2 + cxy x y + cxz x z + cyz y z + + cx x + cy y + cz z + c1 = 0. + **/ + class QuadraticSurface : public OneSurfacePrimitive + { + protected: + double cxx, cyy, czz, cxy, cxz, cyz, cx, cy, cz, c1; + + public: + virtual double CalcFunctionValue (const Point<3> & point) const; + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + /* + virtual int RootInBox (const Box<3> & box) + const { return 0; } + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) + const { return DOES_INTERSECT; } + */ + virtual double HesseNorm () const { return cxx + cyy + czz; } + + virtual Point<3> GetSurfacePoint () const; + + + virtual void Print (ostream & ist) const; + virtual void Read (istream & ist); + void PrintCoeff (ostream & ost) const; + }; + + + /// A Plane (i.e., the plane and everything behind it). + class Plane : public QuadraticSurface + { + /// a point in the plane + Point<3> p; + /// outward normal vector + Vec<3> n; + + double eps_base; + + public: + /// + Plane (const Point<3> & ap, Vec<3> an); + + virtual void GetPrimitiveData (const char *& classname, + Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + static Primitive * CreateDefault (); + + virtual Primitive * Copy () const; + virtual void Transform (Transformation<3> & trans); + + + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + + /// + virtual void DefineTangentialPlane (const Point<3> & ap1, + const Point<3> & ap2); + /// + virtual void ToPlane (const Point<3> & p3d, + Point<2> & pplane, double h, + int & zone) const; + /// + virtual void FromPlane (const Point<2> & pplane, + Point<3> & p3d, + double h) const; + /// + virtual void Project (Point<3> & p) const; + + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + + /// + inline virtual double CalcFunctionValue (const Point<3> & p3d) const + {return cx * p3d(0) + cy * p3d(1) + cz * p3d(2) + c1;} + /// + virtual void CalcGradient (const Point<3> & point, + Vec<3> & grad) const; + /// + virtual void CalcHesse (const Point<3> & point, + Mat<3> & hesse) const; + /// + virtual double HesseNorm () const; + /// + virtual Point<3> GetSurfacePoint () const; + /// + virtual void GetTriangleApproximation + (TriangleApproximation & tas, + const Box<3> & boundingbox, double facets) const; + + }; + + // typedef Plane Plane; + + + /// + class Sphere : public QuadraticSurface + { + /// + Point<3> c; + /// + double r; + public: + /// + Sphere (const Point<3> & ac, double ar); + + virtual void GetPrimitiveData (const char *& classname, + Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + static Primitive * CreateDefault (); + + virtual Primitive * Copy () const; + virtual void Transform (Transformation<3> & trans); + + + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + + /// + virtual void DefineTangentialPlane (const Point<3> & ap1, + const Point<3> & ap2); + /// + virtual void ToPlane (const Point<3> & p3d, + Point<2> & pplane, double h, + int & zone) const; + /// + virtual void FromPlane (const Point<2> & pplane, + Point<3> & p, double h) const; + /// + virtual void Project (Point<3> & p) const; + + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// + virtual double HesseNorm () const; + /// + virtual Point<3> GetSurfacePoint () const; + /// + const Point<3> & Center () const { return c; } + /// + double Radius () const { return r; } + + /// + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; + }; + + + /// + class Cylinder : public QuadraticSurface + { + /// + Point<3> a, b; + /// + double r; + /// + Vec<3> vab; + + public: + Cylinder (const Point<3> & aa, const Point<3> & ab, double ar); + Cylinder (Array & coeffs); + + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + static Primitive * CreateDefault (); + + virtual Primitive * Copy () const; + virtual void Transform (Transformation<3> & trans); + + /// + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + /// + virtual void DefineTangentialPlane (const Point<3> & ap1, + const Point<3> & ap2); + /// + virtual void ToPlane (const Point<3> & p, + Point<2> & pplane, + double h, + int & zone) const; + /// + virtual void FromPlane (const Point<2> & pplane, + Point<3> & p, + double h) const; + /// + virtual void Project (Point<3> & p) const; + + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// + virtual double HesseNorm () const; + /// + virtual Point<3> GetSurfacePoint () const; + /// + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; + }; + + + + + + /// + class EllipticCylinder : public QuadraticSurface + { + private: + /// + Point<3> a; + /// + Vec<3> vl, vs; + /// + Vec<3> vab, t0vec, t1vec; + /// + double vabl, t0, t1; + public: + /// + EllipticCylinder (const Point<3> & aa, + const Vec<3> & avl, const Vec<3> & avs); + + /* + static Primitive * CreateDefault (); + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + */ + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// + virtual double HesseNorm () const; + /// + virtual Point<3> GetSurfacePoint () const; + + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; - virtual double MaxCurvature () const; + virtual double MaxCurvature () const; - virtual double MaxCurvatureLoc (const Point<3> & /* c */ , - double /* rad */) const; + virtual double MaxCurvatureLoc (const Point<3> & /* c */ , + double /* rad */) const; -private: - void CalcData(); -}; + private: + void CalcData(); + }; -/// -class Ellipsoid : public QuadraticSurface -{ -private: - /// - Point<3> a; - /// - Vec<3> v1, v2, v3; - /// - double rmin; -public: - /// - Ellipsoid (const Point<3> & aa, - const Vec<3> & av1, - const Vec<3> & av2, - const Vec<3> & av3); - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; - /// - virtual double MaxCurvature () const; - /// - virtual Point<3> GetSurfacePoint () const; - - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; - -private: - void CalcData(); -}; - - - - - - - - -/// -class Cone : public QuadraticSurface -{ - /// - Point<3> a, b; - /// - double ra, rb, minr; - /// - Vec<3> vab, t0vec, t1vec; - /// - double vabl, t0, t1; -public: - /// - Cone (const Point<3> & aa, const Point<3> & ab, double ara, double arb); - /// - static Primitive * CreateDefault (); - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; + class Ellipsoid : public QuadraticSurface + { + private: + /// + Point<3> a; + /// + Vec<3> v1, v2, v3; + /// + double rmin; + public: + /// + Ellipsoid (const Point<3> & aa, + const Vec<3> & av1, + const Vec<3> & av2, + const Vec<3> & av3); + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// + virtual double HesseNorm () const; + /// + virtual double MaxCurvature () const; + /// + virtual Point<3> GetSurfacePoint () const; + + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; + + private: + void CalcData(); + }; + + + + + + - virtual double LocH (const Point<3> & p, double x, - double c, double hmax) const; /// - virtual Point<3> GetSurfacePoint () const; + class Cone : public QuadraticSurface + { + /// + Point<3> a, b; + /// + double ra, rb, minr; + /// + Vec<3> vab, t0vec, t1vec; + /// + double vabl, t0, t1; + public: + /// + Cone (const Point<3> & aa, const Point<3> & ab, double ara, double arb); + /// + static Primitive * CreateDefault (); + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; + /// + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// + virtual double HesseNorm () const; -private: - void CalcData(); -}; + virtual double LocH (const Point<3> & p, double x, + double c, double hmax) const; + + /// + virtual Point<3> GetSurfacePoint () const; + + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; + + private: + void CalcData(); + }; @@ -353,84 +356,84 @@ private: -/// Torus -/// Lorenzo Codecasa (codecasa@elet.polimi.it) -/// April 27th, 2005 -/// -/// begin... -class Torus : public OneSurfacePrimitive -{ - /// center of the torus - Point<3> c; - /// vector normal to the symmetry plane of the torus - Vec<3> n; - /// Large radius of the torus - double R; - /// Small radius of the torus - double r; + /// Torus + /// Lorenzo Codecasa (codecasa@elet.polimi.it) + /// April 27th, 2005 + /// + /// begin... + class Torus : public OneSurfacePrimitive + { + /// center of the torus + Point<3> c; + /// vector normal to the symmetry plane of the torus + Vec<3> n; + /// Large radius of the torus + double R; + /// Small radius of the torus + double r; -public: - /// OK - Torus (const Point<3> & ac, const Vec<3> & an, double aR, double ar); - /// OK - const Point<3> & Center () const { return c; } - /// OK - const Vec<3> & NormalToPlane () const { return n; } - /// OK - double LargeRadius () const { return R; } - /// OK - double SmallRadius () const { return r; } - /// OK - virtual double CalcFunctionValue (const Point<3> & point) const; - /// OK - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - /// OK - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - /// OK - virtual double HesseNorm () const; - /// OK - virtual Point<3> GetSurfacePoint () const; - /// OK - virtual void GetPrimitiveData (const char *& classname, - Array & coeffs) const; - /// OK - virtual void SetPrimitiveData (Array & coeffs); - /// OK - static Primitive * CreateDefault (); - /// OK - virtual Primitive * Copy () const; - /// OK - virtual void Transform (Transformation<3> & trans); - /// OK - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - /// OK - /// virtual void DefineTangentialPlane (const Point<3> & ap1, - // const Point<3> & ap2); - /// OK - /// virtual void ToPlane (const Point<3> & p3d, - /// Point<2> & pplane, - /// double h, int & zone) const; - /// OK - /// virtual void FromPlane (const Point<2> & pplane, - // Point<3> & p, double h) const; - /// OK - /// virtual void Project (Point<3> & p) const; - /// OK - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// OK - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; - /// OK - virtual void Print (ostream & ist) const; - /// OK - virtual void Read (istream & ist); -}; - -/// ...end + public: + /// OK + Torus (const Point<3> & ac, const Vec<3> & an, double aR, double ar); + /// OK + const Point<3> & Center () const { return c; } + /// OK + const Vec<3> & NormalToPlane () const { return n; } + /// OK + double LargeRadius () const { return R; } + /// OK + double SmallRadius () const { return r; } + /// OK + virtual double CalcFunctionValue (const Point<3> & point) const; + /// OK + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + /// OK + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + /// OK + virtual double HesseNorm () const; + /// OK + virtual Point<3> GetSurfacePoint () const; + /// OK + virtual void GetPrimitiveData (const char *& classname, + Array & coeffs) const; + /// OK + virtual void SetPrimitiveData (Array & coeffs); + /// OK + static Primitive * CreateDefault (); + /// OK + virtual Primitive * Copy () const; + /// OK + virtual void Transform (Transformation<3> & trans); + /// OK + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + /// OK + /// virtual void DefineTangentialPlane (const Point<3> & ap1, + // const Point<3> & ap2); + /// OK + /// virtual void ToPlane (const Point<3> & p3d, + /// Point<2> & pplane, + /// double h, int & zone) const; + /// OK + /// virtual void FromPlane (const Point<2> & pplane, + // Point<3> & p, double h) const; + /// OK + /// virtual void Project (Point<3> & p) const; + /// OK + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + /// OK + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & bbox, + double facets) const; + /// OK + virtual void Print (ostream & ist) const; + /// OK + virtual void Read (istream & ist); + }; + /// ...end +} diff --git a/libsrc/csg/brick.hpp b/libsrc/csg/brick.hpp index 53265050..25b003e0 100644 --- a/libsrc/csg/brick.hpp +++ b/libsrc/csg/brick.hpp @@ -8,113 +8,119 @@ /* Date: 11. Mar. 98 */ /**************************************************************************/ -/* +namespace netgen +{ + + + /* brick geometry, has several surfaces -*/ + */ -class Parallelogram3d : public Surface -{ - Point<3> p1, p2, p3, p4; - Vec<3> v12, v13; - Vec<3> n; + class Parallelogram3d : public Surface + { + Point<3> p1, p2, p3, p4; + Vec<3> v12, v13; + Vec<3> n; -public: - Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3); - virtual ~Parallelogram3d (); + public: + Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3); + virtual ~Parallelogram3d (); - void SetPoints (Point<3> ap1, Point<3> ap2, Point<3> ap3); + void SetPoints (Point<3> ap1, Point<3> ap2, Point<3> ap3); - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - virtual double CalcFunctionValue (const Point<3> & point) const; - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - virtual double HesseNorm () const; + virtual double CalcFunctionValue (const Point<3> & point) const; + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + virtual double HesseNorm () const; - virtual Point<3> GetSurfacePoint () const; - virtual void Print (ostream & str) const; + virtual Point<3> GetSurfacePoint () const; + virtual void Print (ostream & str) const; - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const; + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & boundingbox, + double facets) const; -protected: - void CalcData(); -}; + protected: + void CalcData(); + }; -class Brick : public Primitive -{ - Point<3> p1, p2, p3, p4; - Vec<3> v12, v13, v14; - // Array faces; - Array faces; + class Brick : public Primitive + { + Point<3> p1, p2, p3, p4; + Vec<3> v12, v13, v14; + // Array faces; + Array faces; -public: - Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4); - virtual ~Brick (); - static Primitive * CreateDefault (); + public: + Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4); + virtual ~Brick (); + static Primitive * CreateDefault (); - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); + virtual Primitive * Copy () const; + virtual void Transform (Transformation<3> & trans); - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const; + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, - const Vec<3> & v, - const Vec<3> & v2, - const Vec<3> & m, - double eps) const; + virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, + const Vec<3> & v, + const Vec<3> & v2, + const Vec<3> & m, + double eps) const; - virtual int GetNSurfaces() const + virtual int GetNSurfaces() const { return 6; } - virtual Surface & GetSurface (int i) + virtual Surface & GetSurface (int i) { return *faces[i]; } - virtual const Surface & GetSurface (int i) const + virtual const Surface & GetSurface (int i) const { return *faces[i]; } - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); - virtual void Reduce (const BoxSphere<3> & box); - virtual void UnReduce (); + virtual void Reduce (const BoxSphere<3> & box); + virtual void UnReduce (); -protected: - void CalcData(); -}; + protected: + void CalcData(); + }; -class OrthoBrick : public Brick -{ -protected: - Point<3> pmin, pmax; -public: - OrthoBrick (const Point<3> & ap1, const Point<3> & ap2); + class OrthoBrick : public Brick + { + protected: + Point<3> pmin, pmax; + public: + OrthoBrick (const Point<3> & ap1, const Point<3> & ap2); - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual void Reduce (const BoxSphere<3> & box); -}; + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + virtual void Reduce (const BoxSphere<3> & box); + }; + +} #endif diff --git a/libsrc/csg/csg.hpp b/libsrc/csg/csg.hpp index 792219d1..8ce43e81 100644 --- a/libsrc/csg/csg.hpp +++ b/libsrc/csg/csg.hpp @@ -13,8 +13,10 @@ #include -namespace netgen -{ + + + + #include "surface.hpp" #include "solid.hpp" #include "identify.hpp" @@ -22,16 +24,8 @@ namespace netgen #include "csgeom.hpp" #include "csgparser.hpp" -#ifndef SMALLLIB -#define _INCLUDE_MORE -#endif -//#ifdef LINUX -#define _INCLUDE_MORE -//#endif -#ifdef _INCLUDE_MORE #include "triapprox.hpp" - #include "algprim.hpp" #include "brick.hpp" #include "spline3d.hpp" @@ -45,7 +39,6 @@ namespace netgen #include "specpoin.hpp" #include "edgeflw.hpp" #include "meshsurf.hpp" -#endif -} + #endif diff --git a/libsrc/csg/csgeom.hpp b/libsrc/csg/csgeom.hpp index c4744f6e..bb8676b1 100644 --- a/libsrc/csg/csgeom.hpp +++ b/libsrc/csg/csgeom.hpp @@ -7,312 +7,315 @@ /* Date: 27. Nov. 97 */ /**************************************************************************/ -/** - Constructive Solid Geometry -*/ - - -class TriangleApproximation; -class TATriangle; - - -/** - A top level object is an entity to be meshed. - I can be either a solid, or one surface patch of a solid. - */ -class TopLevelObject +namespace netgen { - Solid * solid; - Surface * surface; - double red, blue, green; - bool visible, transp; - double maxh; - string material; - int layer; - int bc; // for surface patches, only - string bcname; + /** + Constructive Solid Geometry + */ -public: - TopLevelObject (Solid * asolid, - Surface * asurface = NULL); - const Solid * GetSolid() const { return solid; } - Solid * GetSolid() { return solid; } + class TriangleApproximation; + class TATriangle; - const Surface * GetSurface () const { return surface; } - Surface * GetSurface () { return surface; } - void GetData (ostream & ost); - void SetData (istream & ist); - - void SetMaxH (double amaxh) { maxh = amaxh; } - double GetMaxH () const { return maxh; } - - void SetRGB (double ared, double agreen, double ablue) + /** + A top level object is an entity to be meshed. + I can be either a solid, or one surface patch of a solid. + */ + class TopLevelObject { - red = ared; - green = agreen; - blue = ablue; - } + Solid * solid; + Surface * surface; - double GetRed () const { return red; } - double GetGreen () const { return green; } - double GetBlue () const { return blue; } + double red, blue, green; + bool visible, transp; + double maxh; + string material; + int layer; + int bc; // for surface patches, only + string bcname; - void SetTransparent (bool atransp) - { transp = atransp; } - bool GetTransparent () const { return transp; } - - void SetVisible (bool avisible) - { visible = avisible; } - bool GetVisible () const { return visible; } - - const string GetMaterial () const { return material; } - void SetMaterial (const string & mat) { material = mat; } - - int GetLayer () const { return layer; } - void SetLayer (int alayer) { layer = alayer; } - - void SetBCProp (int abc) { bc = abc; } - int GetBCProp () const { return bc; } - - void SetBCName (string abc) { bcname = abc; } - const string GetBCName () const { return bcname; } -}; - - - - - -/** - CSGeometry has the whole geometric information - */ -class CSGeometry : public NetgenGeometry -{ -private: - /// all surfaces - SYMBOLTABLE surfaces; - -public: - /// primitive of surface - Array surf2prim; - -private: - Array delete_them; - - /// all named solids - SYMBOLTABLE solids; - - /// all 2d splinecurves - SYMBOLTABLE< SplineGeometry<2>* > splinecurves2d; - /// all 3d splinecurves - SYMBOLTABLE< SplineGeometry<3>* > splinecurves3d; - - /// all top level objects: solids and surfaces - Array toplevelobjects; - - /// additional points specified by user - Array > userpoints; - Array userpoints_ref_factor; - - mutable Array > identpoints; - - /// triangular approximation of top level objects - Array triapprox; - - /// increment, if geometry is changed - static int changeval; - - /// bounding box of geometry - Box<3> boundingbox; - - /// bounding box, if not set by input file - static Box<3> default_boundingbox; - - /// identic surfaces are stored by pair of indizes, val = inverse - INDEX_2_HASHTABLE identicsurfaces; - Array isidenticto; - /// identification of boundaries (periodic, thin domains, ...) - - double ideps; - - /// filename of inputfile - string filename; - -public: - CSGeometry (); - CSGeometry (const string & afilename); - ~CSGeometry (); - - void Clean (); - - void Save (ostream & ost); - void Load (istream & ist); - - void SaveSurfaces (ostream & out); - void LoadSurfaces (istream & in); - - int GetChangeVal() { return changeval; } - void Change() { changeval++; } - - void AddSurface (Surface * surf); - void AddSurface (char * name, Surface * surf); - void AddSurfaces (Primitive * prim); - - int GetNSurf () const { return surfaces.Size(); } - const Surface * GetSurface (const char * name) const; - const Surface * GetSurface (int i) const - { return surfaces[i]; } - - void SetSolid (const char * name, Solid * sol); - const Solid * GetSolid (const char * name) const; - const Solid * GetSolid (const string & name) const; - int GetNSolids () const { return solids.Size(); } - const Solid * GetSolid (int i) const { return solids[i]; } - const SYMBOLTABLE & GetSolids () const { return solids; } - - - void SetSplineCurve (const char * name, SplineGeometry<2> * spl); - void SetSplineCurve (const char * name, SplineGeometry<3> * spl); - const SplineGeometry<2> * GetSplineCurve2d (const string & name) const; - const SplineGeometry<3> * GetSplineCurve3d (const string & name) const; - - - void SetFlags (const char * solidname, const Flags & flags); - - - int GetNTopLevelObjects () const - { return toplevelobjects.Size(); } - int SetTopLevelObject (Solid * sol, Surface * surf = NULL); - void GetTopLevelObject (int nr, Solid *& sol, Surface *& surf) - { - sol = toplevelobjects[nr]->GetSolid(); - surf = toplevelobjects[nr]->GetSurface(); - } - void GetTopLevelObject (int nr, const Solid *& sol, const Surface *& surf) const - { - sol = toplevelobjects[nr]->GetSolid(); - surf = toplevelobjects[nr]->GetSurface(); - } - - TopLevelObject * GetTopLevelObject (const Solid * sol, const Surface * surf = NULL); - TopLevelObject * GetTopLevelObject (int nr) - { return toplevelobjects[nr]; } - const TopLevelObject * GetTopLevelObject (int nr) const - { return toplevelobjects[nr]; } - void RemoveTopLevelObject (Solid * sol, Surface * surf = NULL); - - - void AddUserPoint (const Point<3> & p, double ref_factor = 0) - { userpoints.Append (p); userpoints_ref_factor.Append (ref_factor); } - int GetNUserPoints () const - { return userpoints.Size(); } - const Point<3> & GetUserPoint (int nr) const - { return userpoints[nr]; } - double GetUserPointRefFactor (int nr) const - { return userpoints_ref_factor[nr]; } - - void AddIdentPoint (const Point<3> & p) const - { identpoints.Append(p);} - int GetNIdentPoints (void) const - { return identpoints.Size();} - const Point<3> & GetIdentPoint(int nr) const - { return identpoints[nr]; } - void DeleteIdentPoints(void) const - { identpoints.DeleteAll();} - - - // quick implementations: - Array singfaces; - Array singedges; - Array singpoints; - Array identifications; - - int GetNIdentifications (void) const { return identifications.Size(); } - void AddIdentification (Identification * ident); - - - /// - void CalcTriangleApproximation(const Box<3> & boundingbox, - double detail, double facets); - - /// - void FindIdenticSurfaces (double eps); - /// - void GetSurfaceIndices (const Solid * sol, - const BoxSphere<3> & box, - Array & locsurf) const; - /// - void GetIndependentSurfaceIndices (const Solid * sol, - const BoxSphere<3> & box, - Array & locsurf) const; - /// - void GetIndependentSurfaceIndices (const Solid * sol, - const Point<3> & p, Vec<3> & v, - Array & locsurf) const; - /// - void GetIndependentSurfaceIndices (Array & locsurf) const; - - /// - int GetSurfaceClassRepresentant (int si) const - { return isidenticto[si]; } - - /// - const TriangleApproximation * GetTriApprox (int msnr) - { - if (msnr < triapprox.Size()) - return triapprox[msnr]; - return 0; - } - - - void IterateAllSolids (SolidIterator & it, bool only_once = false); - - void RefineTriangleApprox (Solid * locsol, - int surfind, - const BoxSphere<3> & box, - double detail, - const TATriangle & tria, - TriangleApproximation & tams, - IndexSet & iset, - int level); - - const Box<3> & BoundingBox () const { return boundingbox; } - - void SetBoundingBox (const Box<3> & abox) - { - boundingbox = abox; - } - - - static void SetDefaultBoundingBox (const Box<3> & abox) - { - default_boundingbox = abox; - } - - double MaxSize () const; - - void SetIdEps(double eps){ideps = eps;} - double GetIdEps(void) const {return ideps;} - - class BCModification { public: - int si; - int tlonr; - int bcnr; - string * bcname; + TopLevelObject (Solid * asolid, + Surface * asurface = NULL); + + const Solid * GetSolid() const { return solid; } + Solid * GetSolid() { return solid; } + + const Surface * GetSurface () const { return surface; } + Surface * GetSurface () { return surface; } + + void GetData (ostream & ost); + void SetData (istream & ist); + + void SetMaxH (double amaxh) { maxh = amaxh; } + double GetMaxH () const { return maxh; } + + void SetRGB (double ared, double agreen, double ablue) + { + red = ared; + green = agreen; + blue = ablue; + } + + double GetRed () const { return red; } + double GetGreen () const { return green; } + double GetBlue () const { return blue; } + + void SetTransparent (bool atransp) + { transp = atransp; } + bool GetTransparent () const { return transp; } + + void SetVisible (bool avisible) + { visible = avisible; } + bool GetVisible () const { return visible; } + + const string GetMaterial () const { return material; } + void SetMaterial (const string & mat) { material = mat; } + + int GetLayer () const { return layer; } + void SetLayer (int alayer) { layer = alayer; } + + void SetBCProp (int abc) { bc = abc; } + int GetBCProp () const { return bc; } + + void SetBCName (string abc) { bcname = abc; } + const string GetBCName () const { return bcname; } }; - Array bcmodifications; - - virtual int GenerateMesh (Mesh*& mesh, - int perfstepsstart, int perfstepsend, char* optstring); - - virtual const Refinement & GetRefinement () const; -}; + + /** + CSGeometry has the whole geometric information + */ + class CSGeometry : public NetgenGeometry + { + private: + /// all surfaces + SYMBOLTABLE surfaces; + + public: + /// primitive of surface + Array surf2prim; + + private: + Array delete_them; + + /// all named solids + SYMBOLTABLE solids; + + /// all 2d splinecurves + SYMBOLTABLE< SplineGeometry<2>* > splinecurves2d; + /// all 3d splinecurves + SYMBOLTABLE< SplineGeometry<3>* > splinecurves3d; + + /// all top level objects: solids and surfaces + Array toplevelobjects; + + /// additional points specified by user + Array > userpoints; + Array userpoints_ref_factor; + + mutable Array > identpoints; + + /// triangular approximation of top level objects + Array triapprox; + + /// increment, if geometry is changed + static int changeval; + + /// bounding box of geometry + Box<3> boundingbox; + + /// bounding box, if not set by input file + static Box<3> default_boundingbox; + + /// identic surfaces are stored by pair of indizes, val = inverse + INDEX_2_HASHTABLE identicsurfaces; + Array isidenticto; + /// identification of boundaries (periodic, thin domains, ...) + + double ideps; + + /// filename of inputfile + string filename; + + public: + CSGeometry (); + CSGeometry (const string & afilename); + ~CSGeometry (); + + void Clean (); + + void Save (ostream & ost); + void Load (istream & ist); + + void SaveSurfaces (ostream & out); + void LoadSurfaces (istream & in); + + int GetChangeVal() { return changeval; } + void Change() { changeval++; } + + void AddSurface (Surface * surf); + void AddSurface (char * name, Surface * surf); + void AddSurfaces (Primitive * prim); + + int GetNSurf () const { return surfaces.Size(); } + const Surface * GetSurface (const char * name) const; + const Surface * GetSurface (int i) const + { return surfaces[i]; } + + void SetSolid (const char * name, Solid * sol); + const Solid * GetSolid (const char * name) const; + const Solid * GetSolid (const string & name) const; + int GetNSolids () const { return solids.Size(); } + const Solid * GetSolid (int i) const { return solids[i]; } + const SYMBOLTABLE & GetSolids () const { return solids; } + + + void SetSplineCurve (const char * name, SplineGeometry<2> * spl); + void SetSplineCurve (const char * name, SplineGeometry<3> * spl); + const SplineGeometry<2> * GetSplineCurve2d (const string & name) const; + const SplineGeometry<3> * GetSplineCurve3d (const string & name) const; + + + void SetFlags (const char * solidname, const Flags & flags); + + + int GetNTopLevelObjects () const + { return toplevelobjects.Size(); } + int SetTopLevelObject (Solid * sol, Surface * surf = NULL); + void GetTopLevelObject (int nr, Solid *& sol, Surface *& surf) + { + sol = toplevelobjects[nr]->GetSolid(); + surf = toplevelobjects[nr]->GetSurface(); + } + void GetTopLevelObject (int nr, const Solid *& sol, const Surface *& surf) const + { + sol = toplevelobjects[nr]->GetSolid(); + surf = toplevelobjects[nr]->GetSurface(); + } + + TopLevelObject * GetTopLevelObject (const Solid * sol, const Surface * surf = NULL); + TopLevelObject * GetTopLevelObject (int nr) + { return toplevelobjects[nr]; } + const TopLevelObject * GetTopLevelObject (int nr) const + { return toplevelobjects[nr]; } + void RemoveTopLevelObject (Solid * sol, Surface * surf = NULL); + + + void AddUserPoint (const Point<3> & p, double ref_factor = 0) + { userpoints.Append (p); userpoints_ref_factor.Append (ref_factor); } + int GetNUserPoints () const + { return userpoints.Size(); } + const Point<3> & GetUserPoint (int nr) const + { return userpoints[nr]; } + double GetUserPointRefFactor (int nr) const + { return userpoints_ref_factor[nr]; } + + void AddIdentPoint (const Point<3> & p) const + { identpoints.Append(p);} + int GetNIdentPoints (void) const + { return identpoints.Size();} + const Point<3> & GetIdentPoint(int nr) const + { return identpoints[nr]; } + void DeleteIdentPoints(void) const + { identpoints.DeleteAll();} + + + // quick implementations: + Array singfaces; + Array singedges; + Array singpoints; + Array identifications; + + int GetNIdentifications (void) const { return identifications.Size(); } + void AddIdentification (Identification * ident); + + + /// + void CalcTriangleApproximation(const Box<3> & boundingbox, + double detail, double facets); + + /// + void FindIdenticSurfaces (double eps); + /// + void GetSurfaceIndices (const Solid * sol, + const BoxSphere<3> & box, + Array & locsurf) const; + /// + void GetIndependentSurfaceIndices (const Solid * sol, + const BoxSphere<3> & box, + Array & locsurf) const; + /// + void GetIndependentSurfaceIndices (const Solid * sol, + const Point<3> & p, Vec<3> & v, + Array & locsurf) const; + /// + void GetIndependentSurfaceIndices (Array & locsurf) const; + + /// + int GetSurfaceClassRepresentant (int si) const + { return isidenticto[si]; } + + /// + const TriangleApproximation * GetTriApprox (int msnr) + { + if (msnr < triapprox.Size()) + return triapprox[msnr]; + return 0; + } + + + void IterateAllSolids (SolidIterator & it, bool only_once = false); + + void RefineTriangleApprox (Solid * locsol, + int surfind, + const BoxSphere<3> & box, + double detail, + const TATriangle & tria, + TriangleApproximation & tams, + IndexSet & iset, + int level); + + const Box<3> & BoundingBox () const { return boundingbox; } + + void SetBoundingBox (const Box<3> & abox) + { + boundingbox = abox; + } + + + static void SetDefaultBoundingBox (const Box<3> & abox) + { + default_boundingbox = abox; + } + + double MaxSize () const; + + void SetIdEps(double eps){ideps = eps;} + double GetIdEps(void) const {return ideps;} + + class BCModification { + public: + int si; + int tlonr; + int bcnr; + string * bcname; + }; + + Array bcmodifications; + + virtual int GenerateMesh (Mesh*& mesh, + int perfstepsstart, int perfstepsend, char* optstring); + + virtual const Refinement & GetRefinement () const; + }; + +} + #endif diff --git a/libsrc/csg/csgparser.hpp b/libsrc/csg/csgparser.hpp index 1f8dab1d..dfbd24ac 100644 --- a/libsrc/csg/csgparser.hpp +++ b/libsrc/csg/csgparser.hpp @@ -2,10 +2,9 @@ #define _CSGPARSER_HPP +namespace netgen +{ - -//namespace netgen -//{ enum TOKEN_TYPE { TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']', @@ -94,14 +93,9 @@ -//} +} +#endif - - - - - -#endif // _CSGPARSER_HPP diff --git a/libsrc/csg/curve2d.hpp b/libsrc/csg/curve2d.hpp index 917bd532..066a40ad 100644 --- a/libsrc/csg/curve2d.hpp +++ b/libsrc/csg/curve2d.hpp @@ -7,53 +7,61 @@ /* Date: 24. Jul. 96 */ /**************************************************************************/ -/* +namespace netgen +{ + + + /* 2D Curve repesentation -*/ + */ -/// -class Curve2d : public Manifold + /// + class Curve2d : public Manifold { public: - /// - virtual void Project (Point<2> & p) const = 0; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const = 0; + /// + virtual void Project (Point<2> & p) const = 0; + /// + virtual void NormalVector (const Point<2> & p, Vec<2> & n) const = 0; }; -/// -class CircleCurve2d : public Curve2d + /// + class CircleCurve2d : public Curve2d { - /// - Point<2> center; - /// - double rad; + /// + Point<2> center; + /// + double rad; public: - /// - CircleCurve2d (const Point<2> & acenter, double arad); - /// - virtual void Project (Point<2> & p) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; + /// + CircleCurve2d (const Point<2> & acenter, double arad); + /// + virtual void Project (Point<2> & p) const; + /// + virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; }; -/// -class QuadraticCurve2d : public Curve2d -{ /// - double cxx, cyy, cxy, cx, cy, c; -public: - /// - QuadraticCurve2d (); - /// - void Read (istream & ist); - /// - virtual void Project (Point<2> & p) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; -}; + class QuadraticCurve2d : public Curve2d + { + /// + double cxx, cyy, cxy, cx, cy, c; + public: + /// + QuadraticCurve2d (); + /// + void Read (istream & ist); + /// + virtual void Project (Point<2> & p) const; + /// + virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; + }; + + +} + #endif diff --git a/libsrc/csg/edgeflw.hpp b/libsrc/csg/edgeflw.hpp index fcd6d1da..4c2fc949 100644 --- a/libsrc/csg/edgeflw.hpp +++ b/libsrc/csg/edgeflw.hpp @@ -7,98 +7,104 @@ /* Date: 01. Okt. 95 */ /**************************************************************************/ -/* - - Edge - following function and - Projection to edge of implicitly given edge +namespace netgen +{ -*/ + + + /* + + Edge - following function and + Projection to edge of implicitly given edge + + */ -/** - Calculates edges. - The edges of a solid geometry are computed. Special - points have to be given. - */ -extern void CalcEdges (const CSGeometry & geometry, - const Array & specpoints, - double h, Mesh & mesh); + /** + Calculates edges. + The edges of a solid geometry are computed. Special + points have to be given. + */ + extern void CalcEdges (const CSGeometry & geometry, + const Array & specpoints, + double h, Mesh & mesh); -class EdgeCalculation -{ - const CSGeometry & geometry; - Array & specpoints; - Point3dTree * searchtree; - Point3dTree * meshpoint_tree; - int cntedge; + class EdgeCalculation + { + const CSGeometry & geometry; + Array & specpoints; + Point3dTree * searchtree; + Point3dTree * meshpoint_tree; + int cntedge; - double ideps; + double ideps; -public: - EdgeCalculation (const CSGeometry & ageometry, - Array & aspecpoints); + public: + EdgeCalculation (const CSGeometry & ageometry, + Array & aspecpoints); - ~EdgeCalculation(); + ~EdgeCalculation(); - void SetIdEps(const double epsin) {ideps = epsin;} + void SetIdEps(const double epsin) {ideps = epsin;} - void Calc(double h, Mesh & mesh); + void Calc(double h, Mesh & mesh); -private: - void CalcEdges1 (double h, Mesh & mesh); + private: + void CalcEdges1 (double h, Mesh & mesh); - void FollowEdge (int pi1, int & ep, int & pos, - // const Array & hsp, - const Array & hsp, - double h, const Mesh & mesh, - Array > & edgepoints, - Array & curvelength); + void FollowEdge (int pi1, int & ep, int & pos, + // const Array & hsp, + const Array & hsp, + double h, const Mesh & mesh, + Array > & edgepoints, + Array & curvelength); - void AnalyzeEdge (int s1, int s2, int s1_rep, int s2_rep, int pos, int layer, + void AnalyzeEdge (int s1, int s2, int s1_rep, int s2_rep, int pos, int layer, + const Array > & edgepoints, + Array & refedges, + Array & refedgesinv); + + void StoreEdge (const Array & refedges, + const Array & refedgesinv, const Array > & edgepoints, - Array & refedges, - Array & refedgesinv); + const Array & curvelength, + int layer, + Mesh & mesh); - void StoreEdge (const Array & refedges, - const Array & refedgesinv, - const Array > & edgepoints, - const Array & curvelength, - int layer, - Mesh & mesh); + void StoreShortEdge (const Array & refedges, + const Array & refedgesinv, + const Array > & edgepoints, + const Array & curvelength, + int layer, + Mesh & mesh); - void StoreShortEdge (const Array & refedges, - const Array & refedgesinv, - const Array > & edgepoints, - const Array & curvelength, - int layer, - Mesh & mesh); - - void CopyEdge (const Array & refedges, - const Array & refedgesinv, - int copyfromedge, - const Point<3> & fromstart, const Point<3> & fromend, - const Point<3> & tostart, const Point<3> & toend, - int copyedgeidentification, - int layer, - Mesh & mesh); + void CopyEdge (const Array & refedges, + const Array & refedgesinv, + int copyfromedge, + const Point<3> & fromstart, const Point<3> & fromend, + const Point<3> & tostart, const Point<3> & toend, + int copyedgeidentification, + int layer, + Mesh & mesh); - void SplitEqualOneSegEdges (Mesh & mesh); - void FindClosedSurfaces (double h, Mesh & mesh); + void SplitEqualOneSegEdges (Mesh & mesh); + void FindClosedSurfaces (double h, Mesh & mesh); -public: - bool point_on_edge_problem; + public: + bool point_on_edge_problem; -}; + }; +} #endif diff --git a/libsrc/csg/explicitcurve2d.hpp b/libsrc/csg/explicitcurve2d.hpp index 8b596f0f..559030b2 100644 --- a/libsrc/csg/explicitcurve2d.hpp +++ b/libsrc/csg/explicitcurve2d.hpp @@ -7,103 +7,107 @@ /* Date: 14. Oct. 96 */ /**************************************************************************/ -/* + +namespace netgen +{ + + /* Explicit 2D Curve repesentation -*/ + */ -/// -class ExplicitCurve2d : public Curve2d -{ -public: /// - ExplicitCurve2d (); + class ExplicitCurve2d : public Curve2d + { + public: + /// + ExplicitCurve2d (); - /// - virtual void Project (Point<2> & p) const; - /// - virtual double ProjectParam (const Point<2> & p) const = 0; - /// - virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const; - /// - virtual double MinParam () const = 0; - /// - virtual double MaxParam () const = 0; - /// - virtual Point<2> Eval (double t) const = 0; - /// - virtual Vec<2> EvalPrime (double t) const = 0; - /// - virtual Vec<2> Normal (double t) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; - /// - virtual Vec<2> EvalPrimePrime (double t) const = 0; + /// + virtual void Project (Point<2> & p) const; + /// + virtual double ProjectParam (const Point<2> & p) const = 0; + /// + virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const; + /// + virtual double MinParam () const = 0; + /// + virtual double MaxParam () const = 0; + /// + virtual Point<2> Eval (double t) const = 0; + /// + virtual Vec<2> EvalPrime (double t) const = 0; + /// + virtual Vec<2> Normal (double t) const; + /// + virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; + /// + virtual Vec<2> EvalPrimePrime (double t) const = 0; - /// - virtual double MaxCurvature () const; - /// - virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const; + /// + virtual double MaxCurvature () const; + /// + virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const; - /// - virtual Point<2> CurvCircle (double t) const; - /// - virtual void Print (ostream & /* str */) const { }; + /// + virtual Point<2> CurvCircle (double t) const; + /// + virtual void Print (ostream & /* str */) const { }; - /// - virtual int SectionUsed (double /* t */) const { return 1; } - /// - virtual void Reduce (const Point<2> & /* p */, double /* rad */) { }; - /// - virtual void UnReduce () { }; -}; + /// + virtual int SectionUsed (double /* t */) const { return 1; } + /// + virtual void Reduce (const Point<2> & /* p */, double /* rad */) { }; + /// + virtual void UnReduce () { }; + }; -/// -class BSplineCurve2d : public ExplicitCurve2d -{ /// - Array > points; - /// - Array intervallused; - /// - int redlevel; + class BSplineCurve2d : public ExplicitCurve2d + { + /// + Array > points; + /// + Array intervallused; + /// + int redlevel; -public: - /// - BSplineCurve2d (); - /// - void AddPoint (const Point<2> & apoint); + public: + /// + BSplineCurve2d (); + /// + void AddPoint (const Point<2> & apoint); - bool Inside (const Point<2> & p, double & dist) const; + bool Inside (const Point<2> & p, double & dist) const; - /// - virtual double ProjectParam (const Point<2> & p) const; - /// - virtual double MinParam () const { return 0; } - /// - virtual double MaxParam () const { return points.Size(); } - /// - virtual Point<2> Eval (double t) const; - /// - virtual Vec<2> EvalPrime (double t) const; - /// - virtual Vec<2> EvalPrimePrime (double t) const; - /// - virtual void Print (ostream & str) const; - - /// - virtual int SectionUsed (double t) const; - /// - virtual void Reduce (const Point<2> & p, double rad); - /// - virtual void UnReduce (); -}; + /// + virtual double ProjectParam (const Point<2> & p) const; + /// + virtual double MinParam () const { return 0; } + /// + virtual double MaxParam () const { return points.Size(); } + /// + virtual Point<2> Eval (double t) const; + /// + virtual Vec<2> EvalPrime (double t) const; + /// + virtual Vec<2> EvalPrimePrime (double t) const; + /// + virtual void Print (ostream & str) const; + /// + virtual int SectionUsed (double t) const; + /// + virtual void Reduce (const Point<2> & p, double rad); + /// + virtual void UnReduce (); + }; +} #endif diff --git a/libsrc/csg/extrusion.hpp b/libsrc/csg/extrusion.hpp index eb2d0a6a..189639bd 100644 --- a/libsrc/csg/extrusion.hpp +++ b/libsrc/csg/extrusion.hpp @@ -1,152 +1,155 @@ #ifndef _EXTRUSION_HPP #define _EXTRUSION_HPP - -class Extrusion; - -class ExtrusionFace : public Surface +namespace netgen { -private: - const SplineSeg<2> * profile; - const SplineGeometry<3> * path; - Vec<3> glob_z_direction; - bool deletable; + class Extrusion; + + class ExtrusionFace : public Surface + { + private: + const SplineSeg<2> * profile; + const SplineGeometry<3> * path; + Vec<3> glob_z_direction; + + bool deletable; - Array< const SplineSeg3<3> * > spline3_path; - Array< const LineSeg<3> * > line_path; + Array< const SplineSeg3<3> * > spline3_path; + Array< const LineSeg<3> * > line_path; - mutable Array < Vec<3> > x_dir, y_dir, z_dir, loc_z_dir; - mutable Array < Point<3> > p0; + mutable Array < Vec<3> > x_dir, y_dir, z_dir, loc_z_dir; + mutable Array < Point<3> > p0; - mutable Vec<3> profile_tangent; - mutable double profile_par; + mutable Vec<3> profile_tangent; + mutable double profile_par; - mutable Vector profile_spline_coeff; + mutable Vector profile_spline_coeff; - mutable int latest_seg; - mutable double latest_t; - mutable Point<2> latest_point2d; - mutable Point<3> latest_point3d; + mutable int latest_seg; + mutable double latest_t; + mutable Point<2> latest_point2d; + mutable Point<3> latest_point3d; -private: - void Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const; + private: + void Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const; - void Init(void); + void Init(void); -public: - double CalcProj(const Point<3> & point3d, Point<2> & point2d, - int seg) const; - void CalcProj(const Point<3> & point3d, Point<2> & point2d, - int & seg, double & t) const; + public: + double CalcProj(const Point<3> & point3d, Point<2> & point2d, + int seg) const; + void CalcProj(const Point<3> & point3d, Point<2> & point2d, + int & seg, double & t) const; -public: - ExtrusionFace(const SplineSeg<2> * profile_in, - const SplineGeometry<3> * path_in, - const Vec<3> & z_direction); + public: + ExtrusionFace(const SplineSeg<2> * profile_in, + const SplineGeometry<3> * path_in, + const Vec<3> & z_direction); - ExtrusionFace(const Array & raw_data); + ExtrusionFace(const Array & raw_data); - ~ExtrusionFace(); + ~ExtrusionFace(); - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - virtual double CalcFunctionValue (const Point<3> & point) const; - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - virtual double HesseNorm () const; + virtual double CalcFunctionValue (const Point<3> & point) const; + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + virtual double HesseNorm () const; - virtual double MaxCurvature () const; - //virtual double MaxCurvatureLoc (const Point<3> & /* c */ , - // double /* rad */) const; + virtual double MaxCurvature () const; + //virtual double MaxCurvatureLoc (const Point<3> & /* c */ , + // double /* rad */) const; - virtual void Project (Point<3> & p) const; + virtual void Project (Point<3> & p) const; - virtual Point<3> GetSurfacePoint () const; - virtual void Print (ostream & str) const; + virtual Point<3> GetSurfacePoint () const; + virtual void Print (ostream & str) const; - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const; + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & boundingbox, + double facets) const; - const SplineGeometry<3> & GetPath(void) const {return *path;} - const SplineSeg<2> & GetProfile(void) const {return *profile;} + const SplineGeometry<3> & GetPath(void) const {return *path;} + const SplineSeg<2> & GetProfile(void) const {return *profile;} - bool BoxIntersectsFace(const Box<3> & box) const; + bool BoxIntersectsFace(const Box<3> & box) const; - void LineIntersections ( const Point<3> & p, - const Vec<3> & v, - const double eps, - int & before, - int & after, - bool & intersecting ) const; + void LineIntersections ( const Point<3> & p, + const Vec<3> & v, + const double eps, + int & before, + int & after, + bool & intersecting ) const; - INSOLID_TYPE VecInFace ( const Point<3> & p, - const Vec<3> & v, - const double eps ) const; + INSOLID_TYPE VecInFace ( const Point<3> & p, + const Vec<3> & v, + const double eps ) const; - const Vec<3> & GetYDir ( void ) const {return y_dir[latest_seg];} - const Vec<3> & GetProfileTangent (void) const {return profile_tangent;} - double GetProfilePar(void) const {return profile_par;} + const Vec<3> & GetYDir ( void ) const {return y_dir[latest_seg];} + const Vec<3> & GetProfileTangent (void) const {return profile_tangent;} + double GetProfilePar(void) const {return profile_par;} - void GetRawData(Array & data) const; + void GetRawData(Array & data) const; - void CalcLocalCoordinates (int seg, double t, - Vec<3> & ex, Vec<3> & ey, Vec<3> & ez) const; + void CalcLocalCoordinates (int seg, double t, + Vec<3> & ex, Vec<3> & ey, Vec<3> & ez) const; - void CalcLocalCoordinatesDeriv (int seg, double t, - Vec<3> & ex, Vec<3> & ey, Vec<3> & ez, - Vec<3> & dex, Vec<3> & dey, Vec<3> & dez) const; + void CalcLocalCoordinatesDeriv (int seg, double t, + Vec<3> & ex, Vec<3> & ey, Vec<3> & ez, + Vec<3> & dex, Vec<3> & dey, Vec<3> & dez) const; -}; + }; -class Extrusion : public Primitive -{ -private: - const SplineGeometry<3> & path; - const SplineGeometry<2> & profile; + class Extrusion : public Primitive + { + private: + const SplineGeometry<3> & path; + const SplineGeometry<2> & profile; - const Vec<3> & z_direction; + const Vec<3> & z_direction; - Array faces; + Array faces; - mutable int latestfacenum; + mutable int latestfacenum; -public: - Extrusion(const SplineGeometry<3> & path_in, - const SplineGeometry<2> & profile_in, - const Vec<3> & z_dir); - ~Extrusion(); - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + public: + Extrusion(const SplineGeometry<3> & path_in, + const SplineGeometry<2> & profile_in, + const Vec<3> & z_dir); + ~Extrusion(); + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const; + INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps, + Array * const facenums) const; + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, double eps) const; - INSOLID_TYPE PointInSolid (const Point<3> & p, - double eps, - Array * const facenums) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual int GetNSurfaces() const; - virtual Surface & GetSurface (int i = 0); - virtual const Surface & GetSurface (int i = 0) const; + virtual int GetNSurfaces() const; + virtual Surface & GetSurface (int i = 0); + virtual const Surface & GetSurface (int i = 0) const; - virtual void Reduce (const BoxSphere<3> & box); - virtual void UnReduce (); + virtual void Reduce (const BoxSphere<3> & box); + virtual void UnReduce (); -}; + }; +} #endif //_EXTRUSION_HPP diff --git a/libsrc/csg/gencyl.hpp b/libsrc/csg/gencyl.hpp index 424c867a..e5db270d 100644 --- a/libsrc/csg/gencyl.hpp +++ b/libsrc/csg/gencyl.hpp @@ -7,58 +7,64 @@ /* Date: 14. Oct. 96 */ /**************************************************************************/ -/* +namespace netgen +{ + + + /* Generalized Cylinder -*/ + */ -/// -class GeneralizedCylinder : public Surface -{ /// - ExplicitCurve2d & crosssection; - /// - Point<3> planep; - /// - Vec<3> planee1, planee2, planee3; - - /// Vec<3> ex, ey, ez; - Vec2d e2x, e2y; + class GeneralizedCylinder : public Surface + { /// - Point<3> cp; + ExplicitCurve2d & crosssection; + /// + Point<3> planep; + /// + Vec<3> planee1, planee2, planee3; -public: - /// - GeneralizedCylinder (ExplicitCurve2d & acrosssection, - Point<3> ap, Vec<3> ae1, Vec<3> ae2); + /// Vec<3> ex, ey, ez; + Vec2d e2x, e2y; + /// + Point<3> cp; - /// - virtual void Project (Point<3> & p) const; + public: + /// + GeneralizedCylinder (ExplicitCurve2d & acrosssection, + Point<3> ap, Vec<3> ae1, Vec<3> ae2); - /// - virtual int BoxInSolid (const BoxSphere<3> & box) const; - /// 0 .. no, 1 .. yes, 2 .. maybe + /// + virtual void Project (Point<3> & p) const; - virtual double CalcFunctionValue (const Point<3> & point) const; - /// - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - /// - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - /// - virtual double HesseNorm () const; - /// - virtual double MaxCurvatureLoc (const Point<3> & c, double rad) const; - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void Print (ostream & str) const; + /// + virtual int BoxInSolid (const BoxSphere<3> & box) const; + /// 0 .. no, 1 .. yes, 2 .. maybe - /// - virtual void Reduce (const BoxSphere<3> & box); - /// - virtual void UnReduce (); -}; + virtual double CalcFunctionValue (const Point<3> & point) const; + /// + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + /// + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + /// + virtual double HesseNorm () const; + /// + virtual double MaxCurvatureLoc (const Point<3> & c, double rad) const; + /// + virtual Point<3> GetSurfacePoint () const; + /// + virtual void Print (ostream & str) const; + + /// + virtual void Reduce (const BoxSphere<3> & box); + /// + virtual void UnReduce (); + }; + +} #endif diff --git a/libsrc/csg/identify.hpp b/libsrc/csg/identify.hpp index f53a9bf0..cf9149fe 100644 --- a/libsrc/csg/identify.hpp +++ b/libsrc/csg/identify.hpp @@ -6,199 +6,205 @@ /* File: identify.hh */ /* Author: Joachim Schoeberl */ /* Date: 1. Aug. 99 */ - /**************************************************************************/ - -/** - Identify surfaces for periodic b.c. or - thin domains -*/ +/**************************************************************************/ -class SpecialPoint; -class Identification +namespace netgen { -protected: - const CSGeometry & geom; - // identified faces, index sorted - INDEX_2_HASHTABLE identfaces; - int nr; -public: - Identification (int anr, const CSGeometry & ageom); - virtual ~Identification (); - virtual void Print (ostream & ost) const = 0; - virtual void GetData (ostream & ost) const = 0; + /** + Identify surfaces for periodic b.c. or + thin domains + */ - /// obsolete - // virtual void IdentifySpecialPoints (Array & points); - /// can identify both special points (fixed direction) - /// (identified points, same tangent) - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, - const TABLE & specpoint2solid, - const TABLE & specpoint2surface) const; - /// - virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; - /// is it possible to identify sp1 with some other ? - virtual int IdentifyableCandidate (const SpecialPoint & sp1) const; + class SpecialPoint; + class Identification + { + protected: + const CSGeometry & geom; + // identified faces, index sorted + INDEX_2_HASHTABLE identfaces; + int nr; + + public: + Identification (int anr, const CSGeometry & ageom); + virtual ~Identification (); + virtual void Print (ostream & ost) const = 0; + virtual void GetData (ostream & ost) const = 0; + + /// obsolete + // virtual void IdentifySpecialPoints (Array & points); + + /// can identify both special points (fixed direction) + /// (identified points, same tangent) + virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, + const TABLE & specpoint2solid, + const TABLE & specpoint2surface) const; + /// + virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; + /// is it possible to identify sp1 with some other ? + virtual int IdentifyableCandidate (const SpecialPoint & sp1) const; - /// are points (if connected) by a short edge (direction anyhow) ? - virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; + /// are points (if connected) by a short edge (direction anyhow) ? + virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; - /// add entries in mesh identification tables - virtual void IdentifyPoints (class Mesh & mesh); + /// add entries in mesh identification tables + virtual void IdentifyPoints (class Mesh & mesh); - /// add entries to identified faces (based on segment infos) - virtual void IdentifyFaces (class Mesh & mesh); + /// add entries to identified faces (based on segment infos) + virtual void IdentifyFaces (class Mesh & mesh); - /// get point on other surface, add entry in mesh identifications - virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); + /// get point on other surface, add entry in mesh identifications + virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); - /// copy surfaces, or fill rectangles - virtual void BuildSurfaceElements (Array & segs, - class Mesh & mesh, - const Surface * surf); + /// copy surfaces, or fill rectangles + virtual void BuildSurfaceElements (Array & segs, + class Mesh & mesh, + const Surface * surf); - /// insert volume elements in thin layers - virtual void BuildVolumeElements (Array & surfels, - class Mesh & mesh); + /// insert volume elements in thin layers + virtual void BuildVolumeElements (Array & surfels, + class Mesh & mesh); - /// get list of identified faces - virtual void GetIdentifiedFaces (Array & idfaces) const; + /// get list of identified faces + virtual void GetIdentifiedFaces (Array & idfaces) const; - friend ostream & operator<< (ostream & ost, Identification & ident); -}; + friend ostream & operator<< (ostream & ost, Identification & ident); + }; -class PeriodicIdentification : public Identification -{ - const Surface * s1; - const Surface * s2; -public: - PeriodicIdentification (int anr, - const CSGeometry & ageom, - const Surface * as1, - const Surface * as2); - virtual ~PeriodicIdentification (); - virtual void Print (ostream & ost) const; - virtual void GetData (ostream & ost) const; - - - // virtual void IdentifySpecialPoints (Array & points); - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, - const TABLE & specpoint2solid, - const TABLE & specpoint2surface) const; - - 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 void BuildSurfaceElements (Array & segs, - class Mesh & mesh, - const Surface * surf); -}; - - -/// -class TopLevelObject; -class CloseSurfaceIdentification : public Identification -{ - const Surface * s1; - const Surface * s2; - const TopLevelObject * domain; - /// - int dom_nr; - /// number of refinement levels (in Z-refinement) - int ref_levels; - /// number of refinement levels for layer next to s1 (in Z-refinement) - int ref_levels_s1; - /// number of refinement levels for layer next to s2 (in Z-refinement) - int ref_levels_s2; - /// - double eps_n; - Array slices; - /// used only for domain-local identification: - Array domain_surfaces; - /// - bool dom_surf_valid; - - /// - Vec<3> direction; - /// - bool usedirection; -public: - CloseSurfaceIdentification (int anr, - const CSGeometry & ageom, - const Surface * as1, - const Surface * as2, - const TopLevelObject * adomain, - const Flags & flags); - virtual ~CloseSurfaceIdentification (); - - virtual void Print (ostream & ost) const; - virtual void GetData (ostream & ost) const; - - - // virtual void IdentifySpecialPoints (Array & points); - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, - const TABLE & specpoint2solid, - const TABLE & specpoint2surface) const; - virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; - virtual int IdentifyableCandidate (const SpecialPoint & sp1) const; - virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; - virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); - const Array & GetSlices () const { return slices; } - virtual void IdentifyPoints (class Mesh & mesh); - virtual void IdentifyFaces (class Mesh & mesh); - virtual void BuildSurfaceElements (Array & segs, - class Mesh & mesh, - const Surface * surf); - void BuildSurfaceElements2 (Array & segs, - class Mesh & mesh, - const Surface * surf); - - virtual void BuildVolumeElements (Array & surfels, - class Mesh & mesh); - - int RefLevels () const { return ref_levels; } - int RefLevels1 () const { return ref_levels_s1; } - int RefLevels2 () const { return ref_levels_s2; } - - bool IsSkewIdentification(void) const {return usedirection;} - const Vec<3> & GetDirection(void) const {return direction;} - - const Surface & GetSurface1(void) const - { return *s1;} - const Surface & GetSurface2(void) const - { return *s2;} -}; - - -class CloseEdgesIdentification : public Identification -{ - const Surface * facet; - const Surface * s1; - const Surface * s2; -public: - CloseEdgesIdentification (int anr, + class PeriodicIdentification : public Identification + { + const Surface * s1; + const Surface * s2; + public: + PeriodicIdentification (int anr, const CSGeometry & ageom, - const Surface * afacet, const Surface * as1, const Surface * as2); - virtual ~CloseEdgesIdentification (); - virtual void Print (ostream & ost) const; - virtual void GetData (ostream & ost) const; - - // virtual void IdentifySpecialPoints (Array & points); - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, - const TABLE & specpoint2solid, - const TABLE & specpoint2surface) const; + virtual ~PeriodicIdentification (); + virtual void Print (ostream & ost) const; + virtual void GetData (ostream & ost) const; - virtual void IdentifyPoints (class Mesh & mesh); - virtual void BuildSurfaceElements (Array & segs, - class Mesh & mesh, - const Surface * surf); -}; + // virtual void IdentifySpecialPoints (Array & points); + virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, + const TABLE & specpoint2solid, + const TABLE & specpoint2surface) const; + + 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 void BuildSurfaceElements (Array & segs, + class Mesh & mesh, + const Surface * surf); + }; + + + /// + class TopLevelObject; + class CloseSurfaceIdentification : public Identification + { + const Surface * s1; + const Surface * s2; + const TopLevelObject * domain; + /// + int dom_nr; + /// number of refinement levels (in Z-refinement) + int ref_levels; + /// number of refinement levels for layer next to s1 (in Z-refinement) + int ref_levels_s1; + /// number of refinement levels for layer next to s2 (in Z-refinement) + int ref_levels_s2; + /// + double eps_n; + Array slices; + /// used only for domain-local identification: + Array domain_surfaces; + /// + bool dom_surf_valid; + + /// + Vec<3> direction; + /// + bool usedirection; + public: + CloseSurfaceIdentification (int anr, + const CSGeometry & ageom, + const Surface * as1, + const Surface * as2, + const TopLevelObject * adomain, + const Flags & flags); + virtual ~CloseSurfaceIdentification (); + + virtual void Print (ostream & ost) const; + virtual void GetData (ostream & ost) const; + + + // virtual void IdentifySpecialPoints (Array & points); + virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, + const TABLE & specpoint2solid, + const TABLE & specpoint2surface) const; + virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; + virtual int IdentifyableCandidate (const SpecialPoint & sp1) const; + virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; + virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); + const Array & GetSlices () const { return slices; } + virtual void IdentifyPoints (class Mesh & mesh); + virtual void IdentifyFaces (class Mesh & mesh); + virtual void BuildSurfaceElements (Array & segs, + class Mesh & mesh, + const Surface * surf); + void BuildSurfaceElements2 (Array & segs, + class Mesh & mesh, + const Surface * surf); + + virtual void BuildVolumeElements (Array & surfels, + class Mesh & mesh); + + int RefLevels () const { return ref_levels; } + int RefLevels1 () const { return ref_levels_s1; } + int RefLevels2 () const { return ref_levels_s2; } + + bool IsSkewIdentification(void) const {return usedirection;} + const Vec<3> & GetDirection(void) const {return direction;} + + const Surface & GetSurface1(void) const + { return *s1;} + const Surface & GetSurface2(void) const + { return *s2;} + }; + + + class CloseEdgesIdentification : public Identification + { + const Surface * facet; + const Surface * s1; + const Surface * s2; + public: + CloseEdgesIdentification (int anr, + const CSGeometry & ageom, + const Surface * afacet, + const Surface * as1, + const Surface * as2); + virtual ~CloseEdgesIdentification (); + virtual void Print (ostream & ost) const; + virtual void GetData (ostream & ost) const; + + // virtual void IdentifySpecialPoints (Array & points); + virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, + const TABLE & specpoint2solid, + const TABLE & specpoint2surface) const; + + + virtual void IdentifyPoints (class Mesh & mesh); + virtual void BuildSurfaceElements (Array & segs, + class Mesh & mesh, + const Surface * surf); + }; + +} #endif diff --git a/libsrc/csg/manifold.hpp b/libsrc/csg/manifold.hpp index 5deb7236..cc60e955 100644 --- a/libsrc/csg/manifold.hpp +++ b/libsrc/csg/manifold.hpp @@ -7,16 +7,23 @@ /* Date: 7. Aug. 96 */ /**************************************************************************/ -/** - Basis class for manifolds in 2d and 3d -*/ -class Manifold +namespace netgen { -public: - /// - Manifold (); - /// - virtual ~Manifold (); -}; + + + /** + Basis class for manifolds in 2d and 3d + */ + class Manifold + { + public: + /// + Manifold (); + /// + virtual ~Manifold (); + }; + +} + #endif diff --git a/libsrc/csg/meshsurf.hpp b/libsrc/csg/meshsurf.hpp index 3e3e3241..9ffd552e 100644 --- a/libsrc/csg/meshsurf.hpp +++ b/libsrc/csg/meshsurf.hpp @@ -1,46 +1,49 @@ #ifndef FILE_MESHSURF #define FILE_MESHSURF -/// -class Meshing2Surfaces : public Meshing2 +namespace netgen { - /// - const Surface & surface; - -public: - /// - // Meshing2Surfaces (const Surface & asurf); - /// - Meshing2Surfaces (const Surface & asurf, const Box<3> & aboundingbox); -protected: /// - virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, - const PointGeomInfo * geominfo1, - const PointGeomInfo * geominfo2); - /// - virtual void TransformToPlain (const Point3d & locpoint, - const MultiPointGeomInfo & geominfo, - Point2d & plainpoint, - double h, int & zone); - /// - virtual int TransformFromPlain (Point2d & plainpoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h); - /// - virtual double CalcLocalH (const Point3d & p, double gh) const; -}; - - - -/// -class MeshOptimize2dSurfaces : public MeshOptimize2d + class Meshing2Surfaces : public Meshing2 { - /// - const CSGeometry & geometry; + /// + const Surface & surface; + + public: + /// + // Meshing2Surfaces (const Surface & asurf); + /// + Meshing2Surfaces (const Surface & asurf, const Box<3> & aboundingbox); -public: + protected: + /// + virtual void DefineTransformation (const Point3d & p1, const Point3d & p2, + const PointGeomInfo * geominfo1, + const PointGeomInfo * geominfo2); + /// + virtual void TransformToPlain (const Point3d & locpoint, + const MultiPointGeomInfo & geominfo, + Point2d & plainpoint, + double h, int & zone); + /// + virtual int TransformFromPlain (Point2d & plainpoint, + Point3d & locpoint, + PointGeomInfo & gi, + double h); + /// + virtual double CalcLocalH (const Point3d & p, double gh) const; + }; + + + + /// + class MeshOptimize2dSurfaces : public MeshOptimize2d + { + /// + const CSGeometry & geometry; + + public: /// MeshOptimize2dSurfaces (const CSGeometry & ageometry); @@ -50,43 +53,44 @@ public: virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const; /// virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const; -}; + }; -class RefinementSurfaces : public Refinement -{ - const CSGeometry & geometry; + class RefinementSurfaces : public Refinement + { + const CSGeometry & geometry; -public: - RefinementSurfaces (const CSGeometry & ageometry); - virtual ~RefinementSurfaces (); + public: + RefinementSurfaces (const CSGeometry & ageometry); + virtual ~RefinementSurfaces (); - virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point<3> & newp, PointGeomInfo & newgi); + virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, + int surfi, + const PointGeomInfo & gi1, + const PointGeomInfo & gi2, + Point<3> & newp, PointGeomInfo & newgi); - virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point<3> & newp, EdgePointGeomInfo & newgi); + virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, + int surfi1, int surfi2, + const EdgePointGeomInfo & ap1, + const EdgePointGeomInfo & ap2, + Point<3> & newp, EdgePointGeomInfo & newgi); - virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, - const EdgePointGeomInfo & ap1) const; + virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, + const EdgePointGeomInfo & ap1) const; - virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, - const PointGeomInfo & gi) const; + virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, + const PointGeomInfo & gi) const; - virtual void ProjectToSurface (Point<3> & p, int surfi); + virtual void ProjectToSurface (Point<3> & p, int surfi); - virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const; + virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, const EdgePointGeomInfo & egi) const; -}; + }; +} #endif diff --git a/libsrc/csg/polyhedra.hpp b/libsrc/csg/polyhedra.hpp index 4b95e9ea..0a785042 100644 --- a/libsrc/csg/polyhedra.hpp +++ b/libsrc/csg/polyhedra.hpp @@ -8,92 +8,97 @@ /* Date: 19. Mar. 2000 */ /**************************************************************************/ -/* +namespace netgen +{ + + /* Polyhedral primitive -*/ + */ + + class Polyhedra : public Primitive + { + class Face { + public: + int pnums[3]; + int planenr; + + int inputnr; + + Box<3> bbox; + // Point<3> center; + Vec<3> v1, v2; // edges + Vec<3> w1, w2; // pseudo-inverse + Vec<3> n; // normal to face + Vec<3> nn; // normed normal + + Face () { ; } + Face (int pi1, int pi2, int pi3, + const Array > & points, + int ainputnr); + }; + + Array > points; + Array faces; + Array planes; + Box<3> poly_bbox; + + double eps_base1; -class Polyhedra : public Primitive -{ - class Face { public: - int pnums[3]; - int planenr; + Polyhedra (); + virtual ~Polyhedra (); + static Primitive * CreateDefault (); - int inputnr; + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const; + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, + double eps) const; - Box<3> bbox; - // Point<3> center; - Vec<3> v1, v2; // edges - Vec<3> w1, w2; // pseudo-inverse - Vec<3> n; // normal to face - Vec<3> nn; // normed normal + // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - Face () { ; } - Face (int pi1, int pi2, int pi3, - const Array > & points, - int ainputnr); + virtual void GetTangentialSurfaceIndices (const Point<3> & p, + Array & surfind, double eps) const; + + + virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, + Array & surfind, double eps) const; + + virtual void CalcSpecialPoints (Array > & pts) const; + virtual void AnalyzeSpecialPoint (const Point<3> & pt, + Array > & specpts) const; + virtual Vec<3> SpecialPointTangentialVector (const Point<3> & p, int s1, int s2) const; + + virtual int GetNSurfaces() const + { return planes.Size(); } + virtual Surface & GetSurface (int i) + { return *planes[i]; } + virtual const Surface & GetSurface (int i) const + { return *planes[i]; } + + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + + virtual void Reduce (const BoxSphere<3> & box); + virtual void UnReduce (); + + int AddPoint (const Point<3> & p); + int AddFace (int pi1, int pi2, int pi3, int inputnum); + + void GetPolySurfs(Array < Array * > & polysurfs); + + protected: + int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const; + // void CalcData(); }; - Array > points; - Array faces; - Array planes; - Box<3> poly_bbox; - - double eps_base1; - -public: - Polyhedra (); - virtual ~Polyhedra (); - static Primitive * CreateDefault (); - - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, - double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - - // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; - - virtual void GetTangentialSurfaceIndices (const Point<3> & p, - Array & surfind, double eps) const; - - - virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - Array & surfind, double eps) const; - - virtual void CalcSpecialPoints (Array > & pts) const; - virtual void AnalyzeSpecialPoint (const Point<3> & pt, - Array > & specpts) const; - virtual Vec<3> SpecialPointTangentialVector (const Point<3> & p, int s1, int s2) const; - - virtual int GetNSurfaces() const - { return planes.Size(); } - virtual Surface & GetSurface (int i) - { return *planes[i]; } - virtual const Surface & GetSurface (int i) const - { return *planes[i]; } - - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - - virtual void Reduce (const BoxSphere<3> & box); - virtual void UnReduce (); - - int AddPoint (const Point<3> & p); - int AddFace (int pi1, int pi2, int pi3, int inputnum); - - void GetPolySurfs(Array < Array * > & polysurfs); - -protected: - int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const; - // void CalcData(); -}; +} #endif diff --git a/libsrc/csg/revolution.hpp b/libsrc/csg/revolution.hpp index 4ab45906..f1c719fe 100644 --- a/libsrc/csg/revolution.hpp +++ b/libsrc/csg/revolution.hpp @@ -1,149 +1,153 @@ #ifndef _REVOLUTION_HPP #define _REVOLUTION_HPP -class Revolution; - -class RevolutionFace : public Surface +namespace netgen { -private: - bool isfirst, islast; - const SplineSeg<2> * spline; - bool deletable; - Point<3> p0; - Vec<3> v_axis; + class Revolution; - int id; + class RevolutionFace : public Surface + { + private: + bool isfirst, islast; + const SplineSeg<2> * spline; + bool deletable; + + Point<3> p0; + Vec<3> v_axis; + + int id; - mutable Vector spline_coefficient; + mutable Vector spline_coefficient; - Array < Vec<2>* > checklines_vec; - Array < Point<2>* > checklines_start; - Array < Vec<2>* > checklines_normal; + Array < Vec<2>* > checklines_vec; + Array < Point<2>* > checklines_start; + Array < Vec<2>* > checklines_normal; -private: - void Init (void); + private: + void Init (void); -public: - void CalcProj(const Point<3> & point3d, Point<2> & point2d) const; - void CalcProj(const Point<3> & point3d, Point<2> & point2d, - const Vec<3> & vector3d, Vec<2> & vector2d) const; - void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const; + public: + void CalcProj(const Point<3> & point3d, Point<2> & point2d) const; + void CalcProj(const Point<3> & point3d, Point<2> & point2d, + const Vec<3> & vector3d, Vec<2> & vector2d) const; + void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const; -public: - RevolutionFace(const SplineSeg<2> & spline_in, - const Point<3> & p, - const Vec<3> & vec, - bool first = false, - bool last = false, - const int id_in = 0); + public: + RevolutionFace(const SplineSeg<2> & spline_in, + const Point<3> & p, + const Vec<3> & vec, + bool first = false, + bool last = false, + const int id_in = 0); - RevolutionFace(const Array & raw_data); + RevolutionFace(const Array & raw_data); - ~RevolutionFace(); + ~RevolutionFace(); - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; + virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - virtual double CalcFunctionValue (const Point<3> & point) const; - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - virtual double HesseNorm () const; + virtual double CalcFunctionValue (const Point<3> & point) const; + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + virtual double HesseNorm () const; - virtual double MaxCurvature () const; - //virtual double MaxCurvatureLoc (const Point<3> & /* c */ , - // double /* rad */) const; + virtual double MaxCurvature () const; + //virtual double MaxCurvatureLoc (const Point<3> & /* c */ , + // double /* rad */) const; - virtual void Project (Point<3> & p) const; + virtual void Project (Point<3> & p) const; - virtual Point<3> GetSurfacePoint () const; - virtual void Print (ostream & str) const; + virtual Point<3> GetSurfacePoint () const; + virtual void Print (ostream & str) const; - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const; + virtual void GetTriangleApproximation (TriangleApproximation & tas, + const Box<3> & boundingbox, + double facets) const; + + bool BoxIntersectsFace (const Box<3> & box) const; + /* + bool BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const; + bool BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const; + */ + + const SplineSeg<2> & GetSpline(void) const {return *spline;} + + INSOLID_TYPE PointInFace (const Point<3> & p, const double eps) const; + + void GetRawData(Array & data) const; + + }; + + - bool BoxIntersectsFace (const Box<3> & box) const; /* - bool BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const; - bool BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const; - */ - - const SplineSeg<2> & GetSpline(void) const {return *spline;} - - INSOLID_TYPE PointInFace (const Point<3> & p, const double eps) const; - - void GetRawData(Array & data) const; - -}; - - - -/* Primitive of revolution -*/ - - -class Revolution : public Primitive -{ -private: - Point<3> p0,p1; - Vec<3> v_axis; - const SplineGeometry<2> & splinecurve; - const int nsplines; - - // 1 ... torus-like - // 2 ... sphere-like - int type; - - - Array faces; - - mutable int intersecting_face; - -public: - Revolution(const Point<3> & p0_in, - const Point<3> & p1_in, - const SplineGeometry<2> & spline_in); - - ~Revolution(); - - - /* - Check, whether box intersects solid defined by surface. - - return values: - 0 .. box outside solid \\ - 1 .. box in solid \\ - 2 .. can't decide (allowed, iff box is close to solid) */ - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, - double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + + class Revolution : public Primitive + { + private: + Point<3> p0,p1; + Vec<3> v_axis; + const SplineGeometry<2> & splinecurve; + const int nsplines; + + // 1 ... torus-like + // 2 ... sphere-like + int type; + + + Array faces; + + mutable int intersecting_face; + + public: + Revolution(const Point<3> & p0_in, + const Point<3> & p1_in, + const SplineGeometry<2> & spline_in); + + ~Revolution(); + + + /* + Check, whether box intersects solid defined by surface. + + return values: + 0 .. box outside solid \\ + 1 .. box in solid \\ + 2 .. can't decide (allowed, iff box is close to solid) + */ + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const; + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, + double eps) const; + + // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual int GetNSurfaces() const; - virtual Surface & GetSurface (int i = 0); - virtual const Surface & GetSurface (int i = 0) const; + virtual int GetNSurfaces() const; + virtual Surface & GetSurface (int i = 0); + virtual const Surface & GetSurface (int i = 0) const; - virtual void Reduce (const BoxSphere<3> & box); - virtual void UnReduce (); + virtual void Reduce (const BoxSphere<3> & box); + virtual void UnReduce (); -}; + }; +} #endif diff --git a/libsrc/csg/singularref.hpp b/libsrc/csg/singularref.hpp index ffe073f5..c029fbef 100644 --- a/libsrc/csg/singularref.hpp +++ b/libsrc/csg/singularref.hpp @@ -7,72 +7,78 @@ /* Date: 25. Sep. 99 */ /**************************************************************************/ -/** - Control for local refinement -*/ - - - -/** - Singular Face. - Causes a bounday layer mesh refinement. - All elements in subdomain domnr will get a boundary layer - on faces sharing the solid sol - */ -class SingularFace +namespace netgen { -public: - int domnr; - const Solid *sol; - double factor; - // Array > points; - // Array segms; -public: - SingularFace (int adomnr, const Solid * asol, double sf) - : domnr(adomnr), sol(asol), factor(sf) { ; } - const Solid * GetSolid() const { return sol; } - int GetDomainNr () const { return domnr; } -}; -/// -class SingularEdge -{ -public: - double beta; - int domnr; - const CSGeometry& geom; - const Solid *sol1, *sol2; - Array > points; - Array segms; - double factor; - - double maxhinit; -public: - SingularEdge (double abeta, int adomnr, - const CSGeometry & ageom, - const Solid * asol1, const Solid * asol2, double sf, - const double maxh_at_initialization = -1); - void FindPointsOnEdge (class Mesh & mesh); - void SetMeshSize (class Mesh & mesh, double globalh); -}; + /** + Control for local refinement + */ -/// -class SingularPoint -{ -public: - double beta; - const Solid *sol1, *sol2, *sol3; - Array > points; - double factor; + + /** + Singular Face. + Causes a bounday layer mesh refinement. + All elements in subdomain domnr will get a boundary layer + on faces sharing the solid sol + */ + class SingularFace + { + public: + int domnr; + const Solid *sol; + double factor; + // Array > points; + // Array segms; + public: + SingularFace (int adomnr, const Solid * asol, double sf) + : domnr(adomnr), sol(asol), factor(sf) { ; } + const Solid * GetSolid() const { return sol; } + int GetDomainNr () const { return domnr; } + }; + + + /// + class SingularEdge + { + public: + double beta; + int domnr; + const CSGeometry& geom; + const Solid *sol1, *sol2; + Array > points; + Array segms; + double factor; + + double maxhinit; + public: + SingularEdge (double abeta, int adomnr, + const CSGeometry & ageom, + const Solid * asol1, const Solid * asol2, double sf, + const double maxh_at_initialization = -1); + void FindPointsOnEdge (class Mesh & mesh); + void SetMeshSize (class Mesh & mesh, double globalh); + }; + + + /// + class SingularPoint + { + public: + double beta; + const Solid *sol1, *sol2, *sol3; + Array > points; + double factor; -public: - SingularPoint (double abeta, const Solid * asol1, const Solid * asol2, - const Solid * asol3, double sf); - void FindPoints (class Mesh & mesh); - void SetMeshSize (class Mesh & mesh, double globalh); -}; + public: + SingularPoint (double abeta, const Solid * asol1, const Solid * asol2, + const Solid * asol3, double sf); + void FindPoints (class Mesh & mesh); + void SetMeshSize (class Mesh & mesh, double globalh); + }; + +} #endif diff --git a/libsrc/csg/solid.hpp b/libsrc/csg/solid.hpp index cbb5aa15..ebd7c88c 100644 --- a/libsrc/csg/solid.hpp +++ b/libsrc/csg/solid.hpp @@ -7,235 +7,240 @@ /* Date: 1. Dez. 95 */ /**************************************************************************/ -/* +namespace netgen +{ + + /* + Constructive Solid Model (csg) -*/ - - - - -class Solid; - -class SolidIterator -{ -public: - SolidIterator () { ; } - virtual ~SolidIterator () { ; } - virtual void Do (Solid * sol) = 0; -}; - - - -class Solid -{ -public: + */ - typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT /*, DUMMY */ } optyp; + + + + class Solid; -private: - char * name; - Primitive * prim; - Solid * s1, * s2; + class SolidIterator + { + public: + SolidIterator () { ; } + virtual ~SolidIterator () { ; } + virtual void Do (Solid * sol) = 0; + }; + + + + class Solid + { + public: - optyp op; - bool visited; - double maxh; + typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT /*, DUMMY */ } optyp; + + private: + char * name; + Primitive * prim; + Solid * s1, * s2; + + optyp op; + bool visited; + double maxh; - // static int cntnames; + // static int cntnames; -public: - Solid (Primitive * aprim); - Solid (optyp aop, Solid * as1, Solid * as2 = NULL); - ~Solid (); + public: + Solid (Primitive * aprim); + Solid (optyp aop, Solid * as1, Solid * as2 = NULL); + ~Solid (); - const char * Name () const { return name; } - void SetName (const char * aname); + const char * Name () const { return name; } + void SetName (const char * aname); - Solid * Copy (class CSGeometry & geom) const; - void Transform (Transformation<3> & trans); + Solid * Copy (class CSGeometry & geom) const; + void Transform (Transformation<3> & trans); - void IterateSolid (SolidIterator & it, bool only_once = 0); + void IterateSolid (SolidIterator & it, bool only_once = 0); - void Boundaries (const Point<3> & p, Array & bounds) const; - int NumPrimitives () const; - void GetSurfaceIndices (Array & surfind) const; - void GetSurfaceIndices (IndexSet & iset) const; + void Boundaries (const Point<3> & p, Array & bounds) const; + int NumPrimitives () const; + void GetSurfaceIndices (Array & surfind) const; + void GetSurfaceIndices (IndexSet & iset) const; - void GetTangentialSurfaceIndices (const Point<3> & p, Array & surfids, double eps) const; - void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array & surfids, double eps) const; - void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, Array & surfids, double eps) const; + void GetTangentialSurfaceIndices (const Point<3> & p, Array & surfids, double eps) const; + void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array & surfids, double eps) const; + void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, Array & surfids, double eps) const; - Primitive * GetPrimitive () + Primitive * GetPrimitive () { return (op == TERM || op == TERM_REF) ? prim : NULL; } - const Primitive * GetPrimitive () const + const Primitive * GetPrimitive () const { return (op == TERM || op == TERM_REF) ? prim : NULL; } - Solid * S1() { return s1; } - Solid * S2() { return s2; } + Solid * S1() { return s1; } + Solid * S2() { return s2; } - // geometric tests + // geometric tests - bool IsIn (const Point<3> & p, double eps = 1e-6) const; - bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const; - bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; - bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; + bool IsIn (const Point<3> & p, double eps = 1e-6) const; + bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const; + bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; + bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; - bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - double eps) const; - bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - double eps) const; + bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, + double eps) const; + bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, + double eps) const; - /// compute localization in point p - void TangentialSolid (const Point<3> & p, Solid *& tansol, Array & surfids, double eps) const; + /// compute localization in point p + void TangentialSolid (const Point<3> & p, Solid *& tansol, Array & surfids, double eps) const; - /// compute localization in point p tangential to vector t - void TangentialSolid2 (const Point<3> & p, const Vec<3> & t, - Solid *& tansol, Array & surfids, double eps) const; + /// compute localization in point p tangential to vector t + void TangentialSolid2 (const Point<3> & p, const Vec<3> & t, + Solid *& tansol, Array & surfids, double eps) const; - /** compute localization in point p, with second order approximation to edge - p + s t + s*s/2 t2 **/ - void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, - Solid *& tansol, Array & surfids, double eps) const; + /** compute localization in point p, with second order approximation to edge + p + s t + s*s/2 t2 **/ + void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, + Solid *& tansol, Array & surfids, double eps) const; - /** tangential solid, which follows the edge - p + s t + s*s/2 t2 - with second order, and the neighbouring face - p + s t + s*s/2 t2 + r m - with first order - **/ - void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, - const Vec<3> & m, - Solid *& tansol, Array & surfids, double eps) const; + /** tangential solid, which follows the edge + p + s t + s*s/2 t2 + with second order, and the neighbouring face + p + s t + s*s/2 t2 + r m + with first order + **/ + void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, + const Vec<3> & m, + Solid *& tansol, Array & surfids, double eps) const; - void CalcOnePrimitiveSpecialPoints (const Box<3> & box, Array > & pts) const; + void CalcOnePrimitiveSpecialPoints (const Box<3> & box, Array > & pts) const; - /// - int Edge (const Point<3> & p, const Vec<3> & v, double eps) const; - /// - int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const; - /// - void Print (ostream & str) const; - /// - void CalcSurfaceInverse (); - /// - Solid * GetReducedSolid (const BoxSphere<3> & box) const; + /// + int Edge (const Point<3> & p, const Vec<3> & v, double eps) const; + /// + int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const; + /// + void Print (ostream & str) const; + /// + void CalcSurfaceInverse (); + /// + Solid * GetReducedSolid (const BoxSphere<3> & box) const; - void SetMaxH (double amaxh) + void SetMaxH (double amaxh) { maxh = amaxh; } - double GetMaxH () const + double GetMaxH () const { return maxh; } - void GetSolidData (ostream & ost, int first = 1) const; - static Solid * CreateSolid (istream & ist, const SYMBOLTABLE & solids); + void GetSolidData (ostream & ost, int first = 1) const; + static Solid * CreateSolid (istream & ist, const SYMBOLTABLE & solids); - static BlockAllocator ball; - void * operator new(size_t /* s */) + static BlockAllocator ball; + void * operator new(size_t /* s */) + { + return ball.Alloc(); + } + + void operator delete (void * p) + { + ball.Free (p); + } + + + protected: + /// + + void RecBoundaries (const Point<3> & p, Array & bounds, + int & in, int & strin) const; + /// + void RecTangentialSolid (const Point<3> & p, Solid *& tansol, Array & surfids, + int & in, int & strin, double eps) const; + + void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec, + Solid *& tansol, Array & surfids, + int & in, int & strin, double eps) const; + /// + void RecTangentialSolid3 (const Point<3> & p, const Vec<3> & vec,const Vec<3> & vec2, + Solid *& tansol, Array & surfids, + int & in, int & strin, double eps) const; + /// + void RecTangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, + const Vec<3> & m, + Solid *& tansol, Array & surfids, + int & in, int & strin, double eps) const; + + /// + void RecEdge (const Point<3> & p, const Vec<3> & v, + int & in, int & strin, int & faces, double eps) const; + /// + void CalcSurfaceInverseRec (int inv); + /// + Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const; + /// + void RecGetSurfaceIndices (Array & surfind) const; + void RecGetTangentialSurfaceIndices (const Point<3> & p, Array & surfids, double eps) const; + void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array & surfids, double eps) const; + void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, + Array & surfids, double eps) const; + void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m, + Array & surfids, double eps) const; + void RecGetSurfaceIndices (IndexSet & iset) const; + + void RecCalcOnePrimitiveSpecialPoints (Array > & pts) const; + + friend class SolidIterator; + friend class ClearVisitedIt; + friend class RemoveDummyIterator; + friend class CSGeometry; + }; + + + inline ostream & operator<< (ostream & ost, const Solid & sol) { - return ball.Alloc(); - } - - void operator delete (void * p) - { - ball.Free (p); + sol.Print (ost); + return ost; } -protected: - /// - - void RecBoundaries (const Point<3> & p, Array & bounds, - int & in, int & strin) const; - /// - void RecTangentialSolid (const Point<3> & p, Solid *& tansol, Array & surfids, - int & in, int & strin, double eps) const; - - void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec, - Solid *& tansol, Array & surfids, - int & in, int & strin, double eps) const; - /// - void RecTangentialSolid3 (const Point<3> & p, const Vec<3> & vec,const Vec<3> & vec2, - Solid *& tansol, Array & surfids, - int & in, int & strin, double eps) const; - /// - void RecTangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, - const Vec<3> & m, - Solid *& tansol, Array & surfids, - int & in, int & strin, double eps) const; - - /// - void RecEdge (const Point<3> & p, const Vec<3> & v, - int & in, int & strin, int & faces, double eps) const; - /// - void CalcSurfaceInverseRec (int inv); - /// - Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const; - /// - void RecGetSurfaceIndices (Array & surfind) const; - void RecGetTangentialSurfaceIndices (const Point<3> & p, Array & surfids, double eps) const; - void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array & surfids, double eps) const; - void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, - Array & surfids, double eps) const; - void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m, - Array & surfids, double eps) const; - void RecGetSurfaceIndices (IndexSet & iset) const; - - void RecCalcOnePrimitiveSpecialPoints (Array > & pts) const; - - friend class SolidIterator; - friend class ClearVisitedIt; - friend class RemoveDummyIterator; - friend class CSGeometry; -}; -inline ostream & operator<< (ostream & ost, const Solid & sol) -{ - sol.Print (ost); - return ost; + + + class ReducePrimitiveIterator : public SolidIterator + { + const BoxSphere<3> & box; + public: + ReducePrimitiveIterator (const BoxSphere<3> & abox) + : SolidIterator(), box(abox) { ; } + virtual ~ReducePrimitiveIterator () { ; } + virtual void Do (Solid * sol) + { + if (sol -> GetPrimitive()) + sol -> GetPrimitive() -> Reduce (box); + } + }; + + + class UnReducePrimitiveIterator : public SolidIterator + { + public: + UnReducePrimitiveIterator () { ; } + virtual ~UnReducePrimitiveIterator () { ; } + virtual void Do (Solid * sol) + { + if (sol -> GetPrimitive()) + sol -> GetPrimitive() -> UnReduce (); + } + }; + } - - - - - -class ReducePrimitiveIterator : public SolidIterator -{ - const BoxSphere<3> & box; -public: - ReducePrimitiveIterator (const BoxSphere<3> & abox) - : SolidIterator(), box(abox) { ; } - virtual ~ReducePrimitiveIterator () { ; } - virtual void Do (Solid * sol) - { - if (sol -> GetPrimitive()) - sol -> GetPrimitive() -> Reduce (box); - } -}; - - -class UnReducePrimitiveIterator : public SolidIterator -{ -public: - UnReducePrimitiveIterator () { ; } - virtual ~UnReducePrimitiveIterator () { ; } - virtual void Do (Solid * sol) - { - if (sol -> GetPrimitive()) - sol -> GetPrimitive() -> UnReduce (); - } -}; - - #endif diff --git a/libsrc/csg/specpoin.hpp b/libsrc/csg/specpoin.hpp index 2fa09364..bc36903c 100644 --- a/libsrc/csg/specpoin.hpp +++ b/libsrc/csg/specpoin.hpp @@ -8,166 +8,171 @@ /* Date: 01. Okt. 95 */ /**************************************************************************/ -/* - -Special Point Calculation - -*/ - -class Surface; -class Solid; - -/// Special point. -class SpecialPoint +namespace netgen { -public: - /// coordinates - Point<3> p; - /// tangential to edge - Vec<3> v; - /// - int layer; - /// point must be used in mesh - bool unconditional; - - /// surfaces defining edge - int s1, s2; - /// if s1 and s2 are only representatives, then these are the original indices - int s1_orig, s2_orig; - int nr; - /// - SpecialPoint () : p(0,0,0), v(0,0,0), layer(0), unconditional(0), s1(0), s2(0), s1_orig(0), s2_orig(0) - { ; } - - /// - SpecialPoint (const SpecialPoint & sp2); - - /// - SpecialPoint & operator= (const SpecialPoint & sp2); - - /// - void Print (ostream & str) const; - - - int GetLayer() const { return layer; } - - /// - bool HasSurfaces (int as1, int as2) const - { - return ( (s1 == as1 && s2 == as2) || (s1 == as2 && s2 == as1) ); - } -}; - -inline ostream & operator<< (ostream & ost, const SpecialPoint & sp) -{ - sp.Print (ost); - return ost; -} - - - - -/// -class SpecialPointCalculation -{ -private: - /// - const CSGeometry * geometry; - /// - Array * points; - /// - Array boxesinlevel; - - /// - double size; - /// - double relydegtest; // maximal dimension of bisection intervall for - /// test of degeneration parameters - double cpeps1, epeps1, epeps2, epspointdist2; - - double ideps; - -public: - - /// - SpecialPointCalculation (); - - /// - void SetIdEps(const double epsin) {ideps = epsin;} - - /// - void CalcSpecialPoints (const CSGeometry & ageometry, - Array & points); - /// - void AnalyzeSpecialPoints (const CSGeometry & geometry, - Array & points, - Array & specpoints); - -protected: - /// - void CalcSpecialPointsRec (const Solid * sol, int layer, - const BoxSphere<3> & box, - int level, - bool calccp, bool calcep); - - - /// - bool CrossPointNewtonConvergence (const Surface * f1, const Surface * f2, - const Surface * f3, const BoxSphere<3> & box); - /// - bool CrossPointDegenerated (const Surface * f1, const Surface * f2, - const Surface * f3, const BoxSphere<3> & box) const; - /// - void CrossPointNewton (const Surface * f1, const Surface * f2, - const Surface * f3, Point<3> & p); - - bool EdgeNewtonConvergence (const Surface * f1, const Surface * f2, - const Point<3> & p); - /// - bool EdgeDegenerated (const Surface * f1, const Surface * f2, - const BoxSphere<3> & box) const; - /// - void EdgeNewton (const Surface * f1, const Surface * f2, - Point<3> & p); - /// - bool IsEdgeExtremalPoint (const Surface * f1, const Surface * f2, - const Point<3> & p, Point<3> & pp, double rad); - - /* - /// - bool ExtremalPointPossible (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box); - /// - bool ExtremalPointDegenerated (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box); - /// - bool ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box); + + Special Point Calculation + */ - /// - void ExtremalPointNewton (const Surface * f1, const Surface * f2, - int dir, Point<3> & p); + + class Surface; + class Solid; + + /// Special point. + class SpecialPoint + { + public: + /// coordinates + Point<3> p; + /// tangential to edge + Vec<3> v; + /// + int layer; + /// point must be used in mesh + bool unconditional; + + /// surfaces defining edge + int s1, s2; + /// if s1 and s2 are only representatives, then these are the original indices + int s1_orig, s2_orig; + int nr; + /// + SpecialPoint () : p(0,0,0), v(0,0,0), layer(0), unconditional(0), s1(0), s2(0), s1_orig(0), s2_orig(0) + { ; } + + /// + SpecialPoint (const SpecialPoint & sp2); + + /// + SpecialPoint & operator= (const SpecialPoint & sp2); + + /// + void Print (ostream & str) const; + + + int GetLayer() const { return layer; } + + /// + bool HasSurfaces (int as1, int as2) const + { + return ( (s1 == as1 && s2 == as2) || (s1 == as2 && s2 == as1) ); + } + }; + + inline ostream & operator<< (ostream & ost, const SpecialPoint & sp) + { + sp.Print (ost); + return ost; + } + + /// - bool AddPoint (const Point<3> & p, int layer); + class SpecialPointCalculation + { + private: + /// + const CSGeometry * geometry; + /// + Array * points; + /// + Array boxesinlevel; - void ComputeExtremalPoints (const Plane * plane, - const QuadraticSurface * quadric, - Array > & pts); + /// + double size; + /// + double relydegtest; // maximal dimension of bisection intervall for + /// test of degeneration parameters + double cpeps1, epeps1, epeps2, epspointdist2; - void ComputeCrossPoints (const Plane * plane1, - const Plane * plane2, - const Plane * plane3, - Array > & pts); + double ideps; - void ComputeCrossPoints (const Plane * plane1, - const Plane * plane2, - const QuadraticSurface * quadratic, - Array > & pts); -}; + public: + + /// + SpecialPointCalculation (); + + /// + void SetIdEps(const double epsin) {ideps = epsin;} + + /// + void CalcSpecialPoints (const CSGeometry & ageometry, + Array & points); + /// + void AnalyzeSpecialPoints (const CSGeometry & geometry, + Array & points, + Array & specpoints); + + protected: + /// + void CalcSpecialPointsRec (const Solid * sol, int layer, + const BoxSphere<3> & box, + int level, + bool calccp, bool calcep); + + + /// + bool CrossPointNewtonConvergence (const Surface * f1, const Surface * f2, + const Surface * f3, const BoxSphere<3> & box); + /// + bool CrossPointDegenerated (const Surface * f1, const Surface * f2, + const Surface * f3, const BoxSphere<3> & box) const; + /// + void CrossPointNewton (const Surface * f1, const Surface * f2, + const Surface * f3, Point<3> & p); + + bool EdgeNewtonConvergence (const Surface * f1, const Surface * f2, + const Point<3> & p); + /// + bool EdgeDegenerated (const Surface * f1, const Surface * f2, + const BoxSphere<3> & box) const; + /// + void EdgeNewton (const Surface * f1, const Surface * f2, + Point<3> & p); + /// + bool IsEdgeExtremalPoint (const Surface * f1, const Surface * f2, + const Point<3> & p, Point<3> & pp, double rad); + + + + /* + /// + bool ExtremalPointPossible (const Surface * f1, const Surface * f2, + int dir, const BoxSphere<3> & box); + /// + bool ExtremalPointDegenerated (const Surface * f1, const Surface * f2, + int dir, const BoxSphere<3> & box); + /// + bool ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2, + int dir, const BoxSphere<3> & box); + */ + /// + void ExtremalPointNewton (const Surface * f1, const Surface * f2, + int dir, Point<3> & p); + + + /// + bool AddPoint (const Point<3> & p, int layer); + + void ComputeExtremalPoints (const Plane * plane, + const QuadraticSurface * quadric, + Array > & pts); + + void ComputeCrossPoints (const Plane * plane1, + const Plane * plane2, + const Plane * plane3, + Array > & pts); + + void ComputeCrossPoints (const Plane * plane1, + const Plane * plane2, + const QuadraticSurface * quadratic, + Array > & pts); + }; + +} #endif diff --git a/libsrc/csg/spline3d.hpp b/libsrc/csg/spline3d.hpp index fca2eecf..db3a40c5 100644 --- a/libsrc/csg/spline3d.hpp +++ b/libsrc/csg/spline3d.hpp @@ -1,92 +1,99 @@ -/// -class splinesegment3d - { +namespace netgen +{ + /// - Point<3> p1, p2, p3; + class splinesegment3d + { + /// + Point<3> p1, p2, p3; public: - /// - splinesegment3d (const Point<3> & ap1, const Point<3> & ap2, - const Point<3> & ap3); - /// - void Evaluate (double t, Point<3> & p) const; - /// - void EvaluateTangent (double t, Vec<3> & tang) const; - /// - const Point<3> & P1() const { return p1; } - /// - const Point<3> & P2() const { return p2; } - /// - const Point<3> & P3() const { return p3; } + /// + splinesegment3d (const Point<3> & ap1, const Point<3> & ap2, + const Point<3> & ap3); + /// + void Evaluate (double t, Point<3> & p) const; + /// + void EvaluateTangent (double t, Vec<3> & tang) const; + /// + const Point<3> & P1() const { return p1; } + /// + const Point<3> & P2() const { return p2; } + /// + const Point<3> & P3() const { return p3; } }; -/// -class spline3d - { /// - Array segments; + class spline3d + { + /// + Array segments; public: - /// - spline3d () { }; - /// - void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3); - /// - int GetNumSegments () const { return segments.Size(); } - /// - double ProjectToSpline (Point<3> & p) const; - /// - double ProjectToSpline (Point<3> & p, double t) const; - /// - void Evaluate (double t, Point<3> & p) const; - /// - void EvaluateTangent (double t, Vec<3> & tang) const; - /// - const Point<3> & P1(int i) const { return segments.Get(i)->P1(); } - /// - const Point<3> & P2(int i) const { return segments.Get(i)->P2(); } - /// - const Point<3> & P3(int i) const { return segments.Get(i)->P3(); } + /// + spline3d () { }; + /// + void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3); + /// + int GetNumSegments () const { return segments.Size(); } + /// + double ProjectToSpline (Point<3> & p) const; + /// + double ProjectToSpline (Point<3> & p, double t) const; + /// + void Evaluate (double t, Point<3> & p) const; + /// + void EvaluateTangent (double t, Vec<3> & tang) const; + /// + const Point<3> & P1(int i) const { return segments.Get(i)->P1(); } + /// + const Point<3> & P2(int i) const { return segments.Get(i)->P2(); } + /// + const Point<3> & P3(int i) const { return segments.Get(i)->P3(); } }; -/// -class splinetube : public Surface + /// + class splinetube : public Surface { - /// - const spline3d & middlecurve; - /// - double r; -/// Vec<3> ex, ey, ez; - Vec<2> e2x, e2y; - /// - Point<3> cp; + /// + const spline3d & middlecurve; + /// + double r; + /// Vec<3> ex, ey, ez; + Vec<2> e2x, e2y; + /// + Point<3> cp; public: - /// - splinetube (const spline3d & amiddlecurve, double ar); + /// + splinetube (const spline3d & amiddlecurve, double ar); - /// - virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2); - /// - virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const; - /// - virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const; - /// - virtual void Project (Point<3> & p) const; + /// + virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2); + /// + virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const; + /// + virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const; + /// + virtual void Project (Point<3> & p) const; -// virtual int RootInBox (const box3d & box) const { return 0; } + // virtual int RootInBox (const box3d & box) const { return 0; } /// 0 .. no, 1 .. yes, 2 .. maybe - virtual int BoxInSolid (const BoxSphere<3> & box) const; + virtual int BoxInSolid (const BoxSphere<3> & box) const; /// 0 .. no, 1 .. yes, 2 .. maybe - virtual double CalcFunctionValue (const Point<3> & point) const; - /// - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - /// - virtual double HesseNorm () const { return 0.5 / r; } - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void Print (ostream & str) const; + virtual double CalcFunctionValue (const Point<3> & point) const; + /// + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; + /// + virtual double HesseNorm () const { return 0.5 / r; } + /// + virtual Point<3> GetSurfacePoint () const; + /// + virtual void Print (ostream & str) const; }; + + +} + diff --git a/libsrc/csg/surface.hpp b/libsrc/csg/surface.hpp index 1bad84aa..98215bd6 100644 --- a/libsrc/csg/surface.hpp +++ b/libsrc/csg/surface.hpp @@ -8,369 +8,371 @@ /**************************************************************************/ - - -// class DenseMatrix; -// class Box3dSphere; -class TriangleApproximation; - -/** - Basis class for implicit surface geometry. - This class is used for generation of surface meshes - in NETGEN as well as for mesh refinement in FEPP. - */ - - - - -class Surface +namespace netgen { -protected: - /// invert normal vector - bool inverse; - /// maximal h in surface - double maxh; - /// name of surface - char * name; - /// boundary condition nr - int bcprop; - /// - string bcname; - -public: - Surface (); - /** @name Tangential plane. - The tangential plane is used for surface mesh generation. - */ - - virtual ~Surface(); -protected: - /** @name Points in the surface defining tangential plane. - Tangential plane is taken in p1, the local x-axis - is directed to p2. - */ - //@{ - /// - Point<3> p1; - /// - Point<3> p2; - //@} - /** @name Base-vectos for local coordinate system. */ - //@{ - /// in plane, directed p1->p2 - Vec<3> ex; - /// in plane - Vec<3> ey; - /// outer normal direction - Vec<3> ez; - //@} -public: + // class DenseMatrix; + // class Box3dSphere; + class TriangleApproximation; - void SetName (const char * aname); - const char * Name () const { return name; } - - //@{ /** - Defines tangential plane in ap1. - The local x-coordinate axis point to the direction of ap2 */ - virtual void DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2); - - /// Transforms 3d point p3d to local coordinates pplane - virtual void ToPlane (const Point<3> & p3d, Point<2> & pplane, - double h, int & zone) const; - - /// Transforms point pplane in local coordinates to 3d point - virtual void FromPlane (const Point<2> & pplane, - Point<3> & p3d, double h) const; - //@} - - - /// Move Point p to closes point in surface - virtual void Project (Point<3> & p) const; - - /// - virtual void SkewProject(Point<3> & p, const Vec<3> & direction) const; - - virtual int IsIdentic (const Surface & /* s2 */, int & /* inv */, - double /* eps */) const - { return 0; } - - /// - virtual int PointOnSurface (const Point<3> & p, - double eps = 1e-6) const; - - - /** @name Implicit function. - Calculate function value and derivatives. + Basis class for implicit surface geometry. + This class is used for generation of surface meshes + in NETGEN as well as for mesh refinement in FEPP. */ - //@{ - /// Calculate implicit function value in point point - virtual double CalcFunctionValue (const Point<3> & point) const = 0; - - /** - Calc gradient of implicit function. - gradient should be O(1) at surface - */ - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const = 0; - - /** - Calculate second derivatives of implicit function. - */ - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - - /** - Returns outer normal vector. - */ - // virtual void GetNormalVector (const Point<3> & p, Vec<3> & n) const; - virtual Vec<3> GetNormalVector (const Point<3> & p) const; - - /** - Upper bound for spectral norm of Hesse-matrix - */ - virtual double HesseNorm () const = 0; - - /** - Upper bound for spectral norm of Hesse-matrix in the - rad - environment of point c. - */ - virtual double HesseNormLoc (const Point<3> & /* c */, - double /* rad */) const - { return HesseNorm (); } - //@} - /// - virtual double MaxCurvature () const; - /// - virtual double MaxCurvatureLoc (const Point<3> & /* c */ , - double /* rad */) const; - /** Returns any point in the surface. - Needed to start surface mesh generation e.g. on sphere */ - virtual Point<3> GetSurfacePoint () const = 0; - /// - bool Inverse () const { return inverse; } - /// - void SetInverse (bool ainverse) { inverse = ainverse; } - /// - virtual void Print (ostream & str) const = 0; + class Surface + { + protected: + /// invert normal vector + bool inverse; + /// maximal h in surface + double maxh; + /// name of surface + char * name; + /// boundary condition nr + int bcprop; + /// + string bcname; - /// - virtual void Reduce (const BoxSphere<3> & /* box */) { }; - /// - virtual void UnReduce () { }; + public: + Surface (); + /** @name Tangential plane. + The tangential plane is used for surface mesh generation. + */ + + virtual ~Surface(); - /// set max h in surface - void SetMaxH (double amaxh) { maxh = amaxh; } - /// - double GetMaxH () const { return maxh; } - /// - int GetBCProperty () const { return bcprop; } - /// - void SetBCProperty (int abc) { bcprop = abc; } + protected: + /** @name Points in the surface defining tangential plane. + Tangential plane is taken in p1, the local x-axis + is directed to p2. + */ + //@{ + /// + Point<3> p1; + /// + Point<3> p2; + //@} + /** @name Base-vectos for local coordinate system. */ + //@{ + /// in plane, directed p1->p2 + Vec<3> ex; + /// in plane + Vec<3> ey; + /// outer normal direction + Vec<3> ez; + //@} + public: - /** Determine local mesh-size. - Find - \[ h \leq hmax, \] - such that - \[ h \times \kappa (x) \leq c \qquad \mbox{in} B(x, h), \] - where kappa(x) is the curvature in x. */ - virtual double LocH (const Point<3> & p, double x, - double c, double hmax) const; + void SetName (const char * aname); + const char * Name () const { return name; } - /** - Gets Approximation by triangles, - where qual is about the number of triangles per radius - */ - virtual void GetTriangleApproximation (TriangleApproximation & /* tas */, - const Box<3> & /* boundingbox */, - double /* facets */ ) const { }; + //@{ + /** + Defines tangential plane in ap1. + The local x-coordinate axis point to the direction of ap2 */ + virtual void DefineTangentialPlane (const Point<3> & ap1, + const Point<3> & ap2); + + /// Transforms 3d point p3d to local coordinates pplane + virtual void ToPlane (const Point<3> & p3d, Point<2> & pplane, + double h, int & zone) const; + + /// Transforms point pplane in local coordinates to 3d point + virtual void FromPlane (const Point<2> & pplane, + Point<3> & p3d, double h) const; + //@} - string GetBCName() const { return bcname; } + /// Move Point p to closes point in surface + virtual void Project (Point<3> & p) const; - void SetBCName( string abc ) { bcname = abc; } + /// + virtual void SkewProject(Point<3> & p, const Vec<3> & direction) const; + + virtual int IsIdentic (const Surface & /* s2 */, int & /* inv */, + double /* eps */) const + { return 0; } + + /// + virtual int PointOnSurface (const Point<3> & p, + double eps = 1e-6) const; + + + /** @name Implicit function. + Calculate function value and derivatives. + */ + //@{ + /// Calculate implicit function value in point point + virtual double CalcFunctionValue (const Point<3> & point) const = 0; + + /** + Calc gradient of implicit function. + gradient should be O(1) at surface + */ + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const = 0; + + /** + Calculate second derivatives of implicit function. + */ + virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; + + /** + Returns outer normal vector. + */ + // virtual void GetNormalVector (const Point<3> & p, Vec<3> & n) const; + virtual Vec<3> GetNormalVector (const Point<3> & p) const; + + /** + Upper bound for spectral norm of Hesse-matrix + */ + virtual double HesseNorm () const = 0; + + /** + Upper bound for spectral norm of Hesse-matrix in the + rad - environment of point c. + */ + virtual double HesseNormLoc (const Point<3> & /* c */, + double /* rad */) const + { return HesseNorm (); } + //@} + + + /// + virtual double MaxCurvature () const; + /// + virtual double MaxCurvatureLoc (const Point<3> & /* c */ , + double /* rad */) const; + + /** Returns any point in the surface. + Needed to start surface mesh generation e.g. on sphere */ + virtual Point<3> GetSurfacePoint () const = 0; + + /// + bool Inverse () const { return inverse; } + /// + void SetInverse (bool ainverse) { inverse = ainverse; } + /// + virtual void Print (ostream & str) const = 0; + + /// + virtual void Reduce (const BoxSphere<3> & /* box */) { }; + /// + virtual void UnReduce () { }; + + /// set max h in surface + void SetMaxH (double amaxh) { maxh = amaxh; } + /// + double GetMaxH () const { return maxh; } + /// + int GetBCProperty () const { return bcprop; } + /// + void SetBCProperty (int abc) { bcprop = abc; } + + /** Determine local mesh-size. + Find + \[ h \leq hmax, \] + such that + \[ h \times \kappa (x) \leq c \qquad \mbox{in} B(x, h), \] + where kappa(x) is the curvature in x. */ + virtual double LocH (const Point<3> & p, double x, + double c, double hmax) const; + + /** + Gets Approximation by triangles, + where qual is about the number of triangles per radius + */ + virtual void GetTriangleApproximation (TriangleApproximation & /* tas */, + const Box<3> & /* boundingbox */, + double /* facets */ ) const { }; + + + string GetBCName() const { return bcname; } + + void SetBCName( string abc ) { bcname = abc; } }; -inline ostream & operator<< (ostream & ost, const Surface & surf) -{ - surf.Print(ost); - return ost; -} + inline ostream & operator<< (ostream & ost, const Surface & surf) + { + surf.Print(ost); + return ost; + } -typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2} -INSOLID_TYPE; + typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2} + INSOLID_TYPE; -class DummySurface : public Surface -{ - virtual double CalcFunctionValue (const Point<3> & point) const - { return 0; } + class DummySurface : public Surface + { + virtual double CalcFunctionValue (const Point<3> & point) const + { return 0; } - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const - { grad = Vec<3> (0,0,0); } + virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const + { grad = Vec<3> (0,0,0); } - virtual Point<3> GetSurfacePoint () const - { return Point<3> (0,0,0); } + virtual Point<3> GetSurfacePoint () const + { return Point<3> (0,0,0); } - virtual double HesseNorm () const - { return 0; } + virtual double HesseNorm () const + { return 0; } - virtual void Project (Point<3> & p) const - { ; } + virtual void Project (Point<3> & p) const + { ; } - virtual void Print (ostream & ost) const - { ost << "dummy surface"; } -}; + virtual void Print (ostream & ost) const + { ost << "dummy surface"; } + }; -class Primitive -{ + class Primitive + { -public: + public: - Primitive (); + Primitive (); - virtual ~Primitive(); + virtual ~Primitive(); - /* - Check, whether box intersects solid defined by surface. + /* + Check, whether box intersects solid defined by surface. - return values: - 0 .. box outside solid \\ - 1 .. box in solid \\ - 2 .. can't decide (allowed, iff box is close to solid) - */ - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const = 0; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + return values: + 0 .. box outside solid \\ + 1 .. box in solid \\ + 2 .. can't decide (allowed, iff box is close to solid) + */ + virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const = 0; + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const = 0; + + virtual void GetTangentialSurfaceIndices (const Point<3> & p, + Array & surfind, double eps) const; + + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, double eps) const = 0; - virtual void GetTangentialSurfaceIndices (const Point<3> & p, - Array & surfind, double eps) const; + // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const = 0; + // checks if p + s v1 + s*s/2 v2 is inside + virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + // like VecInSolid2, but second order approximation + virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, + const Vec<3> & v, + const Vec<3> & v2, + const Vec<3> & m, + double eps) const; - // checks if p + s v1 + s*s/2 v2 is inside - virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + virtual void GetTangentialVecSurfaceIndices (const Point<3> & p, const Vec<3> & v, + Array & surfind, double eps) const; - // like VecInSolid2, but second order approximation - virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, - const Vec<3> & v, - const Vec<3> & v2, - const Vec<3> & m, - double eps) const; - - virtual void GetTangentialVecSurfaceIndices (const Point<3> & p, const Vec<3> & v, - Array & surfind, double eps) const; - - virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - Array & surfind, double eps) const; + virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, + Array & surfind, double eps) const; - virtual void CalcSpecialPoints (Array > & /* pts */) const { ; } - virtual void AnalyzeSpecialPoint (const Point<3> & /* pt */, - Array > & /* specpts */) const { ; } - virtual Vec<3> SpecialPointTangentialVector (const Point<3> & /* p */, - int /* s1 */, int /* s2 */) const - { return Vec<3> (0,0,0); } + virtual void CalcSpecialPoints (Array > & /* pts */) const { ; } + virtual void AnalyzeSpecialPoint (const Point<3> & /* pt */, + Array > & /* specpts */) const { ; } + virtual Vec<3> SpecialPointTangentialVector (const Point<3> & /* p */, + int /* s1 */, int /* s2 */) const + { return Vec<3> (0,0,0); } - virtual int GetNSurfaces() const = 0; - virtual Surface & GetSurface (int i = 0) = 0; - virtual const Surface & GetSurface (int i = 0) const = 0; + virtual int GetNSurfaces() const = 0; + virtual Surface & GetSurface (int i = 0) = 0; + virtual const Surface & GetSurface (int i = 0) const = 0; - Array surfaceids; - Array surfaceactive; + Array surfaceids; + Array surfaceactive; - int GetSurfaceId (int i = 0) const; - void SetSurfaceId (int i, int id); - int SurfaceActive (int i) const { return surfaceactive[i]; } - virtual int SurfaceInverted (int /* i */ = 0) const { return 0; } + int GetSurfaceId (int i = 0) const; + void SetSurfaceId (int i, int id); + int SurfaceActive (int i) const { return surfaceactive[i]; } + virtual int SurfaceInverted (int /* i */ = 0) const { return 0; } - virtual void GetPrimitiveData (const char *& classname, - Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - static Primitive * CreatePrimitive (const char * classname); + virtual void GetPrimitiveData (const char *& classname, + Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); + static Primitive * CreatePrimitive (const char * classname); - virtual void Reduce (const BoxSphere<3> & /* box */) { }; - virtual void UnReduce () { }; + virtual void Reduce (const BoxSphere<3> & /* box */) { }; + virtual void UnReduce () { }; - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); -}; + virtual Primitive * Copy () const; + virtual void Transform (Transformation<3> & trans); + }; -class OneSurfacePrimitive : public Surface, public Primitive -{ -public: - OneSurfacePrimitive(); - ~OneSurfacePrimitive(); + class OneSurfacePrimitive : public Surface, public Primitive + { + public: + OneSurfacePrimitive(); + ~OneSurfacePrimitive(); - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + virtual INSOLID_TYPE PointInSolid (const Point<3> & p, + double eps) const; + virtual INSOLID_TYPE VecInSolid (const Point<3> & p, + const Vec<3> & v, double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; + virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, + const Vec<3> & v1, + const Vec<3> & v2, + double eps) const; - virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, - const Vec<3> & v, - const Vec<3> & v2, - const Vec<3> & m, - double eps) const; + virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, + const Vec<3> & v, + const Vec<3> & v2, + const Vec<3> & m, + double eps) const; - virtual int GetNSurfaces() const; - virtual Surface & GetSurface (int i = 0); - virtual const Surface & GetSurface (int i = 0) const; -}; + virtual int GetNSurfaces() const; + virtual Surface & GetSurface (int i = 0); + virtual const Surface & GetSurface (int i = 0) const; + }; -/** - Projects point to edge. - The point hp is projected to the edge descibed by f1 and f2. - It is assumed that the edge is non-degenerated, and the - (generalized) Newton method converges. - */ -extern void ProjectToEdge (const Surface * f1, - const Surface * f2, - Point<3> & hp); + /** + Projects point to edge. + The point hp is projected to the edge descibed by f1 and f2. + It is assumed that the edge is non-degenerated, and the + (generalized) Newton method converges. + */ + extern void ProjectToEdge (const Surface * f1, + const Surface * f2, + Point<3> & hp); +} #endif diff --git a/libsrc/csg/triapprox.hpp b/libsrc/csg/triapprox.hpp index 3f71c589..c17a3e94 100644 --- a/libsrc/csg/triapprox.hpp +++ b/libsrc/csg/triapprox.hpp @@ -7,51 +7,57 @@ /* Date: 2. Mar. 98 */ /**************************************************************************/ -/** - Triangulated approxiamtion to true surface -*/ + +namespace netgen +{ + + /** + Triangulated approxiamtion to true surface + */ -class TATriangle -{ - int pi[3]; - int surfind; -public: - TATriangle () { ; } + class TATriangle + { + int pi[3]; + int surfind; + public: + TATriangle () { ; } - TATriangle (int si, int pi1, int pi2, int pi3) + TATriangle (int si, int pi1, int pi2, int pi3) { surfind = si; pi[0] = pi1; pi[1] = pi2; pi[2] = pi3; } - int SurfaceIndex() const { return surfind; } - int & SurfaceIndex() { return surfind; } + int SurfaceIndex() const { return surfind; } + int & SurfaceIndex() { return surfind; } - int & operator[] (int i) { return pi[i]; } - const int & operator[] (int i) const { return pi[i]; } -}; + int & operator[] (int i) { return pi[i]; } + const int & operator[] (int i) const { return pi[i]; } + }; -class TriangleApproximation -{ - Array > points; - Array > normals; - Array trigs; + class TriangleApproximation + { + Array > points; + Array > normals; + Array trigs; -public: - TriangleApproximation(); - int GetNP () const { return points.Size(); } - int GetNT () const { return trigs.Size(); } + public: + TriangleApproximation(); + int GetNP () const { return points.Size(); } + int GetNT () const { return trigs.Size(); } - int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; } - int AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; } - int AddTriangle (const TATriangle & tri, bool invert = 0); + int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; } + int AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; } + int AddTriangle (const TATriangle & tri, bool invert = 0); - const Point<3> & GetPoint (int i) const { return points[i]; } - const TATriangle & GetTriangle (int i) const { return trigs[i]; } - const Vec<3> & GetNormal (int i) const { return normals[i]; } + const Point<3> & GetPoint (int i) const { return points[i]; } + const TATriangle & GetTriangle (int i) const { return trigs[i]; } + const Vec<3> & GetNormal (int i) const { return normals[i]; } - void RemoveUnusedPoints (); + void RemoveUnusedPoints (); - friend class CSGeometry; -}; + friend class CSGeometry; + }; + +} #endif diff --git a/libsrc/geom2d/genmesh2d.cpp b/libsrc/geom2d/genmesh2d.cpp index 8fed2a10..bec84518 100644 --- a/libsrc/geom2d/genmesh2d.cpp +++ b/libsrc/geom2d/genmesh2d.cpp @@ -195,20 +195,33 @@ namespace netgen Meshing2 meshing (Box<3> (pmin, pmax)); + Array compress(bnp); + compress = -1; + int cnt = 0; for (PointIndex pi = PointIndex::BASE; pi < bnp+PointIndex::BASE; pi++) - meshing.AddPoint ( (*mesh)[pi], pi); - + if ( (*mesh)[pi].GetLayer() == geometry.GetDomainLayer(domnr)) + { + meshing.AddPoint ( (*mesh)[pi], pi); + cnt++; + compress[pi] = cnt; + } PointGeomInfo gi; gi.trignum = 1; for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++) { if ( (*mesh)[si].domin == domnr) - meshing.AddBoundaryElement ( (*mesh)[si][0] + 1 - PointIndex::BASE, - (*mesh)[si][1] + 1 - PointIndex::BASE, gi, gi); + { + meshing.AddBoundaryElement ( compress[(*mesh)[si][0]], + compress[(*mesh)[si][1]], gi, gi); + } if ( (*mesh)[si].domout == domnr) - meshing.AddBoundaryElement ( (*mesh)[si][1] + 1 - PointIndex::BASE, - (*mesh)[si][0] + 1 - PointIndex::BASE, gi, gi); + { + meshing.AddBoundaryElement ( compress[(*mesh)[si][1]], + compress[(*mesh)[si][0]], gi, gi); + + } + } diff --git a/libsrc/geom2d/geom2dmesh.hpp b/libsrc/geom2d/geom2dmesh.hpp index 88971043..df4f1d99 100644 --- a/libsrc/geom2d/geom2dmesh.hpp +++ b/libsrc/geom2d/geom2dmesh.hpp @@ -8,41 +8,44 @@ /**************************************************************************/ -class Refinement2d : public Refinement +namespace netgen { - const SplineGeometry2d & geometry; -public: - Refinement2d (const SplineGeometry2d & ageometry); - virtual ~Refinement2d (); + class Refinement2d : public Refinement + { + const SplineGeometry2d & geometry; + + public: + Refinement2d (const SplineGeometry2d & ageometry); + virtual ~Refinement2d (); - virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point<3> & newp, PointGeomInfo & newgi); + virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, + int surfi, + const PointGeomInfo & gi1, + const PointGeomInfo & gi2, + Point<3> & newp, PointGeomInfo & newgi); - virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point<3> & newp, EdgePointGeomInfo & newgi); + virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, + int surfi1, int surfi2, + const EdgePointGeomInfo & ap1, + const EdgePointGeomInfo & ap2, + Point<3> & newp, EdgePointGeomInfo & newgi); - virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, - const EdgePointGeomInfo & ap1) const; + virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, + const EdgePointGeomInfo & ap1) const; - virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, - const PointGeomInfo & gi) const; + virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, + const PointGeomInfo & gi) const; - virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */); - - virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, - const EdgePointGeomInfo & egi) const; -}; + virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */); + virtual void ProjectToEdge (Point<3> & p, int surfi1, int surfi2, + const EdgePointGeomInfo & egi) const; + }; +} diff --git a/libsrc/geom2d/geometry2d.hpp b/libsrc/geom2d/geometry2d.hpp index 6601f58f..bc05806c 100644 --- a/libsrc/geom2d/geometry2d.hpp +++ b/libsrc/geom2d/geometry2d.hpp @@ -10,11 +10,10 @@ #include #include -namespace netgen -{ + #include "spline.hpp" #include "splinegeometry.hpp" #include "geom2dmesh.hpp" -} + #endif diff --git a/libsrc/geom2d/spline.hpp b/libsrc/geom2d/spline.hpp index c45ad910..1487d623 100644 --- a/libsrc/geom2d/spline.hpp +++ b/libsrc/geom2d/spline.hpp @@ -7,6 +7,9 @@ /* Date: 24. Jul. 96 */ /**************************************************************************/ +namespace netgen +{ + void CalcPartition (double l, double h, double h1, double h2, double hcurve, double elto0, Array & points); @@ -60,6 +63,14 @@ public: bool hpref_left; /// perfrom anisotropic refinement (hp-refinement) to edge bool hpref_right; + /// + int layer; + + + SplineSeg () + { + layer = 1; + } /// calculates length of curve virtual double Length () const; @@ -344,10 +355,18 @@ void SplineSeg :: Partition (double h, double elto0, Vec<3> v (1e-4*h, 1e-4*h, 1e-4*h); searchtree.GetIntersecting (oldmark3 - v, oldmark3 + v, locsearch); - if (locsearch.Size()) pi1 = locsearch[0]; + + for (int k = 0; k < locsearch.Size(); k++) + if ( mesh[PointIndex(locsearch[k])].GetLayer() == layer) + pi1 = locsearch[k]; + // if (locsearch.Size()) pi1 = locsearch[0]; searchtree.GetIntersecting (mark3 - v, mark3 + v, locsearch); - if (locsearch.Size()) pi2 = locsearch[0]; + for (int k = 0; k < locsearch.Size(); k++) + if ( mesh[PointIndex(locsearch[k])].GetLayer() == layer) + pi2 = locsearch[k]; + // if (locsearch.Size()) pi2 = locsearch[0]; + /* for (PointIndex pk = PointIndex::BASE; pk < mesh.GetNP()+PointIndex::BASE; pk++) @@ -363,20 +382,15 @@ void SplineSeg :: Partition (double h, double elto0, if (pi1 == -1) { - pi1 = mesh.AddPoint(oldmark3); + pi1 = mesh.AddPoint(oldmark3, layer); searchtree.Insert (oldmark3, pi1); } if (pi2 == -1) { - pi2 = mesh.AddPoint(mark3); + pi2 = mesh.AddPoint(mark3, layer); searchtree.Insert (mark3, pi2); } - /* - cout << "pi1 = " << pi1 << endl; - cout << "pi2 = " << pi2 << endl; - cout << "leftdom = " << leftdom << ", rightdom = " << rightdom << endl; - */ Segment seg; seg.edgenr = segnr; seg.si = bc; // segnr; @@ -854,6 +868,9 @@ typedef CircleSeg<2> CircleSegment; typedef DiscretePointsSeg<2> DiscretePointsSegment; +} + + #endif diff --git a/libsrc/geom2d/splinegeometry.cpp b/libsrc/geom2d/splinegeometry.cpp index 4a2800d2..ddf1292a 100644 --- a/libsrc/geom2d/splinegeometry.cpp +++ b/libsrc/geom2d/splinegeometry.cpp @@ -295,6 +295,8 @@ void SplineGeometry :: LoadDataV2 ( ifstream & infile ) quadmeshing = false; tensormeshing.SetSize ( numdomains ); tensormeshing = false; + layer.SetSize ( numdomains ); + layer = 1; TestComment ( infile ); @@ -329,6 +331,7 @@ void SplineGeometry :: LoadDataV2 ( ifstream & infile ) maxh[domainnr-1] = flags.GetNumFlag ( "maxh", 1000); if (flags.GetDefineFlag("quad")) quadmeshing[domainnr-1] = true; if (flags.GetDefineFlag("tensor")) tensormeshing[domainnr-1] = true; + layer[domainnr-1] = int(flags.GetNumFlag ("layer", 1)); } } } @@ -989,11 +992,15 @@ void SplineGeometry :: PartitionBoundary (double h, Mesh & mesh2d) pmax(j) = bbox.PMax()(j); } - - if (printmessage_importance>0) - cout << "searchtree from " << pmin << " to " << pmax << endl; Point3dTree searchtree (pmin, pmax); + for (int i = 0; i < splines.Size(); i++) + for (int side = 0; side <= 1; side++) + { + int dom = (side == 0) ? splines[i]->leftdom : splines[i]->rightdom; + if (dom != 0) splines[i] -> layer = GetDomainLayer (dom); + } + for (int i = 0; i < splines.Size(); i++) if (splines[i]->copyfrom == -1) { diff --git a/libsrc/geom2d/splinegeometry.hpp b/libsrc/geom2d/splinegeometry.hpp index 3cb17ca4..7b1f28c1 100644 --- a/libsrc/geom2d/splinegeometry.hpp +++ b/libsrc/geom2d/splinegeometry.hpp @@ -13,139 +13,148 @@ in geom2d only 2D - Geometry classes (with material properties etc.) - - #ifndef _FILE_SPLINEGEOMETRY #define _FILE_SPLINEGEOMETRY #include "../csg/csgparser.hpp" -/// -extern void LoadBoundarySplines (const char * filename, - Array < GeomPoint<2> > & geompoints, - Array < SplineSeg<2>* > & splines, - double & elto0); -/// -extern void PartitionBoundary (const Array < SplineSeg<2>* > & splines, - double h, double elto0, - Mesh & mesh2d); - -// allow to turn off messages: cover all couts !! -extern int printmessage_importance; - -template < int D > -class SplineGeometry +namespace netgen { - Array < GeomPoint > geompoints; - Array < SplineSeg* > splines; - double elto0; - Array materials; - Array bcnames; - Array maxh; - Array quadmeshing; - Array tensormeshing; -private: - void AppendSegment(SplineSeg * spline, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom); + /// + extern void LoadBoundarySplines (const char * filename, + Array < GeomPoint<2> > & geompoints, + Array < SplineSeg<2>* > & splines, + double & elto0); + /// + extern void PartitionBoundary (const Array < SplineSeg<2>* > & splines, + double h, double elto0, + Mesh & mesh2d); -public: - ~SplineGeometry(); - int Load (const Array & raw_data, const int startpos = 0); - void Load (const char * filename); - void CSGLoad (CSGScanner & scan); + // allow to turn off messages: cover all couts !! + extern int printmessage_importance; - void LoadData( ifstream & infile ); - void LoadDataNew ( ifstream & infile ); - void LoadDataV2 ( ifstream & infile ); + template < int D > + class SplineGeometry + { + Array < GeomPoint > geompoints; + Array < SplineSeg* > splines; + double elto0; + Array materials; + Array bcnames; + Array maxh; + Array quadmeshing; + Array tensormeshing; + Array layer; - void PartitionBoundary (double h, Mesh & mesh2d); + private: + void AppendSegment(SplineSeg * spline, const int leftdomain, const int rightdomain, + const int bc, + const double reffac, const bool hprefleft, const bool hprefright, + const int copyfrom); - void GetRawData (Array & raw_data) const; + public: + ~SplineGeometry(); - void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); + int Load (const Array & raw_data, const int startpos = 0); + void Load (const char * filename); + void CSGLoad (CSGScanner & scan); - const Array*> & GetSplines () const - { return splines; } + void LoadData( ifstream & infile ); + void LoadDataNew ( ifstream & infile ); + void LoadDataV2 ( ifstream & infile ); - int GetNSplines (void) const { return splines.Size(); } - string GetSplineType (const int i) const { return splines[i]->GetType(); } - SplineSeg & GetSpline (const int i) {return *splines[i];} - const SplineSeg & GetSpline (const int i) const {return *splines[i];} + void PartitionBoundary (double h, Mesh & mesh2d); - void GetBoundingBox (Box & box) const; - Box GetBoundingBox () const - { Box box; GetBoundingBox (box); return box; } + void GetRawData (Array & raw_data) const; - int GetNP () const { return geompoints.Size(); } - const GeomPoint & GetPoint(int i) const { return geompoints[i]; } + void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); - void SetGrading (const double grading); - // void AppendPoint (const double x, const double y, const double reffac = 1., const bool hpref = false); - void AppendPoint (const Point & p, const double reffac = 1., const bool hpref = false); + const Array*> & GetSplines () const + { return splines; } + + int GetNSplines (void) const { return splines.Size(); } + string GetSplineType (const int i) const { return splines[i]->GetType(); } + SplineSeg & GetSpline (const int i) {return *splines[i];} + const SplineSeg & GetSpline (const int i) const {return *splines[i];} + + void GetBoundingBox (Box & box) const; + Box GetBoundingBox () const + { Box box; GetBoundingBox (box); return box; } + + int GetNP () const { return geompoints.Size(); } + const GeomPoint & GetPoint(int i) const { return geompoints[i]; } + + void SetGrading (const double grading); + // void AppendPoint (const double x, const double y, const double reffac = 1., const bool hpref = false); + void AppendPoint (const Point & p, const double reffac = 1., const bool hpref = false); - void AppendLineSegment (const int n1, const int n2, - const int leftdomain, const int rightdomain, const int bc = -1, - const double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - void AppendSplineSegment (const int n1, const int n2, const int n3, + void AppendLineSegment (const int n1, const int n2, const int leftdomain, const int rightdomain, const int bc = -1, const double reffac = 1., const bool hprefleft = false, const bool hprefright = false, const int copyfrom = -1); - void AppendCircleSegment (const int n1, const int n2, const int n3, - const int leftdomain, const int rightdomain, const int bc = -1, - const double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - void AppendDiscretePointsSegment (const Array< Point > & points, - const int leftdomain, const int rightdomain, const int bc = -1, - const double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - void TestComment ( ifstream & infile ) ; - void GetMaterial( const int domnr, char* & material ); + void AppendSplineSegment (const int n1, const int n2, const int n3, + const int leftdomain, const int rightdomain, const int bc = -1, + const double reffac = 1., + const bool hprefleft = false, const bool hprefright = false, + const int copyfrom = -1); + void AppendCircleSegment (const int n1, const int n2, const int n3, + const int leftdomain, const int rightdomain, const int bc = -1, + const double reffac = 1., + const bool hprefleft = false, const bool hprefright = false, + const int copyfrom = -1); + void AppendDiscretePointsSegment (const Array< Point > & points, + const int leftdomain, const int rightdomain, const int bc = -1, + const double reffac = 1., + const bool hprefleft = false, const bool hprefright = false, + const int copyfrom = -1); + void TestComment ( ifstream & infile ) ; + void GetMaterial( const int domnr, char* & material ); - double GetDomainMaxh ( const int domnr ); - bool GetDomainQuadMeshing ( int domnr ) - { - if ( quadmeshing.Size() ) return quadmeshing[domnr-1]; - else return false; - } - bool GetDomainTensorMeshing ( int domnr ) - { - if ( tensormeshing.Size() ) return tensormeshing[domnr-1]; - else return false; - } + double GetDomainMaxh ( const int domnr ); + bool GetDomainQuadMeshing ( int domnr ) + { + if ( quadmeshing.Size() ) return quadmeshing[domnr-1]; + else return false; + } + bool GetDomainTensorMeshing ( int domnr ) + { + if ( tensormeshing.Size() ) return tensormeshing[domnr-1]; + else return false; + } + int GetDomainLayer ( int domnr ) + { + if ( layer.Size() ) return layer[domnr-1]; + else return 1; + } - string GetBCName ( const int bcnr ) const; + string GetBCName ( const int bcnr ) const; - string * BCNamePtr ( const int bcnr ); + string * BCNamePtr ( const int bcnr ); -}; + }; -void MeshFromSpline2D (SplineGeometry<2> & geometry, - Mesh *& mesh, - MeshingParameters & mp); + void MeshFromSpline2D (SplineGeometry<2> & geometry, + Mesh *& mesh, + MeshingParameters & mp); -class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry -{ -public: - virtual ~SplineGeometry2d(); + class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry + { + public: + virtual ~SplineGeometry2d(); - virtual int GenerateMesh (Mesh*& mesh, - int perfstepsstart, int perfstepsend, char* optstring); + virtual int GenerateMesh (Mesh*& mesh, + int perfstepsstart, int perfstepsend, char* optstring); - virtual const Refinement & GetRefinement () const; -}; + virtual const Refinement & GetRefinement () const; + }; +} #endif // _FILE_SPLINEGEOMETRY diff --git a/libsrc/include/nginterface_v2.hpp b/libsrc/include/nginterface_v2.hpp index 43ba546a..033c3932 100644 --- a/libsrc/include/nginterface_v2.hpp +++ b/libsrc/include/nginterface_v2.hpp @@ -79,7 +79,16 @@ namespace netgen DLL_HEADER Ng_Element Ng_GetElement (int nr); + + class Ng_Point + { + public: + double * pt; + double operator[] (int i) + { return pt[i]; } + }; + DLL_HEADER Ng_Point Ng_GetPoint (int nr); @@ -127,8 +136,7 @@ namespace netgen template DLL_HEADER int Ng_GetElementIndex (int nr); - - + /// Curved Elements: diff --git a/ng/nginterface_v2.cpp b/ng/nginterface_v2.cpp index 93279ed4..c0b2ca77 100644 --- a/ng/nginterface_v2.cpp +++ b/ng/nginterface_v2.cpp @@ -155,6 +155,13 @@ namespace netgen } + DLL_HEADER Ng_Point Ng_GetPoint (int nr) + { + Ng_Point ret; + ret.pt = &mesh->Point(nr + PointIndex::BASE)(0); + } + + template <> DLL_HEADER int Ng_GetElementIndex<1> (int nr) { @@ -175,9 +182,6 @@ namespace netgen } - - - template <> DLL_HEADER void Ng_MultiElementTransformation<3,3> (int elnr, int npts, const double * xi, int sxi,