diff --git a/libsrc/gprim/CMakeLists.txt b/libsrc/gprim/CMakeLists.txt index 402973dc..4944858e 100644 --- a/libsrc/gprim/CMakeLists.txt +++ b/libsrc/gprim/CMakeLists.txt @@ -7,7 +7,7 @@ target_sources(gprim INTERFACE ) install(FILES - adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp geomobjects2.hpp + adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp geomobjects.hpp geomops2.hpp geomops.hpp geomtest3d.hpp gprim.hpp splinegeometry.hpp spline.hpp transform3d.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE}/gprim COMPONENT netgen_devel diff --git a/libsrc/gprim/geomobjects2.hpp b/libsrc/gprim/geomobjects2.hpp deleted file mode 100644 index 014a3852..00000000 --- a/libsrc/gprim/geomobjects2.hpp +++ /dev/null @@ -1,366 +0,0 @@ -#ifndef FILE_OBJECTS -#define FILE_OBJECTS - -/* *************************************************************************/ -/* File: geomobjects.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 20. Jul. 02 */ -/* *************************************************************************/ - -template -class VecExpr -{ -public: - VecExpr () { ; } - double operator() (int i) const { return static_cast (*this) (i); } -}; - - -template class Vec; -template class Point; - - -template -class Point : public VecExpr > -{ - -protected: - double x[D]; - -public: - Point () { ; } - Point (double ax) { x[0] = ax; } - Point (double ax, double ay) { x[0] = ax; x[1] = ay; } - Point (double ax, double ay, double az) - { x[0] = ax; x[1] = ay; x[2] = az; } - Point (double ax, double ay, double az, double au) - { x[0] = ax; x[1] = ay; x[2] = az; x[3] = au;} - - Point (const Point & p2) - { for (int i = 0; i < D; i++) x[i] = p2.x[i]; } - - explicit Point (const Vec & v) - { for (int i = 0; i < D; i++) x[i] = v(i); } - - - template - explicit Point (const VecExpr & expr) - { - for (int i = 0; i < D; i++) x[i] = expr(i); - } - - Point & operator= (const Point & p2) - { - for (int i = 0; i < D; i++) x[i] = p2.x[i]; - return *this; - } - - template - Point & operator= (const VecExpr & expr) - { - for (int i = 0; i < D; i++) x[i] = expr(i); - return *this; - } - - double & operator() (int i) { return x[i]; } - const double & operator() (int i) const { return x[i]; } - - operator const double* () const { return x; } -}; - - - - - -template -class Vec : public VecExpr > -{ - -protected: - double x[D]; - -public: - Vec () { ; } - Vec (double ax) { for (int i = 0; i < D; i++) x[i] = ax; } - Vec (double ax, double ay) { x[0] = ax; x[1] = ay; } - Vec (double ax, double ay, double az) - { x[0] = ax; x[1] = ay; x[2] = az; } - Vec (double ax, double ay, double az, double au) - { x[0] = ax; x[1] = ay; x[2] = az; x[3] = au; } - - Vec (const Vec & p2) - { for (int i = 0; i < D; i++) x[i] = p2.x[i]; } - - explicit Vec (const Point & p) - { for (int i = 0; i < D; i++) x[i] = p(i); } - - template - explicit Vec (const VecExpr & expr) - { - for (int i = 0; i < D; i++) x[i] = expr(i); - } - - - Vec & operator= (const Vec & p2) - { - for (int i = 0; i < D; i++) x[i] = p2.x[i]; - return *this; - } - - template - Vec & operator= (const VecExpr & expr) - { - for (int i = 0; i < D; i++) x[i] = expr(i); - return *this; - } - - Vec & operator= (double s) - { - for (int i = 0; i < D; i++) x[i] = s; - return *this; - } - - double & operator() (int i) { return x[i]; } - const double & operator() (int i) const { return x[i]; } - - operator const double* () const { return x; } - - double Length () const - { - double l = 0; - for (int i = 0; i < D; i++) - l += x[i] * x[i]; - return sqrt (l); - } - - double Length2 () const - { - double l = 0; - for (int i = 0; i < D; i++) - l += x[i] * x[i]; - return l; - } - - const Vec & Normalize () - { - double l = Length(); - if (l != 0) - for (int i = 0; i < D; i++) - x[i] /= l; - return *this; - } - - Vec GetNormal () const; -}; - - - - - -template -class Mat -{ - -protected: - double x[H*W]; - -public: - Mat () { ; } - Mat (const Mat & b) - { for (int i = 0; i < H*W; i++) x[i] = b.x[i]; } - - Mat & operator= (double s) - { - for (int i = 0; i < H*W; i++) x[i] = s; - return *this; - } - - Mat & operator= (const Mat & b) - { - for (int i = 0; i < H*W; i++) x[i] = b.x[i]; - return *this; - } - - double & operator() (int i, int j) { return x[i*W+j]; } - const double & operator() (int i, int j) const { return x[i*W+j]; } - - Vec Col (int i) const - { - Vec hv; - for (int j = 0; j < H; j++) - hv(j) = x[j*W+i]; - return hv; - } - - Vec Row (int i) const - { - Vec hv; - for (int j = 0; j < W; j++) - hv(j) = x[i*W+j]; - return hv; - } - - void Solve (const Vec & rhs, Vec & sol) const - { - Mat inv; - CalcInverse (*this, inv); - sol = inv * rhs; - } -}; - - - - -template -class Box -{ -protected: - Point pmin, pmax; -public: - Box () { ; } - Box ( const Point & p1, const Point & p2) - { - for (int i = 0; i < D; i++) - { - pmin(i) = min2(p1(i), p2(i)); - pmax(i) = max2(p1(i), p2(i)); - } - } - - const Point & PMin () const { return pmin; } - const Point & PMax () const { return pmax; } - - void Set (const Point & p) - { pmin = pmax = p; } - - void Add (const Point & p) - { - for (int i = 0; i < D; i++) - { - if (p(i) < pmin(i)) pmin(i) = p(i); - else if (p(i) > pmax(i)) pmax(i) = p(i); - } - } - - Point Center () const - { - Point c; - for (int i = 0; i < D; i++) - c(i) = 0.5 * (pmin(i)+pmax(i)); - return c; - } - double Diam () const { return Abs (pmax-pmin); } - - Point GetPointNr (int nr) const - { - Point p; - for (int i = 0; i < D; i++) - { - p(i) = (nr & 1) ? pmax(i) : pmin(i); - nr >>= 1; - } - return p; - } - - - bool Intersect (const Box & box2) const - { - for (int i = 0; i < D; i++) - if (pmin(i) > box2.pmax(i) || - pmax(i) < box2.pmin(i)) return 0; - return 1; - } - - - bool IsIn (const Point & p) const - { - for (int i = 0; i < D; i++) - if (p(i) < pmin(i) || p(i) > pmax(i)) return 0; - return 1; - } - - - void Increase (double dist) - { - for (int i = 0; i < D; i++) - { - pmin(i) -= dist; - pmax(i) += dist; - } - } -}; - - - - -template -class BoxSphere : public Box -{ -protected: - /// - Point c; - /// - double diam; - /// - double inner; -public: - /// - BoxSphere () { }; - /// - BoxSphere ( Point pmin, Point pmax ) - : Box (pmin, pmax) - { - CalcDiamCenter(); - } - - /// - const Point & Center () const { return c; } - /// - double Diam () const { return diam; } - /// - double Inner () const { return inner; } - - - /// - void GetSubBox (int nr, BoxSphere & sbox) const - { - for (int i = 0; i < D; i++) - { - if (nr & 1) - { - sbox.pmin(i) = c(i); - sbox.pmax(i) = this->pmax(i); - } - else - { - sbox.pmin(i) = this->pmin(i); - sbox.pmax(i) = c(i); - } - sbox.c(i) = 0.5 * (sbox.pmin(i) + sbox.pmax(i)); - nr >>= 1; - } - sbox.diam = 0.5 * diam; - sbox.inner = 0.5 * inner; - } - - - /// - void CalcDiamCenter () - { - c = Box::Center (); - diam = Dist (this->pmin, this->pmax); - - inner = this->pmax(0) - this->pmin(0); - for (int i = 1; i < D; i++) - if (this->pmax(i) - this->pmin(i) < inner) - inner = this->pmax(i) - this->pmin(i); - } - -}; - - - - - - -#endif