namespaces, layers for 2D geometry

This commit is contained in:
Joachim Schoeberl 2009-09-07 11:50:13 +00:00
parent c429a6cc6c
commit 975d220350
29 changed files with 2608 additions and 2465 deletions

View File

@ -3,348 +3,351 @@
/**************************************************************************/ /**************************************************************************/
/* File: algprim.hh */ /* File: algprim.hpp */
/* Author: Joachim Schoeberl */ /* Author: Joachim Schoeberl */
/* Date: 1. Dez. 95 */ /* 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs);
virtual void GetPrimitiveData (const char *& classname, Array<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs);
virtual void GetPrimitiveData (const char *& classname, Array<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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 */ , virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
double /* rad */) const; double /* rad */) const;
private: private:
void CalcData(); 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & coeffs);
/// ///
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; class Ellipsoid : public QuadraticSurface
/// {
virtual double HesseNorm () const; 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & coeffs);
virtual void GetTriangleApproximation (TriangleApproximation & tas, ///
const Box<3> & bbox, virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
double facets) const; ///
virtual double HesseNorm () const;
private: virtual double LocH (const Point<3> & p, double x,
void CalcData(); 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 /// Torus
/// Lorenzo Codecasa (codecasa@elet.polimi.it) /// Lorenzo Codecasa (codecasa@elet.polimi.it)
/// April 27th, 2005 /// April 27th, 2005
/// ///
/// begin... /// begin...
class Torus : public OneSurfacePrimitive class Torus : public OneSurfacePrimitive
{ {
/// center of the torus /// center of the torus
Point<3> c; Point<3> c;
/// vector normal to the symmetry plane of the torus /// vector normal to the symmetry plane of the torus
Vec<3> n; Vec<3> n;
/// Large radius of the torus /// Large radius of the torus
double R; double R;
/// Small radius of the torus /// Small radius of the torus
double r; double r;
public: public:
/// OK /// OK
Torus (const Point<3> & ac, const Vec<3> & an, double aR, double ar); Torus (const Point<3> & ac, const Vec<3> & an, double aR, double ar);
/// OK /// OK
const Point<3> & Center () const { return c; } const Point<3> & Center () const { return c; }
/// OK /// OK
const Vec<3> & NormalToPlane () const { return n; } const Vec<3> & NormalToPlane () const { return n; }
/// OK /// OK
double LargeRadius () const { return R; } double LargeRadius () const { return R; }
/// OK /// OK
double SmallRadius () const { return r; } double SmallRadius () const { return r; }
/// OK /// OK
virtual double CalcFunctionValue (const Point<3> & point) const; virtual double CalcFunctionValue (const Point<3> & point) const;
/// OK /// OK
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
/// OK /// OK
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
/// OK /// OK
virtual double HesseNorm () const; virtual double HesseNorm () const;
/// OK /// OK
virtual Point<3> GetSurfacePoint () const; virtual Point<3> GetSurfacePoint () const;
/// OK /// OK
virtual void GetPrimitiveData (const char *& classname, virtual void GetPrimitiveData (const char *& classname,
Array<double> & coeffs) const; Array<double> & coeffs) const;
/// OK /// OK
virtual void SetPrimitiveData (Array<double> & coeffs); virtual void SetPrimitiveData (Array<double> & coeffs);
/// OK /// OK
static Primitive * CreateDefault (); static Primitive * CreateDefault ();
/// OK /// OK
virtual Primitive * Copy () const; virtual Primitive * Copy () const;
/// OK /// OK
virtual void Transform (Transformation<3> & trans); virtual void Transform (Transformation<3> & trans);
/// OK /// OK
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
/// OK /// OK
/// virtual void DefineTangentialPlane (const Point<3> & ap1, /// virtual void DefineTangentialPlane (const Point<3> & ap1,
// const Point<3> & ap2); // const Point<3> & ap2);
/// OK /// OK
/// virtual void ToPlane (const Point<3> & p3d, /// virtual void ToPlane (const Point<3> & p3d,
/// Point<2> & pplane, /// Point<2> & pplane,
/// double h, int & zone) const; /// double h, int & zone) const;
/// OK /// OK
/// virtual void FromPlane (const Point<2> & pplane, /// virtual void FromPlane (const Point<2> & pplane,
// Point<3> & p, double h) const; // Point<3> & p, double h) const;
/// OK /// OK
/// virtual void Project (Point<3> & p) const; /// virtual void Project (Point<3> & p) const;
/// OK /// OK
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
/// OK /// OK
virtual void GetTriangleApproximation (TriangleApproximation & tas, virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & bbox, const Box<3> & bbox,
double facets) const; double facets) const;
/// OK /// OK
virtual void Print (ostream & ist) const; virtual void Print (ostream & ist) const;
/// OK /// OK
virtual void Read (istream & ist); virtual void Read (istream & ist);
}; };
/// ...end
/// ...end
}

View File

@ -8,113 +8,119 @@
/* Date: 11. Mar. 98 */ /* Date: 11. Mar. 98 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
/*
brick geometry, has several surfaces brick geometry, has several surfaces
*/ */
class Parallelogram3d : public Surface class Parallelogram3d : public Surface
{ {
Point<3> p1, p2, p3, p4; Point<3> p1, p2, p3, p4;
Vec<3> v12, v13; Vec<3> v12, v13;
Vec<3> n; Vec<3> n;
public: public:
Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3); Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3);
virtual ~Parallelogram3d (); 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 double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const; virtual double HesseNorm () const;
virtual Point<3> GetSurfacePoint () const; virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const; virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas, virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox, const Box<3> & boundingbox,
double facets) const; double facets) const;
protected: protected:
void CalcData(); void CalcData();
}; };
class Brick : public Primitive class Brick : public Primitive
{ {
Point<3> p1, p2, p3, p4; Point<3> p1, p2, p3, p4;
Vec<3> v12, v13, v14; Vec<3> v12, v13, v14;
// Array<OneSurfacePrimitive*> faces; // Array<OneSurfacePrimitive*> faces;
Array<Plane*> faces; Array<Plane*> faces;
public: public:
Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4); Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4);
virtual ~Brick (); virtual ~Brick ();
static Primitive * CreateDefault (); static Primitive * CreateDefault ();
virtual Primitive * Copy () const; virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans); 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; double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p, virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v, const Vec<3> & v1,
double eps) const; const Vec<3> & v2,
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, double eps) const;
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
const Vec<3> & v1, const Vec<3> & v1,
const Vec<3> & v2, const Vec<3> & v2,
double eps) const; double eps) const;
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v, const Vec<3> & v,
const Vec<3> & v2, const Vec<3> & v2,
const Vec<3> & m, const Vec<3> & m,
double eps) const; double eps) const;
virtual int GetNSurfaces() const virtual int GetNSurfaces() const
{ return 6; } { return 6; }
virtual Surface & GetSurface (int i) virtual Surface & GetSurface (int i)
{ return *faces[i]; } { return *faces[i]; }
virtual const Surface & GetSurface (int i) const virtual const Surface & GetSurface (int i) const
{ return *faces[i]; } { return *faces[i]; }
virtual void GetPrimitiveData (const char *& classname, Array<double> & coeffs) const; virtual void GetPrimitiveData (const char *& classname, Array<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & coeffs); virtual void SetPrimitiveData (Array<double> & coeffs);
virtual void Reduce (const BoxSphere<3> & box); virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce (); virtual void UnReduce ();
protected: protected:
void CalcData(); void CalcData();
}; };
class OrthoBrick : public Brick class OrthoBrick : public Brick
{ {
protected: protected:
Point<3> pmin, pmax; Point<3> pmin, pmax;
public: public:
OrthoBrick (const Point<3> & ap1, const Point<3> & ap2); OrthoBrick (const Point<3> & ap1, const Point<3> & ap2);
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual void Reduce (const BoxSphere<3> & box); virtual void Reduce (const BoxSphere<3> & box);
}; };
}
#endif #endif

View File

@ -13,8 +13,10 @@
#include <geometry2d.hpp> #include <geometry2d.hpp>
namespace netgen
{
#include "surface.hpp" #include "surface.hpp"
#include "solid.hpp" #include "solid.hpp"
#include "identify.hpp" #include "identify.hpp"
@ -22,16 +24,8 @@ namespace netgen
#include "csgeom.hpp" #include "csgeom.hpp"
#include "csgparser.hpp" #include "csgparser.hpp"
#ifndef SMALLLIB
#define _INCLUDE_MORE
#endif
//#ifdef LINUX
#define _INCLUDE_MORE
//#endif
#ifdef _INCLUDE_MORE
#include "triapprox.hpp" #include "triapprox.hpp"
#include "algprim.hpp" #include "algprim.hpp"
#include "brick.hpp" #include "brick.hpp"
#include "spline3d.hpp" #include "spline3d.hpp"
@ -45,7 +39,6 @@ namespace netgen
#include "specpoin.hpp" #include "specpoin.hpp"
#include "edgeflw.hpp" #include "edgeflw.hpp"
#include "meshsurf.hpp" #include "meshsurf.hpp"
#endif
}
#endif #endif

View File

