header files

This commit is contained in:
Joachim Schoeberl 2011-02-28 14:17:25 +00:00
parent 9a043aae26
commit 807d091d9e
19 changed files with 2049 additions and 2046 deletions

View File

@ -7,7 +7,6 @@ lib_LTLIBRARIES = libgeom2d.la libgeom2dvis.la
libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp libgeom2d_la_SOURCES = genmesh2d.cpp geom2dmesh.cpp geometry2d.cpp
libgeom2d_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la libgeom2d_la_LIBADD = $(top_builddir)/libsrc/meshing/libmesh.la
# $(top_builddir)/libsrc/gprim/libgprim.la
libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp libgeom2dvis_la_SOURCES = geom2dpkg.cpp vsgeom2d.cpp
libgeom2dvis_la_LIBADD = libgeom2d.la libgeom2dvis_la_LIBADD = libgeom2d.la

View File

@ -1,8 +1,6 @@
#include <mystdlib.h>
#include <meshing.hpp> #include <meshing.hpp>
#include <geometry2d.hpp> #include <geometry2d.hpp>
namespace netgen namespace netgen
{ {
@ -10,10 +8,6 @@ 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);

View File

@ -1,6 +1,4 @@
#include <mystdlib.h>
#include <meshing.hpp> #include <meshing.hpp>
#include <geometry2d.hpp> #include <geometry2d.hpp>
namespace netgen namespace netgen

View File

@ -1,15 +1,8 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <incvis.hpp>
#include <meshing.hpp> #include <meshing.hpp>
#include <geometry2d.hpp> #include <geometry2d.hpp>
#include <visual.hpp> #include <visual.hpp>
#include "vsgeom2d.hpp"
#include "vsgeom2d.hpp"
// extern "C" int Ng_CSG_Init (Tcl_Interp * interp); // extern "C" int Ng_CSG_Init (Tcl_Interp * interp);

View File

@ -4,8 +4,6 @@
*/ */
#include <mystdlib.h>
#include <meshing.hpp> #include <meshing.hpp>
#include <geometry2d.hpp> #include <geometry2d.hpp>

View File

@ -12,10 +12,9 @@
// #include "../gprim/spline.hpp" // #include "../gprim/spline.hpp"
#include "../gprim/splinegeometry.hpp" // #include "../gprim/splinegeometry.hpp"
#include "geom2dmesh.hpp" #include "geom2dmesh.hpp"
namespace netgen namespace netgen
{ {

View File

@ -1,9 +1,4 @@
#include <mystdlib.h>
#include "incvis.hpp"
#include <myadt.hpp>
#include <meshing.hpp> #include <meshing.hpp>
#include <geometry2d.hpp> #include <geometry2d.hpp>
#include <visual.hpp> #include <visual.hpp>

View File

@ -9,13 +9,15 @@
/* *************************************************************************/ /* *************************************************************************/
namespace netgen
{
/** /**
Alternating Digital Tree Alternating Digital Tree
*/ */
#include "../include/mystdlib.h" // #include "../include/mystdlib.h"
#include "../include/myadt.hpp" // #include "../include/myadt.hpp"
class ADTreeNode class ADTreeNode
{ {
@ -478,4 +480,7 @@ public:
const ADTree6 & Tree() const { return *tree; }; const ADTree6 & Tree() const { return *tree; };
}; };
}
#endif #endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,150 +8,155 @@
/* *************************************************************************/ /* *************************************************************************/
template <int D> namespace netgen
inline double Abs (const Vec<D> & v)
{ {
double sum = 0;
for (int i = 0; i < D; i++) template <int D>
sum += v(i) * v(i); inline double Abs (const Vec<D> & v)
return sqrt (sum); {
double sum = 0;
for (int i = 0; i < D; i++)
sum += v(i) * v(i);
return sqrt (sum);
}
template <int D>
inline double Abs2 (const Vec<D> & v)
{
double sum = 0;
for (int i = 0; i < D; i++)
sum += v(i) * v(i);
return sum;
}
template <int D>
inline double Dist (const Point<D> & a, const Point<D> & b)
{
return Abs (a-b);
}
template <int D>
inline double Dist2 (const Point<D> & a, const Point<D> & b)
{
return Abs2 (a-b);
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = 0.5 * (a(i) + b(i));
return res;
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b, const Point<D> & c)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = (1.0/3.0) * (a(i) + b(i) + c(i));
return res;
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b, const Point<D> & c, const Point<D> & d)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = (1.0/4.0) * (a(i) + b(i) + c(i) + d(i));
return res;
}
inline Vec<3> Cross (const Vec<3> & v1, const Vec<3> & v2)
{
return Vec<3>
( v1(1) * v2(2) - v1(2) * v2(1),
v1(2) * v2(0) - v1(0) * v2(2),
v1(0) * v2(1) - v1(1) * v2(0) );
}
inline double Determinant (const Vec<3> & col1,
const Vec<3> & col2,
const Vec<3> & col3)
{
return
col1(0) * ( col2(1) * col3(2) - col2(2) * col3(1)) +
col1(1) * ( col2(2) * col3(0) - col2(0) * col3(2)) +
col1(2) * ( col2(0) * col3(1) - col2(1) * col3(0));
}
template <>
inline Vec<2> Vec<2> :: GetNormal () const
{
return Vec<2> (-x[1], x[0]);
}
template <>
inline Vec<3> Vec<3> :: GetNormal () const
{
if (fabs (x[0]) > fabs (x[2]))
return Vec<3> (-x[1], x[0], 0);
else
return Vec<3> (0, x[2], -x[1]);
}
// template <int H, int W>
inline void CalcInverse (const Mat<2,2> & m, Mat<2,2> & inv)
{
double det = m(0,0) * m(1,1) - m(0,1) * m(1,0);
if (det == 0)
{
inv = 0;
return;
}
double idet = 1.0 / det;
inv(0,0) = idet * m(1,1);
inv(0,1) = -idet * m(0,1);
inv(1,0) = -idet * m(1,0);
inv(1,1) = idet * m(0,0);
}
void CalcInverse (const Mat<3,3> & m, Mat<3,3> & inv);
inline void CalcInverse (const Mat<2,3> & m, Mat<3,2> & inv)
{
Mat<2,2> a = m * Trans (m);
Mat<2,2> ainv;
CalcInverse (a, ainv);
inv = Trans (m) * ainv;
}
void CalcInverse (const Mat<3,2> & m, Mat<2,3> & inv);
inline void CalcInverse (const Mat<3,2> & m, Mat<2,3> & inv)
{
Mat<2,2> a = Trans (m) * m;
Mat<2,2> ainv;
CalcInverse (a, ainv);
inv = ainv * Trans (m);
}
double Det (const Mat<2,2> & m);
double Det (const Mat<3,3> & m);
// eigenvalues of a symmetric matrix
void EigenValues (const Mat<3,3> & m, Vec<3> & ev);
void EigenValues (const Mat<2,2> & m, Vec<3> & ev);
} }
template <int D>
inline double Abs2 (const Vec<D> & v)
{
double sum = 0;
for (int i = 0; i < D; i++)
sum += v(i) * v(i);
return sum;
}
template <int D>
inline double Dist (const Point<D> & a, const Point<D> & b)
{
return Abs (a-b);
}
template <int D>
inline double Dist2 (const Point<D> & a, const Point<D> & b)
{
return Abs2 (a-b);
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = 0.5 * (a(i) + b(i));
return res;
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b, const Point<D> & c)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = (1.0/3.0) * (a(i) + b(i) + c(i));
return res;
}
template <int D>
inline Point<D> Center (const Point<D> & a, const Point<D> & b, const Point<D> & c, const Point<D> & d)
{
Point<D> res;
for (int i = 0; i < D; i++)
res(i) = (1.0/4.0) * (a(i) + b(i) + c(i) + d(i));
return res;
}
inline Vec<3> Cross (const Vec<3> & v1, const Vec<3> & v2)
{
return Vec<3>
( v1(1) * v2(2) - v1(2) * v2(1),
v1(2) * v2(0) - v1(0) * v2(2),
v1(0) * v2(1) - v1(1) * v2(0) );
}
inline double Determinant (const Vec<3> & col1,
const Vec<3> & col2,
const Vec<3> & col3)
{
return
col1(0) * ( col2(1) * col3(2) - col2(2) * col3(1)) +
col1(1) * ( col2(2) * col3(0) - col2(0) * col3(2)) +
col1(2) * ( col2(0) * col3(1) - col2(1) * col3(0));
}
template <>
inline Vec<2> Vec<2> :: GetNormal () const
{
return Vec<2> (-x[1], x[0]);
}
template <>
inline Vec<3> Vec<3> :: GetNormal () const
{
if (fabs (x[0]) > fabs (x[2]))
return Vec<3> (-x[1], x[0], 0);
else
return Vec<3> (0, x[2], -x[1]);
}
// template <int H, int W>
inline void CalcInverse (const Mat<2,2> & m, Mat<2,2> & inv)
{
double det = m(0,0) * m(1,1) - m(0,1) * m(1,0);
if (det == 0)
{
inv = 0;
return;
}
double idet = 1.0 / det;
inv(0,0) = idet * m(1,1);
inv(0,1) = -idet * m(0,1);
inv(1,0) = -idet * m(1,0);
inv(1,1) = idet * m(0,0);
}
void CalcInverse (const Mat<3,3> & m, Mat<3,3> & inv);
inline void CalcInverse (const Mat<2,3> & m, Mat<3,2> & inv)
{
Mat<2,2> a = m * Trans (m);
Mat<2,2> ainv;
CalcInverse (a, ainv);
inv = Trans (m) * ainv;
}
void CalcInverse (const Mat<3,2> & m, Mat<2,3> & inv);
inline void CalcInverse (const Mat<3,2> & m, Mat<2,3> & inv)
{
Mat<2,2> a = Trans (m) * m;
Mat<2,2> ainv;
CalcInverse (a, ainv);
inv = ainv * Trans (m);
}
double Det (const Mat<2,2> & m);
double Det (const Mat<3,3> & m);
// eigenvalues of a symmetric matrix
void EigenValues (const Mat<3,3> & m, Vec<3> & ev);
void EigenValues (const Mat<2,2> & m, Vec<3> & ev);
#endif #endif