@ -7,312 +7,315 @@
/* Date: 27. Nov. 97 */ /* Date: 27. Nov. 97 */
/**************************************************************************/ /**************************************************************************/
/** namespace netgen
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
{ {
Solid * solid;
Surface * surface;
double red, blue, green; /**
bool visible, transp; Constructive Solid Geometry
double maxh; */
string material;
int layer;
int bc; // for surface patches, only
string bcname;
public:
TopLevelObject (Solid * asolid,
Surface * asurface = NULL);
const Solid * GetSolid() const { return solid; } class TriangleApproximation;
Solid * GetSolid() { return solid; } class TATriangle;
const Surface * GetSurface () const { return surface; }
Surface * GetSurface () { return surface; }
void GetData (ostream & ost); /**
void SetData (istream & ist); A top level object is an entity to be meshed.
I can be either a solid, or one surface patch of a solid.
void SetMaxH (double amaxh) { maxh = amaxh; } */
double GetMaxH () const { return maxh; } class TopLevelObject
void SetRGB (double ared, double agreen, double ablue)
{ {
red = ared; Solid * solid;
green = agreen; Surface * surface;
blue = ablue;
}
double GetRed () const { return red; } double red, blue, green;
double GetGreen () const { return green; } bool visible, transp;
double GetBlue () const { return blue; } 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<Surface*> surfaces;
public:
/// primitive of surface
Array<const Primitive*> surf2prim;
private:
Array<Surface*> delete_them;
/// all named solids
SYMBOLTABLE<Solid*> solids;
/// all 2d splinecurves
SYMBOLTABLE< SplineGeometry<2>* > splinecurves2d;
/// all 3d splinecurves
SYMBOLTABLE< SplineGeometry<3>* > splinecurves3d;
/// all top level objects: solids and surfaces
Array<TopLevelObject*> toplevelobjects;
/// additional points specified by user
Array<Point<3> > userpoints;
Array<double> userpoints_ref_factor;
mutable Array<Point<3> > identpoints;
/// triangular approximation of top level objects
Array<TriangleApproximation*> 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<int> identicsurfaces;
Array<int> 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<Solid*> & 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<SingularFace*> singfaces;
Array<SingularEdge*> singedges;
Array<SingularPoint*> singpoints;
Array<Identification*> 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<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const BoxSphere<3> & box,
Array<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const Point<3> & p, Vec<3> & v,
Array<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (Array<int> & 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: public:
int si; TopLevelObject (Solid * asolid,
int tlonr; Surface * asurface = NULL);
int bcnr;
string * bcname; 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<BCModification> 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<Surface*> surfaces;
public:
/// primitive of surface
Array<const Primitive*> surf2prim;
private:
Array<Surface*> delete_them;
/// all named solids
SYMBOLTABLE<Solid*> solids;
/// all 2d splinecurves
SYMBOLTABLE< SplineGeometry<2>* > splinecurves2d;
/// all 3d splinecurves
SYMBOLTABLE< SplineGeometry<3>* > splinecurves3d;
/// all top level objects: solids and surfaces
Array<TopLevelObject*> toplevelobjects;
/// additional points specified by user
Array<Point<3> > userpoints;
Array<double> userpoints_ref_factor;
mutable Array<Point<3> > identpoints;
/// triangular approximation of top level objects
Array<TriangleApproximation*> 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<int> identicsurfaces;
Array<int> 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<Solid*> & 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<SingularFace*> singfaces;
Array<SingularEdge*> singedges;
Array<SingularPoint*> singpoints;
Array<Identification*> 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<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const BoxSphere<3> & box,
Array<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (const Solid * sol,
const Point<3> & p, Vec<3> & v,
Array<int> & locsurf) const;
///
void GetIndependentSurfaceIndices (Array<int> & 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<BCModification> bcmodifications;
virtual int GenerateMesh (Mesh*& mesh,
int perfstepsstart, int perfstepsend, char* optstring);
virtual const Refinement & GetRefinement () const;
};
}
#endif #endif

View File

@ -2,10 +2,9 @@
#define _CSGPARSER_HPP #define _CSGPARSER_HPP
namespace netgen
{
//namespace netgen
//{
enum TOKEN_TYPE enum TOKEN_TYPE
{ {
TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']', TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']',
@ -94,14 +93,9 @@
//} }
#endif
#endif // _CSGPARSER_HPP

View File

@ -7,53 +7,61 @@
/* Date: 24. Jul. 96 */ /* Date: 24. Jul. 96 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
/*
2D Curve repesentation 2D Curve repesentation
*/ */
/// ///
class Curve2d : public Manifold class Curve2d : public Manifold
{ {
public: public:
/// ///
virtual void Project (Point<2> & p) const = 0; virtual void Project (Point<2> & p) const = 0;
/// ///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) 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; Point<2> center;
/// ///
double rad; double rad;
public: public:
/// ///
CircleCurve2d (const Point<2> & acenter, double arad); CircleCurve2d (const Point<2> & acenter, double arad);
/// ///
virtual void Project (Point<2> & p) const; virtual void Project (Point<2> & p) const;
/// ///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
}; };
///
class QuadraticCurve2d : public Curve2d
{
/// ///
double cxx, cyy, cxy, cx, cy, c; class QuadraticCurve2d : public Curve2d
public: {
/// ///
QuadraticCurve2d (); double cxx, cyy, cxy, cx, cy, c;
/// public:
void Read (istream & ist); ///
/// QuadraticCurve2d ();
virtual void Project (Point<2> & p) const; ///
/// void Read (istream & ist);
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; ///
}; virtual void Project (Point<2> & p) const;
///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
};
}
#endif #endif

View File

@ -7,98 +7,104 @@
/* Date: 01. Okt. 95 */ /* Date: 01. Okt. 95 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
Edge - following function and
Projection to edge of implicitly given edge
*/
/*
Edge - following function and
Projection to edge of implicitly given edge
*/
/** /**
Calculates edges. Calculates edges.
The edges of a solid geometry are computed. Special The edges of a solid geometry are computed. Special
points have to be given. points have to be given.
*/ */
extern void CalcEdges (const CSGeometry & geometry, extern void CalcEdges (const CSGeometry & geometry,
const Array<SpecialPoint> & specpoints, const Array<SpecialPoint> & specpoints,
double h, Mesh & mesh); double h, Mesh & mesh);
class EdgeCalculation class EdgeCalculation
{ {
const CSGeometry & geometry; const CSGeometry & geometry;
Array<SpecialPoint> & specpoints; Array<SpecialPoint> & specpoints;
Point3dTree * searchtree; Point3dTree * searchtree;
Point3dTree * meshpoint_tree; Point3dTree * meshpoint_tree;
int cntedge; int cntedge;
double ideps; double ideps;
public: public:
EdgeCalculation (const CSGeometry & ageometry, EdgeCalculation (const CSGeometry & ageometry,
Array<SpecialPoint> & aspecpoints); Array<SpecialPoint> & 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: private:
void CalcEdges1 (double h, Mesh & mesh); void CalcEdges1 (double h, Mesh & mesh);
void FollowEdge (int pi1, int & ep, int & pos, void FollowEdge (int pi1, int & ep, int & pos,
// const Array<SpecialPoint> & hsp, // const Array<SpecialPoint> & hsp,
const Array<int> & hsp, const Array<int> & hsp,
double h, const Mesh & mesh, double h, const Mesh & mesh,
Array<Point<3> > & edgepoints, Array<Point<3> > & edgepoints,
Array<double> & curvelength); Array<double> & 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<Point<3> > & edgepoints,
Array<Segment> & refedges,
Array<bool> & refedgesinv);
void StoreEdge (const Array<Segment> & refedges,
const Array<bool> & refedgesinv,
const Array<Point<3> > & edgepoints, const Array<Point<3> > & edgepoints,
Array<Segment> & refedges, const Array<double> & curvelength,
Array<bool> & refedgesinv); int layer,
Mesh & mesh);
void StoreEdge (const Array<Segment> & refedges, void StoreShortEdge (const Array<Segment> & refedges,
const Array<bool> & refedgesinv, const Array<bool> & refedgesinv,
const Array<Point<3> > & edgepoints, const Array<Point<3> > & edgepoints,
const Array<double> & curvelength, const Array<double> & curvelength,
int layer, int layer,
Mesh & mesh); Mesh & mesh);
void StoreShortEdge (const Array<Segment> & refedges, void CopyEdge (const Array<Segment> & refedges,
const Array<bool> & refedgesinv, const Array<bool> & refedgesinv,
const Array<Point<3> > & edgepoints, int copyfromedge,
const Array<double> & curvelength, const Point<3> & fromstart, const Point<3> & fromend,
int layer, const Point<3> & tostart, const Point<3> & toend,
Mesh & mesh); int copyedgeidentification,
int layer,
void CopyEdge (const Array<Segment> & refedges, Mesh & mesh);
const Array<bool> & 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 SplitEqualOneSegEdges (Mesh & mesh);
void FindClosedSurfaces (double h, Mesh & mesh); void FindClosedSurfaces (double h, Mesh & mesh);
public: public:
bool point_on_edge_problem; bool point_on_edge_problem;
}; };
}
#endif #endif

View File

@ -7,103 +7,107 @@
/* Date: 14. Oct. 96 */ /* Date: 14. Oct. 96 */
/**************************************************************************/ /**************************************************************************/
/*
namespace netgen
{
/*
Explicit 2D Curve repesentation Explicit 2D Curve repesentation
*/ */
///
class ExplicitCurve2d : public Curve2d
{
public:
/// ///
ExplicitCurve2d (); class ExplicitCurve2d : public Curve2d
{
public:
///
ExplicitCurve2d ();
/// ///
virtual void Project (Point<2> & p) const; virtual void Project (Point<2> & p) const;
/// ///
virtual double ProjectParam (const Point<2> & p) const = 0; virtual double ProjectParam (const Point<2> & p) const = 0;
/// ///
virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const; virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const;
/// ///
virtual double MinParam () const = 0; virtual double MinParam () const = 0;
/// ///
virtual double MaxParam () const = 0; virtual double MaxParam () const = 0;
/// ///
virtual Point<2> Eval (double t) const = 0; virtual Point<2> Eval (double t) const = 0;
/// ///
virtual Vec<2> EvalPrime (double t) const = 0; virtual Vec<2> EvalPrime (double t) const = 0;
/// ///
virtual Vec<2> Normal (double t) const; virtual Vec<2> Normal (double t) const;
/// ///
virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; virtual void NormalVector (const Point<2> & p, Vec<2> & n) const;
/// ///
virtual Vec<2> EvalPrimePrime (double t) const = 0; virtual Vec<2> EvalPrimePrime (double t) const = 0;
/// ///
virtual double MaxCurvature () const; virtual double MaxCurvature () const;
/// ///
virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const; virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const;
/// ///
virtual Point<2> CurvCircle (double t) const; virtual Point<2> CurvCircle (double t) const;
/// ///
virtual void Print (ostream & /* str */) const { }; virtual void Print (ostream & /* str */) const { };
/// ///
virtual int SectionUsed (double /* t */) const { return 1; } virtual int SectionUsed (double /* t */) const { return 1; }
/// ///
virtual void Reduce (const Point<2> & /* p */, double /* rad */) { }; virtual void Reduce (const Point<2> & /* p */, double /* rad */) { };
/// ///
virtual void UnReduce () { }; virtual void UnReduce () { };
}; };
///
class BSplineCurve2d : public ExplicitCurve2d
{
/// ///
Array<Point<2> > points; class BSplineCurve2d : public ExplicitCurve2d
/// {
Array<int> intervallused; ///
/// Array<Point<2> > points;
int redlevel; ///
Array<int> intervallused;
///
int redlevel;
public: public:
/// ///
BSplineCurve2d (); BSplineCurve2d ();
/// ///
void AddPoint (const Point<2> & apoint); 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 ProjectParam (const Point<2> & p) const;
/// ///
virtual double MinParam () const { return 0; } virtual double MinParam () const { return 0; }
/// ///
virtual double MaxParam () const { return points.Size(); } virtual double MaxParam () const { return points.Size(); }
/// ///
virtual Point<2> Eval (double t) const; virtual Point<2> Eval (double t) const;
/// ///
virtual Vec<2> EvalPrime (double t) const; virtual Vec<2> EvalPrime (double t) const;
/// ///
virtual Vec<2> EvalPrimePrime (double t) const; virtual Vec<2> EvalPrimePrime (double t) const;
/// ///
virtual void Print (ostream & str) 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 int SectionUsed (double t) const;
///
virtual void Reduce (const Point<2> & p, double rad);
///
virtual void UnReduce ();
};
}
#endif #endif

View File

@ -1,152 +1,155 @@
#ifndef _EXTRUSION_HPP #ifndef _EXTRUSION_HPP
#define _EXTRUSION_HPP #define _EXTRUSION_HPP
namespace netgen
class Extrusion;
class ExtrusionFace : public Surface
{ {
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 SplineSeg3<3> * > spline3_path;
Array< const LineSeg<3> * > line_path; Array< const LineSeg<3> * > line_path;
mutable Array < Vec<3> > x_dir, y_dir, z_dir, loc_z_dir; mutable Array < Vec<3> > x_dir, y_dir, z_dir, loc_z_dir;
mutable Array < Point<3> > p0; mutable Array < Point<3> > p0;
mutable Vec<3> profile_tangent; mutable Vec<3> profile_tangent;
mutable double profile_par; mutable double profile_par;
mutable Vector profile_spline_coeff; mutable Vector profile_spline_coeff;
mutable int latest_seg; mutable int latest_seg;
mutable double latest_t; mutable double latest_t;
mutable Point<2> latest_point2d; mutable Point<2> latest_point2d;
mutable Point<3> latest_point3d; mutable Point<3> latest_point3d;
private: private:
void Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const; void Orthogonalize(const Vec<3> & v1, Vec<3> & v2) const;
void Init(void); void Init(void);
public: public:
double CalcProj(const Point<3> & point3d, Point<2> & point2d, double CalcProj(const Point<3> & point3d, Point<2> & point2d,
int seg) const; int seg) const;
void CalcProj(const Point<3> & point3d, Point<2> & point2d, void CalcProj(const Point<3> & point3d, Point<2> & point2d,
int & seg, double & t) const; int & seg, double & t) const;
public: public:
ExtrusionFace(const SplineSeg<2> * profile_in, ExtrusionFace(const SplineSeg<2> * profile_in,
const SplineGeometry<3> * path_in, const SplineGeometry<3> * path_in,
const Vec<3> & z_direction); const Vec<3> & z_direction);
ExtrusionFace(const Array<double> & raw_data); ExtrusionFace(const Array<double> & 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 double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const; virtual double HesseNorm () const;
virtual double MaxCurvature () const; virtual double MaxCurvature () const;
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ , //virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
// double /* rad */) const; // double /* rad */) const;
virtual void Project (Point<3> & p) const; virtual void Project (Point<3> & p) const;
virtual Point<3> GetSurfacePoint () const; virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const; virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas, virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox, const Box<3> & boundingbox,
double facets) const; double facets) const;
const SplineGeometry<3> & GetPath(void) const {return *path;} const SplineGeometry<3> & GetPath(void) const {return *path;}
const SplineSeg<2> & GetProfile(void) const {return *profile;} 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, void LineIntersections ( const Point<3> & p,
const Vec<3> & v, const Vec<3> & v,
const double eps, const double eps,
int & before, int & before,
int & after, int & after,
bool & intersecting ) const; bool & intersecting ) const;
INSOLID_TYPE VecInFace ( const Point<3> & p, INSOLID_TYPE VecInFace ( const Point<3> & p,
const Vec<3> & v, const Vec<3> & v,
const double eps ) const; const double eps ) const;
const Vec<3> & GetYDir ( void ) const {return y_dir[latest_seg];} const Vec<3> & GetYDir ( void ) const {return y_dir[latest_seg];}
const Vec<3> & GetProfileTangent (void) const {return profile_tangent;} const Vec<3> & GetProfileTangent (void) const {return profile_tangent;}
double GetProfilePar(void) const {return profile_par;} double GetProfilePar(void) const {return profile_par;}
void GetRawData(Array<double> & data) const; void GetRawData(Array<double> & data) const;
void CalcLocalCoordinates (int seg, double t, void CalcLocalCoordinates (int seg, double t,
Vec<3> & ex, Vec<3> & ey, Vec<3> & ez) const; Vec<3> & ex, Vec<3> & ey, Vec<3> & ez) const;
void CalcLocalCoordinatesDeriv (int seg, double t, void CalcLocalCoordinatesDeriv (int seg, double t,
Vec<3> & ex, Vec<3> & ey, Vec<3> & ez, Vec<3> & ex, Vec<3> & ey, Vec<3> & ez,
Vec<3> & dex, Vec<3> & dey, Vec<3> & dez) const; Vec<3> & dex, Vec<3> & dey, Vec<3> & dez) const;
}; };
class Extrusion : public Primitive class Extrusion : public Primitive
{ {
private: private:
const SplineGeometry<3> & path; const SplineGeometry<3> & path;
const SplineGeometry<2> & profile; const SplineGeometry<2> & profile;
const Vec<3> & z_direction; const Vec<3> & z_direction;
Array<ExtrusionFace*> faces; Array<ExtrusionFace*> faces;
mutable int latestfacenum; mutable int latestfacenum;
public: public:
Extrusion(const SplineGeometry<3> & path_in, Extrusion(const SplineGeometry<3> & path_in,
const SplineGeometry<2> & profile_in, const SplineGeometry<2> & profile_in,
const Vec<3> & z_dir); const Vec<3> & z_dir);
~Extrusion(); ~Extrusion();
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;
INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps,
Array<int> * const facenums) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const; double eps) const;
INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps,
Array<int> * 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 // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v1, const Vec<3> & v1,
const Vec<3> & v2, const Vec<3> & v2,
double eps) const; double eps) const;
virtual int GetNSurfaces() const; virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0); virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const; virtual const Surface & GetSurface (int i = 0) const;
virtual void Reduce (const BoxSphere<3> & box); virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce (); virtual void UnReduce ();
}; };
}
#endif //_EXTRUSION_HPP #endif //_EXTRUSION_HPP

View File

@ -7,58 +7,64 @@
/* Date: 14. Oct. 96 */ /* Date: 14. Oct. 96 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
/*
Generalized Cylinder Generalized Cylinder
*/ */
///
class GeneralizedCylinder : public Surface
{
/// ///
ExplicitCurve2d & crosssection; class GeneralizedCylinder : public Surface
/// {
Point<3> planep;
///
Vec<3> planee1, planee2, planee3;
/// Vec<3> ex, ey, ez;
Vec2d e2x, e2y;
/// ///
Point<3> cp; ExplicitCurve2d & crosssection;
///
Point<3> planep;
///
Vec<3> planee1, planee2, planee3;
public: /// Vec<3> ex, ey, ez;
/// Vec2d e2x, e2y;
GeneralizedCylinder (ExplicitCurve2d & acrosssection, ///
Point<3> ap, Vec<3> ae1, Vec<3> ae2); Point<3> cp;
/// public:
virtual void Project (Point<3> & p) const; ///
GeneralizedCylinder (ExplicitCurve2d & acrosssection,
Point<3> ap, Vec<3> ae1, Vec<3> ae2);
/// ///
virtual int BoxInSolid (const BoxSphere<3> & box) const; virtual void Project (Point<3> & p) const;
/// 0 .. no, 1 .. yes, 2 .. maybe
virtual double CalcFunctionValue (const Point<3> & point) const; ///
/// virtual int BoxInSolid (const BoxSphere<3> & box) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; /// 0 .. no, 1 .. yes, 2 .. maybe
///
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 double CalcFunctionValue (const Point<3> & point) const;
virtual void Reduce (const BoxSphere<3> & box); ///
/// virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void UnReduce (); ///
}; 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 #endif

View File