View File

@ -8,360 +8,363 @@
/* *************************************************************************/ /* *************************************************************************/
namespace netgen
template <int D> class Vec;
template <int D> class Point;
template <int D>
class Point
{ {
protected:
double x[D];
public: template <int D> class Vec;
Point () { ; } template <int D> class Point;
Point (double ax) { for (int i = 0; i < D; i++) x[i] = 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<D> & p2)
{ for (int i = 0; i < D; i++) x[i] = p2.x[i]; }
explicit Point (const Vec<D> & v)
{ for (int i = 0; i < D; i++) x[i] = v(i); }
Point & operator= (const Point<D> & p2) template <int D>
class Point
{ {
for (int i = 0; i < D; i++) x[i] = p2.x[i];
return *this;
}
Point & operator= (double val) protected:
{ double x[D];
for (int i = 0; i < D; i++) x[i] = val;
return *this;
}
double & operator() (int i) { return x[i]; } public:
const double & operator() (int i) const { return x[i]; } Point () { ; }
Point (double ax) { for (int i = 0; i < D; i++) x[i] = 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;}
operator const double* () const { return x; } Point (const Point<D> & p2)
}; { for (int i = 0; i < D; i++) x[i] = p2.x[i]; }
explicit Point (const Vec<D> & v)
{ for (int i = 0; i < D; i++) x[i] = v(i); }
Point & operator= (const Point<D> & p2)
{
for (int i = 0; i < D; i++) x[i] = p2.x[i];
return *this;
}
Point & operator= (double val)
{
for (int i = 0; i < D; i++) x[i] = val;
return *this;
}
double & operator() (int i) { return x[i]; }
const double & operator() (int i) const { return x[i]; }
template <int D> operator const double* () const { return x; }
class Vec
{
protected:
double x[D];
public:
Vec () { ; } // for (int i = 0; i < D; i++) x[i] = 0; }
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<D> & p2)
{ for (int i = 0; i < D; i++) x[i] = p2.x[i]; }
explicit Vec (const Point<D> & p)
{ for (int i = 0; i < D; i++) x[i] = p(i); }
Vec (const Vec<D> & p1, const Vec<D> & p2)
{ for(int i=0; i<D; i++) x[i] = p2(i)-p1(1); }
Vec & operator= (const Vec<D> & p2)
{
for (int i = 0; i < D; i++) x[i] = p2.x[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<D> & Normalize ()
{
double l = Length();
if (l != 0)
for (int i = 0; i < D; i++)
x[i] /= l;
return *this;
}
Vec<D> GetNormal () const;
};
template <int H, int W=H>
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]; }
double & operator() (int i) { return x[i]; }
const double & operator() (int i) const { return x[i]; }
Vec<H> Col (int i) const
{
Vec<H> hv;
for (int j = 0; j < H; j++)
hv(j) = x[j*W+i];
return hv;
}
Vec<W> Row (int i) const
{
Vec<W> hv;
for (int j = 0; j < W; j++)
hv(j) = x[i*W+j];
return hv;
}
void Solve (const Vec<H> & rhs, Vec<W> & sol) const
{
Mat<W,H> inv;
CalcInverse (*this, inv);
sol = inv * rhs;
}
};
template <int D>
class Box
{
protected:
Point<D> pmin, pmax;
public:
Box () { ; }
Box ( const Point<D> & p1)
{
for (int i = 0; i < D; i++)
pmin(i) = pmax(i) = p1(i);
}
Box ( const Point<D> & p1, const Point<D> & p2)
{
for (int i = 0; i < D; i++)
{
pmin(i) = min2(p1(i), p2(i));
pmax(i) = max2(p1(i), p2(i));
}
}
enum EB_TYPE { EMPTY_BOX = 1 };
Box ( EB_TYPE et )
{
pmin = Point<3> (1e99, 1e99, 1e99);
pmax = Point<3> (-1e99, -1e99, -1e99);
}
const Point<D> & PMin () const { return pmin; }
const Point<D> & PMax () const { return pmax; }
void Set (const Point<D> & p)
{ pmin = pmax = p; }
void Add (const Point<D> & 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<D> Center () const
{
Point<D> 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<D> GetPointNr (int nr) const
{
Point<D> p;
for (int i = 0; i < D; i++)
{
p(i) = (nr & 1) ? pmax(i) : pmin(i);
nr >>= 1;
}
return p;
}
bool Intersect (const Box<D> & 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<D> & 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 <int D>
class BoxSphere : public Box<D>
{
protected:
///
Point<D> c;
///
double diam;
///
double inner;
public:
///
BoxSphere () { };
///
BoxSphere (const Box<D> & box)
: Box<D> (box)
{
CalcDiamCenter();
}; };
///
BoxSphere ( Point<D> apmin, Point<D> apmax )
: Box<D> (apmin, apmax)
template <int D>
class Vec
{ {
CalcDiamCenter();
}
/// protected:
const Point<D> & Center () const { return c; } double x[D];
///
double Diam () const { return diam; } public:
/// Vec () { ; } // for (int i = 0; i < D; i++) x[i] = 0; }
double Inner () const { return inner; } 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<D> & p2)
{ for (int i = 0; i < D; i++) x[i] = p2.x[i]; }
explicit Vec (const Point<D> & p)
{ for (int i = 0; i < D; i++) x[i] = p(i); }
Vec (const Vec<D> & p1, const Vec<D> & p2)
{ for(int i=0; i<D; i++) x[i] = p2(i)-p1(1); }
///
void GetSubBox (int nr, BoxSphere & sbox) const Vec & operator= (const Vec<D> & p2)
{
for (int i = 0; i < D; i++) x[i] = p2.x[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<D> & Normalize ()
{
double l = Length();
if (l != 0)
for (int i = 0; i < D; i++)
x[i] /= l;
return *this;
}
Vec<D> GetNormal () const;
};
template <int H, int W=H>
class Mat
{ {
for (int i = 0; i < D; i++)
{ protected:
if (nr & 1) double x[H*W];
{
sbox.pmin(i) = c(i); public:
sbox.pmax(i) = this->pmax(i); Mat () { ; }
} Mat (const Mat & b)
else { for (int i = 0; i < H*W; i++) x[i] = b.x[i]; }
{
sbox.pmin(i) = this->pmin(i); Mat & operator= (double s)
sbox.pmax(i) = c(i); {
} for (int i = 0; i < H*W; i++) x[i] = s;
sbox.c(i) = 0.5 * (sbox.pmin(i) + sbox.pmax(i)); return *this;
nr >>= 1; }
}
sbox.diam = 0.5 * diam; Mat & operator= (const Mat & b)
sbox.inner = 0.5 * inner; {
} 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]; }
double & operator() (int i) { return x[i]; }
const double & operator() (int i) const { return x[i]; }
Vec<H> Col (int i) const
{
Vec<H> hv;
for (int j = 0; j < H; j++)
hv(j) = x[j*W+i];
return hv;
}
Vec<W> Row (int i) const
{
Vec<W> hv;
for (int j = 0; j < W; j++)
hv(j) = x[i*W+j];
return hv;
}
void Solve (const Vec<H> & rhs, Vec<W> & sol) const
{
Mat<W,H> inv;
CalcInverse (*this, inv);
sol = inv * rhs;
}
};
///
void CalcDiamCenter ()
template <int D>
class Box
{ {
c = Box<D>::Center (); protected:
diam = Dist (this->pmin, this->pmax); Point<D> pmin, pmax;
public:
Box () { ; }
inner = this->pmax(0) - this->pmin(0); Box ( const Point<D> & p1)
for (int i = 1; i < D; i++) {
if (this->pmax(i) - this->pmin(i) < inner) for (int i = 0; i < D; i++)
inner = this->pmax(i) - this->pmin(i); pmin(i) = pmax(i) = p1(i);
} }
};
Box ( const Point<D> & p1, const Point<D> & p2)
{
for (int i = 0; i < D; i++)
{
pmin(i) = min2(p1(i), p2(i));
pmax(i) = max2(p1(i), p2(i));
}
}
enum EB_TYPE { EMPTY_BOX = 1 };
Box ( EB_TYPE et )
{
pmin = Point<3> (1e99, 1e99, 1e99);
pmax = Point<3> (-1e99, -1e99, -1e99);
}
const Point<D> & PMin () const { return pmin; }
const Point<D> & PMax () const { return pmax; }
void Set (const Point<D> & p)
{ pmin = pmax = p; }
void Add (const Point<D> & 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<D> Center () const
{
Point<D> 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<D> GetPointNr (int nr) const
{
Point<D> p;
for (int i = 0; i < D; i++)
{
p(i) = (nr & 1) ? pmax(i) : pmin(i);
nr >>= 1;
}
return p;
}
bool Intersect (const Box<D> & 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<D> & 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 <int D>
class BoxSphere : public Box<D>
{
protected:
///
Point<D> c;
///
double diam;
///
double inner;
public:
///
BoxSphere () { };
///
BoxSphere (const Box<D> & box)
: Box<D> (box)
{
CalcDiamCenter();
};
///
BoxSphere ( Point<D> apmin, Point<D> apmax )
: Box<D> (apmin, apmax)
{
CalcDiamCenter();
}
///
const Point<D> & 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<D>::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 #endif

View File

@ -8,384 +8,387 @@
/* *************************************************************************/ /* *************************************************************************/
/* namespace netgen
Point - Vector operations
*/
template <int D>
inline Vec<D> operator+ (const Vec<D> & a, const Vec<D> & b)
{ {
Vec<D> res;
for (int i = 0; i < D; i++) /*
res(i) = a(i) + b(i);
return res; Point - Vector operations
}
*/
template <int D>
inline Vec<D> operator+ (const Vec<D> & a, const Vec<D> & b)
{
Vec<D> res;
for (int i = 0; i < D; i++)
res(i) = a(i) + b(i);
return res;
}
template <int D> template <int D>
inline Point<D> operator+ (const Point<D> & a, const Vec<D> & b) inline Point<D> operator+ (const Point<D> & a, const Vec<D> & b)
{ {
Point<D> res; Point<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = a(i) + b(i); res(i) = a(i) + b(i);
return res; return res;
} }
template <int D> template <int D>
inline Vec<D> operator- (const Point<D> & a, const Point<D> & b) inline Vec<D> operator- (const Point<D> & a, const Point<D> & b)
{ {
Vec<D> res; Vec<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = a(i) - b(i); res(i) = a(i) - b(i);
return res; return res;
} }
template <int D> template <int D>
inline Point<D> operator- (const Point<D> & a, const Vec<D> & b) inline Point<D> operator- (const Point<D> & a, const Vec<D> & b)
{ {
Point<D> res; Point<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = a(i) - b(i); res(i) = a(i) - b(i);
return res; return res;
} }
template <int D> template <int D>
inline Vec<D> operator- (const Vec<D> & a, const Vec<D> & b) inline Vec<D> operator- (const Vec<D> & a, const Vec<D> & b)
{ {
Vec<D> res; Vec<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = a(i) - b(i); res(i) = a(i) - b(i);
return res; return res;
} }
template <int D> template <int D>
inline Vec<D> operator* (double s, const Vec<D> & b) inline Vec<D> operator* (double s, const Vec<D> & b)
{ {
Vec<D> res; Vec<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = s * b(i); res(i) = s * b(i);
return res; return res;
} }
template <int D> template <int D>
inline double operator* (const Vec<D> & a, const Vec<D> & b) inline double operator* (const Vec<D> & a, const Vec<D> & b)
{ {
double sum = 0; double sum = 0;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
sum += a(i) * b(i); sum += a(i) * b(i);
return sum; return sum;
} }
template <int D> template <int D>
inline Vec<D> operator- (const Vec<D> & b) inline Vec<D> operator- (const Vec<D> & b)
{ {
Vec<D> res; Vec<D> res;
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
res(i) = -b(i); res(i) = -b(i);
return res; return res;
} }
template <int D> template <int D>
inline Point<D> & operator+= (Point<D> & a, const Vec<D> & b) inline Point<D> & operator+= (Point<D> & a, const Vec<D> & b)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) += b(i); a(i) += b(i);
return a; return a;
} }
template <int D> template <int D>
inline Vec<D> & operator+= (Vec<D> & a, const Vec<D> & b) inline Vec<D> & operator+= (Vec<D> & a, const Vec<D> & b)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) += b(i); a(i) += b(i);
return a; return a;
} }
template <int D> template <int D>
inline Point<D> & operator-= (Point<D> & a, const Vec<D> & b) inline Point<D> & operator-= (Point<D> & a, const Vec<D> & b)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) -= b(i); a(i) -= b(i);
return a; return a;
} }
template <int D> template <int D>
inline Vec<D> & operator-= (Vec<D> & a, const Vec<D> & b) inline Vec<D> & operator-= (Vec<D> & a, const Vec<D> & b)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) -= b(i); a(i) -= b(i);
return a; return a;
} }
template <int D> template <int D>
inline Vec<D> & operator*= (Vec<D> & a, double s) inline Vec<D> & operator*= (Vec<D> & a, double s)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) *= s; a(i) *= s;
return a; return a;
} }
template <int D> template <int D>
inline Vec<D> & operator/= (Vec<D> & a, double s) inline Vec<D> & operator/= (Vec<D> & a, double s)
{ {
for (int i = 0; i < D; i++) for (int i = 0; i < D; i++)
a(i) /= s; a(i) /= s;
return a; return a;
} }
// Matrix - Vector operations // Matrix - Vector operations
/* /*
template <int H, int W> template <int H, int W>
inline Vec<H> operator* (const Mat<H,W> & m, const Vec<W> & v) inline Vec<H> operator* (const Mat<H,W> & m, const Vec<W> & v)
{
Vec<H> res;
for (int i = 0; i < H; i++)
{ {
res(i) = 0; Vec<H> res;
for (int j = 0; j < W; j++) for (int i = 0; i < H; i++)
res(i) += m(i,j) * v(j);
}
return res;
}
*/
// thanks to VC60 partial template specialization features !!!
inline Vec<2> operator* (const Mat<2,2> & m, const Vec<2> & v)
{
Vec<2> res;
for (int i = 0; i < 2; i++)
{ {
res(i) = 0; res(i) = 0;
for (int j = 0; j < 2; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<2> operator* (const Mat<2,3> & m, const Vec<3> & v)
{
Vec<2> res;
for (int i = 0; i < 2; i++)
{
res(i) = 0;
for (int j = 0; j < 3; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<3> operator* (const Mat<3,2> & m, const Vec<2> & v)
{
Vec<3> res;
for (int i = 0; i < 3; i++)
{
res(i) = 0;
for (int j = 0; j < 2; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<3> operator* (const Mat<3,3> & m, const Vec<3> & v)
{
Vec<3> res;
for (int i = 0; i < 3; i++)
{
res(i) = 0;
for (int j = 0; j < 3; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
/*
template <int H1, int W1, int H2, int W2>
inline Mat<H1,W2> operator* (const Mat<H1,W1> & a, const Mat<H2,W2> & b)
{
Mat<H1,W2> m;
for (int i = 0; i < H1; i++)
for (int j = 0; j < W2; j++)
{
double sum = 0;
for (int k = 0; k < W1; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
*/
inline Mat<2,2> operator* (const Mat<2,2> & a, const Mat<2,2> & b)
{
Mat<2,2> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<2,2> operator* (const Mat<2,3> & a, const Mat<3,2> & b)
{
Mat<2,2> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 3; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<3,2> operator* (const Mat<3,2> & a, const Mat<2,2> & b)
{
Mat<3,2> m;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<2,3> operator* (const Mat<2,2> & a, const Mat<2,3> & b)
{
Mat<2,3> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<3,3> operator* (const Mat<3,3> & a, const Mat<3,3> & b)
{
Mat<3,3> m;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{
double sum = 0;
for (int k = 0; k < 3; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
template <int H, int W>
inline Mat<W,H> Trans (const Mat<H,W> & m)
{
Mat<W,H> res;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++) for (int j = 0; j < W; j++)
res(j,i) = m(i,j); res(i) += m(i,j) * v(j);
return res;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Vec<D> & a)
{
ost << "(";
for (int i = 0; i < D-1; i++)
ost << a(i) << ", ";
ost << a(D-1) << ")";
return ost;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Point<D> & a)
{
ost << "(";
for (int i = 0; i < D-1; i++)
ost << a(i) << ", ";
ost << a(D-1) << ")";
return ost;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Box<D> & b)
{
ost << b.PMin() << " - " << b.PMax();
return ost;
}
template <int H, int W>
inline ostream & operator<< (ostream & ost, const Mat<H,W> & m)
{
ost << "(";
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
ost << m(i,j) << " ";
ost << endl;
} }
return ost; return res;
}
*/
// thanks to VC60 partial template specialization features !!!
inline Vec<2> operator* (const Mat<2,2> & m, const Vec<2> & v)
{
Vec<2> res;
for (int i = 0; i < 2; i++)
{
res(i) = 0;
for (int j = 0; j < 2; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<2> operator* (const Mat<2,3> & m, const Vec<3> & v)
{
Vec<2> res;
for (int i = 0; i < 2; i++)
{
res(i) = 0;
for (int j = 0; j < 3; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<3> operator* (const Mat<3,2> & m, const Vec<2> & v)
{
Vec<3> res;
for (int i = 0; i < 3; i++)
{
res(i) = 0;
for (int j = 0; j < 2; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
inline Vec<3> operator* (const Mat<3,3> & m, const Vec<3> & v)
{
Vec<3> res;
for (int i = 0; i < 3; i++)
{
res(i) = 0;
for (int j = 0; j < 3; j++)
res(i) += m(i,j) * v(j);
}
return res;
}
/*
template <int H1, int W1, int H2, int W2>
inline Mat<H1,W2> operator* (const Mat<H1,W1> & a, const Mat<H2,W2> & b)
{
Mat<H1,W2> m;
for (int i = 0; i < H1; i++)
for (int j = 0; j < W2; j++)
{
double sum = 0;
for (int k = 0; k < W1; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
*/
inline Mat<2,2> operator* (const Mat<2,2> & a, const Mat<2,2> & b)
{
Mat<2,2> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<2,2> operator* (const Mat<2,3> & a, const Mat<3,2> & b)
{
Mat<2,2> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 3; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<3,2> operator* (const Mat<3,2> & a, const Mat<2,2> & b)
{
Mat<3,2> m;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 2; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<2,3> operator* (const Mat<2,2> & a, const Mat<2,3> & b)
{
Mat<2,3> m;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
{
double sum = 0;
for (int k = 0; k < 2; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
inline Mat<3,3> operator* (const Mat<3,3> & a, const Mat<3,3> & b)
{
Mat<3,3> m;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
{
double sum = 0;
for (int k = 0; k < 3; k++)
sum += a(i,k) * b(k, j);
m(i,j) = sum;
}
return m;
}
template <int H, int W>
inline Mat<W,H> Trans (const Mat<H,W> & m)
{
Mat<W,H> res;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
res(j,i) = m(i,j);
return res;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Vec<D> & a)
{
ost << "(";
for (int i = 0; i < D-1; i++)
ost << a(i) << ", ";
ost << a(D-1) << ")";
return ost;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Point<D> & a)
{
ost << "(";
for (int i = 0; i < D-1; i++)
ost << a(i) << ", ";
ost << a(D-1) << ")";
return ost;
}
template <int D>
inline ostream & operator<< (ostream & ost, const Box<D> & b)
{
ost << b.PMin() << " - " << b.PMax();
return ost;
}
template <int H, int W>
inline ostream & operator<< (ostream & ost, const Mat<H,W> & m)
{
ost << "(";
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
ost << m(i,j) << " ";
ost << endl;
}
return ost;
}
} }
#endif #endif

View File

@ -8,6 +8,9 @@
/* *************************************************************************/ /* *************************************************************************/
namespace netgen
{
extern int extern int
IntersectTriangleLine (const Point<3> ** tri, const Point<3> ** line); IntersectTriangleLine (const Point<3> ** tri, const Point<3> ** line);
@ -79,5 +82,6 @@ extern double MinDistTP2 (const Point3d & tp1, const Point3d & tp2,
extern double MinDistLL2 (const Point3d & l1p1, const Point3d & l1p2, extern double MinDistLL2 (const Point3d & l1p1, const Point3d & l1p2,
const Point3d & l2p1, const Point3d & l2p2); const Point3d & l2p1, const Point3d & l2p2);
}
#endif #endif

View File

@ -8,19 +8,26 @@
/* *************************************************************************/ /* *************************************************************************/
namespace netgen #include <myadt.hpp>
{ #include <linalg.hpp>
#include "geomobjects.hpp" #include "geomobjects.hpp"
#include "geomops.hpp" #include "geomops.hpp"
#include "geomfuncs.hpp" #include "geomfuncs.hpp"
#include "geom2d.hpp" #include "geom2d.hpp"
#include "geom3d.hpp" #include "geom3d.hpp"
#include "geomtest3d.hpp" #include "geomtest3d.hpp"
// #include "rot3d.hpp"
#include "transform3d.hpp" #include "transform3d.hpp"
// #include "reftrans.hpp"
#include "adtree.hpp" #include "adtree.hpp"
}
#include "spline.hpp"
#include "splinegeometry.hpp"
#endif #endif

View File

@ -11,6 +11,9 @@
Affine - Linear mapping in 3D space Affine - Linear mapping in 3D space
*/ */
namespace netgen
{
class Transformation3d; class Transformation3d;
ostream & operator<< (ostream & ost, Transformation3d & trans); ostream & operator<< (ostream & ost, Transformation3d & trans);
@ -185,6 +188,6 @@ template <int D>
ostream & operator<< (ostream & ost, Transformation<D> & trans); ostream & operator<< (ostream & ost, Transformation<D> & trans);
}
#endif #endif

View File

@ -1,14 +1,7 @@
#include <mystdlib.h>
#include <myadt.hpp>
#include <linalg.hpp>
#include <gprim.hpp>
#include <meshing.hpp> #include <meshing.hpp>
#include "stlgeom.hpp" #include "stlgeom.hpp"
namespace netgen namespace netgen
{ {
@ -39,12 +32,14 @@ void STLMeshing (STLGeometry & geom,
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
STLGeometry :: STLGeometry() STLGeometry :: STLGeometry()
/*
: edges(), edgesperpoint(), : edges(), edgesperpoint(),
normals(), externaledges(), normals(), externaledges(),
atlas(), chartmark(), atlas(), chartmark(),
lines(), outerchartspertrig(), vicinity(), markedtrigs(), markedsegs(), lines(), outerchartspertrig(), vicinity(), markedtrigs(), markedsegs(),
lineendpoints(), spiralpoints(), selectedmultiedge() lineendpoints(), spiralpoints(), selectedmultiedge()
*/
{ {
edgedata = new STLEdgeDataList(*this); edgedata = new STLEdgeDataList(*this);
externaledges.SetSize(0); externaledges.SetSize(0);

View File

@ -21,11 +21,9 @@
*/ */
#include <gprim.hpp>
#include <meshing.hpp> #include <meshing.hpp>
namespace netgen namespace netgen
{ {
extern int IsInArray(int n, const Array<int>& ia); extern int IsInArray(int n, const Array<int>& ia);

View File

@ -856,7 +856,8 @@ void STLBoundarySeg :: Swap ()
STLBoundary :: STLBoundary (STLGeometry * ageometry) STLBoundary :: STLBoundary (STLGeometry * ageometry)
: boundary(), geometry(ageometry) : // boundary(),
geometry(ageometry)
{ {
; ;
} }