@ -6,199 +6,205 @@
/* File: identify.hh */ /* File: identify.hh */
/* Author: Joachim Schoeberl */ /* Author: Joachim Schoeberl */
/* Date: 1. Aug. 99 */ /* Date: 1. Aug. 99 */
/**************************************************************************/ /**************************************************************************/
/**
Identify surfaces for periodic b.c. or
thin domains
*/
class SpecialPoint; namespace netgen
class Identification
{ {
protected:
const CSGeometry & geom;
// identified faces, index sorted
INDEX_2_HASHTABLE<int> identfaces;
int nr;
public: /**
Identification (int anr, const CSGeometry & ageom); Identify surfaces for periodic b.c. or
virtual ~Identification (); thin domains
virtual void Print (ostream & ost) const = 0; */
virtual void GetData (ostream & ost) const = 0;
/// obsolete
// virtual void IdentifySpecialPoints (Array<class SpecialPoint> & points);
/// can identify both special points (fixed direction) class SpecialPoint;
/// (identified points, same tangent) class Identification
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2, {
const TABLE<int> & specpoint2solid, protected:
const TABLE<int> & specpoint2surface) const; const CSGeometry & geom;
/// // identified faces, index sorted
virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; INDEX_2_HASHTABLE<int> identfaces;
/// is it possible to identify sp1 with some other ? int nr;
virtual int IdentifyableCandidate (const SpecialPoint & sp1) const;
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<class SpecialPoint> & points);
/// can identify both special points (fixed direction)
/// (identified points, same tangent)
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & 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) ? /// are points (if connected) by a short edge (direction anyhow) ?
virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const;
/// add entries in mesh identification tables /// add entries in mesh identification tables
virtual void IdentifyPoints (class Mesh & mesh); virtual void IdentifyPoints (class Mesh & mesh);
/// add entries to identified faces (based on segment infos) /// add entries to identified faces (based on segment infos)
virtual void IdentifyFaces (class Mesh & mesh); virtual void IdentifyFaces (class Mesh & mesh);
/// get point on other surface, add entry in mesh identifications /// get point on other surface, add entry in mesh identifications
virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1);
/// copy surfaces, or fill rectangles /// copy surfaces, or fill rectangles
virtual void BuildSurfaceElements (Array<class Segment> & segs, virtual void BuildSurfaceElements (Array<class Segment> & segs,
class Mesh & mesh, class Mesh & mesh,
const Surface * surf); const Surface * surf);
/// insert volume elements in thin layers /// insert volume elements in thin layers
virtual void BuildVolumeElements (Array<class Element2d> & surfels, virtual void BuildVolumeElements (Array<class Element2d> & surfels,
class Mesh & mesh); class Mesh & mesh);
/// get list of identified faces /// get list of identified faces
virtual void GetIdentifiedFaces (Array<INDEX_2> & idfaces) const; virtual void GetIdentifiedFaces (Array<INDEX_2> & idfaces) const;
friend ostream & operator<< (ostream & ost, Identification & ident); friend ostream & operator<< (ostream & ost, Identification & ident);
}; };
class PeriodicIdentification : public Identification class PeriodicIdentification : public Identification
{ {
const Surface * s1; const Surface * s1;
const Surface * s2; const Surface * s2;
public: public:
PeriodicIdentification (int anr, 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<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & 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<class Segment> & 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<double> slices;
/// used only for domain-local identification:
Array<int> 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<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & 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<double> & GetSlices () const { return slices; }
virtual void IdentifyPoints (class Mesh & mesh);
virtual void IdentifyFaces (class Mesh & mesh);
virtual void BuildSurfaceElements (Array<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
void BuildSurfaceElements2 (Array<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
virtual void BuildVolumeElements (Array<class Element2d> & 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 CSGeometry & ageom,
const Surface * afacet,
const Surface * as1, const Surface * as1,
const Surface * as2); const Surface * as2);
virtual ~CloseEdgesIdentification (); virtual ~PeriodicIdentification ();
virtual void Print (ostream & ost) const; virtual void Print (ostream & ost) const;
virtual void GetData (ostream & ost) const; virtual void GetData (ostream & ost) const;
// virtual void IdentifySpecialPoints (Array<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
virtual void IdentifyPoints (class Mesh & mesh); // virtual void IdentifySpecialPoints (Array<class SpecialPoint> & points);
virtual void BuildSurfaceElements (Array<class Segment> & segs, virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
class Mesh & mesh, const TABLE<int> & specpoint2solid,
const Surface * surf); const TABLE<int> & 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<class Segment> & 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<double> slices;
/// used only for domain-local identification:
Array<int> 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<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & 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<double> & GetSlices () const { return slices; }
virtual void IdentifyPoints (class Mesh & mesh);
virtual void IdentifyFaces (class Mesh & mesh);
virtual void BuildSurfaceElements (Array<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
void BuildSurfaceElements2 (Array<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
virtual void BuildVolumeElements (Array<class Element2d> & 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<class SpecialPoint> & points);
virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2,
const TABLE<int> & specpoint2solid,
const TABLE<int> & specpoint2surface) const;
virtual void IdentifyPoints (class Mesh & mesh);
virtual void BuildSurfaceElements (Array<class Segment> & segs,
class Mesh & mesh,
const Surface * surf);
};
}
#endif #endif

View File

@ -7,16 +7,23 @@
/* Date: 7. Aug. 96 */ /* Date: 7. Aug. 96 */
/**************************************************************************/ /**************************************************************************/
/** namespace netgen
Basis class for manifolds in 2d and 3d
*/
class Manifold
{ {
public:
///
Manifold (); /**
/// Basis class for manifolds in 2d and 3d
virtual ~Manifold (); */
}; class Manifold
{
public:
///
Manifold ();
///
virtual ~Manifold ();
};
}
#endif #endif

View File

@ -1,46 +1,49 @@
#ifndef FILE_MESHSURF #ifndef FILE_MESHSURF
#define FILE_MESHSURF #define FILE_MESHSURF
/// namespace netgen
class Meshing2Surfaces : public Meshing2
{ {
///
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, class Meshing2Surfaces : public Meshing2
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; 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); MeshOptimize2dSurfaces (const CSGeometry & ageometry);
@ -50,43 +53,44 @@ public:
virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const; virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point<3> & p) const;
/// ///
virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const; virtual void GetNormalVector(INDEX surfind, const Point<3> & p, Vec<3> & n) const;
}; };
class RefinementSurfaces : public Refinement class RefinementSurfaces : public Refinement
{ {
const CSGeometry & geometry; const CSGeometry & geometry;
public: public:
RefinementSurfaces (const CSGeometry & ageometry); RefinementSurfaces (const CSGeometry & ageometry);
virtual ~RefinementSurfaces (); virtual ~RefinementSurfaces ();
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi);
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi);
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const; const EdgePointGeomInfo & ap1) const;
virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, virtual Vec<3> GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const; 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 #endif

View File

@ -8,92 +8,97 @@
/* Date: 19. Mar. 2000 */ /* Date: 19. Mar. 2000 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
/*
Polyhedral primitive 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<Point<3> > & points,
int ainputnr);
};
Array<Point<3> > points;
Array<Face> faces;
Array<Plane*> planes;
Box<3> poly_bbox;
double eps_base1;
class Polyhedra : public Primitive
{
class Face {
public: public:
int pnums[3]; Polyhedra ();
int planenr; 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; // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
// Point<3> center; virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
Vec<3> v1, v2; // edges const Vec<3> & v1,
Vec<3> w1, w2; // pseudo-inverse const Vec<3> & v2,
Vec<3> n; // normal to face double eps) const;
Vec<3> nn; // normed normal
Face () { ; } virtual void GetTangentialSurfaceIndices (const Point<3> & p,
Face (int pi1, int pi2, int pi3, Array<int> & surfind, double eps) const;
const Array<Point<3> > & points,
int ainputnr);
virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
Array<int> & surfind, double eps) const;
virtual void CalcSpecialPoints (Array<Point<3> > & pts) const;
virtual void AnalyzeSpecialPoint (const Point<3> & pt,
Array<Point<3> > & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<int> * > & polysurfs);
protected:
int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const;
// void CalcData();
}; };
Array<Point<3> > points; }
Array<Face> faces;
Array<Plane*> 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<int> & surfind, double eps) const;
virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
Array<int> & surfind, double eps) const;
virtual void CalcSpecialPoints (Array<Point<3> > & pts) const;
virtual void AnalyzeSpecialPoint (const Point<3> & pt,
Array<Point<3> > & 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<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & 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<int> * > & polysurfs);
protected:
int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const;
// void CalcData();
};
#endif #endif

View File

@ -1,149 +1,153 @@
#ifndef _REVOLUTION_HPP #ifndef _REVOLUTION_HPP
#define _REVOLUTION_HPP #define _REVOLUTION_HPP
class Revolution; namespace netgen
class RevolutionFace : public Surface
{ {
private:
bool isfirst, islast;
const SplineSeg<2> * spline;
bool deletable;
Point<3> p0; class Revolution;
Vec<3> v_axis;
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 < Vec<2>* > checklines_vec;
Array < Point<2>* > checklines_start; Array < Point<2>* > checklines_start;
Array < Vec<2>* > checklines_normal; Array < Vec<2>* > checklines_normal;
private: private:
void Init (void); void Init (void);
public: public:
void CalcProj(const Point<3> & point3d, Point<2> & point2d) const; void CalcProj(const Point<3> & point3d, Point<2> & point2d) const;
void CalcProj(const Point<3> & point3d, Point<2> & point2d, void CalcProj(const Point<3> & point3d, Point<2> & point2d,
const Vec<3> & vector3d, Vec<2> & vector2d) const; const Vec<3> & vector3d, Vec<2> & vector2d) const;
void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const; void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const;
public: public:
RevolutionFace(const SplineSeg<2> & spline_in, RevolutionFace(const SplineSeg<2> & spline_in,
const Point<3> & p, const Point<3> & p,
const Vec<3> & vec, const Vec<3> & vec,
bool first = false, bool first = false,
bool last = false, bool last = false,
const int id_in = 0); const int id_in = 0);
RevolutionFace(const Array<double> & raw_data); RevolutionFace(const Array<double> & 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 double CalcFunctionValue (const Point<3> & point) const;
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const;
virtual double HesseNorm () const; virtual double HesseNorm () const;
virtual double MaxCurvature () const; virtual double MaxCurvature () const;
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ , //virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
// double /* rad */) const; // double /* rad */) const;
virtual void Project (Point<3> & p) const; virtual void Project (Point<3> & p) const;
virtual Point<3> GetSurfacePoint () const; virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const; virtual void Print (ostream & str) const;
virtual void GetTriangleApproximation (TriangleApproximation & tas, virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox, const Box<3> & boundingbox,
double facets) const; 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<double> & 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<double> & data) const;
};
/*
Primitive of revolution 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<RevolutionFace*> 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, class Revolution : public Primitive
const Vec<3> & v1, {
const Vec<3> & v2, private:
double eps) const; Point<3> p0,p1;
Vec<3> v_axis;
const SplineGeometry<2> & splinecurve;
const int nsplines;
// 1 ... torus-like
// 2 ... sphere-like
int type;
Array<RevolutionFace*> 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 int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0); virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const; virtual const Surface & GetSurface (int i = 0) const;
virtual void Reduce (const BoxSphere<3> & box); virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce (); virtual void UnReduce ();
}; };
}
#endif #endif

View File

@ -7,72 +7,78 @@
/* Date: 25. Sep. 99 */ /* Date: 25. Sep. 99 */
/**************************************************************************/ /**************************************************************************/
/** namespace netgen
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
{ {
public:
int domnr;
const Solid *sol;
double factor;
// Array<Point<3> > points;
// Array<INDEX_2> 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 Control for local refinement
{ */
public:
double beta;
int domnr;
const CSGeometry& geom;
const Solid *sol1, *sol2;
Array<Point<3> > points;
Array<INDEX_2> 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 /**
{ Singular Face.
public: Causes a bounday layer mesh refinement.
double beta; All elements in subdomain domnr will get a boundary layer
const Solid *sol1, *sol2, *sol3; on faces sharing the solid sol
Array<Point<3> > points; */
double factor; class SingularFace
{
public:
int domnr;
const Solid *sol;
double factor;
// Array<Point<3> > points;
// Array<INDEX_2> 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<Point<3> > points;
Array<INDEX_2> 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<Point<3> > points;
double factor;
public: public:
SingularPoint (double abeta, const Solid * asol1, const Solid * asol2, SingularPoint (double abeta, const Solid * asol1, const Solid * asol2,
const Solid * asol3, double sf); const Solid * asol3, double sf);
void FindPoints (class Mesh & mesh); void FindPoints (class Mesh & mesh);
void SetMeshSize (class Mesh & mesh, double globalh); void SetMeshSize (class Mesh & mesh, double globalh);
}; };
}
#endif #endif

View File

@ -7,235 +7,240 @@
/* Date: 1. Dez. 95 */ /* Date: 1. Dez. 95 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
{
/*
Constructive Solid Model (csg) 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: class SolidIterator
char * name; {
Primitive * prim; public:
Solid * s1, * s2; SolidIterator () { ; }
virtual ~SolidIterator () { ; }
virtual void Do (Solid * sol) = 0;
};
class Solid
{
public:
optyp op; typedef enum optyp1 { TERM, TERM_REF, SECTION, UNION, SUB, ROOT /*, DUMMY */ } optyp;
bool visited;
double maxh; private:
char * name;
Primitive * prim;
Solid * s1, * s2;
optyp op;
bool visited;
double maxh;
// static int cntnames; // static int cntnames;
public: public:
Solid (Primitive * aprim); Solid (Primitive * aprim);
Solid (optyp aop, Solid * as1, Solid * as2 = NULL); Solid (optyp aop, Solid * as1, Solid * as2 = NULL);
~Solid (); ~Solid ();
const char * Name () const { return name; } const char * Name () const { return name; }
void SetName (const char * aname); void SetName (const char * aname);
Solid * Copy (class CSGeometry & geom) const; Solid * Copy (class CSGeometry & geom) const;
void Transform (Transformation<3> & trans); 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<int> & bounds) const; void Boundaries (const Point<3> & p, Array<int> & bounds) const;
int NumPrimitives () const; int NumPrimitives () const;
void GetSurfaceIndices (Array<int> & surfind) const; void GetSurfaceIndices (Array<int> & surfind) const;
void GetSurfaceIndices (IndexSet & iset) const; void GetSurfaceIndices (IndexSet & iset) const;
void GetTangentialSurfaceIndices (const Point<3> & p, Array<int> & surfids, double eps) const; void GetTangentialSurfaceIndices (const Point<3> & p, Array<int> & surfids, double eps) const;
void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array<int> & surfids, double eps) const; void GetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array<int> & surfids, double eps) const;
void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, Array<int> & surfids, double eps) const; void GetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, Array<int> & surfids, double eps) const;
Primitive * GetPrimitive () Primitive * GetPrimitive ()
{ return (op == TERM || op == TERM_REF) ? prim : NULL; } { return (op == TERM || op == TERM_REF) ? prim : NULL; }
const Primitive * GetPrimitive () const const Primitive * GetPrimitive () const
{ return (op == TERM || op == TERM_REF) ? prim : NULL; } { return (op == TERM || op == TERM_REF) ? prim : NULL; }
Solid * S1() { return s1; } Solid * S1() { return s1; }
Solid * S2() { return s2; } Solid * S2() { return s2; }
// geometric tests // geometric tests
bool IsIn (const Point<3> & p, 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 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 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 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, bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
double eps) const; double eps) const;
bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
double eps) const; double eps) const;
/// compute localization in point p /// compute localization in point p
void TangentialSolid (const Point<3> & p, Solid *& tansol, Array<int> & surfids, double eps) const; void TangentialSolid (const Point<3> & p, Solid *& tansol, Array<int> & surfids, double eps) const;
/// compute localization in point p tangential to vector t /// compute localization in point p tangential to vector t
void TangentialSolid2 (const Point<3> & p, const Vec<3> & t, void TangentialSolid2 (const Point<3> & p, const Vec<3> & t,
Solid *& tansol, Array<int> & surfids, double eps) const; Solid *& tansol, Array<int> & surfids, double eps) const;
/** compute localization in point p, with second order approximation to edge /** compute localization in point p, with second order approximation to edge
p + s t + s*s/2 t2 **/ p + s t + s*s/2 t2 **/
void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, void TangentialSolid3 (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
Solid *& tansol, Array<int> & surfids, double eps) const; Solid *& tansol, Array<int> & surfids, double eps) const;
/** tangential solid, which follows the edge /** tangential solid, which follows the edge
p + s t + s*s/2 t2 p + s t + s*s/2 t2
with second order, and the neighbouring face with second order, and the neighbouring face
p + s t + s*s/2 t2 + r m p + s t + s*s/2 t2 + r m
with first order with first order
**/ **/
void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2, void TangentialEdgeSolid (const Point<3> & p, const Vec<3> & t, const Vec<3> & t2,
const Vec<3> & m, const Vec<3> & m,
Solid *& tansol, Array<int> & surfids, double eps) const; Solid *& tansol, Array<int> & surfids, double eps) const;
void CalcOnePrimitiveSpecialPoints (const Box<3> & box, Array<Point<3> > & pts) const; void CalcOnePrimitiveSpecialPoints (const Box<3> & box, Array<Point<3> > & pts) const;
/// ///
int Edge (const Point<3> & p, const Vec<3> & v, double eps) 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; int OnFace (const Point<3> & p, const Vec<3> & v, double eps) const;
/// ///
void Print (ostream & str) const; void Print (ostream & str) const;
/// ///
void CalcSurfaceInverse (); void CalcSurfaceInverse ();
/// ///
Solid * GetReducedSolid (const BoxSphere<3> & box) const; Solid * GetReducedSolid (const BoxSphere<3> & box) const;
void SetMaxH (double amaxh) void SetMaxH (double amaxh)
{ maxh = amaxh; } { maxh = amaxh; }
double GetMaxH () const double GetMaxH () const
{ return maxh; } { return maxh; }
void GetSolidData (ostream & ost, int first = 1) const; void GetSolidData (ostream & ost, int first = 1) const;
static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids); static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids);
static BlockAllocator ball; static BlockAllocator ball;
void * operator new(size_t /* s */) 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<int> & bounds,
int & in, int & strin) const;
///
void RecTangentialSolid (const Point<3> & p, Solid *& tansol, Array<int> & surfids,
int & in, int & strin, double eps) const;
void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec,
Solid *& tansol, Array<int> & 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<int> & 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<int> & 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<int> & surfind) const;
void RecGetTangentialSurfaceIndices (const Point<3> & p, Array<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
Array<int> & surfids, double eps) const;
void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m,
Array<int> & surfids, double eps) const;
void RecGetSurfaceIndices (IndexSet & iset) const;
void RecCalcOnePrimitiveSpecialPoints (Array<Point<3> > & 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(); sol.Print (ost);
} return ost;
void operator delete (void * p)
{
ball.Free (p);
} }
protected:
///
void RecBoundaries (const Point<3> & p, Array<int> & bounds,
int & in, int & strin) const;
///
void RecTangentialSolid (const Point<3> & p, Solid *& tansol, Array<int> & surfids,
int & in, int & strin, double eps) const;
void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec,
Solid *& tansol, Array<int> & 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<int> & 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<int> & 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<int> & surfind) const;
void RecGetTangentialSurfaceIndices (const Point<3> & p, Array<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices2 (const Point<3> & p, const Vec<3> & v, Array<int> & surfids, double eps) const;
void RecGetTangentialSurfaceIndices3 (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2,
Array<int> & surfids, double eps) const;
void RecGetTangentialEdgeSurfaceIndices (const Point<3> & p, const Vec<3> & v, const Vec<3> & v2, const Vec<3> & m,
Array<int> & surfids, double eps) const;
void RecGetSurfaceIndices (IndexSet & iset) const;
void RecCalcOnePrimitiveSpecialPoints (Array<Point<3> > & 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); class ReducePrimitiveIterator : public SolidIterator
return ost; {
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 #endif

View File

@ -8,166 +8,171 @@
/* Date: 01. Okt. 95 */ /* Date: 01. Okt. 95 */
/**************************************************************************/ /**************************************************************************/
/* namespace netgen
Special Point Calculation
*/
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;
}
///
class SpecialPointCalculation
{
private:
///
const CSGeometry * geometry;
///
Array<MeshPoint> * points;
///
Array<long int> 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<MeshPoint> & points);
///
void AnalyzeSpecialPoints (const CSGeometry & geometry,
Array<MeshPoint> & points,
Array<SpecialPoint> & 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, Special Point Calculation
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, class Surface;
int dir, Point<3> & p); 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<MeshPoint> * points;
///
Array<long int> boxesinlevel;
void ComputeExtremalPoints (const Plane * plane, ///
const QuadraticSurface * quadric, double size;
Array<Point<3> > & pts); ///
double relydegtest; // maximal dimension of bisection intervall for
/// test of degeneration parameters
double cpeps1, epeps1, epeps2, epspointdist2;
void ComputeCrossPoints (const Plane * plane1, double ideps;
const Plane * plane2,
const Plane * plane3,
Array<Point<3> > & pts);
void ComputeCrossPoints (const Plane * plane1, public:
const Plane * plane2,
const QuadraticSurface * quadratic, ///
Array<Point<3> > & pts); SpecialPointCalculation ();
};
///
void SetIdEps(const double epsin) {ideps = epsin;}
///
void CalcSpecialPoints (const CSGeometry & ageometry,
Array<MeshPoint> & points);
///
void AnalyzeSpecialPoints (const CSGeometry & geometry,
Array<MeshPoint> & points,
Array<SpecialPoint> & 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<Point<3> > & pts);
void ComputeCrossPoints (const Plane * plane1,
const Plane * plane2,
const Plane * plane3,
Array<Point<3> > & pts);
void ComputeCrossPoints (const Plane * plane1,
const Plane * plane2,
const QuadraticSurface * quadratic,
Array<Point<3> > & pts);
};
}
#endif #endif

View File

@ -1,92 +1,99 @@
/// namespace netgen
class splinesegment3d {
{
/// ///
Point<3> p1, p2, p3; class splinesegment3d
{
///
Point<3> p1, p2, p3;
public: public:
/// ///
splinesegment3d (const Point<3> & ap1, const Point<3> & ap2, splinesegment3d (const Point<3> & ap1, const Point<3> & ap2,
const Point<3> & ap3); const Point<3> & ap3);
/// ///
void Evaluate (double t, Point<3> & p) const; void Evaluate (double t, Point<3> & p) const;
/// ///
void EvaluateTangent (double t, Vec<3> & tang) const; void EvaluateTangent (double t, Vec<3> & tang) const;
/// ///
const Point<3> & P1() const { return p1; } const Point<3> & P1() const { return p1; }
/// ///
const Point<3> & P2() const { return p2; } const Point<3> & P2() const { return p2; }
/// ///
const Point<3> & P3() const { return p3; } const Point<3> & P3() const { return p3; }
}; };
///
class spline3d
{
/// ///
Array<splinesegment3d *> segments; class spline3d
{
///
Array<splinesegment3d *> segments;
public: public:
/// ///
spline3d () { }; spline3d () { };
/// ///
void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3); void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3);
/// ///
int GetNumSegments () const { return segments.Size(); } int GetNumSegments () const { return segments.Size(); }
/// ///
double ProjectToSpline (Point<3> & p) const; double ProjectToSpline (Point<3> & p) const;
/// ///
double ProjectToSpline (Point<3> & p, double t) const; double ProjectToSpline (Point<3> & p, double t) const;
/// ///
void Evaluate (double t, Point<3> & p) const; void Evaluate (double t, Point<3> & p) const;
/// ///
void EvaluateTangent (double t, Vec<3> & tang) const; void EvaluateTangent (double t, Vec<3> & tang) const;
/// ///
const Point<3> & P1(int i) const { return segments.Get(i)->P1(); } 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> & P2(int i) const { return segments.Get(i)->P2(); }
/// ///
const Point<3> & P3(int i) const { return segments.Get(i)->P3(); } const Point<3> & P3(int i) const { return segments.Get(i)->P3(); }
}; };
/// ///
class splinetube : public Surface class splinetube : public Surface
{ {
/// ///
const spline3d & middlecurve; const spline3d & middlecurve;
/// ///
double r; double r;
/// Vec<3> ex, ey, ez; /// Vec<3> ex, ey, ez;
Vec<2> e2x, e2y; Vec<2> e2x, e2y;
/// ///
Point<3> cp; Point<3> cp;
public: 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 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 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 FromPlane (const Point<2> & pplain, Point<3> & p, double h) const;
/// ///
virtual void Project (Point<3> & p) 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 /// 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 /// 0 .. no, 1 .. yes, 2 .. maybe
virtual double CalcFunctionValue (const Point<3> & point) const; virtual double CalcFunctionValue (const Point<3> & point) const;
/// ///
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const;
/// ///
virtual double HesseNorm () const { return 0.5 / r; } virtual double HesseNorm () const { return 0.5 / r; }
/// ///
virtual Point<3> GetSurfacePoint () const; virtual Point<3> GetSurfacePoint () const;
/// ///
virtual void Print (ostream & str) const; virtual void Print (ostream & str) const;
}; };
}

View File

@ -8,369 +8,371 @@
/**************************************************************************/ /**************************************************************************/
namespace netgen
// 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
{ {
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: // class DenseMatrix;
/** @name Points in the surface defining tangential plane. // class Box3dSphere;
Tangential plane is taken in p1, the local x-axis class TriangleApproximation;
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:
void SetName (const char * aname);
const char * Name () const { return name; }
//@{
/** /**
Defines tangential plane in ap1. Basis class for implicit surface geometry.
The local x-coordinate axis point to the direction of ap2 */ This class is used for generation of surface meshes
virtual void DefineTangentialPlane (const Point<3> & ap1, in NETGEN as well as for mesh refinement in FEPP.
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.
*/ */
//@{
/// 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;
/// class Surface
bool Inverse () const { return inverse; } {
/// protected:
void SetInverse (bool ainverse) { inverse = ainverse; } /// invert normal vector
/// bool inverse;
virtual void Print (ostream & str) const = 0; /// maximal h in surface
double maxh;
/// name of surface
char * name;
/// boundary condition nr
int bcprop;
///
string bcname;
/// public:
virtual void Reduce (const BoxSphere<3> & /* box */) { }; Surface ();
/// /** @name Tangential plane.
virtual void UnReduce () { }; The tangential plane is used for surface mesh generation.
*/
virtual ~Surface();
/// set max h in surface protected:
void SetMaxH (double amaxh) { maxh = amaxh; } /** @name Points in the surface defining tangential plane.
/// Tangential plane is taken in p1, the local x-axis
double GetMaxH () const { return maxh; } is directed to p2.
/// */
int GetBCProperty () const { return bcprop; } //@{
/// ///
void SetBCProperty (int abc) { bcprop = abc; } 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. void SetName (const char * aname);
Find const char * Name () const { return name; }
\[ 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 Defines tangential plane in ap1.
*/ The local x-coordinate axis point to the direction of ap2 */
virtual void GetTriangleApproximation (TriangleApproximation & /* tas */, virtual void DefineTangentialPlane (const Point<3> & ap1,
const Box<3> & /* boundingbox */, const Point<3> & ap2);
double /* facets */ ) const { };
/// 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) inline ostream & operator<< (ostream & ost, const Surface & surf)
{ {
surf.Print(ost); surf.Print(ost);
return ost; return ost;
} }
typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2} typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2}
INSOLID_TYPE; INSOLID_TYPE;
class DummySurface : public Surface class DummySurface : public Surface
{ {
virtual double CalcFunctionValue (const Point<3> & point) const virtual double CalcFunctionValue (const Point<3> & point) const
{ return 0; } { return 0; }
virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const
{ grad = Vec<3> (0,0,0); } { grad = Vec<3> (0,0,0); }
virtual Point<3> GetSurfacePoint () const virtual Point<3> GetSurfacePoint () const
{ return Point<3> (0,0,0); } { return Point<3> (0,0,0); }
virtual double HesseNorm () const virtual double HesseNorm () const
{ return 0; } { return 0; }
virtual void Project (Point<3> & p) const virtual void Project (Point<3> & p) const
{ ; } { ; }
virtual void Print (ostream & ost) const virtual void Print (ostream & ost) const
{ ost << "dummy surface"; } { 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: return values:
0 .. box outside solid \\ 0 .. box outside solid \\
1 .. box in solid \\ 1 .. box in solid \\
2 .. can't decide (allowed, iff box is close to 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 BoxInSolid (const BoxSphere<3> & box) const = 0;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p, virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const = 0;
virtual void GetTangentialSurfaceIndices (const Point<3> & p,
Array<int> & surfind, double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
double eps) const = 0; double eps) const = 0;
virtual void GetTangentialSurfaceIndices (const Point<3> & p, // checks if lim s->0 lim t->0 p + t(v1 + s v2) in solid
Array<int> & surfind, 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 VecInSolid (const Point<3> & p, // checks if p + s v1 + s*s/2 v2 is inside
const Vec<3> & v, virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
double eps) const = 0; 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 // like VecInSolid2, but second order approximation
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v1, const Vec<3> & v,
const Vec<3> & v2, const Vec<3> & v2,
double eps) const; const Vec<3> & m,
double eps) const;
// checks if p + s v1 + s*s/2 v2 is inside virtual void GetTangentialVecSurfaceIndices (const Point<3> & p, const Vec<3> & v,
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, Array<int> & surfind, double eps) const;
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
// like VecInSolid2, but second order approximation virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, Array<int> & surfind, double eps) const;
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<int> & surfind, double eps) const;
virtual void GetTangentialVecSurfaceIndices2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
Array<int> & surfind, double eps) const;
virtual void CalcSpecialPoints (Array<Point<3> > & /* pts */) const { ; } virtual void CalcSpecialPoints (Array<Point<3> > & /* pts */) const { ; }
virtual void AnalyzeSpecialPoint (const Point<3> & /* pt */, virtual void AnalyzeSpecialPoint (const Point<3> & /* pt */,
Array<Point<3> > & /* specpts */) const { ; } Array<Point<3> > & /* specpts */) const { ; }
virtual Vec<3> SpecialPointTangentialVector (const Point<3> & /* p */, virtual Vec<3> SpecialPointTangentialVector (const Point<3> & /* p */,
int /* s1 */, int /* s2 */) const int /* s1 */, int /* s2 */) const
{ return Vec<3> (0,0,0); } { return Vec<3> (0,0,0); }
virtual int GetNSurfaces() const = 0; virtual int GetNSurfaces() const = 0;
virtual Surface & GetSurface (int i = 0) = 0; virtual Surface & GetSurface (int i = 0) = 0;
virtual const Surface & GetSurface (int i = 0) const = 0; virtual const Surface & GetSurface (int i = 0) const = 0;
Array<int> surfaceids; Array<int> surfaceids;
Array<int> surfaceactive; Array<int> surfaceactive;
int GetSurfaceId (int i = 0) const; int GetSurfaceId (int i = 0) const;
void SetSurfaceId (int i, int id); void SetSurfaceId (int i, int id);
int SurfaceActive (int i) const { return surfaceactive[i]; } int SurfaceActive (int i) const { return surfaceactive[i]; }
virtual int SurfaceInverted (int /* i */ = 0) const { return 0; } virtual int SurfaceInverted (int /* i */ = 0) const { return 0; }
virtual void GetPrimitiveData (const char *& classname, virtual void GetPrimitiveData (const char *& classname,
Array<double> & coeffs) const; Array<double> & coeffs) const;
virtual void SetPrimitiveData (Array<double> & coeffs); virtual void SetPrimitiveData (Array<double> & coeffs);
static Primitive * CreatePrimitive (const char * classname); static Primitive * CreatePrimitive (const char * classname);
virtual void Reduce (const BoxSphere<3> & /* box */) { }; virtual void Reduce (const BoxSphere<3> & /* box */) { };
virtual void UnReduce () { }; virtual void UnReduce () { };
virtual Primitive * Copy () const; virtual Primitive * Copy () const;
virtual void Transform (Transformation<3> & trans); virtual void Transform (Transformation<3> & trans);
}; };
class OneSurfacePrimitive : public Surface, public Primitive class OneSurfacePrimitive : public Surface, public Primitive
{ {
public: public:
OneSurfacePrimitive(); OneSurfacePrimitive();
~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; double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p, virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p,
const Vec<3> & v, const Vec<3> & v1,
double eps) const; const Vec<3> & v2,
virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, double eps) const;
const Vec<3> & v1,
const Vec<3> & v2,
double eps) const;
virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid3 (const Point<3> & p,
const Vec<3> & v1, const Vec<3> & v1,
const Vec<3> & v2, const Vec<3> & v2,
double eps) const; double eps) const;
virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p, virtual INSOLID_TYPE VecInSolid4 (const Point<3> & p,
const Vec<3> & v, const Vec<3> & v,
const Vec<3> & v2, const Vec<3> & v2,
const Vec<3> & m, const Vec<3> & m,
double eps) const; double eps) const;
virtual int GetNSurfaces() const; virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0); virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const; virtual const Surface & GetSurface (int i = 0) const;
}; };
/** /**
Projects point to edge. Projects point to edge.
The point hp is projected to the edge descibed by f1 and f2. The point hp is projected to the edge descibed by f1 and f2.
It is assumed that the edge is non-degenerated, and the It is assumed that the edge is non-degenerated, and the
(generalized) Newton method converges. (generalized) Newton method converges.
*/ */
extern void ProjectToEdge (const Surface * f1, extern void ProjectToEdge (const Surface * f1,
const Surface * f2, const Surface * f2,
Point<3> & hp); Point<3> & hp);
}
#endif #endif

View File

@ -7,51 +7,57 @@
/* Date: 2. Mar. 98 */ /* Date: 2. Mar. 98 */
/**************************************************************************/ /**************************************************************************/
/**
Triangulated approxiamtion to true surface namespace netgen
*/ {
/**
Triangulated approxiamtion to true surface
*/
class TATriangle class TATriangle
{ {
int pi[3]; int pi[3];
int surfind; int surfind;
public: public:
TATriangle () { ; } 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; } { surfind = si; pi[0] = pi1; pi[1] = pi2; pi[2] = pi3; }
int SurfaceIndex() const { return surfind; } int SurfaceIndex() const { return surfind; }
int & SurfaceIndex() { return surfind; } int & SurfaceIndex() { return surfind; }
int & operator[] (int i) { return pi[i]; } int & operator[] (int i) { return pi[i]; }
const int & operator[] (int i) const { return pi[i]; } const int & operator[] (int i) const { return pi[i]; }
}; };
class TriangleApproximation class TriangleApproximation
{ {
Array<Point<3> > points; Array<Point<3> > points;
Array<Vec<3> > normals; Array<Vec<3> > normals;
Array<TATriangle> trigs; Array<TATriangle> trigs;
public: public:
TriangleApproximation(); TriangleApproximation();
int GetNP () const { return points.Size(); } int GetNP () const { return points.Size(); }
int GetNT () const { return trigs.Size(); } int GetNT () const { return trigs.Size(); }
int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; } 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 AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; }
int AddTriangle (const TATriangle & tri, bool invert = 0); int AddTriangle (const TATriangle & tri, bool invert = 0);
const Point<3> & GetPoint (int i) const { return points[i]; } const Point<3> & GetPoint (int i) const { return points[i]; }
const TATriangle & GetTriangle (int i) const { return trigs[i]; } const TATriangle & GetTriangle (int i) const { return trigs[i]; }
const Vec<3> & GetNormal (int i) const { return normals[i]; } const Vec<3> & GetNormal (int i) const { return normals[i]; }
void RemoveUnusedPoints (); void RemoveUnusedPoints ();
friend class CSGeometry; friend class CSGeometry;
}; };
}
#endif #endif

View File

@ -195,20 +195,33 @@ namespace netgen
Meshing2 meshing (Box<3> (pmin, pmax)); Meshing2 meshing (Box<3> (pmin, pmax));
Array<int, PointIndex::BASE> compress(bnp);
compress = -1;
int cnt = 0;
for (PointIndex pi = PointIndex::BASE; pi < bnp+PointIndex::BASE; pi++) 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; PointGeomInfo gi;
gi.trignum = 1; gi.trignum = 1;
for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++) for (SegmentIndex si = 0; si < mesh->GetNSeg(); si++)
{ {
if ( (*mesh)[si].domin == domnr) 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) 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);
}
} }

View File

@ -8,41 +8,44 @@
/**************************************************************************/ /**************************************************************************/
class Refinement2d : public Refinement namespace netgen
{ {
const SplineGeometry2d & geometry;
public: class Refinement2d : public Refinement
Refinement2d (const SplineGeometry2d & ageometry); {
virtual ~Refinement2d (); const SplineGeometry2d & geometry;
public:
Refinement2d (const SplineGeometry2d & ageometry);
virtual ~Refinement2d ();
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi, int surfi,
const PointGeomInfo & gi1, const PointGeomInfo & gi1,
const PointGeomInfo & gi2, const PointGeomInfo & gi2,
Point<3> & newp, PointGeomInfo & newgi); Point<3> & newp, PointGeomInfo & newgi);
virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint, virtual void PointBetween (const Point<3> & p1, const Point<3> & p2, double secpoint,
int surfi1, int surfi2, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1, const EdgePointGeomInfo & ap1,
const EdgePointGeomInfo & ap2, const EdgePointGeomInfo & ap2,
Point<3> & newp, EdgePointGeomInfo & newgi); Point<3> & newp, EdgePointGeomInfo & newgi);
virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2, virtual Vec<3> GetTangent (const Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & ap1) const; const EdgePointGeomInfo & ap1) const;
virtual Vec<3> GetNormal (const Point<3> & p, int surfi1, virtual Vec<3> GetNormal (const Point<3> & p, int surfi1,
const PointGeomInfo & gi) const; const PointGeomInfo & gi) const;
virtual void ProjectToSurface (Point<3> & p, int surfi, const PointGeomInfo & /* gi */); 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 ProjectToEdge (Point<3> & p, int surfi1, int surfi2,
const EdgePointGeomInfo & egi) const;
};
}

View File

@ -10,11 +10,10 @@
#include <myadt.hpp> #include <myadt.hpp>
#include <gprim.hpp> #include <gprim.hpp>
namespace netgen
{
#include "spline.hpp" #include "spline.hpp"
#include "splinegeometry.hpp" #include "splinegeometry.hpp"
#include "geom2dmesh.hpp" #include "geom2dmesh.hpp"
}
#endif #endif

View File

@ -7,6 +7,9 @@
/* Date: 24. Jul. 96 */ /* Date: 24. Jul. 96 */
/**************************************************************************/ /**************************************************************************/
namespace netgen
{
void CalcPartition (double l, double h, double h1, double h2, void CalcPartition (double l, double h, double h1, double h2,
double hcurve, double elto0, Array<double> & points); double hcurve, double elto0, Array<double> & points);
@ -60,6 +63,14 @@ public:
bool hpref_left; bool hpref_left;
/// perfrom anisotropic refinement (hp-refinement) to edge /// perfrom anisotropic refinement (hp-refinement) to edge
bool hpref_right; bool hpref_right;
///
int layer;
SplineSeg ()
{
layer = 1;
}
/// calculates length of curve /// calculates length of curve
virtual double Length () const; virtual double Length () const;
@ -344,10 +355,18 @@ void SplineSeg<D> :: Partition (double h, double elto0,
Vec<3> v (1e-4*h, 1e-4*h, 1e-4*h); Vec<3> v (1e-4*h, 1e-4*h, 1e-4*h);
searchtree.GetIntersecting (oldmark3 - v, oldmark3 + v, locsearch); 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); 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; for (PointIndex pk = PointIndex::BASE;
pk < mesh.GetNP()+PointIndex::BASE; pk++) pk < mesh.GetNP()+PointIndex::BASE; pk++)
@ -363,20 +382,15 @@ void SplineSeg<D> :: Partition (double h, double elto0,
if (pi1 == -1) if (pi1 == -1)
{ {
pi1 = mesh.AddPoint(oldmark3); pi1 = mesh.AddPoint(oldmark3, layer);
searchtree.Insert (oldmark3, pi1); searchtree.Insert (oldmark3, pi1);
} }
if (pi2 == -1) if (pi2 == -1)
{ {
pi2 = mesh.AddPoint(mark3); pi2 = mesh.AddPoint(mark3, layer);
searchtree.Insert (mark3, pi2); searchtree.Insert (mark3, pi2);
} }
/*
cout << "pi1 = " << pi1 << endl;
cout << "pi2 = " << pi2 << endl;
cout << "leftdom = " << leftdom << ", rightdom = " << rightdom << endl;
*/
Segment seg; Segment seg;
seg.edgenr = segnr; seg.edgenr = segnr;
seg.si = bc; // segnr; seg.si = bc; // segnr;
@ -854,6 +868,9 @@ typedef CircleSeg<2> CircleSegment;
typedef DiscretePointsSeg<2> DiscretePointsSegment; typedef DiscretePointsSeg<2> DiscretePointsSegment;
}
#endif #endif

View File

@ -295,6 +295,8 @@ void SplineGeometry<D> :: LoadDataV2 ( ifstream & infile )
quadmeshing = false; quadmeshing = false;
tensormeshing.SetSize ( numdomains ); tensormeshing.SetSize ( numdomains );
tensormeshing = false; tensormeshing = false;
layer.SetSize ( numdomains );
layer = 1;
TestComment ( infile ); TestComment ( infile );
@ -329,6 +331,7 @@ void SplineGeometry<D> :: LoadDataV2 ( ifstream & infile )
maxh[domainnr-1] = flags.GetNumFlag ( "maxh", 1000); maxh[domainnr-1] = flags.GetNumFlag ( "maxh", 1000);
if (flags.GetDefineFlag("quad")) quadmeshing[domainnr-1] = true; if (flags.GetDefineFlag("quad")) quadmeshing[domainnr-1] = true;
if (flags.GetDefineFlag("tensor")) tensormeshing[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<D> :: PartitionBoundary (double h, Mesh & mesh2d)
pmax(j) = bbox.PMax()(j); pmax(j) = bbox.PMax()(j);
} }
if (printmessage_importance>0)
cout << "searchtree from " << pmin << " to " << pmax << endl;
Point3dTree searchtree (pmin, pmax); 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++) for (int i = 0; i < splines.Size(); i++)
if (splines[i]->copyfrom == -1) if (splines[i]->copyfrom == -1)
{ {

View File

@ -13,139 +13,148 @@ in geom2d only 2D - Geometry classes (with material properties etc.)
#ifndef _FILE_SPLINEGEOMETRY #ifndef _FILE_SPLINEGEOMETRY
#define _FILE_SPLINEGEOMETRY #define _FILE_SPLINEGEOMETRY
#include "../csg/csgparser.hpp" #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);
namespace netgen
// allow to turn off messages: cover all couts !!
extern int printmessage_importance;
template < int D >
class SplineGeometry
{ {
Array < GeomPoint<D> > geompoints;
Array < SplineSeg<D>* > splines;
double elto0;
Array<char*> materials;
Array<string*> bcnames;
Array<double> maxh;
Array<bool> quadmeshing;
Array<bool> tensormeshing;
private: ///
void AppendSegment(SplineSeg<D> * spline, const int leftdomain, const int rightdomain, extern void LoadBoundarySplines (const char * filename,
const int bc, Array < GeomPoint<2> > & geompoints,
const double reffac, const bool hprefleft, const bool hprefright, Array < SplineSeg<2>* > & splines,
const int copyfrom); double & elto0);
///
extern void PartitionBoundary (const Array < SplineSeg<2>* > & splines,
double h, double elto0,
Mesh & mesh2d);
public:
~SplineGeometry();
int Load (const Array<double> & raw_data, const int startpos = 0); // allow to turn off messages: cover all couts !!
void Load (const char * filename); extern int printmessage_importance;
void CSGLoad (CSGScanner & scan);
void LoadData( ifstream & infile ); template < int D >
void LoadDataNew ( ifstream & infile ); class SplineGeometry
void LoadDataV2 ( ifstream & infile ); {
Array < GeomPoint<D> > geompoints;
Array < SplineSeg<D>* > splines;
double elto0;
Array<char*> materials;
Array<string*> bcnames;
Array<double> maxh;
Array<bool> quadmeshing;
Array<bool> tensormeshing;
Array<int> layer;
void PartitionBoundary (double h, Mesh & mesh2d); private:
void AppendSegment(SplineSeg<D> * 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<double> & raw_data) const; public:
~SplineGeometry();
void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); int Load (const Array<double> & raw_data, const int startpos = 0);
void Load (const char * filename);
void CSGLoad (CSGScanner & scan);
const Array<SplineSeg<D>*> & GetSplines () const void LoadData( ifstream & infile );
{ return splines; } void LoadDataNew ( ifstream & infile );
void LoadDataV2 ( ifstream & infile );
int GetNSplines (void) const { return splines.Size(); } void PartitionBoundary (double h, Mesh & mesh2d);
string GetSplineType (const int i) const { return splines[i]->GetType(); }
SplineSeg<D> & GetSpline (const int i) {return *splines[i];}
const SplineSeg<D> & GetSpline (const int i) const {return *splines[i];}
void GetBoundingBox (Box<D> & box) const; void GetRawData (Array<double> & raw_data) const;
Box<D> GetBoundingBox () const
{ Box<D> box; GetBoundingBox (box); return box; }
int GetNP () const { return geompoints.Size(); } void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree);
const GeomPoint<D> & GetPoint(int i) const { return geompoints[i]; }
void SetGrading (const double grading); const Array<SplineSeg<D>*> & GetSplines () const
// void AppendPoint (const double x, const double y, const double reffac = 1., const bool hpref = false); { return splines; }
void AppendPoint (const Point<D> & p, const double reffac = 1., const bool hpref = false);
int GetNSplines (void) const { return splines.Size(); }
string GetSplineType (const int i) const { return splines[i]->GetType(); }
SplineSeg<D> & GetSpline (const int i) {return *splines[i];}
const SplineSeg<D> & GetSpline (const int i) const {return *splines[i];}
void GetBoundingBox (Box<D> & box) const;
Box<D> GetBoundingBox () const
{ Box<D> box; GetBoundingBox (box); return box; }
int GetNP () const { return geompoints.Size(); }
const GeomPoint<D> & 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<D> & p, const double reffac = 1., const bool hpref = false);
void AppendLineSegment (const int n1, const int n2, 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,
const int leftdomain, const int rightdomain, const int bc = -1, const int leftdomain, const int rightdomain, const int bc = -1,
const double reffac = 1., const double reffac = 1.,
const bool hprefleft = false, const bool hprefright = false, const bool hprefleft = false, const bool hprefright = false,
const int copyfrom = -1); const int copyfrom = -1);
void AppendCircleSegment (const int n1, const int n2, const int n3, void AppendSplineSegment (const int n1, const int n2, const int n3,
const int leftdomain, const int rightdomain, const int bc = -1, const int leftdomain, const int rightdomain, const int bc = -1,
const double reffac = 1., const double reffac = 1.,
const bool hprefleft = false, const bool hprefright = false, const bool hprefleft = false, const bool hprefright = false,
const int copyfrom = -1); const int copyfrom = -1);
void AppendDiscretePointsSegment (const Array< Point<D> > & points, void AppendCircleSegment (const int n1, const int n2, const int n3,
const int leftdomain, const int rightdomain, const int bc = -1, const int leftdomain, const int rightdomain, const int bc = -1,
const double reffac = 1., const double reffac = 1.,
const bool hprefleft = false, const bool hprefright = false, const bool hprefleft = false, const bool hprefright = false,
const int copyfrom = -1); const int copyfrom = -1);
void TestComment ( ifstream & infile ) ; void AppendDiscretePointsSegment (const Array< Point<D> > & points,
void GetMaterial( const int domnr, char* & material ); 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 ); double GetDomainMaxh ( const int domnr );
bool GetDomainQuadMeshing ( int domnr ) bool GetDomainQuadMeshing ( int domnr )
{ {
if ( quadmeshing.Size() ) return quadmeshing[domnr-1]; if ( quadmeshing.Size() ) return quadmeshing[domnr-1];
else return false; else return false;
} }
bool GetDomainTensorMeshing ( int domnr ) bool GetDomainTensorMeshing ( int domnr )
{ {
if ( tensormeshing.Size() ) return tensormeshing[domnr-1]; if ( tensormeshing.Size() ) return tensormeshing[domnr-1];
else return false; 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, void MeshFromSpline2D (SplineGeometry<2> & geometry,
Mesh *& mesh, Mesh *& mesh,
MeshingParameters & mp); MeshingParameters & mp);
class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry class SplineGeometry2d : public SplineGeometry<2>, public NetgenGeometry
{ {
public: public:
virtual ~SplineGeometry2d(); virtual ~SplineGeometry2d();
virtual int GenerateMesh (Mesh*& mesh, virtual int GenerateMesh (Mesh*& mesh,
int perfstepsstart, int perfstepsend, char* optstring); int perfstepsstart, int perfstepsend, char* optstring);
virtual const Refinement & GetRefinement () const; virtual const Refinement & GetRefinement () const;
}; };
}
#endif // _FILE_SPLINEGEOMETRY #endif // _FILE_SPLINEGEOMETRY

View File

@ -79,7 +79,16 @@ namespace netgen
DLL_HEADER Ng_Element Ng_GetElement (int nr); 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 <int DIM> template <int DIM>
DLL_HEADER int Ng_GetElementIndex (int nr); DLL_HEADER int Ng_GetElementIndex (int nr);
/// Curved Elements: /// Curved Elements:

View File

@ -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 <> template <>
DLL_HEADER int Ng_GetElementIndex<1> (int nr) DLL_HEADER int Ng_GetElementIndex<1> (int nr)
{ {
@ -175,9 +182,6 @@ namespace netgen
} }
template <> template <>
DLL_HEADER void Ng_MultiElementTransformation<3,3> (int elnr, int npts, DLL_HEADER void Ng_MultiElementTransformation<3,3> (int elnr, int npts,
const double * xi, int sxi, const double * xi, int sxi,