diff --git a/contrib/Netgen/libsrc/Makefile b/contrib/Netgen/libsrc/Makefile deleted file mode 100644 index 4bf820bc2af6e3397b6d08e1781fb8c46442bea5..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -# -# -appl = NETGEN -.default all: -# -# -all: - @ (cd linalg; $(MAKE) -f Makefile) - @ (cd general; $(MAKE) -f Makefile) - @ (cd gprim; $(MAKE) -f Makefile) - @ (cd csg; $(MAKE) -f Makefile) - @ (cd geom2d; $(MAKE) -f Makefile) - @ (cd stlgeom; $(MAKE) -f Makefile) - @ (cd occ; $(MAKE) -f Makefile) - @ (cd meshing; $(MAKE) -f Makefile) - @ (cd opti; $(MAKE) -f Makefile) - @ (cd visualization; $(MAKE) -f Makefile) - @ (cd interface; $(MAKE) -f Makefile) -# -# @ (cd step; $(MAKE) -f Makefile) -# @ (cd stepgeom; $(MAKE) -f Makefile) -# @ (cd graphics; $(MAKE) -f Makefile) - -tar: - tar cvf ../../libsrc.tar Makefile - tar rf ../../libsrc.tar linalg/Makefile linalg/*.hh linalg/*.cc - tar rf ../../libsrc.tar general/Makefile general/*.hh general/*.cc - tar rf ../../libsrc.tar gprim/Makefile gprim/*.hh gprim/*.cc - tar rf ../../libsrc.tar csg/Makefile csg/*.hh csg/*.cc - tar rf ../../libsrc.tar stlgeom/Makefile stlgeom/*.hh stlgeom/*.cc - tar rf ../../libsrc.tar occ/Makefile occ/*.h* occ/*.c* - tar rf ../../libsrc.tar meshing/Makefile meshing/*.hh meshing/*.cc meshing/*.h - tar rf ../../libsrc.tar opti/Makefile opti/*.hh opti/*.cc - tar rf ../../libsrc.tar step/Makefile step/*.h step/*.cc - tar rf ../../libsrc.tar stepgeom/Makefile stepgeom/*.hh stepgeom/*.cc - tar tf ../../libsrc.tar include/*.h include/*.hh - gzip -9 ../../libsrc.tar - diff --git a/contrib/Netgen/libsrc/csg/Makefile b/contrib/Netgen/libsrc/csg/Makefile deleted file mode 100644 index e8c51dc218b97e62ada15b3e372284bd0333ddde..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -# -# Makefile for geometric library -# -src = csgparser.cpp algprim.cpp curve2d.cpp brick.cpp \ - solid.cpp spline3d.cpp surface.cpp bspline2d.cpp \ - explicitcurve2d.cpp gencyl.cpp csgeom.cpp polyhedra.cpp extrusion.cpp revolution.cpp \ - manifold.cpp curve2d.cpp triapprox.cpp identify.cpp \ - singularref.cpp \ - edgeflw.cpp specpoin.cpp meshsurf.cpp genmesh.cpp -# -# lex.yy.cpp geometry.cpp -# -lib = csg -libpath = libsrc/csg -# -# -include ../makefile.inc -# -# geometry.cpp : geometry.yy -# bison -d -o geometry.c geometry.yy -# mv -f geometry.c geometry.cpp -# -# lex.yy.cpp : geometry.yy geometry.ll -# flex -+ -d -I geometry.ll -# mv lex.yy.cc lex.yy.cpp - diff --git a/contrib/Netgen/libsrc/csg/algprim.cpp b/contrib/Netgen/libsrc/csg/algprim.cpp deleted file mode 100644 index 1123706b1ed1d612fb816f64430f5c35e89ce02a..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/algprim.cpp +++ /dev/null @@ -1,1389 +0,0 @@ -#include <mystdlib.h> - - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - -double -QuadraticSurface :: CalcFunctionValue (const Point<3> & p) const -{ - return p(0) * (cxx * p(0) + cxy * p(1) + cxz * p(2) + cx) + - p(1) * (cyy * p(1) + cyz * p(2) + cy) + - p(2) * (czz * p(2) + cz) + c1; -} - -void -QuadraticSurface :: CalcGradient (const Point<3> & p, Vec<3> & grad) const -{ - grad(0) = 2 * cxx * p(0) + cxy * p(1) + cxz * p(2) + cx; - grad(1) = 2 * cyy * p(1) + cxy * p(0) + cyz * p(2) + cy; - grad(2) = 2 * czz * p(2) + cxz * p(0) + cyz * p(1) + cz; -} - -void -QuadraticSurface :: CalcHesse (const Point<3> & /* p */, Mat<3> & hesse) const -{ - hesse(0,0) = 2 * cxx; - hesse(1,1) = 2 * cyy; - hesse(2,2) = 2 * czz; - hesse(0,1) = hesse(1,0) = cxy; - hesse(0,2) = hesse(2,0) = cxz; - hesse(1,2) = hesse(2,1) = cyz; -} - - -void QuadraticSurface :: Read (istream & ist) -{ - ist >> cxx >> cyy >> czz >> cxy >> cxz >> cyz >> cx >> cy >> cz >> c1; -} - -void QuadraticSurface :: Print (ostream & ost) const -{ - ost << cxx << " " << cyy << " " << czz << " " - << cxy << " " << cxz << " " << cyz << " " - << cx << " " << cy << " " << cz << " " - << c1 << endl; -} - - -void QuadraticSurface :: PrintCoeff (ostream & ost) const -{ - ost << " cxx = " << cxx - << " cyy = " << cyy - << " czz = " << czz - << " cxy = " << cxy - << " cxz = " << cxz - << " cyz = " << cyz - << " cx = " << cx - << " cy = " << cy - << " cz = " << cz - << " c1 = " << c1 << endl; -} - - - -Point<3> QuadraticSurface :: GetSurfacePoint () const -{ - MyError ("GetSurfacePoint called for QuadraticSurface"); - return Point<3> (0, 0, 0); -} - - -Plane :: Plane (const Point<3> & ap, Vec<3> an) -{ - p = ap; - n = an; - n.Normalize(); - - cxx = cyy = czz = cxy = cxz = cyz = 0; - cx = n(0); cy = n(1); cz = n(2); - c1 = - (cx * p(0) + cy * p(1) + cz * p(2)); -} - -Primitive * Plane :: Copy () const -{ - return new Plane (p, n); -} - -void Plane :: Transform (Transformation<3> & trans) -{ - Point<3> hp; - Vec<3> hn; - trans.Transform (p, hp); - trans.Transform (n, hn); - p = hp; - n = hn; - - cxx = cyy = czz = cxy = cxz = cyz = 0; - cx = n(0); cy = n(1); cz = n(2); - c1 = - (cx * p(0) + cy * p(1) + cz * p(2)); -} - - - -void Plane :: GetPrimitiveData (char *& classname, - ARRAY<double> & coeffs) const -{ - classname = "plane"; - coeffs.SetSize (6); - coeffs.Elem(1) = p(0); - coeffs.Elem(2) = p(1); - coeffs.Elem(3) = p(2); - coeffs.Elem(4) = n(0); - coeffs.Elem(5) = n(1); - coeffs.Elem(6) = n(2); -} - -void Plane :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - p(0) = coeffs.Elem(1); - p(1) = coeffs.Elem(2); - p(2) = coeffs.Elem(3); - n(0) = coeffs.Elem(4); - n(1) = coeffs.Elem(5); - n(2) = coeffs.Elem(6); - - n.Normalize(); - - cxx = cyy = czz = cxy = cxz = cyz = 0; - cx = n(0); cy = n(1); cz = n(2); - c1 = - (cx * p(0) + cy * p(1) + cz * p(2)); -} - -Primitive * Plane :: CreateDefault () -{ - return new Plane (Point<3> (0,0,0), Vec<3> (0,0,1)); -} - - -int Plane :: IsIdentic (const Surface & s2, int & inv, double eps) const -{ - if (fabs (s2.CalcFunctionValue(p)) > eps) return 0; - Vec<3> hv1, hv2; - hv1 = n.GetNormal (); - hv2 = Cross (n, hv1); - - Point<3> hp = p + hv1; - if (fabs (s2.CalcFunctionValue(hp)) > eps) return 0; - hp = p + hv2; - if (fabs (s2.CalcFunctionValue(hp)) > eps) return 0; - - Vec<3> n1, n2; - n1 = GetNormalVector (p); - n2 = s2.GetNormalVector (p); - inv = (n1 * n2 < 0); - return 1; -} - - - -void Plane :: DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2) -{ - Surface::DefineTangentialPlane (ap1, ap2); -} - - -void Plane :: ToPlane (const Point<3> & p3d, - Point<2> & pplane, - double h, int & zone) const -{ - Vec<3> p1p; - - p1p = p3d - p1; - p1p /= h; - pplane(0) = p1p * ex; - pplane(1) = p1p * ey; - zone = 0; -} - -void Plane :: FromPlane (const Point<2> & pplane, Point<3> & p3d, double h) const -{ - /* - Vec<3> p1p; - Point<2> pplane2 = pplane; - - pplane2 *= h; - p1p = pplane2(0) * ex + pplane2(1) * ey; - p3d = p1 + p1p; - */ - p3d = p1 + (h * pplane(0)) * ex + (h * pplane(1)) * ey; -} - - -void Plane :: Project (Point<3> & p3d) const -{ - double val = Plane::CalcFunctionValue (p3d); - p3d -= val * n; -} - -INSOLID_TYPE Plane :: BoxInSolid (const BoxSphere<3> & box) const -{ - int i; - double val; - Point<3> p; - - val = Plane::CalcFunctionValue (box.Center()); - if (val > box.Diam() / 2) return IS_OUTSIDE; - if (val < -box.Diam() / 2) return IS_INSIDE; - - if (val > 0) - { - /* - double modify = - ((box.MaxX()-box.MinX()) * fabs (cx) + - (box.MaxY()-box.MinY()) * fabs (cy) + - (box.MaxZ()-box.MinZ()) * fabs (cz)) / 2; - */ - Vec<3> vdiag = box.PMax() - box.PMin(); - double modify = (vdiag(0) * fabs (cx) + - vdiag(1) * fabs (cy) + - vdiag(2) * fabs (cz) ) / 2; - - if (val - modify < 0) - return DOES_INTERSECT; - return IS_OUTSIDE; - - // only outside or intersect possible - for (i = 0; i < 8; i++) - { - p = box.GetPointNr (i); - val = Plane::CalcFunctionValue (p); - if (val < 0) - return DOES_INTERSECT; - } - return IS_OUTSIDE; - } - else - { - /* - double modify = - ((box.MaxX()-box.MinX()) * fabs (cx) + - (box.MaxY()-box.MinY()) * fabs (cy) + - (box.MaxZ()-box.MinZ()) * fabs (cz)) / 2; - */ - Vec<3> vdiag = box.PMax() - box.PMin(); - double modify = (vdiag(0) * fabs (cx) + - vdiag(1) * fabs (cy) + - vdiag(2) * fabs (cz) ) / 2; - if (val + modify > 0) - return DOES_INTERSECT; - return IS_INSIDE; - - - // only inside or intersect possible - for (i = 0; i < 8; i++) - { - p = box.GetPointNr (i); - val = Plane::CalcFunctionValue (p); - if (val > 0) - return DOES_INTERSECT; - } - return IS_INSIDE; - } - - - - /* - for (i = 1; i <= 8; i++) - { - box.GetPointNr (i, p); - val = CalcFunctionValue (p); - if (val > 0) inside = 0; - if (val < 0) outside = 0; - } - - if (inside) return IS_INSIDE; - if (outside) return IS_OUTSIDE; - return DOES_INTERSECT; - */ -} - - - -// double Plane :: CalcFunctionValue (const Point<3> & p3d) const -// { -// return cx * p3d(0) + cy * p3d(1) + cz * p3d(2) + c1; -// } - -void Plane :: CalcGradient (const Point<3> & /* p */, Vec<3> & grad) const -{ - grad(0) = cx; - grad(1) = cy; - grad(2) = cz; -} - -void Plane :: CalcHesse (const Point<3> & /* p */, Mat<3> & hesse) const -{ - hesse = 0; -} - -double Plane :: HesseNorm () const -{ - return 0; -} - - -Point<3> Plane :: GetSurfacePoint () const -{ - return p; -} - - -void Plane :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - // find triangle, such that - // boundingbox /cap plane is contained in it - - Point<3> c = boundingbox.Center(); - double r = boundingbox.Diam(); - - Project (c); - Vec<3> t1 = n.GetNormal(); - Vec<3> t2 = Cross (n, t1); - - t1.Normalize(); - t2.Normalize(); - - tas.AddPoint (c + (-0.5 * r) * t2 + (sqrt(0.75) * r) * t1); - tas.AddPoint (c + (-0.5 * r) * t2 + (-sqrt(0.75) * r) * t1); - tas.AddPoint (c + r * t2); - - tas.AddTriangle (TATriangle (0, 0, 1, 2)); -} - - - - -Sphere :: Sphere (const Point<3> & ac, double ar) -{ - c = ac; - r = ar; - - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - c(0) / r; - cy = - c(1) / r; - cz = - c(2) / r; - c1 = (c(0) * c(0) + c(1) * c(1) + c(2) * c(2)) / (2 * r) - r / 2; -} - -void Sphere :: GetPrimitiveData (char *& classname, ARRAY<double> & coeffs) const -{ - classname = "sphere"; - coeffs.SetSize (4); - coeffs.Elem(1) = c(0); - coeffs.Elem(2) = c(1); - coeffs.Elem(3) = c(2); - coeffs.Elem(4) = r; -} - -void Sphere :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - c(0) = coeffs.Elem(1); - c(1) = coeffs.Elem(2); - c(2) = coeffs.Elem(3); - r = coeffs.Elem(4); - - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - c(0) / r; - cy = - c(1) / r; - cz = - c(2) / r; - c1 = (c(0) * c(0) + c(1) * c(1) + c(2) * c(2)) / (2 * r) - r / 2; -} - -Primitive * Sphere :: CreateDefault () -{ - return new Sphere (Point<3> (0,0,0), 1); -} - - - -Primitive * Sphere :: Copy () const -{ - return new Sphere (c, r); -} - -void Sphere :: Transform (Transformation<3> & trans) -{ - Point<3> hp; - trans.Transform (c, hp); - c = hp; - - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - c(0) / r; - cy = - c(1) / r; - cz = - c(2) / r; - c1 = (c(0) * c(0) + c(1) * c(1) + c(2) * c(2)) / (2 * r) - r / 2; -} - - - - -int Sphere :: IsIdentic (const Surface & s2, int & inv, double eps) const -{ - const Sphere * sp2 = dynamic_cast<const Sphere*> (&s2); - - if (!sp2) return 0; - - if (Dist (sp2->c, c) > eps) return 0; - if (fabs (sp2->r - r) > eps) return 0; - - inv = 0; - - return 1; -} - - -void Sphere :: DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2) -{ - Surface::DefineTangentialPlane (ap1, ap2); - - ez = p1 - c; - ez /= ez.Length(); - - ex = p2 - p1; - ex -= (ex * ez) * ez; - ex /= ex.Length(); - - ey = Cross (ez, ex); -} - - -void Sphere :: ToPlane (const Point<3> & p, Point<2> & pplane, double h, int & zone) const -{ - Vec<3> p1p; - - p1p = p - p1; - - /* - if (p1p * ez < -r) - { - zone = -1; - pplane = Point<2> (1E8, 1E8); - } - else - { - zone = 0; - p1p /= h; - pplane(0) = p1p * ex; - pplane(1) = p1p * ey; - } - */ - - Point<3> p1top = c + (c - p1); - - Vec<3> p1topp = p - p1top; - Vec<3> p1topp1 = p1 - p1top; - Vec<3> lam; - // SolveLinearSystem (ex, ey, p1topp, p1topp1, lam); - - Mat<3> m; - for (int i = 0; i < 3; i++) - { - m(i, 0) = ex(i); - m(i, 1) = ey(i); - m(i, 2) = p1topp(i); - } - m.Solve (p1topp1, lam); - - pplane(0) = -lam(0) / h; - pplane(1) = -lam(1) / h; - - if (lam(2) > 2) - zone = -1; - else - zone = 0; -} - -void Sphere :: FromPlane (const Point<2> & pplane, Point<3> & p, double h) const -{ - /* - // Vec<3> p1p; - double z; - Point<2> pplane2 (pplane); - - pplane2(0) *= h; - pplane2(1) *= h; - z = -r + sqrt (sqr (r) - sqr (pplane2(0)) - sqr (pplane2(1))); - // p = p1; - p(0) = p1(0) + pplane2(0) * ex(0) + pplane2(1) * ey(0) + z * ez(0); - p(1) = p1(1) + pplane2(0) * ex(1) + pplane2(1) * ey(1) + z * ez(1); - p(2) = p1(2) + pplane2(0) * ex(2) + pplane2(1) * ey(2) + z * ez(2); - */ - - Point<2> pplane2 (pplane); - - pplane2(0) *= h; - pplane2(1) *= h; - - p(0) = p1(0) + pplane2(0) * ex(0) + pplane2(1) * ey(0); - p(1) = p1(1) + pplane2(0) * ex(1) + pplane2(1) * ey(1); - p(2) = p1(2) + pplane2(0) * ex(2) + pplane2(1) * ey(2); - Project (p); -} - - -void Sphere :: Project (Point<3> & p) const -{ - Vec<3> v; - v = p - c; - v *= (r / v.Length()); - p = c + v; -} - - -INSOLID_TYPE Sphere :: BoxInSolid (const BoxSphere<3> & box) const -{ - double dist; - dist = Dist (box.Center(), c); - - if (dist - box.Diam()/2 > r) return IS_OUTSIDE; - if (dist + box.Diam()/2 < r) return IS_INSIDE; - return DOES_INTERSECT; -} - -double Sphere :: HesseNorm () const -{ - return 2 / r; -} - - -Point<3> Sphere :: GetSurfacePoint () const -{ - return c + Vec<3> (r, 0, 0); -} - - -void Sphere :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - int i, j; - double lg, bg; - int n = int(facets) + 1; - - for (j = 0; j <= n; j++) - for (i = 0; i <= n; i++) - { - lg = 2 * M_PI * double (i) / n; - bg = M_PI * (double(j) / n - 0.5); - - Point<3> p(c(0) + r * cos(bg) * sin (lg), - c(1) + r * cos(bg) * cos (lg), - c(2) + r * sin(bg)); - tas.AddPoint (p); - } - - for (j = 0; j < n; j++) - for (i = 0; i < n; i++) - { - int pi = i + (n+1) * j; - tas.AddTriangle (TATriangle (0, pi, pi+1, pi+n+2)); - tas.AddTriangle (TATriangle (0, pi, pi+n+2, pi+n+1)); - } -} - - - - - -Ellipsoid :: -Ellipsoid (const Point<3> & aa, - const Vec<3> & av1, const Vec<3> & av2, const Vec<3> & av3) -{ - a = aa; - v1 = av1; - v2 = av2; - v3 = av3; - - CalcData(); -} - - -void Ellipsoid :: CalcData () -{ - // f = (x-a, vl)^2 / |vl|^2 + (x-a, vs)^2 / |vs|^2 -1 - // f = sum_{i=1}^3 (x-a,v_i)^2 / |vi|^4 - 1 = sum (x-a,hv_i)^2 - - Vec<3> hv1, hv2, hv3; - double lv1 = v1.Length2 (); - if (lv1 < 1e-32) lv1 = 1; - double lv2 = v2.Length2 (); - if (lv2 < 1e-32) lv2 = 1; - double lv3 = v3.Length2 (); - if (lv3 < 1e-32) lv3 = 1; - - rmin = sqrt (min3 (lv1, lv2, lv3)); - - hv1 = (1.0 / lv1) * v1; - hv2 = (1.0 / lv2) * v2; - hv3 = (1.0 / lv3) * v3; - - cxx = hv1(0) * hv1(0) + hv2(0) * hv2(0) + hv3(0) * hv3(0); - cyy = hv1(1) * hv1(1) + hv2(1) * hv2(1) + hv3(1) * hv3(1); - czz = hv1(2) * hv1(2) + hv2(2) * hv2(2) + hv3(2) * hv3(2); - - cxy = 2 * (hv1(0) * hv1(1) + hv2(0) * hv2(1) + hv3(0) * hv3(1)); - cxz = 2 * (hv1(0) * hv1(2) + hv2(0) * hv2(2) + hv3(0) * hv3(2)); - cyz = 2 * (hv1(1) * hv1(2) + hv2(1) * hv2(2) + hv3(1) * hv3(2)); - - Vec<3> va (a); - c1 = sqr(va * hv1) + sqr(va * hv2) + sqr(va * hv3) - 1; - - Vec<3> v = -2 * (va * hv1) * hv1 - 2 * (va * hv2) * hv2 - 2 * (va * hv3) * hv3; - cx = v(0); - cy = v(1); - cz = v(2); -} - - -INSOLID_TYPE Ellipsoid :: BoxInSolid (const BoxSphere<3> & box) const -{ - // double grad = 2.0 / rmin; - // double grad = 3*(box.Center()-a).Length() / (rmin*rmin*rmin); - - double ggrad = 1.0 / (rmin*rmin); - Vec<3> g; - double val = CalcFunctionValue (box.Center()); - CalcGradient (box.Center(), g); - double grad = g.Length(); - - double r = box.Diam() / 2; - double maxval = grad * r + ggrad * r * r; - - // (*testout) << "box = " << box << ", val = " << val << ", maxval = " << maxval << endl; - - if (val > maxval) return IS_OUTSIDE; - if (val < -maxval) return IS_INSIDE; - return DOES_INTERSECT; -} - - -double Ellipsoid :: HesseNorm () const -{ - return 1.0/ (rmin * rmin); -} - -Point<3> Ellipsoid :: GetSurfacePoint () const -{ - return a + v1; -} - - - -void Ellipsoid :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - int i, j; - double lg, bg; - int n = int(facets) + 1; - - for (j = 0; j <= n; j++) - for (i = 0; i <= n; i++) - { - lg = 2 * M_PI * double (i) / n; - bg = M_PI * (double(j) / n - 0.5); - - - Point<3> p(a + - sin (bg) * v1 + - cos (bg) * sin (lg) * v2 + - cos (bg) * cos (lg) * v3); - - tas.AddPoint (p); - } - - for (j = 0; j < n; j++) - for (i = 0; i < n; i++) - { - int pi = i + (n+1) * j; - tas.AddTriangle (TATriangle (0, pi, pi+1, pi+n+2)); - tas.AddTriangle (TATriangle (0, pi, pi+n+2, pi+n+1)); - } -} - - - - - - - - - - - - - - - - - - - - -Cylinder :: Cylinder (const Point<3> & aa, const Point<3> & ab, double ar) -{ - a = aa; - b = ab; - vab = (b - a); - vab /= vab.Length(); - r = ar; - - // ( <x,x> - 2 <x,a> + <a,a> - // - <x,vab>^2 + 2 <x,vab> <a, vab> - <a, vab>^2 - // - r^2) / (2r) = 0 - - double hv; - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - a(0) / r; - cy = - a(1) / r; - cz = - a(2) / r; - c1 = (a(0) * a(0) + a(1) * a(1) + a(2) * a(2)) / (2 * r); - hv = a(0) * vab(0) + a(1) * vab(1) + a(2) * vab(2); - cxx -= vab(0) * vab(0) / (2 * r); - cyy -= vab(1) * vab(1) / (2 * r); - czz -= vab(2) * vab(2) / (2 * r); - cxy -= vab(0) * vab(1) / r; - cxz -= vab(0) * vab(2) / r; - cyz -= vab(1) * vab(2) / r; - cx += vab(0) * hv / r; - cy += vab(1) * hv / r; - cz += vab(2) * hv / r; - c1 -= hv * hv / (2 * r); - c1 -= r / 2; - // PrintCoeff (); -} - - - -void Cylinder :: GetPrimitiveData (char *& classname, ARRAY<double> & coeffs) const -{ - classname = "cylinder"; - coeffs.SetSize (7); - coeffs.Elem(1) = a(0); - coeffs.Elem(2) = a(1); - coeffs.Elem(3) = a(2); - coeffs.Elem(4) = b(0); - coeffs.Elem(5) = b(1); - coeffs.Elem(6) = b(2); - coeffs.Elem(7) = r; -} - -void Cylinder :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - a(0) = coeffs.Elem(1); - a(1) = coeffs.Elem(2); - a(2) = coeffs.Elem(3); - b(0) = coeffs.Elem(4); - b(1) = coeffs.Elem(5); - b(2) = coeffs.Elem(6); - r = coeffs.Elem(7); - - - vab = (b - a); - vab /= vab.Length(); - - - double hv; - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - a(0) / r; - cy = - a(1) / r; - cz = - a(2) / r; - c1 = (a(0) * a(0) + a(1) * a(1) + a(2) * a(2)) / (2 * r); - hv = a(0) * vab(0) + a(1) * vab(1) + a(2) * vab(2); - cxx -= vab(0) * vab(0) / (2 * r); - cyy -= vab(1) * vab(1) / (2 * r); - czz -= vab(2) * vab(2) / (2 * r); - cxy -= vab(0) * vab(1) / r; - cxz -= vab(0) * vab(2) / r; - cyz -= vab(1) * vab(2) / r; - cx += vab(0) * hv / r; - cy += vab(1) * hv / r; - cz += vab(2) * hv / r; - c1 -= hv * hv / (2 * r); - c1 -= r / 2; -} - -Primitive * Cylinder :: CreateDefault () -{ - return new Cylinder (Point<3> (0,0,0), Point<3> (1,0,0), 1); -} - - - - -Primitive * Cylinder :: Copy () const -{ - return new Cylinder (a, b, r); -} - - -int Cylinder :: IsIdentic (const Surface & s2, int & inv, double eps) const -{ - const Cylinder * cyl2 = dynamic_cast<const Cylinder*> (&s2); - - if (!cyl2) return 0; - - if (fabs (cyl2->r - r) > eps) return 0; - - Vec<3> v1 = b - a; - Vec<3> v2 = cyl2->a - a; - - if ( fabs (v1 * v2) < (1-eps) * v1.Length() * v2.Length()) return 0; - v2 = cyl2->b - a; - if ( fabs (v1 * v2) < (1-eps) * v1.Length() * v2.Length()) return 0; - - inv = 0; - return 1; -} - - - -void Cylinder :: Transform (Transformation<3> & trans) -{ - Point<3> hp; - trans.Transform (a, hp); - a = hp; - trans.Transform (b, hp); - b = hp; - - vab = (b - a); - vab /= vab.Length(); - - // ( <x,x> - 2 <x,a> + <a,a> - // - <x,vab>^2 + 2 <x,vab> <a, vab> - <a, vab>^2 - // - r^2) / (2r) = 0 - - double hv; - cxx = cyy = czz = 0.5 / r; - cxy = cxz = cyz = 0; - cx = - a(0) / r; - cy = - a(1) / r; - cz = - a(2) / r; - c1 = (a(0) * a(0) + a(1) * a(1) + a(2) * a(2)) / (2 * r); - hv = a(0) * vab(0) + a(1) * vab(1) + a(2) * vab(2); - cxx -= vab(0) * vab(0) / (2 * r); - cyy -= vab(1) * vab(1) / (2 * r); - czz -= vab(2) * vab(2) / (2 * r); - cxy -= vab(0) * vab(1) / r; - cxz -= vab(0) * vab(2) / r; - cyz -= vab(1) * vab(2) / r; - cx += vab(0) * hv / r; - cy += vab(1) * hv / r; - cz += vab(2) * hv / r; - c1 -= hv * hv / (2 * r); - c1 -= r / 2; - // PrintCoeff (); -} - - - - - - - - - -void Cylinder :: DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2) -{ - Surface::DefineTangentialPlane (ap1, ap2); - - ez = Center (p1, p2) - a; - ez -= (ez * vab) * vab; - ez /= ez.Length(); - - ex = p2 - p1; - ex -= (ex * ez) * ez; - ex /= ex.Length(); - - ey = Cross (ez, ex); -} - - -void Cylinder :: ToPlane (const Point<3> & p, - Point<2> & pplane, - double h, int & zone) const -{ - Point<3> cp1p2 = Center (p1, p2); - Project (cp1p2); - - Point<3> ccp1p2 = a + ( (cp1p2 - a) * vab ) * vab; - - Vec<3> er = cp1p2 - ccp1p2; - er.Normalize(); - Vec<3> ephi = Cross (vab, er); - - double co, si; - Point<2> p1p, p2p, pp; - - co = er * (p1 - ccp1p2); - si = ephi * (p1 - ccp1p2); - p1p(0) = r * atan2 (si, co); - p1p(1) = vab * (p1 - ccp1p2); - - co = er * (p2 - ccp1p2); - si = ephi * (p2 - ccp1p2); - p2p(0) = r * atan2 (si, co); - p2p(1) = vab * (p2 - ccp1p2); - - co = er * (p - ccp1p2); - si = ephi * (p - ccp1p2); - - double phi = atan2 (si, co); - pp(0) = r * phi; - pp(1) = vab * (p - ccp1p2); - - zone = 0; - if (phi > 1.57) zone = 1; - if (phi < -1.57) zone = 2; - - - - Vec<2> e2x = p2p - p1p; - e2x /= e2x.Length(); - - Vec<2> e2y (-e2x(1), e2x(0)); - - Vec<2> p1pp = pp - p1p; - - - pplane(0) = (p1pp * e2x) / h; - pplane(1) = (p1pp * e2y) / h; - - /* - (*testout) << "p1 = " << p1 << ", p2 = " << p2 << endl; - (*testout) << "p = " << p << ", pp = " << pp << ", pplane = " << pplane << endl; - */ - - /* - Vec<3> p1p; - - p1p = p - p1; - - if (p1p * ez < -1 * r) - { - zone = -1; - pplane(0) = 1e8; - pplane(1) = 1e8; - } - else - { - zone = 0; - p1p /= h; - pplane(0) = p1p * ex; - pplane(1) = p1p * ey; - } - */ -} - -void Cylinder :: FromPlane (const Point<2> & pplane, Point<3> & p, double h) const -{ - Point<2> pplane2 (pplane); - - pplane2(0) *= h; - pplane2(1) *= h; - - p(0) = p1(0) + pplane2(0) * ex(0) + pplane2(1) * ey(0); - p(1) = p1(1) + pplane2(0) * ex(1) + pplane2(1) * ey(1); - p(2) = p1(2) + pplane2(0) * ex(2) + pplane2(1) * ey(2); - Project (p); -} - - -void Cylinder :: Project (Point<3> & p) const -{ - Vec<3> v; - Point<3> c; - - c = a + ((p - a) * vab) * vab; - v = p - c; - v *= (r / v.Length()); - p = c + v; -} -/* -int Cylinder :: RootInBox (const BoxSphere<3> & box) const - { - double dist; - dist = sqrt (2 * CalcFunctionValue(box.Center()) * r + r * r); - if (fabs (dist - r) > box.Diam()/2) return 0; - return 2; - } -*/ - -INSOLID_TYPE Cylinder :: BoxInSolid (const BoxSphere<3> & box) const -{ - double dist; - // dist = sqrt (2 * CalcFunctionValue(box.Center()) * r + r * r); - - dist = (2 * CalcFunctionValue(box.Center()) * r + r * r); - if (dist <= 0) dist = 0; - else dist = sqrt (dist + 1e-16); - - if (dist - box.Diam()/2 > r) return IS_OUTSIDE; - if (dist + box.Diam()/2 < r) return IS_INSIDE; - return DOES_INTERSECT; -} - - -double Cylinder :: HesseNorm () const -{ - return 2 / r; -} - -Point<3> Cylinder :: GetSurfacePoint () const -{ - Vec<3> vr; - if (fabs (vab(0)) > fabs(vab(2))) - vr = Vec<3> (vab(1), -vab(0), 0); - else - vr = Vec<3> (0, -vab(2), vab(1)); - - vr *= (r / vr.Length()); - return a + vr; -} - -void Cylinder :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - int i, j; - double lg, bg; - int n = int(facets) + 1; - - Vec<3> lvab = b - a; - Vec<3> n1 = lvab.GetNormal(); - Vec<3> n2 = Cross (lvab, n1); - - n1.Normalize(); - n2.Normalize(); - - - for (j = 0; j <= n; j++) - for (i = 0; i <= n; i++) - { - lg = 2 * M_PI * double (i) / n; - bg = double(j) / n; - - Point<3> p = a + (bg * lvab) - + ((r * cos(lg)) * n1) - + ((r * sin(lg)) * n2); - - tas.AddPoint (p); - } - - for (j = 0; j < n; j++) - for (i = 0; i < n; i++) - { - int pi = i + (n+1) * j; - tas.AddTriangle (TATriangle (0, pi, pi+1, pi+n+2)); - tas.AddTriangle (TATriangle (0, pi, pi+n+2, pi+n+1)); - } -} - - - - - - - - - -EllipticCylinder :: -EllipticCylinder (const Point<3> & aa, - const Vec<3> & avl, const Vec<3> & avs) -{ - a = aa; - vl = avl; - vs = avs; - - CalcData(); - Print (cout); -} - - -void EllipticCylinder :: CalcData () -{ - // f = (x-a, vl)^2 / |vl|^2 + (x-a, vs)^2 / |vs|^2 -1 - - Vec<3> hvl, hvs; - double lvl = vl.Length2 (); - if (lvl < 1e-32) lvl = 1; - double lvs = vs.Length2 (); - if (lvs < 1e-32) lvs = 1; - - hvl = (1.0 / lvl) * vl; - hvs = (1.0 / lvs) * vs; - - cxx = hvl(0) * hvl(0) + hvs(0) * hvs(0); - cyy = hvl(1) * hvl(1) + hvs(1) * hvs(1); - czz = hvl(2) * hvl(2) + hvs(2) * hvs(2); - - cxy = 2 * (hvl(0) * hvl(1) + hvs(0) * hvs(1)); - cxz = 2 * (hvl(0) * hvl(2) + hvs(0) * hvs(2)); - cyz = 2 * (hvl(1) * hvl(2) + hvs(1) * hvs(2)); - - Vec<3> va (a); - c1 = va * hvl + va * hvs - 1; - - Vec<3> v = -2 * (va * hvl) * hvl - 2 * (va * hvs) * hvs; - cx = v(0); - cy = v(1); - cz = v(2); -} - - -INSOLID_TYPE EllipticCylinder :: BoxInSolid (const BoxSphere<3> & box) const -{ - double grad = 2.0 / vs.Length (); - double ggrad = 1.0 / vs.Length2 (); - - double val = CalcFunctionValue (box.Center()); - double r = box.Diam() / 2; - double maxval = grad * r + ggrad * r * r; - - // (*testout) << "box = " << box << ", val = " << val << ", maxval = " << maxval << endl; - - if (val > maxval) return IS_OUTSIDE; - if (val < -maxval) return IS_INSIDE; - return DOES_INTERSECT; -} - - -double EllipticCylinder :: HesseNorm () const -{ - return 1.0/vs.Length2 (); -} - -Point<3> EllipticCylinder :: GetSurfacePoint () const -{ - return a + vl; -} - - - -void EllipticCylinder :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - int i, j; - double lg, bg; - int n = int(facets) + 1; - - Vec<3> axis = Cross (vl, vs); - - for (j = 0; j <= n; j++) - for (i = 0; i <= n; i++) - { - lg = 2 * M_PI * double (i) / n; - bg = double(j) / n; - - Point<3> p = a + (bg * axis) - + cos(lg) * vl + sin(lg) * vs; - - tas.AddPoint (p); - } - - for (j = 0; j < n; j++) - for (i = 0; i < n; i++) - { - int pi = i + (n+1) * j; - tas.AddTriangle (TATriangle (0, pi, pi+1, pi+n+2)); - tas.AddTriangle (TATriangle (0, pi, pi+n+2, pi+n+1)); - } -} - - - - - - - - - - -Cone :: Cone (const Point<3> & aa, const Point<3> & ab, - double ara, double arb) -{ - a = aa; - b = ab; - ra = ara; - rb = arb; - - CalcData(); - Print (cout); -} - - -Primitive * Cone :: CreateDefault () -{ - return new Cone (Point<3> (0,0,0), Point<3> (1,0,0), 0.5, 0.2); -} - - - - -void Cone :: GetPrimitiveData (char *& classname, ARRAY<double> & coeffs) const -{ - classname = "cone"; - coeffs.SetSize (8); - coeffs.Elem(1) = a(0); - coeffs.Elem(2) = a(1); - coeffs.Elem(3) = a(2); - coeffs.Elem(4) = b(0); - coeffs.Elem(5) = b(1); - coeffs.Elem(6) = b(2); - coeffs.Elem(7) = ra; - coeffs.Elem(8) = rb; -} - -void Cone :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - a(0) = coeffs.Elem(1); - a(1) = coeffs.Elem(2); - a(2) = coeffs.Elem(3); - b(0) = coeffs.Elem(4); - b(1) = coeffs.Elem(5); - b(2) = coeffs.Elem(6); - ra = coeffs.Elem(7); - rb = coeffs.Elem(8); - - CalcData(); -} - -void Cone :: CalcData () -{ - - minr = (ra < rb) ? ra : rb; - - vab = b - a; - vabl = vab.Length(); - - Vec<3> va (a); - - // - // f = r(P)^2 - R(z(P))^2 - // - // z(P) = t0vec * P + t0 = (P-a, b-a)/(b-a,b-a) - // R(z(P)) = t1vec * P + t1 = rb * z + ra * (1-z) - // r(P)^2 =||P-a||^2 - ||a-b||^2 z^2k - - - t0vec = vab; - t0vec /= (vabl * vabl); - t0 = -(va * vab) / (vabl * vabl); - - t1vec = t0vec; - t1vec *= (rb - ra); - t1 = ra + (rb - ra) * t0; - - cxx = cyy = czz = 1; - cxy = cxz = cyz = 0; - - cxx = 1 - (vab*vab) * t0vec(0) * t0vec(0) - t1vec(0) * t1vec(0); - cyy = 1 - (vab*vab) * t0vec(1) * t0vec(1) - t1vec(1) * t1vec(1); - czz = 1 - (vab*vab) * t0vec(2) * t0vec(2) - t1vec(2) * t1vec(2); - - cxy = -2 * (vab * vab) * t0vec(0) * t0vec(1) - 2 * t1vec(0) * t1vec(1); - cxz = -2 * (vab * vab) * t0vec(0) * t0vec(2) - 2 * t1vec(0) * t1vec(2); - cyz = -2 * (vab * vab) * t0vec(1) * t0vec(2) - 2 * t1vec(1) * t1vec(2); - - cx = -2 * a(0) - 2 * (vab * vab) * t0 * t0vec(0) - 2 * t1 * t1vec(0); - cy = -2 * a(1) - 2 * (vab * vab) * t0 * t0vec(1) - 2 * t1 * t1vec(1); - cz = -2 * a(2) - 2 * (vab * vab) * t0 * t0vec(2) - 2 * t1 * t1vec(2); - - c1 = va.Length2() - (vab * vab) * t0 * t0 - t1 * t1; - - // (*testout) << "t0vec = " << t0vec << " t0 = " << t0 << endl; - // (*testout) << "t1vec = " << t1vec << " t1 = " << t1 << endl; - // PrintCoeff (*testout); -} - - -INSOLID_TYPE Cone :: BoxInSolid (const BoxSphere<3> & box) const -{ - double rp, dist; - - Vec<3> cv(box.Center()); - - rp = cv * t1vec + t1; - dist = sqrt (CalcFunctionValue(box.Center()) + rp * rp) - rp; - - if (dist - box.Diam() > 0) return IS_OUTSIDE; - if (dist + box.Diam() < 0) return IS_INSIDE; - return DOES_INTERSECT; -} - - -double Cone :: HesseNorm () const -{ - return 2 / minr; -} - - -double Cone :: LocH (const Point<3> & p, double x, - double c, double hmax) const -{ - double bloch = Surface::LocH (p, x, c, hmax); - Vec<3> g; - CalcGradient (p, g); - - double lam = Abs(g); - double meancurv = - -( 2 * g(0)*g(1)*cxy - 2 * czz * (g(0)*g(0)+g(1)*g(1)) - +2 * g(1)*g(2)*cyz - 2 * cxx * (g(1)*g(1)+g(2)*g(2)) - +2 * g(0)*g(2)*cxz - 2 * cyy * (g(0)*g(0)+g(2)*g(2))) / (3*lam*lam*lam); - - // cout << "type = " << typeid(*this).name() << ", baseh = " << bloch << ", meancurv = " << meancurv << endl; - // return bloch; - - meancurv = fabs (meancurv); - if (meancurv < 1e-20) meancurv = 1e-20; - - // cout << "c = " << c << ", safety = " << mparam.curvaturesafety << endl; - double hcurv = 1.0/(3*meancurv*mparam.curvaturesafety); - - return min2 (hmax, hcurv); -} - - -Point<3> Cone :: GetSurfacePoint () const -{ - Vec<3> vr = vab.GetNormal (); - - vr *= (ra / vr.Length()); - return a + vr; -} - - - - - -void Cone :: GetTriangleApproximation -(TriangleApproximation & tas, - const Box<3> & boundingbox, double facets) const -{ - int i, j; - double lg, bg; - int n = int(facets) + 1; - - Vec<3> lvab = b - a; - Vec<3> n1 = lvab.GetNormal(); - Vec<3> n2 = Cross (lvab, n1); - - n1.Normalize(); - n2.Normalize(); - - - for (j = 0; j <= n; j++) - for (i = 0; i <= n; i++) - { - lg = 2 * M_PI * double (i) / n; - bg = double(j) / n; - - Point<3> p = a + (bg * lvab) - + (( (ra+(rb-ra)*bg) * cos(lg)) * n1) - + (( (ra+(rb-ra)*bg) * sin(lg)) * n2); - - tas.AddPoint (p); - } - - for (j = 0; j < n; j++) - for (i = 0; i < n; i++) - { - int pi = i + (n+1) * j; - tas.AddTriangle (TATriangle (0, pi, pi+1, pi+n+2)); - tas.AddTriangle (TATriangle (0, pi, pi+n+2, pi+n+1)); - } -} -} diff --git a/contrib/Netgen/libsrc/csg/algprim.hpp b/contrib/Netgen/libsrc/csg/algprim.hpp deleted file mode 100644 index aeb829f9c1917c6fce4144650f8a526fc001c8e4..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/algprim.hpp +++ /dev/null @@ -1,338 +0,0 @@ -#ifndef FILE_ALGPRIM -#define FILE_ALGPRIM - - -/**************************************************************************/ -/* File: algprim.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 1. Dez. 95 */ -/**************************************************************************/ - -/* - -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; -public: - /// - Plane (const Point<3> & ap, Vec<3> an); - - virtual void GetPrimitiveData (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 (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); - - virtual void GetPrimitiveData (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 (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; - -private: - void CalcData(); -}; - - - - - - -/// -class Ellipsoid : public QuadraticSurface -{ -private: - /// - Point<3> a; - /// - Vec<3> v1, v2, v3; - /// - double rmin; -public: - /// - Ellipsoid (const Point<3> & aa, - const Vec<3> & av1, - const Vec<3> & av2, - const Vec<3> & av3); - /// - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - /// - virtual double HesseNorm () const; - /// - virtual 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 (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 double LocH (const Point<3> & p, double x, - double c, double hmax) const; - - /// - virtual Point<3> GetSurfacePoint () const; - - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const; - -private: - void CalcData(); -}; - - -#endif diff --git a/contrib/Netgen/libsrc/csg/brick.cpp b/contrib/Netgen/libsrc/csg/brick.cpp deleted file mode 100644 index f408e922f4c6765bebd40fb965a7c8107c1441e6..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/brick.cpp +++ /dev/null @@ -1,409 +0,0 @@ -#include <mystdlib.h> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ - -Parallelogram3d :: Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3) -{ - p1 = ap1; - p2 = ap2; - p3 = ap3; - - CalcData(); -} - -Parallelogram3d ::~Parallelogram3d () -{ - ; -} - -void Parallelogram3d :: SetPoints (Point<3> ap1, - Point<3> ap2, - Point<3> ap3) -{ - p1 = ap1; - p2 = ap2; - p3 = ap3; - - CalcData(); -} - -void Parallelogram3d :: CalcData() -{ - v12 = p2 - p1; - v13 = p3 - p1; - p4 = p2 + v13; - - n = Cross (v12, v13); - n.Normalize(); -} - -int Parallelogram3d :: -IsIdentic (const Surface & s2, int & inv, double eps) const -{ - int id = - (fabs (s2.CalcFunctionValue (p1)) <= eps) && - (fabs (s2.CalcFunctionValue (p2)) <= eps) && - (fabs (s2.CalcFunctionValue (p3)) <= eps); - - if (id) - { - Vec<3> n2; - n2 = s2.GetNormalVector(p1); - inv = (n * n2) < 0; - } - return id; -} - - -double Parallelogram3d :: CalcFunctionValue (const Point<3> & point) const -{ - return n * (point - p1); -} - -void Parallelogram3d :: CalcGradient (const Point<3> & point, - Vec<3> & grad) const -{ - grad = n; -} - -void Parallelogram3d :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const -{ - hesse = 0; -} - -double Parallelogram3d :: HesseNorm () const -{ - return 0; -} - -Point<3> Parallelogram3d :: GetSurfacePoint () const -{ - return p1; -} - -void Parallelogram3d :: Print (ostream & str) const -{ - str << "Parallelogram3d " << p1 << " - " << p2 << " - " << p3 << endl; -} - - -void Parallelogram3d :: -GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & bbox, - double facets) const -{ - tas.AddPoint (p1); - tas.AddPoint (p2); - tas.AddPoint (p3); - tas.AddPoint (p4); - tas.AddTriangle (TATriangle (0, 0, 1, 2)); - tas.AddTriangle (TATriangle (0, 2, 1, 3)); -} - - - - - - - - - - -Brick :: Brick (Point<3> ap1, Point<3> ap2, - Point<3> ap3, Point<3> ap4) -{ - faces.SetSize (6); - surfaceids.SetSize (6); - surfaceactive.SetSize(6); - - p1 = ap1; p2 = ap2; - p3 = ap3; p4 = ap4; - - for (int i = 0; i < 6; i++) - { - faces[i] = new Plane (Point<3>(0,0,0), Vec<3> (0,0,1)); - surfaceactive[i] = 1; - } - - CalcData(); -} - -Brick :: ~Brick () -{ - for (int i = 0; i < 6; i++) - delete faces[i]; -} - -Primitive * Brick :: CreateDefault () -{ - return new Brick (Point<3> (0,0,0), - Point<3> (1,0,0), - Point<3> (0,1,0), - Point<3> (0,0,1)); -} - - -INSOLID_TYPE Brick :: BoxInSolid (const BoxSphere<3> & box) const -{ - /* - int i; - double maxval; - for (i = 1; i <= 6; i++) - { - double val = faces.Get(i)->CalcFunctionValue (box.Center()); - if (i == 1 || val > maxval) - maxval = val; - } - - if (maxval > box.Diam()) return IS_OUTSIDE; - if (maxval < -box.Diam()) return IS_INSIDE; - return DOES_INTERSECT; - */ - - bool inside = 1; - bool outside = 0; - - for (int i = 0; i < 6; i++) - { - bool outsidei = 1; - for (int j = 0; j < 8; j++) - { - Point<3> p = box.GetPointNr (j); - double val = faces[i]->CalcFunctionValue (p); - - if (val > 0) inside = 0; - if (val < 0) outsidei = 0; - } - if (outsidei) outside = 1; - } - - if (outside) return IS_OUTSIDE; - if (inside) return IS_INSIDE; - return DOES_INTERSECT; -} - -INSOLID_TYPE Brick :: PointInSolid (const Point<3> & p, - double eps) const -{ - double maxval = faces[0] -> CalcFunctionValue (p); - for (int i = 1; i < 6; i++) - { - double val = faces[i] -> CalcFunctionValue (p); - if (val > maxval) maxval = val; - } - - if (maxval > eps) return IS_OUTSIDE; - if (maxval < -eps) return IS_INSIDE; - return DOES_INTERSECT; -} - -INSOLID_TYPE Brick :: VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const -{ - INSOLID_TYPE is = IS_INSIDE; - Vec<3> grad; - double scal; - - for (int i = 0; i < faces.Size(); i++) - { - if (faces[i] -> PointOnSurface (p, eps)) - { - GetSurface(i).CalcGradient (p, grad); - scal = v * grad; - - if (scal >= eps) - is = IS_OUTSIDE; - if (scal >= -eps && is == IS_INSIDE) - is = DOES_INTERSECT; - } - } - return is; - /* - Point<3> p2 = p + 1e-2 * v; - return PointInSolid (p2, eps); - */ -} - - -void Brick :: -GetPrimitiveData (char *& classname, ARRAY<double> & coeffs) const -{ - classname = "brick"; - coeffs.SetSize(12); - coeffs.Elem(1) = p1(0); - coeffs.Elem(2) = p1(1); - coeffs.Elem(3) = p1(2); - - coeffs.Elem(4) = p2(0); - coeffs.Elem(5) = p2(1); - coeffs.Elem(6) = p2(2); - - coeffs.Elem(7) = p3(0); - coeffs.Elem(8) = p3(1); - coeffs.Elem(9) = p3(2); - - coeffs.Elem(10) = p4(0); - coeffs.Elem(11) = p4(1); - coeffs.Elem(12) = p4(2); -} - -void Brick :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - p1(0) = coeffs.Elem(1); - p1(1) = coeffs.Elem(2); - p1(2) = coeffs.Elem(3); - - p2(0) = coeffs.Elem(4); - p2(1) = coeffs.Elem(5); - p2(2) = coeffs.Elem(6); - - p3(0) = coeffs.Elem(7); - p3(1) = coeffs.Elem(8); - p3(2) = coeffs.Elem(9); - - p4(0) = coeffs.Elem(10); - p4(1) = coeffs.Elem(11); - p4(2) = coeffs.Elem(12); - - CalcData(); -} - - - -void Brick :: CalcData() -{ - v12 = p2 - p1; - v13 = p3 - p1; - v14 = p4 - p1; - - Point<3> pi[8]; - int i1, i2, i3; - int i, j; - - i = 0; - for (i3 = 0; i3 <= 1; i3++) - for (i2 = 0; i2 <= 1; i2++) - for (i1 = 0; i1 <= 1; i1++) - { - pi[i] = p1 + i1 * v12 + i2 * v13 + i3 * v14; - i++; - } - - static int lface[6][4] = - { { 1, 3, 2, 4 }, - { 5, 6, 7, 8 }, - { 1, 2, 5, 6 }, - { 3, 7, 4, 8 }, - { 1, 5, 3, 7 }, - { 2, 4, 6, 8 } }; - - ARRAY<double> data(6); - for (i = 0; i < 6; i++) - { - const Point<3> p1 = pi[lface[i][0]-1]; - const Point<3> p2 = pi[lface[i][1]-1]; - const Point<3> p3 = pi[lface[i][2]-1]; - - Vec<3> n = Cross ((p2-p1), (p3-p1)); - n.Normalize(); - - for (j = 0; j < 3; j++) - { - data[j] = p1(j); - data[j+3] = n(j); - } - faces[i] -> SetPrimitiveData (data); - /* - { - faces.Elem(i+1) -> SetPoints - (pi[lface[i][0]-1], - pi[lface[i][1]-1], - pi[lface[i][2]-1]); - } - */ - } -} - - -void Brick :: Reduce (const BoxSphere<3> & box) -{ - double val; - Point<3> p; - for (int i = 0; i < 6; i++) - { - bool hasout = 0; - bool hasin = 0; - for (int j = 0; j < 8; j++) - { - p = box.GetPointNr (j); - val = faces[i]->CalcFunctionValue (p); - if (val > 0) hasout = 1; - else if (val < 0) hasin = 1; - } - surfaceactive[i] = hasout && hasin; - } -} - -void Brick :: UnReduce () -{ - for (int i = 0; i < 6; i++) - surfaceactive[i] = 1; -} - - - -OrthoBrick :: OrthoBrick (const Point<3> & ap1, const Point<3> & ap2) - : Brick (ap1, - Point<3> (ap2(0), ap1(1), ap1(2)), - Point<3> (ap1(0), ap2(1), ap1(2)), - Point<3> (ap1(0), ap1(1), ap2(2))) -{ - pmin = ap1; - pmax = ap2; -} - -INSOLID_TYPE OrthoBrick :: BoxInSolid (const BoxSphere<3> & box) const -{ - if (pmin(0) > box.PMax()(0) || - pmin(1) > box.PMax()(1) || - pmin(2) > box.PMax()(2) || - pmax(0) < box.PMin()(0) || - pmax(1) < box.PMin()(1) || - pmax(2) < box.PMin()(2)) - return IS_OUTSIDE; - - if (pmin(0) < box.PMin()(0) && - pmin(1) < box.PMin()(1) && - pmin(2) < box.PMin()(2) && - pmax(0) > box.PMax()(0) && - pmax(1) > box.PMax()(1) && - pmax(2) > box.PMax()(2)) - return IS_INSIDE; - - return DOES_INTERSECT; -} - - -void OrthoBrick :: Reduce (const BoxSphere<3> & box) -{ - surfaceactive.Elem(1) = - (box.PMin()(2) < pmin(2)) && (pmin(2) < box.PMax()(2)); - surfaceactive.Elem(2) = - (box.PMin()(2) < pmax(2)) && (pmax(2) < box.PMax()(2)); - - surfaceactive.Elem(3) = - (box.PMin()(1) < pmin(1)) && (pmin(1) < box.PMax()(1)); - surfaceactive.Elem(4) = - (box.PMin()(1) < pmax(1)) && (pmax(1) < box.PMax()(1)); - - surfaceactive.Elem(5) = - (box.PMin()(0) < pmin(0)) && (pmin(0) < box.PMax()(0)); - surfaceactive.Elem(6) = - (box.PMin()(0) < pmax(0)) && (pmax(0) < box.PMax()(0)); -} -} diff --git a/contrib/Netgen/libsrc/csg/brick.hpp b/contrib/Netgen/libsrc/csg/brick.hpp deleted file mode 100644 index 11106b66d3533a7c4963c16eb763733ea93a71d7..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/brick.hpp +++ /dev/null @@ -1,98 +0,0 @@ -#ifndef FILE_BRICK -#define FILE_BRICK - - -/**************************************************************************/ -/* File: brick.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 11. Mar. 98 */ -/**************************************************************************/ - -/* - - brick geometry, has several surfaces - -*/ - - - -class Parallelogram3d : public Surface -{ - Point<3> p1, p2, p3, p4; - Vec<3> v12, v13; - Vec<3> n; - -public: - Parallelogram3d (Point<3> ap1, Point<3> ap2, Point<3> ap3); - virtual ~Parallelogram3d (); - void SetPoints (Point<3> ap1, Point<3> ap2, Point<3> ap3); - - virtual int IsIdentic (const Surface & s2, int & inv, double eps) const; - - virtual double CalcFunctionValue (const Point<3> & point) const; - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - virtual double HesseNorm () const; - - virtual Point<3> GetSurfacePoint () const; - virtual void Print (ostream & str) const; - - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const; - -protected: - void CalcData(); -}; - - -class Brick : public Primitive -{ - Point<3> p1, p2, p3, p4; - Vec<3> v12, v13, v14; - ARRAY<OneSurfacePrimitive*> faces; - -public: - Brick (Point<3> ap1, Point<3> ap2, Point<3> ap3, Point<3> ap4); - virtual ~Brick (); - 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; - - virtual int GetNSurfaces() const - { return 6; } - virtual Surface & GetSurface (int i) - { return *faces[i]; } - virtual const Surface & GetSurface (int i) const - { return *faces[i]; } - - - virtual void GetPrimitiveData (char *& classname, ARRAY<double> & coeffs) const; - virtual void SetPrimitiveData (ARRAY<double> & coeffs); - - virtual void Reduce (const BoxSphere<3> & box); - virtual void UnReduce (); - -protected: - void CalcData(); -}; - - -class OrthoBrick : public Brick -{ -protected: - Point<3> pmin, pmax; -public: - OrthoBrick (const Point<3> & ap1, const Point<3> & ap2); - - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; - virtual void Reduce (const BoxSphere<3> & box); -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/bspline2d.cpp b/contrib/Netgen/libsrc/csg/bspline2d.cpp deleted file mode 100644 index 93b5e89621d955619ec35655cc4547e3126d0cbc..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/bspline2d.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include <mystdlib.h> - -#include <csg.hpp> - -namespace netgen -{ - -BSplineCurve2d :: BSplineCurve2d () -{ - redlevel = 0; -} - - -void BSplineCurve2d :: AddPoint (const Point<2> & apoint) -{ - points.Append (apoint); - intervallused.Append (0); -} - -bool BSplineCurve2d :: Inside (const Point<2> & p, double & dist) const -{ - Point<2> hp = p; - double t = ProjectParam (p); - hp = Eval(t); - Vec<2> v = EvalPrime (t); - - Vec<2> n (v(0), -v(1)); - - cout << "p = " << p << ", hp = " << hp << endl; - dist = Dist (p, hp); - double scal = (hp-p) * n; - cout << "scal = " << scal << endl; - - return scal >= 0; -} - -double BSplineCurve2d :: ProjectParam (const Point<2> & p) const -{ - double t, dt, mindist, mint = 0.0; - int n1; - - mindist = 1e10; - dt = 0.2; - for (n1 = 1; n1 <= points.Size(); n1++) - if (intervallused.Get(n1) == 0) - for (t = n1; t <= n1+1; t += dt) - if (Dist (Eval(t), p) < mindist) - { - mint = t; - mindist = Dist (Eval(t), p); - } - - if (mindist > 1e9) - { - for (t = 0; t <= points.Size(); t += dt) - if (Dist (Eval(t), p) < mindist) - { - mint = t; - mindist = Dist (Eval(t), p); - } - } - - while (Dist (Eval (mint-dt), p) < mindist) - { - mindist = Dist (Eval (mint-dt), p); - mint -= dt; - } - while (Dist (Eval (mint+dt), p) < mindist) - { - mindist = Dist (Eval (mint+dt), p); - mint += dt; - } - - - return NumericalProjectParam (p, mint-dt, mint+dt); -} - - -// t \in (n1, n2) - -Point<2> BSplineCurve2d :: Eval (double t) const -{ - int n, n1, n2, n3, n4; - double loct, b1, b2, b3, b4; - Point<2> hp; - - static int cnt = 0; - cnt++; - if (cnt % 100000 == 0) (*mycout) << "cnt = " << cnt << endl; - - n = int(t); - loct = t - n; - - b1 = 0.25 * (1 - loct) * (1 - loct); - b4 = 0.25 * loct * loct; - b2 = 0.5 - b4; - b3 = 0.5 - b1; - - n1 = (n + 10 * points.Size() -1) % points.Size() + 1; - n2 = n1+1; - if (n2 > points.Size()) n2 = 1; - n3 = n2+1; - if (n3 > points.Size()) n3 = 1; - n4 = n3+1; - if (n4 > points.Size()) n4 = 1; - - // (*mycout) << "t = " << t << " n = " << n << " loct = " << loct - // << " n1 = " << n1 << endl; - - - hp(0) = b1 * points.Get(n1)(0) + b2 * points.Get(n2)(0) + - b3 * points.Get(n3)(0) + b4 * points.Get(n4)(0); - hp(1) = b1 * points.Get(n1)(1) + b2 * points.Get(n2)(1) + - b3 * points.Get(n3)(1) + b4 * points.Get(n4)(1); - return hp; -} - -Vec<2> BSplineCurve2d :: EvalPrime (double t) const -{ - int n, n1, n2, n3, n4; - double loct, db1, db2, db3, db4; - Vec<2> hv; - - n = int(t); - loct = t - n; - - db1 = 0.5 * (loct - 1); - db4 = 0.5 * loct; - db2 = -db4; - db3 = -db1; - - n1 = (n + 10 * points.Size() -1) % points.Size() + 1; - n2 = n1+1; - if (n2 > points.Size()) n2 = 1; - n3 = n2+1; - if (n3 > points.Size()) n3 = 1; - n4 = n3+1; - if (n4 > points.Size()) n4 = 1; - - hv(0) = db1 * points.Get(n1)(0) + db2 * points.Get(n2)(0) + - db3 * points.Get(n3)(0) + db4 * points.Get(n4)(0); - hv(1) = db1 * points.Get(n1)(1) + db2 * points.Get(n2)(1) + - db3 * points.Get(n3)(1) + db4 * points.Get(n4)(1); - return hv; -} - -Vec<2> BSplineCurve2d :: EvalPrimePrime (double t) const -{ - int n, n1, n2, n3, n4; - double ddb1, ddb2, ddb3, ddb4; - Vec<2> hv; - - n = int(t); - // double loct = t - n; - - ddb1 = 0.5; - ddb4 = 0.5; - ddb2 = -0.5; - ddb3 = -0.5; - - n1 = (n + 10 * points.Size() -1) % points.Size() + 1; - n2 = n1+1; - if (n2 > points.Size()) n2 = 1; - n3 = n2+1; - if (n3 > points.Size()) n3 = 1; - n4 = n3+1; - if (n4 > points.Size()) n4 = 1; - - hv(0) = ddb1 * points.Get(n1)(0) + ddb2 * points.Get(n2)(0) + - ddb3 * points.Get(n3)(0) + ddb4 * points.Get(n4)(0); - hv(1) = ddb1 * points.Get(n1)(1) + ddb2 * points.Get(n2)(1) + - ddb3 * points.Get(n3)(1) + ddb4 * points.Get(n4)(1); - return hv; -} - - -int BSplineCurve2d :: SectionUsed (double t) const -{ - int n1 = int(t); - n1 = (n1 + 10 * points.Size() - 1) % points.Size() + 1; - return (intervallused.Get(n1) == 0); -} - -void BSplineCurve2d :: Reduce (const Point<2> & p, double rad) -{ - int n1, n; - int j; - double minx, miny, maxx, maxy; - - // (*testout) << "Reduce: " << p << "," << rad << endl; - - redlevel++; - - for (n1 = 1; n1 <= points.Size(); n1++) - { - if (intervallused.Get(n1) != 0) continue; - - minx = maxx = points.Get(n1)(0); - miny = maxy = points.Get(n1)(1); - - n = n1; - for (j = 1; j <= 3; j++) - { - n++; - if (n > points.Size()) n = 1; - if (points.Get(n)(0) < minx) minx = points.Get(n)(0); - if (points.Get(n)(1) < miny) miny = points.Get(n)(1); - if (points.Get(n)(0) > maxx) maxx = points.Get(n)(0); - if (points.Get(n)(1) > maxy) maxy = points.Get(n)(1); - } - - if (minx > p(0) + rad || maxx < p(0) - rad || - miny > p(1) + rad || maxy < p(1) - rad) - { - intervallused.Elem(n1) = redlevel; - // (*testout) << 0; - } - else - { - // (*testout) << 1; - intervallused.Elem(n1) = 0; - } - } - // (*testout) << endl; -} - -void BSplineCurve2d :: UnReduce () -{ - int i; - for (i = 1; i <= intervallused.Size(); i++) - if (intervallused.Get(i) == redlevel) - intervallused.Set (i, 0); - redlevel--; -} - -void BSplineCurve2d :: Print (ostream & ost) const -{ - ost << "SplineCurve: " << points.Size() << " points." << endl; - for (int i = 1; i <= points.Size(); i++) - ost << "P" << i << " = " << points.Get(i) << endl; -} -} diff --git a/contrib/Netgen/libsrc/csg/csg.hpp b/contrib/Netgen/libsrc/csg/csg.hpp deleted file mode 100644 index e150860232e11d491a0743cf5eda9a06c7e68d08..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csg.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef FILE_CSG -#define FILE_CSG - -/* *************************************************************************/ -/* File: geoml.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 21. Jun. 98 */ -/* *************************************************************************/ - -#include <myadt.hpp> -#include <gprim.hpp> -#include <meshing.hpp> - -namespace netgen -{ -#include "surface.hpp" -#include "solid.hpp" -#include "identify.hpp" -#include "singularref.hpp" -#include "csgeom.hpp" - -#ifndef SMALLLIB -#define _INCLUDE_MORE -#endif -#ifdef LINUX -#define _INCLUDE_MORE -#endif - -#ifdef _INCLUDE_MORE -#include "triapprox.hpp" - -#include "algprim.hpp" -#include "brick.hpp" -#include "spline3d.hpp" -#include "manifold.hpp" -#include "curve2d.hpp" -#include "explicitcurve2d.hpp" -#include "gencyl.hpp" -#include "polyhedra.hpp" -#include "extrusion.hpp" -#include "revolution.hpp" -#include "specpoin.hpp" -#include "edgeflw.hpp" -#include "meshsurf.hpp" -#endif -} - -#endif diff --git a/contrib/Netgen/libsrc/csg/csgeom.cpp b/contrib/Netgen/libsrc/csg/csgeom.cpp deleted file mode 100644 index f7c25ee9c68af2ba85f8d29e9751158f971ca020..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csgeom.cpp +++ /dev/null @@ -1,1020 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - - int CSGeometry :: changeval = 0; - - - - TopLevelObject :: - TopLevelObject (Solid * asolid, - Surface * asurface) - { - solid = asolid; - surface = asurface; - - SetRGB (0, 0, 1); - SetTransparent (0); - SetVisible (1); - SetLayer (1); - - if (!surface) - maxh = solid->GetMaxH(); - else - maxh = surface->GetMaxH(); - - SetBCProp (-1); - } - - void TopLevelObject :: GetData (ostream & ost) - { - ost << red << " " << green << " " << blue << " " - << transp << " " << visible << " "; - } - - void TopLevelObject :: SetData (istream & ist) - { - ist >> red >> green >> blue >> transp >> visible; - } - - - - Box<3> CSGeometry::default_boundingbox (Point<3> (-1000, -1000, -1000), - Point<3> ( 1000, 1000, 1000)); - - - CSGeometry :: CSGeometry () - : boundingbox (default_boundingbox), - identicsurfaces (100), filename("") - { - ; - } - - CSGeometry :: CSGeometry (const string & afilename) - : boundingbox (default_boundingbox), - identicsurfaces (100), filename(afilename) - { - changeval++; - } - - CSGeometry :: ~CSGeometry () - { - Clean(); - } - - - void CSGeometry :: Clean () - { - for (int i = 0; i < solids.Size(); i++) - delete solids[i]->S1(); - for (int i = 0; i < solids.Size(); i++) - delete solids[i]; - solids.DeleteAll (); - - /* - for (int i = 0; i < surfaces.Size(); i++) - delete surfaces[i]; - surfaces.DeleteAll (); - */ - - for (int i = 0; i < toplevelobjects.Size(); i++) - delete toplevelobjects[i]; - toplevelobjects.DeleteAll (); - for (int i = 0; i < triapprox.Size(); i++) - delete triapprox[i]; - triapprox.DeleteAll(); - - changeval++; - } - - - - - - class WritePrimitivesIt : public SolidIterator - { - ostream & ost; - public: - WritePrimitivesIt (ostream & aost) : ost(aost) { ; } - virtual ~WritePrimitivesIt () { ; } - - virtual void Do (Solid * sol); - }; - - void WritePrimitivesIt :: Do (Solid * sol) - { - Primitive * prim = sol->GetPrimitive(); - if (prim) - { - char * classname; - ARRAY<double> coeffs; - - prim -> GetPrimitiveData (classname, coeffs); - - if (sol->Name()) - ost << "primitive " - << sol->Name() << " " - << classname << " " << coeffs.Size(); - for (int i = 0; i < coeffs.Size(); i++) - ost << " " << coeffs[i]; - ost << endl; - } - } - - - void CSGeometry :: Save (ostream & ost) - { - ost << "boundingbox " - << boundingbox.PMin()(0) << " " - << boundingbox.PMin()(1) << " " - << boundingbox.PMin()(2) << " " - << boundingbox.PMax()(0) << " " - << boundingbox.PMax()(1) << " " - << boundingbox.PMax()(2) << endl; - - - WritePrimitivesIt wpi(ost); - IterateAllSolids (wpi, 1); - - for (int i = 0; i < solids.Size(); i++) - { - if (!solids[i]->GetPrimitive()) - { - ost << "solid " << solids.GetName(i) << " "; - solids[i] -> GetSolidData (ost); - ost << endl; - } - } - - for (int i = 0; i < GetNTopLevelObjects(); i++) - { - TopLevelObject * tlo = GetTopLevelObject (i); - ost << "toplevel "; - if (tlo -> GetSurface()) - ost << "surface " << tlo->GetSolid()->Name() << " " - << tlo->GetSurface()->Name() << " "; - else - ost << "solid " << tlo->GetSolid()->Name() << " "; - tlo->GetData(ost); - ost << endl; - } - - for (int i = 0; i < identifications.Size(); i++) - { - ost << "identify "; - identifications[i] -> GetData (ost); - ost << endl; - } - - ost << "end" << endl; - } - - - void CSGeometry :: Load (istream & ist) - { - // CSGeometry * geo = new CSGeometry; - - char key[100], name[100], classname[100], sname[100]; - int ncoeff, i, j; - ARRAY<double> coeff; - - while (ist.good()) - { - ist >> key; - if (strcmp (key, "boundingbox") == 0) - { - Point<3> pmin, pmax; - ist >> pmin(0) >> pmin(1) >> pmin(2); - ist >> pmax(0) >> pmax(1) >> pmax(2); - SetBoundingBox (Box<3> (pmin, pmax)); - } - if (strcmp (key, "primitive") == 0) - { - ist >> name >> classname >> ncoeff; - coeff.SetSize (ncoeff); - for (i = 0; i < ncoeff; i++) - ist >> coeff[i]; - - Primitive * nprim = Primitive::CreatePrimitive (classname); - nprim -> SetPrimitiveData (coeff); - Solid * nsol = new Solid (nprim); - - for (j = 0; j < nprim->GetNSurfaces(); j++) - { - sprintf (sname, "%s,%d", name, j); - AddSurface (sname, &nprim->GetSurface(j)); - nprim -> SetSurfaceId (j, GetNSurf()); - } - SetSolid (name, nsol); - } - else if (strcmp (key, "solid") == 0) - { - ist >> name; - Solid * nsol = Solid::CreateSolid (ist, solids); - - cout << " I have found solid " << name << " = "; - nsol -> GetSolidData (cout); - cout << endl; - - SetSolid (name, nsol); - } - else if (strcmp (key, "toplevel") == 0) - { - char type[20], solname[50], surfname[50]; - const Solid * sol = NULL; - const Surface * surf = NULL; - int nr; - - ist >> type; - if (strcmp (type, "solid") == 0) - { - ist >> solname; - sol = GetSolid (solname); - } - if (strcmp (type, "surface") == 0) - { - ist >> solname >> surfname; - sol = GetSolid (solname); - surf = GetSurface (surfname); - } - nr = SetTopLevelObject ((Solid*)sol, (Surface*)surf); - GetTopLevelObject (nr) -> SetData (ist); - } - else if (strcmp (key, "identify") == 0) - { - char type[10], surfname1[50], surfname2[50]; - const Surface * surf1; - const Surface * surf2; - - - ist >> type >> surfname1 >> surfname2; - surf1 = GetSurface(surfname1); - surf2 = GetSurface(surfname2); - - AddIdentification (new PeriodicIdentification - (GetNIdentifications(), - *this, surf1, surf2)); - } - else if (strcmp (key, "end") == 0) - break; - } - - changeval++; - } - - - - - - void CSGeometry :: AddSurface (Surface * surf) - { - static int cntsurfs = 0; - cntsurfs++; - char name[15]; - sprintf (name, "nnsurf%d", cntsurfs); - AddSurface (name, surf); - } - - void CSGeometry :: AddSurface (char * name, Surface * surf) - { - surfaces.Set (name, surf); - surf->SetName (name); - changeval++; - } - - void CSGeometry :: AddSurfaces (Primitive * prim) - { - for (int i = 0; i < prim->GetNSurfaces(); i++) - { - AddSurface (&prim->GetSurface(i)); - prim->SetSurfaceId (i, GetNSurf()-1); - } - } - - const Surface * CSGeometry :: GetSurface (const char * name) const - { - if (surfaces.Used(name)) - return surfaces.Get(name); - else - return NULL; - } - - /* - const Surface * CSGeometry :: GetSurface (int i) const - { - if (i >= 0 && i < surfaces.Size()) - return surfaces[i]; - else - throw NgException ("CSGeometry::GetSurface out of range"); - } - */ - - - - - void CSGeometry :: SetSolid (const char * name, Solid * sol) - { - Solid * oldsol = NULL; - - if (solids.Used (name)) - oldsol = solids.Get(name); - - solids.Set (name, sol); - sol->SetName (name); - - if (oldsol) - { - if (oldsol->op != Solid::ROOT || - sol->op != Solid::ROOT) - { - cerr << "Setsolid: old or new no root" << endl; - } - oldsol -> s1 = sol -> s1; - } - changeval++; - } - - const Solid * CSGeometry :: GetSolid (const char * name) const - { - if (solids.Used(name)) - return solids.Get(name); - else - return NULL; - } - - - - const Solid * CSGeometry :: GetSolid (const string & name) const - { - if (solids.Used(name.c_str())) - return solids.Get(name.c_str()); - else - return NULL; - } - - - - - - - - - class RemoveDummyIterator : public SolidIterator - { - public: - - RemoveDummyIterator() { ; } - virtual ~RemoveDummyIterator() { ; } - virtual void Do(Solid * sol); - }; - - void RemoveDummyIterator :: Do(Solid * sol) - { - if ( (sol->op == Solid::SUB || sol->op == Solid::SECTION || - sol->op == Solid::UNION) - && sol->s1->op == Solid::DUMMY) - sol->s1 = sol->s1->s1; - if ( (sol->op == Solid::SECTION || sol->op == Solid::UNION) - && sol->s2->op == Solid::DUMMY) - sol->s2 = sol->s2->s1; - } - - - - - - - int CSGeometry :: SetTopLevelObject (Solid * sol, Surface * surf) - { - return toplevelobjects.Append (new TopLevelObject (sol, surf)) - 1; - } - - TopLevelObject * CSGeometry :: - GetTopLevelObject (const Solid * sol, const Surface * surf) - { - for (int i = 0; i < toplevelobjects.Size(); i++) - { - if (toplevelobjects[i]->GetSolid() == sol && - toplevelobjects[i]->GetSurface() == surf) - return (toplevelobjects[i]); - } - return NULL; - } - - void CSGeometry :: RemoveTopLevelObject (Solid * sol, Surface * surf) - { - for (int i = 0; i < toplevelobjects.Size(); i++) - { - if (toplevelobjects[i]->GetSolid() == sol && - toplevelobjects[i]->GetSurface() == surf) - { - delete toplevelobjects[i]; - toplevelobjects.DeleteElement (i+1); - changeval++; - break; - } - } - } - - void CSGeometry :: AddIdentification (Identification * ident) - { - identifications.Append (ident); - } - - void CSGeometry :: SetFlags (const char * solidname, const Flags & flags) - { - Solid * solid = solids.Elem(solidname); - ARRAY<int> surfind; - - int i; - double maxh = flags.GetNumFlag ("maxh", -1); - if (maxh > 0 && solid) - { - solid->GetSurfaceIndices (surfind); - - for (i = 0; i < surfind.Size(); i++) - { - if (surfaces[surfind[i]]->GetMaxH() > maxh) - surfaces[surfind[i]] -> SetMaxH (maxh); - } - - solid->SetMaxH (maxh); - } - - if (flags.NumFlagDefined ("bc")) - { - solid->GetSurfaceIndices (surfind); - int bc = int (flags.GetNumFlag("bc", -1)); - for (i = 0; i < surfind.Size(); i++) - { - if (surfaces[surfind[i]]->GetBCProperty() == -1) - surfaces[surfind[i]]->SetBCProperty(bc); - } - } - } - - void CSGeometry :: FindIdenticSurfaces (double eps) - { - int inv; - int nsurf = GetNSurf(); - - isidenticto.SetSize(nsurf); - for (int i = 0; i < nsurf; i++) - isidenticto[i] = i; - - for (int i = 0; i < nsurf; i++) - for (int j = i+1; j < nsurf; j++) - if (GetSurface(j) -> IsIdentic (*GetSurface(i), inv, eps)) - { - INDEX_2 i2(i, j); - identicsurfaces.Set (i2, inv); - isidenticto[j] = isidenticto[i]; - // (*testout) << "surfaces " << i2 << " are identic" << endl; - } - - /* - (*testout) << "identicmap:" << endl; - for (int i = 0; i < isidenticto.Size(); i++) - (*testout) << i << " -> " << isidenticto[i] << endl; - - for (int i = 0; i < nsurf; i++) - GetSurface(i)->Print (*testout); - */ - } - - - void CSGeometry :: - GetIndependentSurfaceIndices (const Solid * sol, - const BoxSphere<3> & box, - ARRAY<int> & locsurf) const - { - ReducePrimitiveIterator rpi(box); - UnReducePrimitiveIterator urpi; - - ((Solid*)sol) -> IterateSolid (rpi); - sol -> GetSurfaceIndices (locsurf); - ((Solid*)sol) -> IterateSolid (urpi); - - for (int i = 0; i < locsurf.Size(); i++) - locsurf[i] = isidenticto[locsurf[i]]; - - for (int i = locsurf.Size()-1; i >= 0; i--) - { - bool indep = 1; - for (int j = 0; j < i; j++) - if (locsurf[i] == locsurf[j]) - { - indep = 0; - break; - } - - if (!indep) locsurf.Delete(i); - } - - - /* - // delete identified - for (int i = locsurf.Size()-1; i >= 0; i--) - { - bool indep = 1; - for (int j = 0; j < i; j++) - { - if (identicsurfaces.Used (INDEX_2::Sort (locsurf[i], locsurf[j])) != - (isidenticto[locsurf[i]] == isidenticto[locsurf[j]])) - { - cerr << "different result" << endl; - exit(1); - } - - if (isidenticto[locsurf[i]] == isidenticto[locsurf[j]]) - { - indep = 0; - break; - } - } - if (!indep) - locsurf.Delete(i); - } - - for (int i = 0; i < locsurf.Size(); i++) - locsurf[i] = isidenticto[locsurf[i]]; - */ - } - - - void CSGeometry :: - GetIndependentSurfaceIndices (const Solid * sol, - const Point<3> & p, Vec<3> & v, - ARRAY<int> & locsurf) const - { - Point<3> p2 = p + 1e-2 * v; - BoxSphere<3> box (p2, p2); - box.Increase (1e-3); - box.CalcDiamCenter(); - GetIndependentSurfaceIndices (sol, box, locsurf); - } - - - void CSGeometry :: - CalcTriangleApproximation(const Box<3> & boundingbox, - double detail, double facets) - { - PrintMessage (1, "Calc Triangle Approximation"); - - // FindIdenticSurfaces (1e-6); - - int ntlo = GetNTopLevelObjects(); - - for (int i = 0; i < triapprox.Size(); i++) - delete triapprox[i]; - triapprox.SetSize (ntlo); - - ARRAY<int> surfind; - - for (int i = 0; i < ntlo; i++) - { - Solid * sol; - Surface * surf; - GetTopLevelObject (i, sol, surf); - - sol -> CalcSurfaceInverse (); - - TriangleApproximation * tams = new TriangleApproximation(); - triapprox[i] = tams; - - // sol -> GetSurfaceIndices (surfind); - for (int j = 0; j < GetNSurf(); j++) - // for (int jj = 0; jj < surfind.Size(); jj++) - { - // int j = surfind[jj]; - - PrintMessageCR (3, "Surface ", j, "/", GetNSurf()); - // PrintMessageCR (3, "Surface ", j, "/", surfind.Size()); - - if (surf && surf != GetSurface(j)) - continue; - - TriangleApproximation tas; - GetSurface (j) -> GetTriangleApproximation (tas, boundingbox, facets); - - int oldnp = tams -> GetNP(); - - if (!tas.GetNP()) - continue; - - for (int k = 0; k < tas.GetNP(); k++) - { - tams -> AddPoint (tas.GetPoint(k)); - Vec<3> n = GetSurface(j) -> GetNormalVector (tas.GetPoint(k)); - n.Normalize(); - if (GetSurface(j)->Inverse()) n *= -1; - tams -> AddNormal (n); - } - - - BoxSphere<3> surfbox; - - if (tas.GetNP()) - surfbox.Set (tas.GetPoint(0)); - for (int k = 1; k < tas.GetNP(); k++) - surfbox.Add (tas.GetPoint(k)); - surfbox.Increase (1e-6); - surfbox.CalcDiamCenter(); - - Solid * surflocsol = sol -> GetReducedSolid (surfbox); - if (!surflocsol) - continue; - - for (int k = 0; k < tas.GetNT(); k++) - { - const TATriangle & tri = tas.GetTriangle (k); - - // check triangle - BoxSphere<3> box; - box.Set (tas.GetPoint (tri[0])); - box.Add (tas.GetPoint (tri[1])); - box.Add (tas.GetPoint (tri[2])); - box.Increase (1e-6); - box.CalcDiamCenter(); - - - Solid * locsol = surflocsol -> GetReducedSolid (box); - - if (locsol) - { - TATriangle tria(j, - tri[0] + oldnp, - tri[1] + oldnp, - tri[2] + oldnp); - - RefineTriangleApprox (locsol, j, box, detail, - tria, *tams); - delete locsol; - } - } - } - - tams->RemoveUnusedPoints (); - PrintMessage (2, "Object ", i, " has ", tams->GetNT(), " triangles"); - } - - Change(); - } - - - - void CSGeometry :: - RefineTriangleApprox (Solid * locsol, - int surfind, - const BoxSphere<3> & box, - double detail, - const TATriangle & tria, - TriangleApproximation & tams) - { - int pinds[6]; - ArrayMem<int,500> surfused(GetNSurf()); - - ReducePrimitiveIterator rpi(box); - UnReducePrimitiveIterator urpi; - - - locsol -> IterateSolid (rpi); - // locsol -> GetSurfaceIndices (lsurfi); - - - IndexSet iset(GetNSurf()); - locsol -> GetSurfaceIndices (iset); - const ARRAY<int> & lsurfi = iset.Array(); - - locsol -> IterateSolid (urpi); - - - int surfii = -1; - for (int i = 0; i < lsurfi.Size(); i++) - if (lsurfi[i] == surfind) - { - surfii = i; - break; - } - - if (surfii == -1) - return; - - - int cntindep = 0; - - for (int i = 0; i < lsurfi.Size(); i++) - { - int linkto = isidenticto[lsurfi[i]]; - surfused[linkto] = 0; - } - - for (int i = 0; i < lsurfi.Size(); i++) - { - int linkto = isidenticto[lsurfi[i]]; - if (!surfused[linkto]) - { - surfused[linkto] = 1; - cntindep++; - } - } - - int inverse = surfaces[surfind]->Inverse(); - - if (cntindep == 1) - { - tams.AddTriangle (tria); - return; - } - - if (cntindep == 2) - { - // just 2 surfaces: - // if smooth, project inner points to edge and finish - - int otherind = -1; - - for (int i = 0; i < lsurfi.Size(); i++) - { - INDEX_2 i2 (lsurfi[i], surfind); - i2.Sort(); - - if (i != surfii && !identicsurfaces.Used(i2)) - otherind = lsurfi[i]; - } - - double kappa = GetSurface(otherind)-> MaxCurvature (); - - if (kappa * box.Diam() < 0.1) - { - int pnums[6]; - static int between[3][3] = - { { 1, 2, 3 }, - { 0, 2, 4 }, - { 0, 1, 5 } }; - int onsurface[3]; - - for (int j = 0; j < 3; j++) - { - int pi = tria[j]; - pnums[j] = pi; - onsurface[j] = - !locsol->IsStrictIn (tams.GetPoint (pi), 1e-6) && - locsol->IsIn (tams.GetPoint (pi), 1e-6); - } - - for (int j = 0; j < 3; j++) - { - int lpi1 = between[j][0]; - int lpi2 = between[j][1]; - int lpin = between[j][2]; - if (onsurface[lpi1] == onsurface[lpi2]) - pnums[lpin] = -1; - else - { - const Point<3> & p1 = tams.GetPoint (pnums[lpi1]); - const Point<3> & p2 = tams.GetPoint (pnums[lpi2]); - double f1 = GetSurface(otherind)->CalcFunctionValue (p1); - double f2 = GetSurface(otherind)->CalcFunctionValue (p2); - - Point<3> pn; - if ( fabs (f1-f2) > 1e-20 ) - { - double l2 = -f1/(f2-f1); - double l1 = f2/(f2-f1); - pn = Point<3>(l1 * p1(0) + l2 * p2(0), - l1 * p1(1) + l2 * p2(1), - l1 * p1(2) + l2 * p2(2)); - } - else - pn = p1; - - pnums[lpin] = tams.AddPoint (pn); - - GetSurface (surfind)->Project (pn); - - Vec<3> n; - n = GetSurface (surfind)->GetNormalVector (pn); - if (inverse) n *= -1; - tams.AddNormal(n); - } - } - - int vcase = 0; - if (onsurface[0]) vcase++; - if (onsurface[1]) vcase+=2; - if (onsurface[2]) vcase+=4; - - static int trias[8][6] = - { { 0, 0, 0, 0, 0, 0 }, - { 1, 6, 5, 0, 0, 0 }, - { 2, 4, 6, 0, 0, 0 }, - { 1, 2, 4, 1, 4, 5 }, - { 3, 5, 4, 0, 0, 0 }, - { 1, 6, 4, 1, 4, 3 }, - { 2, 3, 6, 3, 5, 6 }, - { 1, 2, 3, 0, 0, 0 } }; - static int ntrias[4] = - { 0, 1, 2, 1 }; - - int nvis = 0; - for (int j = 0; j < 3; j++) - if (onsurface[j]) - nvis++; - - for (int j = 0; j < ntrias[nvis]; j++) - { - TATriangle ntria(tria.SurfaceIndex(), - pnums[trias[vcase][3*j]-1], - pnums[trias[vcase][3*j+1]-1], - pnums[trias[vcase][3*j+2]-1]); - tams.AddTriangle (ntria); - } - - /* saturn changes: - - int pvis[3]; - for (j = 0; j < 3; j++) - pvis[j] = !locsol->IsStrictIn (tams.GetPoint (j+1), 1e-6) && - locsol->IsIn (tams.GetPoint (j+1), 1e-6); - - int newpi[3]; - for (j = 0; j < 3; j++) - { - int pi1 = j; - int pi2 = (j+1) % 3; - int pic = j; - - if (pvis[pi1] != pvis[pi2]) - { - Point<3> hp = Center (tams.GetPoint (tria.PNum (pi1+1)), - tams.GetPoint (tria.PNum (pi2+1))); - - newpi[j] = tams.AddPoint (hp); - Vec<3> n = tams.GetNormal (pi1); - tams.AddNormal (n); - } - else - newpi[j] = 0; - } - - int nvis = 0; - for (j = 0; j <= nvis; j++) - if (pvis[j]) nvis++; - - int si = tria.SurfaceIndex(); - switch (nvis) - { - case 0: - break; - case 1: - { - int visj; - for (j = 0; j < 3; j++) - if (pvis[j]) visj = j; - int pivis = tria.PNum (visj+1); - int pic1 = newpi[(visj+1)%3]; - int pic2 = newpi[(visj+2)%3]; - - cout << pivis << "," << pic1 << "," << pic2 << endl; - - tams.AddTriangle (TATriangle (si, pivis, pic1,pic2)); - break; - } - case 2: - { - int nvisj; - for (j = 0; j < 3; j++) - if (!pvis[j]) nvisj = j; - - int pivis1 = tria.PNum ((nvisj+1)%3+1); - int pivis2 = tria.PNum ((nvisj+2)%3+1); - int pic1 = newpi[nvisj]; - int pic2 = newpi[(nvisj+2)%3]; - - tams.AddTriangle (TATriangle (si, pivis1, pic1,pic2)); - tams.AddTriangle (TATriangle (si, pivis1, pic1,pivis2)); - break; - } - case 3: - { - tams.AddTriangle (tria); - break; - } - } - - */ - return; - } - } - - // bisection - if (box.Diam() < detail) - return; - - for (int i = 0; i < 3; i++) - pinds[i] = tria[i]; - - static int between[3][3] = - { { 0, 1, 5 }, - { 0, 2, 4 }, - { 1, 2, 3 } }; - - for (int i = 0; i < 3; i++) - { - // int pi1 = tria[between[i][0]]; - - Point<3> newp = Center (tams.GetPoint (tria[between[i][0]]), - tams.GetPoint (tria[between[i][1]])); - Vec<3> n; - - GetSurface(surfind)->Project (newp); - n = GetSurface(surfind)->GetNormalVector (newp); - - pinds[between[i][2]] = tams.AddPoint (newp); - if (inverse) n *= -1; - tams.AddNormal (n); - } - - static int trias[4][4] = - { { 0, 5, 4 }, - { 5, 1, 3 }, - { 4, 3, 2 }, - { 3, 4, 5 } }; - - for (int i = 0; i < 4; i++) - { - TATriangle ntri(surfind, - pinds[trias[i][0]], - pinds[trias[i][1]], - pinds[trias[i][2]]); - - // check triangle - BoxSphere<3> nbox; - nbox.Set (tams.GetPoint (ntri[0])); - nbox.Add (tams.GetPoint (ntri[1])); - nbox.Add (tams.GetPoint (ntri[2])); - nbox.Increase (1e-6); - nbox.CalcDiamCenter(); - - Solid * nsol = locsol -> GetReducedSolid (nbox); - - if (nsol) - { - RefineTriangleApprox (nsol, surfind, nbox, - detail, ntri, tams); - - delete nsol; - } - } - } - - - - - class ClearVisitedIt : public SolidIterator - { - public: - ClearVisitedIt () { ; } - virtual ~ClearVisitedIt () { ; } - - virtual void Do (Solid * sol) - { - sol -> visited = 0; - } - }; - - - void CSGeometry :: - IterateAllSolids (SolidIterator & it, int only_once) - { - if (only_once) - { - ClearVisitedIt clit; - for (int i = 0; i < solids.Size(); i++) - solids[i] -> IterateSolid (clit, 0); - } - - for (int i = 0; i < solids.Size(); i++) - solids[i] -> IterateSolid (it, only_once); - } - - - double CSGeometry :: MaxSize () const - { - double maxs, mins; - maxs = max3 (boundingbox.PMax()(0), - boundingbox.PMax()(1), - boundingbox.PMax()(2)); - mins = min3 (boundingbox.PMin()(0), - boundingbox.PMin()(1), - boundingbox.PMin()(2)); - return max2 (maxs, -mins) * 1.1; - } -} diff --git a/contrib/Netgen/libsrc/csg/csgeom.hpp b/contrib/Netgen/libsrc/csg/csgeom.hpp deleted file mode 100644 index 6e29a8163be35c68a7074e85d01b2a0d2a2aa841..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csgeom.hpp +++ /dev/null @@ -1,257 +0,0 @@ -#ifndef FILE_CSGEOM -#define FILE_CSGEOM - -/**************************************************************************/ -/* File: csgeom.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 27. Nov. 97 */ -/**************************************************************************/ - -/** - Constructive Solid Geometry -*/ - - -class TriangleApproximation; -class TATriangle; - - -/** - A top level object is an entity to be meshed. - I can be either a solid, or one surface patch of a solid. - */ -class TopLevelObject -{ - Solid * solid; - Surface * surface; - - double red, blue, green; - bool visible, transp; - double maxh; - string material; - int layer; - int bc; // for surface patches, only -public: - TopLevelObject (Solid * asolid, - Surface * asurface = NULL); - - const Solid * GetSolid() const { return solid; } - Solid * GetSolid() { return solid; } - - const Surface * GetSurface () const { return surface; } - Surface * GetSurface () { return surface; } - - void GetData (ostream & ost); - void SetData (istream & ist); - - void SetMaxH (double amaxh) { maxh = amaxh; } - double GetMaxH () const { return maxh; } - - void SetRGB (double ared, double agreen, double ablue) - { - red = ared; - green = agreen; - blue = ablue; - } - - double GetRed () const { return red; } - double GetGreen () const { return green; } - double GetBlue () const { return blue; } - - void SetTransparent (bool atransp) - { transp = atransp; } - bool GetTransparent () const { return transp; } - - void SetVisible (bool avisible) - { visible = avisible; } - bool GetVisible () const { return visible; } - - const string GetMaterial () const { return material; } - void SetMaterial (const string & mat) { material = mat; } - - int GetLayer () const { return layer; } - void SetLayer (int alayer) { layer = alayer; } - - void SetBCProp (int abc) { bc = abc; } - int GetBCProp () const { return bc; } -}; - - -/** - CSGeometry has the whole geometric information - */ -class CSGeometry -{ -private: - /// all surfaces - SYMBOLTABLE<Surface*> surfaces; - - /// all named solids - SYMBOLTABLE<Solid*> solids; - - /// all top level objects: solids and surfaces - ARRAY<TopLevelObject*> toplevelobjects; - - /// additional points specified by user - ARRAY<Point<3> > userpoints; - - /// 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, ...) - - - - /// filename of inputfile - string filename; - -public: - CSGeometry (); - CSGeometry (const string & afilename); - ~CSGeometry (); - - void Clean (); - - void Save (ostream & ost); - void Load (istream & ist); - - 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) { return solids[i]; } - const SYMBOLTABLE<Solid*> & GetSolids () const { return solids; } - - - 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) - { userpoints.Append (p); } - int GetNUserPoints () const - { return userpoints.Size(); } - const Point<3> & GetUserPoint (int nr) const - { return userpoints[nr]; } - - - // quick implementations: - ARRAY<SingularFace*> singfaces; - ARRAY<SingularEdge*> singedges; - ARRAY<SingularPoint*> singpoints; - ARRAY<Identification*> identifications; - - int GetNIdentifications () { return identifications.Size(); } - void AddIdentification (Identification * ident); - - - /// - void CalcTriangleApproximation(const Box<3> & boundingbox, - double detail, double facets); - - /// - void FindIdenticSurfaces (double eps); - /// - 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; - /// - 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, int only_once = 0); - - void RefineTriangleApprox (Solid * locsol, - int surfind, - const BoxSphere<3> & box, - double detail, - const TATriangle & tria, - TriangleApproximation & tams); - - 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; - - - - class BCModification { - public: - int si; - int tlonr; - int bcnr; - }; - ARRAY<BCModification> bcmodifications; - -}; -#endif - diff --git a/contrib/Netgen/libsrc/csg/csgparser.cpp b/contrib/Netgen/libsrc/csg/csgparser.cpp deleted file mode 100644 index b6d4878399acc1667b1ef6142b20f076d071e22b..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csgparser.cpp +++ /dev/null @@ -1,1156 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - using namespace netgen; - - - enum TOKEN_TYPE - { - TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']', - TOK_EQU = '=', TOK_COMMA = ',', TOK_SEMICOLON = ';', - TOK_NUM = 100, TOK_STRING, TOK_NAMED_SOLID, TOK_PRIMITIVE, - TOK_OR, TOK_AND, TOK_NOT, - TOK_SINGULAR, TOK_EDGE, TOK_POINT, TOK_FACE, TOK_IDENTIFY, TOK_CLOSESURFACES, - TOK_CLOSEEDGES, TOK_PERIODIC, - TOK_SOLID, TOK_RECO, TOK_TLO, TOK_BOUNDINGBOX, TOK_BOUNDARYCONDITION, - TOK_END }; - - struct kwstruct - { - TOKEN_TYPE kw; - char * name; - }; - - static kwstruct defkw[] = - { - { TOK_RECO, "algebraic3d" }, - { TOK_SOLID, "solid" }, - { TOK_TLO, "tlo" }, - { TOK_BOUNDINGBOX, "boundingbox" }, - { TOK_OR, "or" }, - { TOK_AND, "and" }, - { TOK_NOT, "not" }, - { TOK_SINGULAR, "singular" }, - { TOK_EDGE, "edge" }, - { TOK_FACE, "face" }, - { TOK_POINT, "point" }, - { TOK_IDENTIFY, "identify" }, - { TOK_CLOSESURFACES, "closesurfaces" }, - { TOK_CLOSEEDGES, "closeedges" }, - { TOK_PERIODIC, "periodic" }, - { TOK_BOUNDARYCONDITION, "boundarycondition" }, - { TOKEN_TYPE(0) } - }; - - enum PRIMITIVE_TYPE - { - TOK_SPHERE = 1, TOK_CYLINDER, TOK_PLANE, TOK_ELLIPTICCYLINDER, - TOK_ELLIPSOID, TOK_CONE, - TOK_ORTHOBRICK, TOK_POLYHEDRON, - - TOK_TUBE, TOK_GENCYL, TOK_EXTRUSION, TOK_REVOLUTION, // currently, out of order - - TOK_TRANSLATE, TOK_MULTITRANSLATE, TOK_ROTATE, TOK_MULTIROTATE - }; - - struct primstruct - { - PRIMITIVE_TYPE kw; - char * name; - }; - - static primstruct defprim[] = - { - { TOK_PLANE, "plane" }, - { TOK_SPHERE, "sphere" }, - { TOK_CYLINDER, "cylinder" }, - { TOK_CONE, "cone" }, - { TOK_ELLIPTICCYLINDER, "ellipticcylinder" }, - { TOK_ELLIPSOID, "ellipsoid" }, - { TOK_ORTHOBRICK, "orthobrick" }, - { TOK_POLYHEDRON, "polyhedron" }, - - { TOK_TUBE, "tube" }, - { TOK_GENCYL, "gencyl" }, - { TOK_EXTRUSION, "extrusion" }, - { TOK_REVOLUTION, "revolution" }, - - { TOK_TRANSLATE, "translate" }, - { TOK_MULTITRANSLATE, "multitranslate" }, - { TOK_ROTATE, "rotate" }, - { TOK_MULTIROTATE, "multirotate" }, - { PRIMITIVE_TYPE(0) } - }; - - static CSGeometry * geom; - - - - class CSGScanner - { - TOKEN_TYPE token; - PRIMITIVE_TYPE prim_token; - double num_value; - string string_value; - - int linenum; - istream * scanin; - - public: - - CSGScanner (istream & ascanin); - - TOKEN_TYPE GetToken() const - { return token; } - - double GetNumValue() const - { return num_value; } - - const string & GetStringValue() const - { return string_value; } - - char GetCharValue() const - { return string_value[0]; } - - PRIMITIVE_TYPE GetPrimitiveToken() const - { return prim_token; } - - void ReadNext(); - - /* - CSGScanner & Parse (char ch); - CSGScanner & Parse (int & i); - CSGScanner & Parse (double & d); - CSGScanner & Parse (Point<3> & p); - CSGScanner & Parse (Vec<3> & p); - */ - void Error (const string & err); - }; - - - CSGScanner :: CSGScanner (istream & ascanin) - { - scanin = &ascanin; - token = TOK_END; - num_value = 0; - linenum = 1; - } - - - void CSGScanner :: ReadNext () - { - char ch; - - - // scan whitespaces - do - { - scanin->get(ch); - - if (ch == '\n') - linenum++; - - // end of file reached - if (scanin->eof()) - { - token = TOK_END; - return; - } - - // skip comment line - if (ch == '#') - { - while (ch != '\n') - { - scanin->get(ch); - if (scanin->eof()) - { - token = TOK_END; - return; - } - } - linenum++; - } - } - while (isspace(ch)); - - switch (ch) - { - case '(': case ')': - case '[': case ']': - case '-': - case '=': case ',': case ';': - { - token = TOKEN_TYPE (ch); - break; - } - - default: - { - if (isdigit (ch) || ch == '.') - { - scanin->putback (ch); - (*scanin) >> num_value; - token = TOK_NUM; - return; - } - - if (isalpha (ch)) - { - string_value = string (1, ch); - scanin->get(ch); - while (isalnum(ch) || ch == '_') - { - string_value += ch; - scanin->get(ch); - } - scanin->putback (ch); - } - - int nr = 0; - while (defkw[nr].kw) - { - if (string_value == defkw[nr].name) - { - token = defkw[nr].kw; - return; - } - nr++; - } - - nr = 0; - while (defprim[nr].kw) - { - if (string_value == defprim[nr].name) - { - token = TOK_PRIMITIVE; - prim_token = defprim[nr].kw; - return; - } - nr++; - } - - token = TOK_STRING; - } - } - } - - void CSGScanner :: Error (const string & err) - { - stringstream errstr; - errstr << "Parsing error in line " << linenum << ": " << endl << err << endl; - throw string(errstr.str()); - } - - - /* - Solid = Term { OR Term } - Term = Primary { AND Primary } - Primary = PRIM | IDENT | ( Solid ) | NOT Primary - */ - - void ParseChar (CSGScanner & scan, char ch) - { - if (scan.GetToken() != TOKEN_TYPE(ch)) - scan.Error (string ("token '") + string(1, ch) + string("' expected")); - scan.ReadNext(); - } - - double ParseNumber(CSGScanner & scan) - { - if (scan.GetToken() == '-') - { - scan.ReadNext(); - return -ParseNumber (scan); - } - if (scan.GetToken() != TOK_NUM) scan.Error ("number expected"); - double val = scan.GetNumValue(); - scan.ReadNext(); - return val; - } - - Vec<3> ParseVector (CSGScanner & scan) - { - Vec<3> v; - v(0) = ParseNumber (scan); - ParseChar (scan, ','); - v(1) = ParseNumber (scan); - ParseChar (scan, ','); - v(2) = ParseNumber (scan); - return v; - } - - - CSGScanner & operator>> (CSGScanner & scan, char ch) - { - if (scan.GetToken() != TOKEN_TYPE(ch)) - scan.Error (string ("token '") + string(1, ch) + string("' expected")); - scan.ReadNext(); - return scan; - } - - CSGScanner & operator>> (CSGScanner & scan, double & d) - { - d = ParseNumber (scan); - return scan; - } - - CSGScanner & operator>> (CSGScanner & scan, int & i) - { - i = int (ParseNumber (scan)); - return scan; - } - - CSGScanner & operator>> (CSGScanner & scan, Point<3> & p) - { - scan >> p(0) >> ',' >> p(1) >> ',' >> p(2); - return scan; - } - - CSGScanner & operator>> (CSGScanner & scan, Vec<3> & v) - { - scan >> v(0) >> ',' >> v(1) >> ',' >> v(2); - return scan; - } - - - Solid * ParseSolid (CSGScanner & scan); - Solid * ParseTerm (CSGScanner & scan); - Solid * ParsePrimary (CSGScanner & scan); - - - Solid * ParsePrimary (CSGScanner & scan) - { - if (scan.GetToken() == TOK_PRIMITIVE) - { - switch (scan.GetPrimitiveToken()) - { - case TOK_PLANE: - { - Point<3> p; - Vec<3> v; - - scan.ReadNext(); - scan >> '(' >> p >> ';' >> v >> ')'; - - OneSurfacePrimitive * surf = new Plane ( p, v ); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - case TOK_CYLINDER: - { - Point<3> pa, pb; - double r; - - scan.ReadNext(); - scan >> '(' >> pa >> ';' >> pb >> ';' >> r >> ')'; - - OneSurfacePrimitive * surf = new Cylinder ( pa, pb, r ); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - case TOK_ELLIPTICCYLINDER: - { - Point<3> pa; - Vec<3> vl, vs; - - scan.ReadNext(); - scan >> '(' >> pa >> ';' >> vl >> ';' >> vs >> ')'; - - OneSurfacePrimitive * surf = new EllipticCylinder ( pa, vl, vs); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - - case TOK_ELLIPSOID: - { - Point<3> pa; - Vec<3> v1, v2, v3; - - scan.ReadNext(); - scan >> '(' >> pa >> ';' >> v1 >> ';' >> v2 >> ';' >> v3 >> ')'; - - OneSurfacePrimitive * surf = new Ellipsoid ( pa, v1, v2, v3); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - - case TOK_CONE: - { - Point<3> pa, pb; - double ra, rb; - - scan.ReadNext(); - scan >> '(' >> pa >> ';' >> ra >> ';' >> pb >> ';' >> rb >> ')'; - - OneSurfacePrimitive * surf = new Cone ( pa, pb, ra, rb ); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - - - case TOK_SPHERE: - { - Point<3> p; - double r; - - scan.ReadNext(); - scan >> '(' >> p >> ';' >> r >> ')'; - - OneSurfacePrimitive * surf = new Sphere ( p, r ); - geom->AddSurfaces (surf); - return new Solid (surf); - } - - case TOK_ORTHOBRICK: - { - Point<3> pa, pb; - - scan.ReadNext(); - scan >> '(' >> pa >> ';' >> pb >> ')'; - - Primitive * nprim = new OrthoBrick (pa, pb); - geom->AddSurfaces (nprim); - return new Solid (nprim); - } - - case TOK_POLYHEDRON: - { - // Added by Dalibor Lukas, October 15, 2003 - - Point<3> p; - int pi1, pi2, pi3, pi4; - - scan.ReadNext(); - ParseChar (scan, '('); - - Polyhedra * polyhedron = new Polyhedra; - - // scanning the points - while (1) - { - p = Point<3> (ParseVector (scan)); - ParseChar (scan, ';'); - - polyhedron->AddPoint(p); - - if (scan.GetToken() == ';') - { - scan.ReadNext(); - break; - } - } - - // scanning the faces - while (1) - { - pi1 = (int) (ParseNumber (scan)); - ParseChar (scan, ','); - pi2 = (int) (ParseNumber (scan)); - ParseChar (scan, ','); - pi3 = (int) (ParseNumber (scan)); - - polyhedron->AddFace(pi1-1,pi2-1,pi3-1); - - if (scan.GetToken() == TOK_COMMA) - { - ParseChar (scan, ','); - pi4 = (int) (ParseNumber (scan)); - polyhedron->AddFace(pi1-1,pi3-1,pi4-1); - } - - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - scan.ReadNext(); - } - - geom->AddSurfaces (polyhedron); - return new Solid (polyhedron); - } - - - case TOK_EXTRUSION: // not functional - { - Point<3> p0; - Vec<3> ex, ey; - ARRAY<Point<2> > points; - - scan.ReadNext(); - - ParseChar (scan, '('); - p0(0) = ParseNumber (scan); - ParseChar (scan, ','); - p0(1) = ParseNumber (scan); - ParseChar (scan, ','); - p0(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - ex(0) = ParseNumber (scan); - ParseChar (scan, ','); - ex(1) = ParseNumber (scan); - ParseChar (scan, ','); - ex(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - ey(0) = ParseNumber (scan); - ParseChar (scan, ','); - ey(1) = ParseNumber (scan); - ParseChar (scan, ','); - ey(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - cout << "p0 = " << p0 << endl; - - // int npseg = 0; - // int nseg = 0; - while (1) - { - Point<2> p1, p2, p3; - - p1(0) = ParseNumber(scan); - ParseChar (scan, ','); - p1(1) = ParseNumber(scan); - points.Append (p1); - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - scan.ReadNext(); - } - - - /* - while (1) - { - Point<2> p1, p2, p3; - - p3 = p2; - p2 = p1; - p1(0) = ParseNumber(scan); - ParseChar (scan, ','); - p1(1) = ParseNumber(scan); - npseg++; - - cout << "p1 = " << p1 << endl; - - if (scan.GetToken() == ';' || scan.GetToken() == ')') - { - if (npseg == 2) - { - p3 = p2; - p2 = Center (p1, p3); - } - if (nseg == 0) - points.Append (p3); - points.Append (p2); - points.Append (p1); - npseg = 1; - nseg++; - - cout << "p1, = " << p1 << ", p2 = " << p2 << ", p3 = " << p3 << endl; - } - - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - if (scan.GetToken() == ';' || scan.GetToken() == ',') - { - scan.ReadNext(); - } - } - */ - cout << "p0 = " << p0 << endl; - cout << ", ex = " << ex << ", ey = " << ey << endl; - cout << "points = " << points << endl; - - Extrusion * extrusion = new Extrusion (p0, ex, ey, points); - - geom->AddSurfaces (extrusion); - return new Solid (extrusion); - - /* - // cout << "define cylinder, pa = " << pa << "; pb = " << pb - // << ", rad = " << r << endl; - OneSurfacePrimitive * surf = new Cylinder ( pa, pb, r ); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - */ - } - - - - - - case TOK_TRANSLATE: - { - Vec<3> v; - scan.ReadNext(); - - ParseChar (scan, '('); - v = ParseVector (scan); - ParseChar (scan, ';'); - - Solid * sol1 = ParseSolid (scan); - - ParseChar (scan, ')'); - - Solid * nsol = sol1 -> Copy(*geom); - Transformation<3> trans(v); - nsol -> Transform (trans); - return nsol; - } - - - case TOK_MULTITRANSLATE: - { - Vec<3> v; - int n; - - scan.ReadNext(); - - scan >> '(' >> v >> ';' >> n >> ';'; - - Solid * sol1 = ParseSolid (scan); - - scan >> ')'; - - Solid * hsol = sol1; - for (int i = 1; i <= n; i++) - { - Solid * nsol = sol1 -> Copy(*geom); - Transformation<3> trans(double(i) * v); - - nsol -> Transform (trans); - hsol = new Solid (Solid::UNION, hsol, nsol); - } - return hsol; - } - - - case TOK_MULTIROTATE: - { - Point<3> c; - Vec<3> v; - int n; - - scan.ReadNext(); - - scan >> '(' >> c >> ';' >> v >> ';' >> n >> ';'; - Solid * sol1 = ParseSolid (scan); - scan >> ')'; - - Transformation<3> trans(c, v(0), v(1), v(2)); - Transformation<3> multi(Vec<3>(0,0,0)); - Transformation<3> ht; - - Solid * hsol = sol1; - for (int i = 1; i <= n; i++) - { - Solid * nsol = sol1 -> Copy(*geom); - - nsol -> Transform (multi); - hsol = new Solid (Solid::UNION, hsol, nsol); - - ht=multi; - multi.Combine (trans, ht); - } - return hsol; - } - - - default: - { - scan.Error (string ("unknown primary ") + scan.GetStringValue()); - } - - } - } - - else if (scan.GetToken() == TOK_STRING && - geom->GetSolid(scan.GetStringValue())) - - { - Solid * sol = const_cast<Solid*> (geom->GetSolid(scan.GetStringValue())); - scan.ReadNext(); - return sol; - } - - else if (scan.GetToken() == TOK_NOT) - - { - scan.ReadNext(); - Solid * sol1 = ParsePrimary (scan); - return new Solid (Solid::SUB, sol1); - } - - else if (scan.GetToken() == '(') - - { - scan.ReadNext(); - Solid * sol1 = ParseSolid (scan); - scan.ReadNext(); - return sol1; - } - - scan.Error (string ("not a primary, name = ")+ - scan.GetStringValue()); - return 0; - } - - - - Solid * ParseTerm (CSGScanner & scan) - { - Solid * sol = ParsePrimary(scan); - while (scan.GetToken() == TOK_AND) - { - scan.ReadNext(); - Solid * sol2 = ParsePrimary(scan); - sol = new Solid (Solid::SECTION, sol, sol2); - } - return sol; - } - - - Solid * ParseSolid (CSGScanner & scan) - { - Solid * sol = ParseTerm(scan); - while (scan.GetToken() == TOK_OR) - { - scan.ReadNext(); - Solid * sol2 = ParseTerm(scan); - sol = new Solid (Solid::UNION, sol, sol2); - } - return sol; - } - - - - void ParseFlags (CSGScanner & scan, Flags & flags) - { - while (scan.GetToken() == '-') - { - scan.ReadNext(); - string name = scan.GetStringValue(); - scan.ReadNext(); - if (scan.GetToken() == '=') - { - scan.ReadNext(); - if (scan.GetToken() == TOK_STRING) - { - flags.SetFlag (name.c_str(), scan.GetStringValue().c_str()); - scan.ReadNext(); - } - else if (scan.GetToken() == '[') - { - scan.ReadNext(); - ARRAY<double> vals; - vals.Append (ParseNumber(scan)); - while (scan.GetToken() == ',') - { - scan.ReadNext(); - vals.Append (ParseNumber(scan)); - } - ParseChar (scan, ']'); - flags.SetFlag (name.c_str(), vals); - } - else if (scan.GetToken() == TOK_NUM) - { - flags.SetFlag (name.c_str(), scan.GetNumValue()); - scan.ReadNext(); - } - } - else - { - flags.SetFlag (name.c_str()); - } - } - } - - - /* - Main parsing function for CSG geometry - */ - CSGeometry * ParseCSG (istream & istr) - { - CSGScanner scan(istr); - - geom = new CSGeometry; - - scan.ReadNext(); - if (scan.GetToken() != TOK_RECO) // keyword 'algebraic3d' - return 0; - - scan.ReadNext(); - - try - { - while (1) - { - if (scan.GetToken() == TOK_END) break; - - if (scan.GetToken() == TOK_SOLID) - { - scan.ReadNext(); - if (scan.GetToken() != TOK_STRING) - scan.Error ("name identifier expected"); - string solidname = scan.GetStringValue(); - - scan.ReadNext(); - - ParseChar (scan, '='); - Solid * solid = ParseSolid (scan); - - Flags flags; - ParseFlags (scan, flags); - - geom->SetSolid (solidname.c_str(), new Solid (Solid::ROOT, solid)); - geom->SetFlags (solidname.c_str(), flags); - - ParseChar (scan, ';'); - - PrintMessage (4, "define solid ", solidname); - } - - else if (scan.GetToken() == TOK_TLO) - - { // a TopLevelObject definition - - scan.ReadNext(); - - string name = scan.GetStringValue(); - scan.ReadNext(); - - if (scan.GetToken() != TOK_STRING) - - { // a solid TLO - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - if (!geom->GetSolid (name)) - scan.Error ("Top-Level-Object "+name+" not defined"); - - int tlonr = - geom->SetTopLevelObject ((Solid*)geom->GetSolid(name)); - TopLevelObject * tlo = geom->GetTopLevelObject (tlonr); - - if (flags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = - flags.GetNumListFlag ("col"); - tlo->SetRGB (col[0], col[1], col[2]); - } - - if (flags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - - tlo->SetMaterial (flags.GetStringFlag ("material", "")); - tlo->SetLayer (int(flags.GetNumFlag ("layer", 1))); - if (flags.NumFlagDefined ("maxh")) - tlo->SetMaxH (flags.GetNumFlag("maxh", 1e10)); - } - - else - - { // a surface TLO - - string surfname = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - ARRAY<int> si; - geom->GetSolid(surfname)->GetSurfaceIndices(si); - int tlonr = - geom->SetTopLevelObject ((Solid*)geom->GetSolid(name), - (Surface*)geom->GetSurface(si.Get(1))); - TopLevelObject * tlo = geom->GetTopLevelObject (tlonr); - if (flags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = flags.GetNumListFlag ("col"); - tlo->SetRGB (col.Get(1), col.Get(2), col.Get(3)); - } - if (flags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - - if (flags.NumFlagDefined ("maxh")) - tlo->SetMaxH (flags.GetNumFlag("maxh", 1e10)); - tlo->SetLayer (int(flags.GetNumFlag ("layer", 1))); - tlo->SetBCProp (int(flags.GetNumFlag ("bc", -1))); - } - } - - else if (scan.GetToken() == TOK_IDENTIFY) - - { - - scan.ReadNext(); - switch (scan.GetToken()) - { - case TOK_CLOSESURFACES: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - - ARRAY<int> si1, si2; - geom->GetSolid(name1)->GetSurfaceIndices(si1); - geom->GetSolid(name2)->GetSurfaceIndices(si2); - - const TopLevelObject * domain = - geom->GetTopLevelObject (geom->GetSolid(flags.GetStringFlag ("tlo",""))); - - geom->AddIdentification - (new CloseSurfaceIdentification - (geom->GetNIdentifications()+1, *geom, - geom->GetSurface (si1[0]), geom->GetSurface (si2[0]), - domain, - flags)); - - break; - } - - case TOK_PERIODIC: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - ParseChar (scan, ';'); - - - ARRAY<int> si1, si2; - geom->GetSolid(name1)->GetSurfaceIndices(si1); - geom->GetSolid(name2)->GetSurfaceIndices(si2); - - geom->AddIdentification - (new PeriodicIdentification - (geom->GetNIdentifications()+1, - *geom, - geom->GetSurface (si1.Get(1)), - geom->GetSurface (si2.Get(1)))); - break; - } - - default: - scan.Error ("keyword 'closesurfaces' or 'periodic' expected"); - } - - } - - else if (scan.GetToken() == TOK_SINGULAR) - - { - - scan.ReadNext(); - switch (scan.GetToken()) - { - case TOK_FACE: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); // tlo - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - const Solid * sol = geom->GetSolid(name2); - - for (int i = 0; i < geom->GetNTopLevelObjects(); i++) - if (name1 == geom->GetTopLevelObject (i)->GetSolid()->Name()) - geom->singfaces.Append (new SingularFace (i+1, sol)); - - break; - } - - case TOK_EDGE: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - const Solid * s1 = geom->GetSolid(name1); - const Solid * s2 = geom->GetSolid(name2); - geom->singedges.Append (new SingularEdge (1, s1, s2)); - break; - } - - case TOK_POINT: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - string name2 = scan.GetStringValue(); - scan.ReadNext(); - string name3 = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - const Solid * s1 = geom->GetSolid(name1); - const Solid * s2 = geom->GetSolid(name2); - const Solid * s3 = geom->GetSolid(name3); - geom->singpoints.Append (new SingularPoint (1, s1, s2, s3)); - break; - } - default: - scan.Error ("keyword 'face' or 'edge' or 'point' expected"); - } - } - - - else if (scan.GetToken() == TOK_POINT) - { - Point<3> p; - - scan.ReadNext(); - ParseChar (scan, '('); - p = Point<3> (ParseVector (scan)); - ParseChar (scan, ')'); - ParseChar (scan, ';'); - - geom->AddUserPoint (p); - } - - else if (scan.GetToken() == TOK_BOUNDINGBOX) - { - Point<3> p1, p2; - - scan.ReadNext(); - ParseChar (scan, '('); - p1 = Point<3> (ParseVector (scan)); - ParseChar (scan, ';'); - p2 = Point<3> (ParseVector (scan)); - ParseChar (scan, ')'); - ParseChar (scan, ';'); - - geom->SetBoundingBox (Box<3> (p1, p2)); - } - - else if (scan.GetToken() == TOK_BOUNDARYCONDITION) - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - int num = int (ParseNumber (scan)); - ParseChar (scan, ';'); - - - CSGeometry::BCModification bcm; - ARRAY<int> si; - - geom->GetSolid(name1)->GetSurfaceIndices(si); - - bcm.tlonr = -1; - int i; - for (i = 0; i < geom->GetNTopLevelObjects(); i++) - if (string (geom->GetTopLevelObject(i)->GetSolid()->Name()) - == name2) - { - bcm.tlonr = i; - break; - } - - bcm.bcnr = num; - for (i = 0; i < si.Size(); i++) - { - bcm.si = si[i]; - geom->bcmodifications.Append (bcm); - } - } - - else - { - cout << "read unidentified token " << scan.GetToken() - << " string = " << scan.GetStringValue() << endl; - scan.ReadNext(); - } - } - } - catch (string errstr) - { - cout << "caught error " << errstr << endl; - throw NgException (errstr); - } - - - return geom; - /* - do - { - scan.ReadNext(); - if (scan.GetToken() == TOK_STRING) - cout << "found string " << scan.GetStringValue() << endl; - else - cout << "token = " << int(scan.GetToken()) << endl; - } - while (scan.GetToken() != TOK_END); - */ - } - - -}; - diff --git a/contrib/Netgen/libsrc/csg/csgparser_dalibor.cpp b/contrib/Netgen/libsrc/csg/csgparser_dalibor.cpp deleted file mode 100644 index 7f640864a3ad4783dc17971ef4e7e5a08bfcf15e..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csgparser_dalibor.cpp +++ /dev/null @@ -1,1111 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - using namespace netgen; - - - enum TOKEN_TYPE - { - TOK_MINUS = '-', TOK_LP = '(', OK_RP = ')', TOK_LSP = '[', TOK_RSP = ']', - TOK_EQU = '=', TOK_COMMA = ',', TOK_SEMICOLON = ';', - TOK_NUM = 100, TOK_STRING, TOK_NAMED_SOLID, TOK_PRIMITIVE, - TOK_OR, TOK_AND, TOK_NOT, - TOK_TRANSLATE, TOK_MULTITRANSLATE, TOK_ROTATE, TOK_MULTIROTATE, - TOK_SINGULAR, TOK_EDGE, TOK_POINT, TOK_IDENTIFY, TOK_CLOSESURFACES, - TOK_CLOSEEDGES, TOK_PERIODIC, - TOK_SOLID, TOK_RECO, TOK_TLO, TOK_BOUNDINGBOX, TOK_BOUNDARYCONDITION, - TOK_END }; - - struct kwstruct - { - TOKEN_TYPE kw; - char * name; - }; - - static kwstruct defkw[] = - { - { TOK_RECO, "algebraic3d" }, - { TOK_SOLID, "solid" }, - { TOK_TLO, "tlo" }, - { TOK_BOUNDINGBOX, "boundingbox" }, - { TOK_OR, "or" }, - { TOK_AND, "and" }, - { TOK_NOT, "not" }, - { TOK_TRANSLATE, "translate" }, - { TOK_MULTITRANSLATE, "multitranslate" }, - { TOK_ROTATE, "rotate" }, - { TOK_MULTIROTATE, "multirotate" }, - { TOK_SINGULAR, "singular" }, - { TOK_EDGE, "edge" }, - { TOK_POINT, "point" }, - { TOK_IDENTIFY, "identify" }, - { TOK_CLOSESURFACES, "closesurfaces" }, - { TOK_CLOSEEDGES, "closeedges" }, - { TOK_PERIODIC, "periodic" }, - { TOK_BOUNDARYCONDITION, "boundarycondition" }, - { TOKEN_TYPE(0) } - }; - - enum PRIMITIVE_TYPE - { TOK_SPHERE = 1, TOK_CYLINDER, TOK_PLANE, TOK_ELLIPTICCYLINDER, - TOK_ELLIPSOID, - TOK_CONE, TOK_TUBE, - TOK_GENCYL, TOK_ORTHOBRICK, TOK_POLYHEDRON, TOK_EXTRUSION, TOK_REVOLUTION }; - - struct primstruct - { - PRIMITIVE_TYPE kw; - char * name; - }; - - static primstruct defprim[] = - { - { TOK_PLANE, "plane" }, - { TOK_SPHERE, "sphere" }, - { TOK_CYLINDER, "cylinder" }, - { TOK_CONE, "cone" }, - { TOK_ELLIPTICCYLINDER, "ellipticcylinder" }, - { TOK_ELLIPSOID, "ellipsoid" }, - { TOK_TUBE, "tube" }, - { TOK_GENCYL, "gencyl" }, - { TOK_ORTHOBRICK, "orthobrick" }, - { TOK_POLYHEDRON, "polyhedron" }, - { TOK_EXTRUSION, "extrusion" }, - { TOK_REVOLUTION, "revolution" }, - { PRIMITIVE_TYPE(0) } - }; - - - - static CSGeometry * geom; - - /* -%token <solidtype> TOK_SPHERE TOK_CYLINDER TOK_CONE TOK_PLAIN TOK_TUBE TOK_GENCYL TOK_ORTHOBRICK TOK_POLYHEDRON TOK_REVOLUTION -%left <solidtype> TOK_OR TOK_AND TOK_NOT -%token <solidtype> TOK_TRANSLATE TOK_MULTITRANSLATE TOK_ROTATE TOK_MULTIROTATE -%type <solidtype> solid solidprimitive -%type <void> splinesegmentlist splinesegment readbspline bsplinepointlist -%type <chptr> anyident -%token TOK_SINGULAR TOK_EDGE TOK_POINT -%token TOK_IDENTIFY TOK_CLOSESURFACES TOK_CLOSEEDGES TOK_PERIODIC -%token TOK_BOUNDARYCONDITION -%type <void> polyhedronpoints polyhedronfaces polyhedronpoint polyhedronface -%type <void> revolutionpoints revolutionpoint - */ - - - - class CSGScanner - { - TOKEN_TYPE token; - PRIMITIVE_TYPE prim_token; - double num_value; - string string_value; - - int linenum; - istream * scanin; - - public: - - CSGScanner (istream & ascanin); - - TOKEN_TYPE GetToken() const - { return token; } - - double GetNumValue() const - { return num_value; } - - const string & GetStringValue() const - { return string_value; } - - PRIMITIVE_TYPE GetPrimitiveToken() const - { return prim_token; } - - void ReadNext(); - void Error (const string & err); - }; - - - CSGScanner :: CSGScanner (istream & ascanin) - { - int i; - - scanin = &ascanin; - token = TOK_END; - num_value = 0; - linenum = 1; - } - - - void CSGScanner :: ReadNext () - { - char ch; - - - // whitespaces ueberspringen - do - { - scanin->get(ch); - - if (ch == '\n') - linenum++; - - // end of file reached - if (scanin->eof()) - { - token = TOK_END; - return; - } - - // skip comment line - if (ch == '#') - { - while (ch != '\n') - { - scanin->get(ch); - if (scanin->eof()) - { - token = TOK_END; - return; - } - } - linenum++; - } - } - while (isspace(ch)); - - switch (ch) - { - case '(': case ')': - case '[': case ']': - case '-': - case '=': case ',': case ';': - { - token = TOKEN_TYPE (ch); - break; - } - - default: - { - if (isdigit (ch) || ch == '.') - { - scanin->putback (ch); - (*scanin) >> num_value; - token = TOK_NUM; - return; - } - - if (isalpha (ch)) - { - string_value = string (1, ch); - scanin->get(ch); - while (isalnum(ch)) - { - string_value += ch; - scanin->get(ch); - } - scanin->putback (ch); - } - /* - (*scanin).putback (ch); - (*scanin) >> string_value; - */ - int nr = 0; - while (defkw[nr].kw) - { - if (string_value == defkw[nr].name) - { - token = defkw[nr].kw; - return; - } - nr++; - } - - nr = 0; - while (defprim[nr].kw) - { - if (string_value == defprim[nr].name) - { - token = TOK_PRIMITIVE; - prim_token = defprim[nr].kw; - return; - } - nr++; - } - - token = TOK_STRING; - } - } - } - - void CSGScanner :: Error (const string & err) - { - stringstream errstr; - errstr << "Parsing error in line " << linenum << ": " << endl << err << endl; - throw string(errstr.str()); - } - - - /* - Solid = Term { OR Term } - Term = Primary { AND Primary } - Primary = PRIM | IDENT | ( Solid ) | NOT Primary - */ - - void ParseChar (CSGScanner & scan, char ch) - { - char str[2]; - str[0] = ch; - str[1] = 0; - if (scan.GetToken() != TOKEN_TYPE(ch)) - scan.Error (string ("token '") + string(str) + string("' expected")); - scan.ReadNext(); - } - - double ParseNumber(CSGScanner & scan) - { - if (scan.GetToken() == '-') - { - scan.ReadNext(); - return -ParseNumber (scan); - } - if (scan.GetToken() != TOK_NUM) scan.Error ("number expected"); - double val = scan.GetNumValue(); - scan.ReadNext(); - return val; - } - - - Solid * ParseSolid (CSGScanner & scan); - Solid * ParseTerm (CSGScanner & scan); - Solid * ParsePrimary (CSGScanner & scan); - - - Solid * ParsePrimary (CSGScanner & scan) - { - if (scan.GetToken() == TOK_PRIMITIVE) - { - // cout << "prim token = " << int (scan.GetPrimitiveToken()) << endl; - switch (scan.GetPrimitiveToken()) - { - case TOK_PLANE: - { - Point<3> p; - Vec<3> v; - - scan.ReadNext(); - - ParseChar (scan, '('); - p(0) = ParseNumber (scan); - ParseChar (scan, ','); - p(1) = ParseNumber (scan); - ParseChar (scan, ','); - p(2) = ParseNumber (scan); - ParseChar (scan, ';'); - v(0) = ParseNumber (scan); - ParseChar (scan, ','); - v(1) = ParseNumber (scan); - ParseChar (scan, ','); - v(2) = ParseNumber (scan); - ParseChar (scan, ')'); - - // cout << "define plane, p = " << p << "; v = " << v << endl; - OneSurfacePrimitive * surf = new Plane ( p, v ); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - case TOK_CYLINDER: - { - Point<3> pa, pb; - double r; - - scan.ReadNext(); - - ParseChar (scan, '('); - pa(0) = ParseNumber (scan); - ParseChar (scan, ','); - pa(1) = ParseNumber (scan); - ParseChar (scan, ','); - pa(2) = ParseNumber (scan); - ParseChar (scan, ';'); - pb(0) = ParseNumber (scan); - ParseChar (scan, ','); - pb(1) = ParseNumber (scan); - ParseChar (scan, ','); - pb(2) = ParseNumber (scan); - ParseChar (scan, ';'); - r = ParseNumber (scan); - ParseChar (scan, ')'); - - OneSurfacePrimitive * surf = new Cylinder ( pa, pb, r ); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - - case TOK_ELLIPTICCYLINDER: - { - Point<3> pa; - Vec<3> vl, vs; - - scan.ReadNext(); - - ParseChar (scan, '('); - pa(0) = ParseNumber (scan); - ParseChar (scan, ','); - pa(1) = ParseNumber (scan); - ParseChar (scan, ','); - pa(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - vl(0) = ParseNumber (scan); - ParseChar (scan, ','); - vl(1) = ParseNumber (scan); - ParseChar (scan, ','); - vl(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - vs(0) = ParseNumber (scan); - ParseChar (scan, ','); - vs(1) = ParseNumber (scan); - ParseChar (scan, ','); - vs(2) = ParseNumber (scan); - ParseChar (scan, ')'); - - OneSurfacePrimitive * surf = new EllipticCylinder ( pa, vl, vs); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - - - case TOK_ELLIPSOID: - { - Point<3> pa; - Vec<3> v1, v2, v3; - - scan.ReadNext(); - - ParseChar (scan, '('); - pa(0) = ParseNumber (scan); - ParseChar (scan, ','); - pa(1) = ParseNumber (scan); - ParseChar (scan, ','); - pa(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - v1(0) = ParseNumber (scan); - ParseChar (scan, ','); - v1(1) = ParseNumber (scan); - ParseChar (scan, ','); - v1(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - v2(0) = ParseNumber (scan); - ParseChar (scan, ','); - v2(1) = ParseNumber (scan); - ParseChar (scan, ','); - v2(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - v3(0) = ParseNumber (scan); - ParseChar (scan, ','); - v3(1) = ParseNumber (scan); - ParseChar (scan, ','); - v3(2) = ParseNumber (scan); - ParseChar (scan, ')'); - - OneSurfacePrimitive * surf = new Ellipsoid ( pa, v1, v2, v3); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - - - case TOK_CONE: - { - Point<3> pa, pb; - double ra, rb; - - scan.ReadNext(); - - ParseChar (scan, '('); - pa(0) = ParseNumber (scan); - ParseChar (scan, ','); - pa(1) = ParseNumber (scan); - ParseChar (scan, ','); - pa(2) = ParseNumber (scan); - ParseChar (scan, ';'); - ra = ParseNumber (scan); - ParseChar (scan, ';'); - pb(0) = ParseNumber (scan); - ParseChar (scan, ','); - pb(1) = ParseNumber (scan); - ParseChar (scan, ','); - pb(2) = ParseNumber (scan); - ParseChar (scan, ';'); - rb = ParseNumber (scan); - ParseChar (scan, ')'); - - OneSurfacePrimitive * surf = new Cone ( pa, pb, ra, rb); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - - - - - case TOK_SPHERE: - { - Point<3> p; - double r; - - scan.ReadNext(); - - ParseChar (scan, '('); - p(0) = ParseNumber (scan); - ParseChar (scan, ','); - p(1) = ParseNumber (scan); - ParseChar (scan, ','); - p(2) = ParseNumber (scan); - ParseChar (scan, ';'); - r = ParseNumber (scan); - ParseChar (scan, ')'); - - // cout << "define sphere, c = " << p << ", rad = " << r << endl; - OneSurfacePrimitive * surf = new Sphere ( p, r ); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - } - - case TOK_ORTHOBRICK: - { - Point<3> pa, pb; - - scan.ReadNext(); - - ParseChar (scan, '('); - pa(0) = ParseNumber (scan); - ParseChar (scan, ','); - pa(1) = ParseNumber (scan); - ParseChar (scan, ','); - pa(2) = ParseNumber (scan); - ParseChar (scan, ';'); - pb(0) = ParseNumber (scan); - ParseChar (scan, ','); - pb(1) = ParseNumber (scan); - ParseChar (scan, ','); - pb(2) = ParseNumber (scan); - ParseChar (scan, ')'); - - // cout << "define orthobrick, p1 = " << pa << "; p2 = " << pb << endl; - - Primitive * nprim = new OrthoBrick (pa, pb); - - for (int j = 0; j < nprim->GetNSurfaces(); j++) - { - geom->AddSurface (&nprim->GetSurface(j)); - nprim->SetSurfaceId (j, geom->GetNSurf()-1); - } - return new Solid (nprim); - } - - - case TOK_EXTRUSION: - { - Point<3> p0; - Vec<3> ex, ey; - ARRAY<Point<2> > points; - - scan.ReadNext(); - - ParseChar (scan, '('); - p0(0) = ParseNumber (scan); - ParseChar (scan, ','); - p0(1) = ParseNumber (scan); - ParseChar (scan, ','); - p0(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - ex(0) = ParseNumber (scan); - ParseChar (scan, ','); - ex(1) = ParseNumber (scan); - ParseChar (scan, ','); - ex(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - ey(0) = ParseNumber (scan); - ParseChar (scan, ','); - ey(1) = ParseNumber (scan); - ParseChar (scan, ','); - ey(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - cout << "p0 = " << p0 << endl; - - int npseg = 0; - int nseg = 0; - while (1) - { - Point<2> p1, p2, p3; - - p1(0) = ParseNumber(scan); - ParseChar (scan, ','); - p1(1) = ParseNumber(scan); - points.Append (p1); - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - scan.ReadNext(); - } - - - /* - while (1) - { - Point<2> p1, p2, p3; - - p3 = p2; - p2 = p1; - p1(0) = ParseNumber(scan); - ParseChar (scan, ','); - p1(1) = ParseNumber(scan); - npseg++; - - cout << "p1 = " << p1 << endl; - - if (scan.GetToken() == ';' || scan.GetToken() == ')') - { - if (npseg == 2) - { - p3 = p2; - p2 = Center (p1, p3); - } - if (nseg == 0) - points.Append (p3); - points.Append (p2); - points.Append (p1); - npseg = 1; - nseg++; - - cout << "p1, = " << p1 << ", p2 = " << p2 << ", p3 = " << p3 << endl; - } - - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - if (scan.GetToken() == ';' || scan.GetToken() == ',') - { - scan.ReadNext(); - } - } - */ - cout << "p0 = " << p0 << endl; - cout << ", ex = " << ex << ", ey = " << ey << endl; - cout << "points = " << points << endl; - - Extrusion * extrusion = new Extrusion (p0, ex, ey, points); - - for (int i = 0; i < extrusion->GetNSurfaces(); i++) - { - geom->AddSurface (&extrusion->GetSurface(i)); - extrusion->SetSurfaceId(i, geom->GetNSurf()-1); - } - return new Solid (extrusion); - - /* - // cout << "define cylinder, pa = " << pa << "; pb = " << pb - // << ", rad = " << r << endl; - OneSurfacePrimitive * surf = new Cylinder ( pa, pb, r ); - - geom->AddSurface (surf); - surf->SetSurfaceId (0, geom->GetNSurf()-1); - - return new Solid (surf); - */ - } - - -// Added by Dalibor Lukas, October 15, 2003 - case TOK_POLYHEDRON: - { - Point<3> p; - int pi1, pi2, pi3, pi4; - - scan.ReadNext(); - ParseChar (scan, '('); - - Polyhedra * polyhedron = new Polyhedra; - - // scanning the points - while (1) - { - p(0) = ParseNumber (scan); - ParseChar (scan, ','); - p(1) = ParseNumber (scan); - ParseChar (scan, ','); - p(2) = ParseNumber (scan); - ParseChar (scan, ';'); - - cout << "point = " << p << endl; - - polyhedron->AddPoint(p); - - if (scan.GetToken() == ';') - { - scan.ReadNext(); - break; - } - } - - // scanning the faces - while (1) - { - pi1 = (int) (ParseNumber (scan)); - ParseChar (scan, ','); - pi2 = (int) (ParseNumber (scan)); - ParseChar (scan, ','); - pi3 = (int) (ParseNumber (scan)); - ParseChar (scan, ','); - pi4 = (int) (ParseNumber (scan)); - - cout << "face = (" << pi1 << ", " << pi2 << ", " << pi3 - << ", " << pi4 << ")" << endl; - - polyhedron->AddFace(pi1-1,pi2-1,pi3-1); - polyhedron->AddFace(pi1-1,pi3-1,pi4-1); - - if (scan.GetToken() == ')') - { - scan.ReadNext(); - break; - } - scan.ReadNext(); - } - - int j; - for (j = 0; j < polyhedron->GetNSurfaces(); j++) - { - geom->AddSurface (&polyhedron->GetSurface(j)); - polyhedron->SetSurfaceId (j, geom->GetNSurf()-1); - } - - return new Solid (polyhedron); - } -// DL - - - } - cout << "unknown primary " << scan.GetStringValue() << endl; - } - - else if (scan.GetToken() == TOK_STRING && - geom->GetSolid(scan.GetStringValue())) - - { - Solid * sol = const_cast<Solid*> (geom->GetSolid(scan.GetStringValue())); - scan.ReadNext(); - return sol; - } - - else if (scan.GetToken() == TOK_NOT) - - { - scan.ReadNext(); - Solid * sol1 = ParsePrimary (scan); - return new Solid (Solid::SUB, sol1); - } - - else if (scan.GetToken() == '(') - - { - scan.ReadNext(); - Solid * sol1 = ParseSolid (scan); - scan.ReadNext(); - return sol1; - } - - scan.Error (string ("not a primary, name = ")+ - scan.GetStringValue()); - return 0; - } - - - Solid * ParseTerm (CSGScanner & scan) - { - Solid * sol = ParsePrimary(scan); - while (scan.GetToken() == TOK_AND) - { - scan.ReadNext(); - Solid * sol2 = ParsePrimary(scan); - sol = new Solid (Solid::SECTION, sol, sol2); - } - return sol; - } - - Solid * ParseSolid (CSGScanner & scan) - { - Solid * sol = ParseTerm(scan); - while (scan.GetToken() == TOK_OR) - { - scan.ReadNext(); - Solid * sol2 = ParseTerm(scan); - sol = new Solid (Solid::UNION, sol, sol2); - } - return sol; - } - - - - void ParseFlags (CSGScanner & scan, Flags & flags) - { - while (scan.GetToken() == '-') - { - scan.ReadNext(); - string name = scan.GetStringValue(); - scan.ReadNext(); - if (scan.GetToken() == '=') - { - scan.ReadNext(); - if (scan.GetToken() == TOK_STRING) - { - flags.SetFlag (name.c_str(), scan.GetStringValue().c_str()); - scan.ReadNext(); - } - else if (scan.GetToken() == '[') - { - scan.ReadNext(); - ARRAY<double> vals; - vals.Append (ParseNumber(scan)); - while (scan.GetToken() == ',') - { - scan.ReadNext(); - vals.Append (ParseNumber(scan)); - } - ParseChar (scan, ']'); - flags.SetFlag (name.c_str(), vals); - } - else if (scan.GetToken() == TOK_NUM) - { - flags.SetFlag (name.c_str(), scan.GetNumValue()); - scan.ReadNext(); - } - } - else - { - flags.SetFlag (name.c_str()); - } - } - } - - - /* - Main parsing function for CSG geometry - */ - CSGeometry * ParseCSG (istream & istr) - { - CSGScanner scan(istr); - - geom = new CSGeometry; - - scan.ReadNext(); - if (scan.GetToken() != TOK_RECO) // keyword 'algebraic3d' - return 0; - scan.ReadNext(); - - try - { - while (1) - { - if (scan.GetToken() == TOK_END) break; - - if (scan.GetToken() == TOK_SOLID) - { - scan.ReadNext(); - if (scan.GetToken() != TOK_STRING) - scan.Error ("name identifier expected"); - string solidname = scan.GetStringValue(); - - scan.ReadNext(); - - ParseChar (scan, '='); - Solid * solid = ParseSolid (scan); - - Flags flags; - ParseFlags (scan, flags); - - geom->SetSolid (solidname.c_str(), new Solid (Solid::ROOT, solid)); - geom->SetFlags (solidname.c_str(), flags); - - ParseChar (scan, ';'); - - PrintMessage (4, "define solid ", solidname); - } - - else if (scan.GetToken() == TOK_TLO) - - { // a TopLevelObject definition - - scan.ReadNext(); - - string name = scan.GetStringValue(); - scan.ReadNext(); - - if (scan.GetToken() != TOK_STRING) - - { // a solid TLO - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - int tlonr = - geom->SetTopLevelObject ((Solid*)geom->GetSolid(name)); - TopLevelObject * tlo = geom->GetTopLevelObject (tlonr); - if (flags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = - flags.GetNumListFlag ("col"); - tlo->SetRGB (col[0], col[1], col[2]); - } - - if (flags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - - tlo->SetMaterial (flags.GetStringFlag ("material", "")); - tlo->SetLayer (int(flags.GetNumFlag ("layer", 1))); - if (flags.NumFlagDefined ("maxh")) - tlo->SetMaxH (flags.GetNumFlag("maxh", 1e10)); - } - - else - - { // a surface TLO - - string surfname = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - ARRAY<int> si; - geom->GetSolid(surfname)->GetSurfaceIndices(si); - int tlonr = - geom->SetTopLevelObject ((Solid*)geom->GetSolid(name), - (Surface*)geom->GetSurface(si.Get(1))); - TopLevelObject * tlo = geom->GetTopLevelObject (tlonr); - if (flags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = flags.GetNumListFlag ("col"); - tlo->SetRGB (col.Get(1), col.Get(2), col.Get(3)); - } - if (flags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - - if (flags.NumFlagDefined ("maxh")) - tlo->SetMaxH (flags.GetNumFlag("maxh", 1e10)); - tlo->SetLayer (int(flags.GetNumFlag ("layer", 1))); - tlo->SetBCProp (int(flags.GetNumFlag ("bc", -1))); - } - } - - else if (scan.GetToken() == TOK_IDENTIFY) - - { - - scan.ReadNext(); - switch (scan.GetToken()) - { - case TOK_CLOSESURFACES: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - Flags flags; - ParseFlags (scan, flags); - - ParseChar (scan, ';'); - - - ARRAY<int> si1, si2; - geom->GetSolid(name1)->GetSurfaceIndices(si1); - geom->GetSolid(name2)->GetSurfaceIndices(si2); - - geom->AddIdentification - (new CloseSurfaceIdentification - (geom->GetNIdentifications()+1, *geom, - geom->GetSurface (si1[0]), geom->GetSurface (si2[0]), - flags)); - break; - } - - case TOK_PERIODIC: - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - ParseChar (scan, ';'); - - - ARRAY<int> si1, si2; - geom->GetSolid(name1)->GetSurfaceIndices(si1); - geom->GetSolid(name2)->GetSurfaceIndices(si2); - - geom->AddIdentification - (new PeriodicIdentification - (geom->GetNIdentifications()+1, - *geom, - geom->GetSurface (si1.Get(1)), - geom->GetSurface (si2.Get(1)))); - break; - } - } - - } - - else if (scan.GetToken() == TOK_POINT) - { - Point<3> p; - - scan.ReadNext(); - ParseChar (scan, '('); - p(0) = ParseNumber (scan); - ParseChar (scan, ','); - p(1) = ParseNumber (scan); - ParseChar (scan, ','); - p(2) = ParseNumber (scan); - ParseChar (scan, ')'); - ParseChar (scan, ';'); - - geom->AddUserPoint (p); - } - - else if (scan.GetToken() == TOK_BOUNDINGBOX) - { - Point<3> p1, p2; - - scan.ReadNext(); - ParseChar (scan, '('); - p1(0) = ParseNumber (scan); - ParseChar (scan, ','); - p1(1) = ParseNumber (scan); - ParseChar (scan, ','); - p1(2) = ParseNumber (scan); - ParseChar (scan, ';'); - p2(0) = ParseNumber (scan); - ParseChar (scan, ','); - p2(1) = ParseNumber (scan); - ParseChar (scan, ','); - p2(2) = ParseNumber (scan); - ParseChar (scan, ')'); - ParseChar (scan, ';'); - - geom->SetBoundingBox (Box<3> (p1, p2)); - } - - else if (scan.GetToken() == TOK_BOUNDARYCONDITION) - { - scan.ReadNext(); - - string name1 = scan.GetStringValue(); - scan.ReadNext(); - - string name2 = scan.GetStringValue(); - scan.ReadNext(); - - int num = int (ParseNumber (scan)); - ParseChar (scan, ';'); - - - CSGeometry::BCModification bcm; - ARRAY<int> si; - - geom->GetSolid(name1)->GetSurfaceIndices(si); - - bcm.tlonr = -1; - int i; - for (i = 0; i < geom->GetNTopLevelObjects(); i++) - if (string (geom->GetTopLevelObject(i)->GetSolid()->Name()) - == name2) - { - bcm.tlonr = i; - break; - } - - bcm.bcnr = num; - for (i = 0; i < si.Size(); i++) - { - bcm.si = si[i]; - geom->bcmodifications.Append (bcm); - } - } - - else - { - cout << "read unidentified token " << scan.GetToken() - << " string = " << scan.GetStringValue() << endl; - scan.ReadNext(); - } - } - } - catch (string errstr) - { - cout << "caught error " << errstr << endl; - } - - - return geom; - /* - do - { - scan.ReadNext(); - if (scan.GetToken() == TOK_STRING) - cout << "found string " << scan.GetStringValue() << endl; - else - cout << "token = " << int(scan.GetToken()) << endl; - } - while (scan.GetToken() != TOK_END); - */ - } - - -}; - diff --git a/contrib/Netgen/libsrc/csg/csgscanner.cpp b/contrib/Netgen/libsrc/csg/csgscanner.cpp deleted file mode 100644 index 50e2213ea64be4b7a51b1a268634d6ec46b32747..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/csgscanner.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - using namespace netgen; - - - enum TOKEN_TYPE - { - LP = '(', RP = ')', EQU = '=', COMMA = ',', SEMICOLON = ';', - TOK_NUM, TOK_STRING, TOK_NAMED_SOLID, TOK_PRIMITIVE, - TOK_OR, TOK_AND, TOK_NOT, - TOK_SOLID, TOK_RECO, TOK_TLO, TOK_BOUNDINGBOX, - TOK_END }; - - struct kwstruct - { - TOKEN_TYPE kw; - string name; - }; - - static kwstruct defkw[] = - { - { TOK_OR, "or" }, - { TOK_AND, "and" }, - { TOKEN_TYPE(0) } - }; - - enum PRIMITIVE_TYPE { TOK_SPHERE, TOK_CYLINDER, TOK_PLANE }; - - /* -%token <solidtype> TOK_SPHERE TOK_CYLINDER TOK_CONE TOK_PLAIN TOK_TUBE TOK_GENCYL TOK_ORTHOBRICK TOK_POLYHEDRON TOK_REVOLUTION -%left <solidtype> TOK_OR TOK_AND TOK_NOT -%token <solidtype> TOK_TRANSLATE TOK_MULTITRANSLATE TOK_ROTATE TOK_MULTIROTATE -%type <solidtype> solid solidprimitive -%type <void> splinesegmentlist splinesegment readbspline bsplinepointlist -%type <chptr> anyident -%token TOK_SINGULAR TOK_EDGE TOK_POINT -%token TOK_IDENTIFY TOK_CLOSESURFACES TOK_CLOSEEDGES TOK_PERIODIC -%token TOK_BOUNDARYCONDITION -%type <void> polyhedronpoints polyhedronfaces polyhedronpoint polyhedronface -%type <void> revolutionpoints revolutionpoint - */ - - - - class CSGScanner - { - TOKEN_TYPE token; - double num_value; - string string_value; - - int linenum; - istream * scanin; - - public: - - CSGScanner (istream & ascanin); - - TOKEN_TYPE GetToken() const - { return token; } - - double GetNumValue() const - { return num_value; } - - const string & GetStringValue() const - { return string_value; } - - void ReadNext(); - - void Error (const string & err); - }; - - - CSGScanner :: CSGScanner (istream & ascanin) - { - int i; - - scanin = &ascanin; - token = TOK_END; - num_value = 0; - linenum = 1; - } - - - void CSGScanner :: ReadNext () - { - char ch; - - - // whitespaces ueberspringen - do - { - scanin->get(ch); - - if (ch == '\n') - linenum++; - - // end of file reached - if (scanin->eof()) - { - token = TOK_END; - return; - } - - // skip comment line - if (ch == '#') - { - while (ch != '\n') - { - scanin->get(ch); - if (scanin->eof()) - { - token = TOK_END; - return; - } - } - linenum++; - } - } - while (isspace(ch)); - - switch (ch) - { - case '(': case ')': - case '=': case ',': case ';': - { - token = TOKEN_TYPE (ch); - break; - } - - default: - { - if (isdigit (ch) || ch == '.' || ch == '-') - { - scanin->putback (ch); - (*scanin) >> num_value; - token = TOK_NUM; - return; - } - - (*scanin).putback (ch); - (*scanin) >> string_value; - - int nr = 0; - while (defkw[nr].kw) - { - if (string_value == defkw[nr].name) - { - token = defkw[nr].kw; - return; - } - } - - token = TOK_STRING; - } - } - } - - void CSGScanner :: Error (const string & err) - { - stringstream errstr; - errstr << "Parsing error in line " << linenum << ": " << endl << err << endl; - /* - errstr << "input continues with <<<"; - for (int i = 0; i < 50; i++) - { - char ch; - scanin->get(ch); - errstr << ch; - if (scanin->eof()) - { - errstr << "(end of file)"; - break; - } - } - errstr << endl << ">>> stop parsing" << endl; - throw Exception (errstr.str()); - */ - } - - - - - - void ParseCSG (istream & istr) - { - CSGScanner scan(istr); - - do - { - scan.ReadNext(); - cout << "token = " << int(scan.GetToken()) << endl; - } - while (scan.GetToken() != TOK_END); - } - - -}; - diff --git a/contrib/Netgen/libsrc/csg/curve2d.cpp b/contrib/Netgen/libsrc/csg/curve2d.cpp deleted file mode 100644 index 7091e87af9556c16e10084815036a0f28d39a498..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/curve2d.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include <mystdlib.h> - -#include <myadt.hpp> -#include <csg.hpp> - -namespace netgen -{ -CircleCurve2d :: CircleCurve2d (const Point<2> & acenter, double arad) - { - center = acenter; - rad = arad; - } - -void CircleCurve2d :: Project (Point<2> & p) const - { - Vec<2> v = p - center; - v *= rad/v.Length(); - p = center + v; - } - -void CircleCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const - { - n = p - center; - n /= n.Length(); - } - - - - - - -QuadraticCurve2d :: QuadraticCurve2d () -{ - cxx = cyy = cxy = cx = cy = c = 0; -} - -void QuadraticCurve2d :: Read (istream & ist) -{ - ist >> cxx >> cyy >> cxy >> cx >> cy >> c; -} - - -void QuadraticCurve2d :: Project (Point<2> & p) const -{ - double f, x, y, gradx, grady, grad2; - int its = 0; - - x = p(0); - y = p(1); - - do - { - f = cxx * x * x + cyy * y * y + cxy * x * y + cx * x + cy * y + c; - gradx = 2 * cxx * x + cxy * y + cx; - grady = 2 * cyy * y + cxy * x + cy; - grad2 = gradx * gradx + grady * grady; - - x -= f * gradx / grad2; - y -= f * grady / grad2; - - // (*mycout) << "x = " << x << " y = " << y << " f = " << f << endl; - its++; - } - while (fabs (f) > 1e-8 && its < 20); - if (its >= 20) - cerr << "QuadraticCurve2d::Project: many iterations, f = " << f << endl; - p(0) = x; - p(1) = y; -} - - -void QuadraticCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const -{ - n(0) = 2 * cxx * p(0) + cxy * p(1) + cx; - n(1) = 2 * cyy * p(1) + cxy * p(0) + cy; - n.Normalize(); -} -} diff --git a/contrib/Netgen/libsrc/csg/curve2d.hpp b/contrib/Netgen/libsrc/csg/curve2d.hpp deleted file mode 100644 index 917bd532056b9e4120a38865ef1a14358f288083..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/curve2d.hpp +++ /dev/null @@ -1,59 +0,0 @@ -#ifndef FILE_CURVE2D -#define FILE_CURVE2D - -/**************************************************************************/ -/* File: curve2d.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 24. Jul. 96 */ -/**************************************************************************/ - -/* - - 2D Curve repesentation - -*/ - - - -/// -class Curve2d : public Manifold - { - public: - /// - virtual void Project (Point<2> & p) const = 0; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const = 0; - }; - -/// -class CircleCurve2d : public Curve2d - { - /// - Point<2> center; - /// - double rad; - public: - /// - CircleCurve2d (const Point<2> & acenter, double arad); - /// - virtual void Project (Point<2> & p) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; - }; - -/// -class QuadraticCurve2d : public Curve2d -{ - /// - double cxx, cyy, cxy, cx, cy, c; -public: - /// - QuadraticCurve2d (); - /// - void Read (istream & ist); - /// - virtual void Project (Point<2> & p) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; -}; -#endif diff --git a/contrib/Netgen/libsrc/csg/edgeflw.cpp b/contrib/Netgen/libsrc/csg/edgeflw.cpp deleted file mode 100644 index 50b425f84f425bfe118794b5179a77b749e01ce0..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/edgeflw.cpp +++ /dev/null @@ -1,1524 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - -#undef DEVELOP - -namespace netgen -{ - - EdgeCalculation :: - EdgeCalculation (const CSGeometry & ageometry, - ARRAY<SpecialPoint> & aspecpoints) - : geometry(ageometry), specpoints(aspecpoints) - { - Box<3> bbox; - if (specpoints.Size() >= 1) - bbox.Set (specpoints[0].p); - else - { bbox.Set (Point<3> (0,0,0)); bbox.Add (Point<3> (1,1,1)); } - for (int i = 1; i < specpoints.Size(); i++) - bbox.Add (specpoints[i].p); - - searchtree = new Point3dTree (bbox.PMin(), bbox.PMax()); - meshpoint_tree = new Point3dTree (bbox.PMin(), bbox.PMax()); - - for (int i = 0; i < specpoints.Size(); i++) - searchtree->Insert (specpoints[i].p, i); - } - - EdgeCalculation :: ~EdgeCalculation() - { - delete searchtree; - delete meshpoint_tree; - } - - - void EdgeCalculation :: Calc(double h, Mesh & mesh) - { - PrintMessage (1, "Find edges"); - PushStatus ("Find edges"); - - CalcEdges1 (h, mesh); - SplitEqualOneSegEdges (mesh); - FindClosedSurfaces (h, mesh); - PrintMessage (3, cntedge, " edges found"); - - PopStatus (); - } - - - - - - void EdgeCalculation :: CalcEdges1 (double h, Mesh & mesh) - { - ARRAY<int> hsp(specpoints.Size()); - ARRAY<int> glob2hsp(specpoints.Size()); - ARRAY<int> startpoints, endpoints; - - int pos, ep; - int layer; - - Point<3> p, np; - int pi1, s1, s2; - - ARRAY<Point<3> > edgepoints; - ARRAY<double> curvelength; - int copyedge, copyfromedge = -1, copyedgeidentification = -1; - - ARRAY<int> locsurfind, locind; - - // double len, corr, lam; - // double steplen, cursteplen, loch, - double hd; - - int checkedcopy = 0; - - // double size = geometry.MaxSize(); - // double epspointdist2 = sqr (size) * 1e-12; - - - // copy special points to work with - for (int i = 0; i < specpoints.Size(); i++) - { - hsp[i] = i; - glob2hsp[i] = i; - } - - - cntedge = 0; - INDEX_2_HASHTABLE<int> identification_used(100); // identification i already used for startpoint j - - - while (hsp.Size()) - { - SetThreadPercent(100 - 100 * double (hsp.Size()) / specpoints.Size()); - - edgepoints.SetSize (0); - curvelength.SetSize (0); - - - pi1 = 0; - copyedge = 0; - // identifyable point available ? - - // (*testout) << endl; - - for (int i = 0; i < geometry.identifications.Size() && !pi1; i++) - for (int j = checkedcopy; j < startpoints.Size() && !pi1; j++) - - if (geometry.identifications[i]->IdentifyableCandidate (specpoints[startpoints[j]])) - - { - int pi1cand = 0; - double mindist = 1e10; - - for (int k = 0; k < hsp.Size() && !pi1; k++) - { - if (identification_used.Used (INDEX_2(i, startpoints[j])) || - identification_used.Used (INDEX_2(i, hsp[k]))) continue; - - if (geometry.identifications[i] - ->Identifyable(specpoints[startpoints[j]], specpoints[hsp[k]]) || - geometry.identifications[i] - ->Identifyable(specpoints[hsp[k]], specpoints[startpoints[j]])) - { - if (Dist (specpoints[startpoints[j]].p, specpoints[hsp[k]].p) < mindist) - { - mindist = Dist (specpoints[startpoints[j]].p, specpoints[hsp[k]].p); - pi1cand = k+1; - } - } - } - - - if (pi1cand) - { - pi1 = pi1cand; - copyedge = 1; - copyfromedge = j+1; - copyedgeidentification = i+1; - - identification_used.Set (INDEX_2(i, startpoints[j]), 1); - identification_used.Set (INDEX_2(i, hsp.Get(pi1)), 1); - } - } - - - // cannot copy from other ege ? - if (!pi1) - checkedcopy = startpoints.Size(); - - // unconditional special point available ? - if (!pi1) - for (int i = 1; i <= hsp.Size(); i++) - if (specpoints[hsp.Get(i)].unconditional == 1) - { - pi1 = i; - break; - } - - - if (!pi1) - { - // only unconditional points available, choose first - pi1 = 1; - } - - layer = specpoints[hsp.Get(pi1)].GetLayer(); - - - if (!specpoints[hsp.Get(pi1)].unconditional) - { - specpoints[hsp.Elem(pi1)].unconditional = 1; - for (int i = 1; i <= hsp.Size(); i++) - if (i != pi1 && - Dist (specpoints[hsp.Get(pi1)].p, specpoints[hsp.Get(i)].p) < 1e-8 && - (specpoints[hsp.Get(pi1)].v + specpoints[hsp.Get(i)].v).Length() < 1e-4) - { - // opposite direction - specpoints[hsp.Elem(i)].unconditional = 1; - } - } - - cntedge++; - startpoints.Append (hsp.Get(pi1)); - -#ifdef DEVELOP - (*testout) << "edge nr " << cntedge << endl; - (*testout) << "start followedge: p1 = " << specpoints[hsp.Get(pi1)].p - << ", v = " << specpoints[hsp.Get(pi1)].v << endl; -#endif - - FollowEdge (pi1, ep, pos, hsp, h, mesh, - edgepoints, curvelength); - - - if (multithread.terminate) - return; - - if (!ep) - { - // ignore starting point - hsp.DeleteElement (pi1); - cout << "yes, this happens" << endl; - continue; - } - - - - endpoints.Append (hsp.Get(ep)); - - - double elen = 0; - for (int i = 1; i <= edgepoints.Size()-1; i++) - elen += Dist (edgepoints.Get(i), edgepoints.Get(i+1)); - - - int shortedge = 0; - for (int i = 1; i <= geometry.identifications.Size(); i++) - if (geometry.identifications.Get(i)->ShortEdge(specpoints[hsp.Get(pi1)], specpoints[hsp.Get(ep)])) - shortedge = 1; - // (*testout) << "shortedge = " << shortedge << endl; - - - if (!shortedge) - { - mesh.RestrictLocalHLine (Point3d (specpoints[hsp.Get(pi1)].p), - Point3d (specpoints[hsp.Get(ep)].p), - elen / mparam.segmentsperedge); - } - - s1 = specpoints[hsp.Get(pi1)].s1; - s2 = specpoints[hsp.Get(pi1)].s2; - - - // delete initial, terminal and conditional points - -#ifdef DEVELOP - (*testout) << "terminal point: p = " << specpoints[hsp.Get(ep)].p - << ", v = " << specpoints[hsp.Get(ep)].v << endl; -#endif - - searchtree -> DeleteElement (hsp.Get(ep)); - searchtree -> DeleteElement (hsp.Get(pi1)); - - if (ep > pi1) - { - glob2hsp[hsp[ep-1]] = -1; - glob2hsp[hsp.Last()] = ep-1; - hsp.DeleteElement (ep); - - glob2hsp[hsp[pi1-1]] = -1; - glob2hsp[hsp.Last()] = pi1-1; - hsp.DeleteElement (pi1); - } - else - { - glob2hsp[hsp[pi1-1]] = -1; - glob2hsp[hsp.Last()] = pi1-1; - hsp.DeleteElement (pi1); - - glob2hsp[hsp[ep-1]] = -1; - glob2hsp[hsp.Last()] = ep-1; - hsp.DeleteElement (ep); - } - - - for (int j = 1; j <= edgepoints.Size()-1; j++) - { - p = edgepoints.Get(j); - np = Center (p, edgepoints.Get(j+1)); - hd = Dist (p, np); - - - Box<3> boxp (np - (1.2 * hd) * Vec<3> (1, 1, 1), - np + (1.2 * hd) * Vec<3> (1, 1, 1)); - searchtree -> GetIntersecting (boxp.PMin(), boxp.PMax(), locind); - - for (int i = 0; i < locind.Size(); i++) - { - if ( specpoints[locind[i]].HasSurfaces (s1, s2) && - specpoints[locind[i]].unconditional == 0) - { - searchtree -> DeleteElement (locind[i]); - - int li = glob2hsp[locind[i]]; - glob2hsp[locind[i]] = -1; - glob2hsp[hsp.Last()] = li; - hsp.Delete (li); - } - } - - - /* - for (int i = 1; i <= hsp.Size(); i++) - if ( specpoints[hsp.Get(i)].HasSurfaces (s1, s2) && - specpoints[hsp.Get(i)].unconditional == 0 && - Dist2 (np, specpoints[hsp.Get(i)].p) < 1.2 * hd) - { - searchtree -> DeleteElement (hsp.Get(i)+1); - hsp.DeleteElement (i); - i--; - } - */ - } - - - ARRAY<Segment> refedges; - ARRAY<bool> refedgesinv; - - - AnalyzeEdge (s1, s2, pos, layer, - edgepoints, - refedges, refedgesinv); - - for (int i = 0; i < refedges.Size(); i++) - refedges[i].edgenr = cntedge; - - - - -#ifdef DEVELOP - (*testout) << "edge " << cntedge << endl - << "startp: " << specpoints[startpoints.Last()].p - << ", v = " << specpoints[startpoints.Last()].v << endl - // << "copy = " << copyedge << endl - << refedges.Size() << " refedges: "; - for (int i = 1; i <= refedges.Size(); i++) - (*testout) << " " << refedges.Get(i).si; - (*testout) << endl; - (*testout) << "inv[1] = " << refedgesinv.Get(1) << endl; -#endif - - if (!copyedge) - { - // int oldnseg = mesh.GetNSeg(); - - if (!shortedge) - StoreEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - else - StoreShortEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - - - /* - for (int i = oldnseg+1; i <= mesh.GetNSeg(); i++) - for (int j = 1; j <= oldnseg; j++) - { - const Point<3> & l1p1 = mesh.Point (mesh.LineSegment(i).p1); - const Point<3> & l1p2 = mesh.Point (mesh.LineSegment(i).p2); - const Point<3> & l2p1 = mesh.Point (mesh.LineSegment(j).p1); - const Point<3> & l2p2 = mesh.Point (mesh.LineSegment(j).p2); - Vec<3> vl1(l1p1, l1p2); - for (double lamk = 0; lamk <= 1; lamk += 0.1) - { - Point<3> l2p = l1p1 + lamk * vl1; - double dist = sqrt (MinDistLP2 (l2p1, l2p2, l2p)); - if (dist > 1e-12) - mesh.RestrictLocalH (l2p, 3*dist); - } - } - */ - } - else - { - CopyEdge (refedges, refedgesinv, - copyfromedge, - specpoints[startpoints.Get(copyfromedge)].p, - specpoints[endpoints.Get(copyfromedge)].p, - edgepoints.Get(1), edgepoints.Last(), - copyedgeidentification, - layer, - mesh); - } - - } - } - - - - - - /* - If two or more edges share the same initial and end-points, - then they need at least two segments - */ - void EdgeCalculation :: - SplitEqualOneSegEdges (Mesh & mesh) - { - // int i, j; - SegmentIndex si; - PointIndex pi; - - ARRAY<int> osedges(cntedge); - INDEX_2_HASHTABLE<int> osedgesht (cntedge+1); - - osedges = 2; - - // count segments on edges - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - osedges.Elem(seg.edgenr)--; - } - - // (*testout) << "osedges = " << osedges << endl; - - // flag one segment edges - for (int i = 0; i < cntedge; i++) - osedges[i] = (osedges[i] > 0) ? 1 : 0; - - // (*testout) << "osedges, now = " << osedges << endl; - - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr)) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2)) - osedgesht.Set (i2, 2); - else - osedgesht.Set (i2, 1); - } - } - } - - - // one edge 1 segment, other 2 segments - // yes, it happens ! - point_on_edge_problem = 0; - for (int i = 1; i <= osedgesht.GetNBags(); i++) - for (int j = 1; j <= osedgesht.GetBagSize(i); j++) - { - INDEX_2 i2; - int val; - osedgesht.GetData (i, j, i2, val); - - const Point<3> & p1 = mesh[PointIndex(i2.I1())]; - const Point<3> & p2 = mesh[PointIndex(i2.I2())]; - Vec<3> v = p2 - p1; - double vlen = v.Length(); - v /= vlen; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (pi != i2.I1() && pi != i2.I2()) - { - const Point<3> & p = mesh[pi]; - Vec<3> v2 = p - p1; - double lam = (v2 * v); - if (lam > 0 && lam < vlen) - { - Point<3> hp = p1 + lam * v; - if (Dist (p, hp) < 1e-4 * vlen) - { - PrintWarning ("Point on edge !!!"); - cout << "seg: " << i2 << ", p = " << pi << endl; - osedgesht.Set (i2, 2); - point_on_edge_problem = 1; - } - } - } - } - - - // insert new points - osedges = -1; - - int nseg = mesh.GetNSeg(); - for (si = 0; si < nseg; si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2) && - osedgesht.Get (i2) == 2 && - osedges.Elem(seg.edgenr) == -1) - { - Point<3> newp = Center (mesh[PointIndex(seg.p1)], - mesh[PointIndex(seg.p2)]); - - ProjectToEdge (geometry.GetSurface(seg.surfnr1), - geometry.GetSurface(seg.surfnr2), - newp); - - osedges.Elem(seg.edgenr) = - mesh.AddPoint (newp, mesh[PointIndex(seg.p1)].GetLayer()); - meshpoint_tree -> Insert (newp, osedges.Elem(seg.edgenr)); - } - } - } - - - for (int i = 1; i <= nseg; i++) - { - Segment & seg = mesh.LineSegment (i); - if (seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr) != -1) - { - Segment newseg = seg; - newseg.p1 = osedges.Get(seg.edgenr); - seg.p2 = osedges.Get(seg.edgenr); - mesh.AddSegment (newseg); - } - } - } - - } - - - - void EdgeCalculation :: - FollowEdge (int pi1, int & ep, int & pos, - const ARRAY<int> & hsp, - double h, const Mesh & mesh, - ARRAY<Point<3> > & edgepoints, - ARRAY<double> & curvelength) - { - int s1, s2; - double len, steplen, cursteplen, loch; - Point<3> p, np, pnp; - Vec<3> a1, a2, t; - - ARRAY<int> locind; - - double size = geometry.MaxSize(); - double epspointdist2 = size * 1e-6; - epspointdist2 = sqr (epspointdist2); - int uselocalh = mparam.uselocalh; - - - s1 = specpoints[hsp.Get(pi1)].s1; - s2 = specpoints[hsp.Get(pi1)].s2; - - p = specpoints[hsp.Get(pi1)].p; - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - - t = Cross (a1, a2); - t.Normalize(); - - pos = (specpoints[hsp.Get(pi1)].v * t) > 0; - if (!pos) t *= -1; - - - edgepoints.Append (p); - curvelength.Append (0); - len = 0; - - loch = min2 (geometry.GetSurface(s1) -> LocH (p, 3, 1, h), - geometry.GetSurface(s2) -> LocH (p, 3, 1, h)); - - - - if (uselocalh) - { - double lh = mesh.GetH(p); - if (lh < loch) - loch = lh; - } - - steplen = 0.1 * loch; - - do - { - if (multithread.terminate) - return; - - if (fabs (p(0)) + fabs (p(1)) + fabs (p(2)) > 100000) - { - ep = 0; - PrintWarning ("Give up line"); - break; - } - - if (steplen > 0.1 * loch) steplen = 0.1 * loch; - - steplen *= 2; - do - { - steplen *= 0.5; - np = p + steplen * t; - pnp = np; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), pnp); - } - while (Dist (np, pnp) > 0.1 * steplen); - - cursteplen = steplen; - if (Dist (np, pnp) < 0.01 * steplen) steplen *= 2; - - - np = pnp; - ep = 0; - - double hvtmin = 1.5 * cursteplen; - - Box<3> boxp (p - (2 * cursteplen) * Vec<3> (1, 1, 1), - p + (2 * cursteplen) * Vec<3> (1, 1, 1)); - - searchtree -> GetIntersecting (boxp.PMin(), boxp.PMax(), locind); - - for (int i = 0; i < locind.Size(); i++) - { - Vec<3> hv = specpoints[locind[i]].p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - specpoints[locind[i]].unconditional == 1 && - (specpoints[locind[i]].v + t).Length() < 0.4 ) - { - Point<3> hep = specpoints[locind[i]].p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, specpoints[locind[i]].p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (specpoints[locind[i]].v + ept).Length() < 1e-4 ) - { - np = specpoints[locind[i]].p; - - for (int jj = 0; jj < hsp.Size(); jj++) - if (hsp[jj] == locind[i]) - ep = jj+1; - - if (!ep) - cerr << "endpoint not found" << endl; - // ep = i; - hvtmin = hvt; - // break; - } - } - } - } - - - - - /* - for (int i = 1; i <= hsp.Size(); i++) - { - if (!boxp.IsIn (specpoints[hsp.Get(i)].p)) - continue; - - Vec<3> hv = specpoints[hsp.Get(i)].p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - specpoints[hsp.Get(i)].unconditional == 1 && - (specpoints[hsp.Get(i)].v + t).Length() < 0.4 ) - { - Point<3> hep = specpoints[hsp.Get(i)].p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, specpoints[hsp.Get(i)].p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (specpoints[hsp.Get(i)].v + ept).Length() < 1e-4 ) - { - np = specpoints[hsp.Get(i)].p; - ep = i; - hvtmin = hvt; - // break; - } - } - } - } - */ - - loch = min2 (geometry.GetSurface(s1) -> LocH (np, 3, 1, h), - geometry.GetSurface(s2) -> LocH (np, 3, 1, h)); - - if (uselocalh) - { - double lh = mesh.GetH(np); - if (lh < loch) - loch = lh; - } - - - len += Dist (p, np) / loch; - edgepoints.Append (np); - curvelength.Append (len); - - p = np; - - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - } - while (! ep); - } - - - - - - - - void EdgeCalculation :: - AnalyzeEdge (int s1, int s2, int pos, int layer, - const ARRAY<Point<3> > & edgepoints, - ARRAY<Segment> & refedges, - ARRAY<bool> & refedgesinv) - { - int i, j, k, l; - int hi; - Point<3> hp; - Vec<3> t, a1, a2, m, n; - Segment seg; - Solid * locsol; - ARRAY<int> locsurfind; - - /* - int pi1 = 0, pi2 = 0; - extern Mesh * mesh; - for (i = 1; i <= mesh->GetNP(); i++) - { - if (Dist2 (edgepoints.Get(1), mesh->Point(i)) < 1e-12) - pi1 = i; - if (Dist2 (edgepoints.Last(), mesh->Point(i)) < 1e-12) - pi2 = i; - } - (*testout) << "Analyze edge: " << pi1 << " - " << pi2 << ", pts = " << edgepoints.Size() << endl; - (*testout) << "p1 = " << edgepoints.Get(1) << " pl = " << edgepoints.Last() << endl; - */ - bool debug = 0; - /* - Dist2 (Point<3> (1.824, -0.104, -0.95), edgepoints.Get(1)) < 1e-6 || - Dist2 (Point<3> (1.824, -0.104, -0.95), edgepoints.Last()) < 1e-6 || - Dist2 (Point<3> (1.72149, -0.26069, -0.95), edgepoints.Get(1)) < 1e-6 || - Dist2 (Point<3> (1.72149, -0.26069, -0.95), edgepoints.Last()) < 1e-6; - */ - - if (debug) - { - (*testout) << "tubious edge !!!" << endl; - (*testout) << "edgepoints = " << edgepoints << endl; - (*testout) << "s1, s2 = " << s1 << " - " << s2 << endl; - } - - refedges.SetSize(0); - refedgesinv.SetSize(0); - hp = Center (edgepoints[0], edgepoints[1]); - ProjectToEdge (geometry.GetSurface(s1), geometry.GetSurface(s2), hp); - - geometry.GetSurface(s1) -> CalcGradient (hp, a1); - geometry.GetSurface(s2) -> CalcGradient (hp, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - - for (i = 0; i < geometry.GetNTopLevelObjects(); i++) - { - if (geometry.GetTopLevelObject(i)->GetLayer() != layer) - continue; - - const Solid * sol = geometry.GetTopLevelObject(i)->GetSolid(); - const Surface * surf = geometry.GetTopLevelObject(i)->GetSurface(); - - sol -> TangentialSolid (hp, locsol); - - if (!locsol) continue; - - BoxSphere<3> boxp (hp, hp); - boxp.Increase (1e-5); - boxp.CalcDiamCenter(); - - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)locsol) -> IterateSolid (rpi); - - locsol -> CalcSurfaceInverse (); - - if (!surf) - { - locsol -> GetSurfaceIndices (locsurfind); - } - else - { - /* - if (fabs (surf->CalcFunctionValue (hp)) < 1e-6) - continue; - */ - locsurfind.SetSize(1); - locsurfind[0] = -1; - for (j = 0; j < geometry.GetNSurf(); j++) - if (geometry.GetSurface(j) == surf) - { - locsurfind[0] = j; - // geometry.GetSurfaceClassRepresentant(j); - break; - } - } - - ((Solid*)locsol) -> IterateSolid (urpi); - - - if (debug) - (*testout) << "edge of tlo " << i << ", has " << locsurfind.Size() << " faces." << endl; - - - for (j = locsurfind.Size()-1; j >= 0; j--) - if (fabs (geometry.GetSurface(locsurfind[j]) - ->CalcFunctionValue (hp) ) > 1e-6) - locsurfind.Delete(j); - - if (debug) - (*testout) << locsurfind.Size() << " faces on hp" << endl; - - for (j = 0; j < locsurfind.Size(); j++) - { - int lsi = locsurfind[j]; - int rlsi = geometry.GetSurfaceClassRepresentant(lsi); - - Vec<3> rn; - - // n is outer normal to solid - n = geometry.GetSurface(lsi) -> GetNormalVector (hp); - if (geometry.GetSurface (lsi)->Inverse()) - n *= -1; - - if (fabs (t * n) > 1e-4) continue; - if (debug) - { - (*testout) << "face " << locsurfind.Get(j) << ", rep = " << rlsi - << " has (t*n) = " << (t*n) << endl; - (*testout) << "n = " << n << endl; - } - - // rn is normal to class representant - rn = geometry.GetSurface(rlsi) -> GetNormalVector (hp); - - int sameasref = ((n * rn) > 0); - - m = Cross (t, rn); - m.Normalize(); - - if (debug) - (*testout) << "m = " << m << endl; - - for (k = 1; k <= 2; k ++) - { - bool edgeinv = (k == 2); - - if (debug) - { - (*testout) << "onface(" << hp << ", " << m << ")= " << flush; - (*testout) << locsol->OnFace (hp, m) << flush; - (*testout) << " vec2in = " - << locsol -> VectorIn2 (hp, m, n) << " and " - << locsol -> VectorIn2 (hp, m, -1 * n) << endl; - } - - // if (locsol -> OnFace (hp, m)) - if (locsol -> VectorIn2 (hp, m, n) == 0 && - locsol -> VectorIn2 (hp, m, -1 * n) == 1) - { - if (debug) - (*testout) << "is true" << endl; - hi = 0; - for (l = 1; l <= refedges.Size(); l++) - { - if (refedges.Get(l).si == rlsi && - refedgesinv.Get(l) == edgeinv) - hi = l; - } - - if (!hi) - { - seg.si = rlsi; - seg.domin = -1; - seg.domout = -1; - seg.tlosurf = -1; - seg.surfnr1 = s1; - seg.surfnr2 = s2; - hi = refedges.Append (seg); - refedgesinv.Append (edgeinv); - } - - if (!surf) - { - if (sameasref) - refedges.Elem(hi).domin = i; - else - refedges.Elem(hi).domout = i; - } - else - refedges.Elem(hi).tlosurf = i; - - if (debug) - (*testout) << "add ref seg:" - << "si = " << refedges.Get(hi).si - << ", domin = " << refedges.Get(hi).domin - << ", domout = " << refedges.Get(hi).domout - << ", surfnr1/2 = " << refedges.Get(hi).surfnr1 - << ", " << refedges.Get(hi).surfnr2 - << ", inv = " << refedgesinv.Get(hi) - << ", refedgenr = " << hi - << endl; - } - else - { - if (debug) - (*testout) << "is false" << endl; - } - m *= -1; - } - } - delete locsol; - } - } - - - - void EdgeCalculation :: - StoreEdge (const ARRAY<Segment> & refedges, - const ARRAY<bool> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - - double len, corr, lam; - PointIndex thispi, lastpi; - Point<3> p, np; - Segment seg; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints.Get(1), edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - - // generate initial point - p = edgepoints.Get(1); - lastpi = -1; - - /* - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist (mesh[pi], p) < 1e-6) - { - lastpi = pi; - break; - } - */ - ARRAY<int> locsearch; - meshpoint_tree -> GetIntersecting (p-Vec<3> (1e-6, 1e-6, 1e-6), - p+Vec<3> (1e-6, 1e-6, 1e-6), locsearch); - if (locsearch.Size()) - lastpi = locsearch[0]; - - - - if (lastpi == -1) - { - lastpi = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, lastpi); - } - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength.Get(j) < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength.Get(j-1)) / - (curvelength.Get(j) - curvelength.Get(j-1)); - - np(0) = (1-lam) * edgepoints.Get(j-1)(0) + lam * edgepoints.Get(j)(0); - np(1) = (1-lam) * edgepoints.Get(j-1)(1) + lam * edgepoints.Get(j)(1); - np(2) = (1-lam) * edgepoints.Get(j-1)(2) + lam * edgepoints.Get(j)(2); - - - thispi = -1; - if (i == ne) - { - /* - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist(mesh[pi], np) < 1e-6) - thispi = pi; - */ - - meshpoint_tree -> GetIntersecting (np-Vec<3> (1e-6, 1e-6, 1e-6), - np+Vec<3> (1e-6, 1e-6, 1e-6), locsearch); - if (locsearch.Size()) - thispi = locsearch[0]; - } - - if (thispi == -1) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np, layer); - meshpoint_tree -> Insert (np, thispi); - } - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = lastpi; - seg.p2 = thispi; - } - else - { - seg.p1 = thispi; - seg.p2 = lastpi; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - - double maxh = min2 (geometry.GetSurface(seg.surfnr1)->GetMaxH(), - geometry.GetSurface(seg.surfnr2)->GetMaxH()); - - if (seg.domin != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domin) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domin)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.domout != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domout) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domout)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.tlosurf != -1) - { - double hi = geometry.GetTopLevelObject(seg.tlosurf) -> GetMaxH(); - maxh = min2 (maxh, hi); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - } - - p = np; - lastpi = thispi; - } - -#ifdef DEVELOP - (*testout) << " eplast = " << lastpi << " = " << p << endl; -#endif - } - - - - - - - void EdgeCalculation :: - StoreShortEdge (const ARRAY<Segment> & refedges, - const ARRAY<bool> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - PointIndex pi; - // int ne; - Segment seg; - - /* - double len, corr, lam; - int thispi, lastpi; - Point<3> p, np; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints[1], edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - */ - - // generate initial point - Point<3> p = edgepoints[0]; - PointIndex pi1 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi1 = pi; - break; - } - - if (pi1 == -1) - { - pi1 = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, pi1); - } - - p = edgepoints.Last(); - PointIndex pi2 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi2 = pi; - break; - } - if (pi2==-1) - { - pi2 = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, pi2); - } - - /* - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength[j] < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength[j-1]) / - (curvelength[j] - curvelength[j-1]); - - np(0) = (1-lam) * edgepoints[j-1](0) + lam * edgepoints[j](0); - np(1) = (1-lam) * edgepoints[j-1](1) + lam * edgepoints[j](1); - np(2) = (1-lam) * edgepoints[j-1](2) + lam * edgepoints[j](2); - - - thispi = 0; - if (i == ne) - for (j = 1; j <= mesh.GetNP(); j++) - if (Dist(mesh.Point(j), np) < 1e-6) - thispi = j; - - if (!thispi) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np); - } - */ - - for (int k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = pi1; - seg.p2 = pi2; - } - else - { - seg.p1 = pi2; - seg.p2 = pi1; - } - - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - } - } - - - - - - - - void EdgeCalculation :: - CopyEdge (const ARRAY<Segment> & refedges, - 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) - { - int k; - PointIndex pi; - - // copy start and end points - for (int i = 1; i <= 2; i++) - { - Point<3> fromp = - (i == 1) ? fromstart : fromend; - Point<3> top = - (i == 1) ? tostart : toend; - - PointIndex frompi = -1; - PointIndex topi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - { - if (Dist2 (mesh[pi], fromp) <= 1e-16) - frompi = pi; - if (Dist2 (mesh[pi], top) <= 1e-16) - topi = pi; - } - - if (topi == -1) - { - topi = mesh.AddPoint (top, layer); - meshpoint_tree -> Insert (top, topi); - } - - const Identification & csi = - (*geometry.identifications.Get(copyedgeidentification)); - - if (csi.Identifyable (mesh[frompi], mesh[topi])) - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - else if (csi.Identifyable (mesh[topi], mesh[frompi])) - mesh.GetIdentifications().Add(topi, frompi, copyedgeidentification); - else - { - cerr << "edgeflw.cpp: should identify, but cannot"; - exit(1); - } - /* - (*testout) << "Add Identification from CopyEdge, p1 = " - << mesh[PointIndex(frompi)] << ", p2 = " - << mesh[PointIndex(topi)] << endl; - - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - */ - } - - int oldns = mesh.GetNSeg(); - for (int i = 1; i <= oldns; i++) - { - // real copy, since array might be reallocated !! - const Segment oldseg = mesh.LineSegment(i); - if (oldseg.edgenr != copyfromedge) - continue; - if (oldseg.seginfo == 0) - continue; - - int pi1 = oldseg.p1; - int pi2 = oldseg.p2; - - int npi1 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi1); - int npi2 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi2); - - Segment seg; - - for (k = 1; k <= refedges.Size(); k++) - { - bool inv = refedgesinv.Get(k); - - // other edge is inverse - if (oldseg.seginfo == 1) - inv = !inv; - - // (*testout) << "inv, now = " << inv << endl; - - if (inv) - { - seg.p1 = npi1; - seg.p2 = npi2; - } - else - { - seg.p1 = npi2; - seg.p2 = npi1; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "copy seg " << seg.p1 << "-" << seg.p2 << endl; -#ifdef DEVELOP - - (*testout) << "copy seg, face = " << seg.si << ": " - << " inv = " << inv << ", refinv = " << refedgesinv.Get(k) - << mesh.Point(seg.p1) << ", " << mesh.Point(seg.p2) << endl; -#endif - - } - - } - } - - - - - - - - void EdgeCalculation :: - FindClosedSurfaces (double h, Mesh & mesh) - { - // if there is no special point at a sphere, one has to add a segment pair - - int i, j; - int nsol; - int nsurf = geometry.GetNSurf(); - int layer; - - BitArray pointatsurface (nsurf); - Point<3> p1, p2; - Vec<3> nv, tv; - Solid * tansol; - ARRAY<int> tansurfind; - // const Solid * sol; - - nsol = geometry.GetNTopLevelObjects(); - - - pointatsurface.Clear(); - - /* - for (i = 1; i <= specpoints.Size(); i++) - { - int classrep; - - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s1); - pointatsurface.Set (classrep); - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s2); - pointatsurface.Set (classrep); - // pointatsurface.Set (specpoints[i].s1); - // pointatsurface.Set (specpoints[i].s2); - } - */ - for (i = 1; i <= mesh.GetNSeg(); i++) - { - const Segment & seg = mesh.LineSegment(i); - int classrep; - -#ifdef DEVELOP - (*testout) << seg.surfnr1 << ", " << seg.surfnr2 << ", si = " << seg.si << endl; -#endif - classrep = geometry.GetSurfaceClassRepresentant (seg.si); - - pointatsurface.Set (classrep); - } - - - for (i = 0; i < nsurf; i++) - { - int classrep = geometry.GetSurfaceClassRepresentant (i); - - if (!pointatsurface.Test(classrep)) - { - const Surface * s = geometry.GetSurface(i); - p1 = s -> GetSurfacePoint(); - nv = s -> GetNormalVector (p1); - - double hloc = - min2 (s->LocH (p1, 3, 1, h), mesh.GetH(p1)); - - tv = nv.GetNormal (); - tv *= (hloc / tv.Length()); - p2 = p1 + tv; - s->Project (p2); - - - Segment seg1; - seg1.si = i; - seg1.domin = -1; - seg1.domout = -1; - - Segment seg2; - seg2.si = i; - seg2.domin = -1; - seg2.domout = -1; - - seg1.surfnr1 = i; - seg2.surfnr1 = i; - seg1.surfnr2 = i; - seg2.surfnr2 = i; - - for (j = 0; j < nsol; j++) - { - if (geometry.GetTopLevelObject(j)->GetSurface()) - continue; - - const Solid * sol = geometry.GetTopLevelObject(j)->GetSolid(); - sol -> TangentialSolid (p1, tansol); - layer = geometry.GetTopLevelObject(j)->GetLayer(); - - if (tansol) - { - tansol -> GetSurfaceIndices (tansurfind); - - if (tansurfind.Size() == 1 && tansurfind.Get(1) == i) - { - if (!tansol->VectorIn(p1, nv)) - { - seg1.domin = j; - seg2.domin = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - else - { - seg1.domout = j; - seg2.domout = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - // seg.s2 = i; - // seg.invs1 = surfaces[i] -> Inverse(); - // seg.invs2 = ! (surfaces[i] -> Inverse()); - } - delete tansol; - } - } - - - if (seg1.domin != -1 || seg1.domout != -1) - { - mesh.AddPoint (p1, layer); - mesh.AddPoint (p2, layer); - seg1.p1 = mesh.GetNP()-1; - seg1.p2 = mesh.GetNP(); - seg2.p2 = mesh.GetNP()-1; - seg2.p1 = mesh.GetNP(); - seg1.geominfo[0].trignum = 1; - seg1.geominfo[1].trignum = 1; - seg2.geominfo[0].trignum = 1; - seg2.geominfo[1].trignum = 1; - mesh.AddSegment (seg1); - mesh.AddSegment (seg2); - - PrintMessage (5, "Add line segment to smooth surface"); - -#ifdef DEVELOP - (*testout) << "Add segment at smooth surface " << i; - if (i != classrep) (*testout) << ", classrep = " << classrep; - (*testout) << ": " - << mesh.Point (mesh.GetNP()-1) << " - " - << mesh.Point (mesh.GetNP()) << endl; -#endif - } - } - } - } - -} diff --git a/contrib/Netgen/libsrc/csg/edgeflw.hpp b/contrib/Netgen/libsrc/csg/edgeflw.hpp deleted file mode 100644 index beb1f690a94811870ba504c72d63db35f5aefe14..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/edgeflw.hpp +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef FILE_EDGEFLW -#define FILE_EDGEFLW - -/**************************************************************************/ -/* File: edgeflw.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 01. Okt. 95 */ -/**************************************************************************/ - -/* - - Edge - following function and - Projection to edge of implicitly given edge - -*/ - - -/** - Calculates edges. - The edges of a solid geometry are computed. Special - points have to be given. - */ -extern void CalcEdges (const CSGeometry & geometry, - const ARRAY<SpecialPoint> & specpoints, - double h, Mesh & mesh); - - - - - -class EdgeCalculation -{ - const CSGeometry & geometry; - ARRAY<SpecialPoint> & specpoints; - Point3dTree * searchtree; - Point3dTree * meshpoint_tree; - int cntedge; -public: - EdgeCalculation (const CSGeometry & ageometry, - ARRAY<SpecialPoint> & aspecpoints); - - ~EdgeCalculation(); - - void Calc(double h, Mesh & mesh); - - -private: - void CalcEdges1 (double h, Mesh & mesh); - - - void FollowEdge (int pi1, int & ep, int & pos, - // const ARRAY<SpecialPoint> & hsp, - const ARRAY<int> & hsp, - double h, const Mesh & mesh, - ARRAY<Point<3> > & edgepoints, - ARRAY<double> & curvelength); - - - void AnalyzeEdge (int s1, int s2, 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<double> & curvelength, - int layer, - Mesh & mesh); - - void StoreShortEdge (const ARRAY<Segment> & refedges, - const ARRAY<bool> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh); - - void CopyEdge (const ARRAY<Segment> & refedges, - 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 FindClosedSurfaces (double h, Mesh & mesh); - - -public: - bool point_on_edge_problem; - -}; - - - -#endif diff --git a/contrib/Netgen/libsrc/csg/edgeflw2.cpp b/contrib/Netgen/libsrc/csg/edgeflw2.cpp deleted file mode 100644 index 87239c05bb2fc1f7326b01fc45dcdaaaa0c1f3d0..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/edgeflw2.cpp +++ /dev/null @@ -1,1404 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - -#undef DEVELOP - -namespace netgen -{ - - EdgeCalculation :: - EdgeCalculation (const CSGeometry & ageometry, - const ARRAY<SpecialPoint> & aspecpoints) - : geometry(ageometry), specpoints(aspecpoints) - { - ; - } - - - - void EdgeCalculation :: Calc(double h, Mesh & mesh) - { - PrintMessage (1, "Find edges"); - PushStatus ("Find edges"); - - CalcEdges1 (h, mesh); - SplitEqualOneSegEdges (mesh); - FindClosedSurfaces (h, mesh); - PrintMessage (3, cntedge, " edges found"); - - PopStatus (); - } - - - - - void EdgeCalculation :: CalcEdges1 (double h, Mesh & mesh) - { - ARRAY<SpecialPoint> hsp(specpoints.Size()); - ARRAY<SpecialPoint> startpoints, endpoints; - - int i, j, k, l, hi, pos, ep, ne; - int layer; - - Vec<3> a1, a2, t, n, m; - Point<3> p, np, pnp, hp; - - Segment seg; - int pi1, s1, s2; - int lastpi, thispi; - - ARRAY<Point<3> > edgepoints; - ARRAY<double> curvelength; - int copyedge, copyfromedge, copyedgeidentification; - - ARRAY<int> locsurfind; - - double len, corr, lam; - double steplen, cursteplen, loch, hd; - - int checkedcopy = 0; - - double size = geometry.MaxSize(); // globflags.GetNumFlag ("maxsize", 500); - double epspointdist2 = size * 1e-6; // globflags.GetNumFlag ("epspointdist", size * 1e-6); - epspointdist2 = sqr (epspointdist2); - - - Solid * locsol; - - - // copy special points to work with - for (i = 0; i < specpoints.Size(); i++) - hsp[i] = specpoints[i]; - - - cntedge = 0; - - while (hsp.Size()) - { - SetThreadPercent(100 - 100 * double (hsp.Size()) / specpoints.Size()); - - edgepoints.SetSize (0); - curvelength.SetSize (0); - - - pi1 = 0; - copyedge = 0; - // identifyable point available ? - - // (*testout) << endl; - - for (i = 1; i <= geometry.identifications.Size() && !pi1; i++) - { - for (j = checkedcopy+1; j <= startpoints.Size() && !pi1; j++) - { - - if (geometry.identifications.Get(i)->IdentifyableCandidate (startpoints.Get(j))) - - { - int pi1cand = 0; - double mindist = 1e10; - - for (k = 1; k <= hsp.Size() && !pi1; k++) - { -#ifdef DEVELOP - (*testout) << "check kand = " << hsp.Get(k).p - << ", v = " << hsp.Get(k).v - << endl; -#endif - if (geometry.identifications.Get(i) - ->Identifyable(startpoints.Get(j), hsp.Get(k)) || - geometry.identifications.Get(i) - ->Identifyable(hsp.Get(k), startpoints.Get(j))) - { - -#ifdef DEVELOP - (*testout) << "identifiable, dist = " - << Dist (startpoints.Get(j).p, hsp.Get(k).p) << endl; -#endif - - if (Dist (startpoints.Get(j).p, hsp.Get(k).p) < mindist) - { - mindist = Dist (startpoints.Get(j).p, hsp.Get(k).p); - pi1cand = k; - } - /* - pi1 = k; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; - - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << hsp.Get(k).p << " - " << hsp.Get(k).v << endl; - */ - } - } - - if (pi1cand) - { - pi1 = pi1cand; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; -#ifdef DEVELOP - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << hsp.Get(pi1).p << " - " << hsp.Get(pi1).v << endl; -#endif - } - } - } - } - - - // cannot copy from other ege ? - if (!pi1) - checkedcopy = startpoints.Size(); - - // unconditional special point available ? - if (!pi1) - for (i = 1; i <= hsp.Size() && pi1 == 0; i++) - if (hsp.Get(i).unconditional == 1) - pi1 = i; - - - if (!pi1) - { - // only unconditional points available, choose first - pi1 = 1; - } - - layer = hsp.Get(pi1).GetLayer(); - - - if (!hsp.Get(pi1).unconditional) - { - hsp.Elem(pi1).unconditional = 1; - for (i = 1; i <= hsp.Size(); i++) - if (i != pi1 && Dist (hsp.Get(pi1).p, hsp.Get(i).p) < 1e-8 && - (hsp.Get(pi1).v + hsp.Get(i).v).Length() < 1e-4) - { - // opposite direction - hsp.Elem(i).unconditional = 1; - } - } - - cntedge++; - startpoints.Append (hsp.Get(pi1)); - -#ifdef DEVELOP - (*testout) << "edge nr " << cntedge << endl; - (*testout) << "start followedge: p1 = " << hsp.Get(pi1).p << ", v = " << hsp.Get(pi1).v << endl; -#endif - - FollowEdge (pi1, ep, pos, hsp, h, mesh, - edgepoints, curvelength); - - - if (multithread.terminate) - return; - - if (!ep) - { - // ignore starting point - hsp.DeleteElement (pi1); - continue; - } - - - - endpoints.Append (hsp.Get(ep)); - - - double elen = 0; - for (i = 1; i <= edgepoints.Size()-1; i++) - elen += Dist (edgepoints.Get(i), edgepoints.Get(i+1)); - - - int shortedge = 0; - for (i = 1; i <= geometry.identifications.Size(); i++) - if (geometry.identifications.Get(i)->ShortEdge(hsp.Get(pi1), hsp.Get(ep))) - shortedge = 1; - (*testout) << "shortedge = " << shortedge << endl; - - - if (!shortedge) - { - mesh.RestrictLocalHLine (Point3d (hsp.Get(pi1).p), - Point3d (hsp.Get(ep).p), - elen / mparam.segmentsperedge); - } - - s1 = hsp.Get(pi1).s1; - s2 = hsp.Get(pi1).s2; - - - // delete initial, terminal and conditional points - -#ifdef DEVELOP - (*testout) << "terminal point: p = " << hsp.Get(ep).p << ", v = " << hsp.Get(ep).v << endl; -#endif - if (ep > pi1) - { - hsp.DeleteElement (ep); - hsp.DeleteElement (pi1); - } - else - { - hsp.DeleteElement (pi1); - hsp.DeleteElement (ep); - } - - - for (j = 1; j <= edgepoints.Size()-1; j++) - { - p = edgepoints.Get(j); - np = Center (p, edgepoints.Get(j+1)); - hd = Dist2 (p, np); - - for (i = 1; i <= hsp.Size(); i++) - if ( hsp.Get(i).HasSurfaces (s1, s2) && - hsp.Get(i).unconditional == 0 && - Dist2 (np, hsp.Get(i).p) < 1.2 * hd) - { - hsp.DeleteElement (i); - i--; - } - } - - - ARRAY<Segment> refedges; - ARRAY<int> refedgesinv; - - - AnalyzeEdge (s1, s2, pos, layer, - edgepoints, - refedges, refedgesinv); - - for (i = 1; i <= refedges.Size(); i++) - refedges.Elem(i).edgenr = cntedge; - - -#ifdef DEVELOP - (*testout) << "edge " << cntedge << endl - << "startp: " << startpoints.Last().p - << ", v = " << startpoints.Last().v << endl - << "copy = " << copyedge << endl - << refedges.Size() << " refedges: "; - for (i = 1; i <= refedges.Size(); i++) - (*testout) << " " << refedges.Get(i).si; - (*testout) << endl; - (*testout) << "inv[1] = " << refedgesinv.Get(1) << endl; -#endif - - if (!copyedge) - { - int oldnseg = mesh.GetNSeg(); - - if (!shortedge) - StoreEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - else - StoreShortEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - - - /* - for (i = oldnseg+1; i <= mesh.GetNSeg(); i++) - for (j = 1; j <= oldnseg; j++) - { - const Point<3> & l1p1 = mesh.Point (mesh.LineSegment(i).p1); - const Point<3> & l1p2 = mesh.Point (mesh.LineSegment(i).p2); - const Point<3> & l2p1 = mesh.Point (mesh.LineSegment(j).p1); - const Point<3> & l2p2 = mesh.Point (mesh.LineSegment(j).p2); - Vec<3> vl1(l1p1, l1p2); - for (double lamk = 0; lamk <= 1; lamk += 0.1) - { - Point<3> l2p = l1p1 + lamk * vl1; - double dist = sqrt (MinDistLP2 (l2p1, l2p2, l2p)); - if (dist > 1e-12) - mesh.RestrictLocalH (l2p, 3*dist); - } - } - */ - } - else - { - CopyEdge (refedges, refedgesinv, - copyfromedge, - startpoints.Get(copyfromedge).p, - endpoints.Get(copyfromedge).p, - edgepoints.Get(1), edgepoints.Last(), - copyedgeidentification, - layer, - mesh); - } - - } - } - - - - /* - If two or more edges share the same initial and end-points, - then they need at least two segments - */ - void EdgeCalculation :: - SplitEqualOneSegEdges (Mesh & mesh) - { - int i, j; - SegmentIndex si; - PointIndex pi; - - ARRAY<int> osedges(cntedge); - INDEX_2_HASHTABLE<int> osedgesht (cntedge+1); - - osedges = 2; - - // count segments on edges - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - osedges.Elem(seg.edgenr)--; - } - - (*testout) << "osedges = " << osedges << endl; - - // flag one segment edges - for (i = 0; i < cntedge; i++) - osedges[i] = (osedges[i] > 0) ? 1 : 0; - - (*testout) << "osedges, now = " << osedges << endl; - - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr)) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2)) - osedgesht.Set (i2, 2); - else - osedgesht.Set (i2, 1); - } - } - } - - - // one edge 1 segment, other 2 segments - // yes, it happens ! - - for (i = 1; i <= osedgesht.GetNBags(); i++) - for (j = 1; j <= osedgesht.GetBagSize(i); j++) - { - INDEX_2 i2; - int val; - osedgesht.GetData (i, j, i2, val); - - const Point<3> & p1 = mesh[PointIndex(i2.I1())]; - const Point<3> & p2 = mesh[PointIndex(i2.I2())]; - Vec<3> v = p2 - p1; - double vlen = v.Length(); - v /= vlen; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (pi != i2.I1() && pi != i2.I2()) - { - const Point<3> & p = mesh[pi]; - Vec<3> v2 = p - p1; - double lam = (v2 * v); - if (lam > 0 && lam < vlen) - { - Point<3> hp = p1 + lam * v; - if (Dist (p, hp) < 1e-4 * vlen) - { - PrintSysError ("Point on edge !!!"); - cout << "seg: " << i2 << ", p = " << pi << endl; - osedgesht.Set (i2, 2); - } - } - } - } - - - // insert new points - osedges = -1; - - int nseg = mesh.GetNSeg(); - for (si = 0; si < nseg; si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2) && - osedgesht.Get (i2) == 2 && - osedges.Elem(seg.edgenr) == -1) - { - Point<3> newp = Center (mesh[PointIndex(seg.p1)], - mesh[PointIndex(seg.p2)]); - - ProjectToEdge (geometry.GetSurface(seg.surfnr1), - geometry.GetSurface(seg.surfnr2), - newp); - - osedges.Elem(seg.edgenr) = - mesh.AddPoint (newp, mesh[PointIndex(seg.p1)].GetLayer()); - } - } - } - - - for (i = 1; i <= nseg; i++) - { - Segment & seg = mesh.LineSegment (i); - if (seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr) != -1) - { - Segment newseg = seg; - newseg.p1 = osedges.Get(seg.edgenr); - seg.p2 = osedges.Get(seg.edgenr); - mesh.AddSegment (newseg); - } - } - } - - } - - - - void EdgeCalculation :: - FollowEdge (int pi1, int & ep, int & pos, - const ARRAY<SpecialPoint> & hsp, - double h, const Mesh & mesh, - ARRAY<Point<3> > & edgepoints, - ARRAY<double> & curvelength) - { - int i, j, s1, s2; - double len, steplen, cursteplen, loch; - Point<3> p, np, pnp; - Vec<3> a1, a2, t; - - - double size = geometry.MaxSize(); - double epspointdist2 = size * 1e-6; - epspointdist2 = sqr (epspointdist2); - int uselocalh = mparam.uselocalh; - - - s1 = hsp.Get(pi1).s1; - s2 = hsp.Get(pi1).s2; - - p = hsp.Get(pi1).p; - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - - t = Cross (a1, a2); - t.Normalize(); - - pos = (hsp.Get(pi1).v * t) > 0; - if (!pos) t *= -1; - - - edgepoints.Append (p); - curvelength.Append (0); - len = 0; - - loch = min2 (geometry.GetSurface(s1) -> LocH (p, 3, 1, h), - geometry.GetSurface(s2) -> LocH (p, 3, 1, h)); - - - - if (uselocalh) - { - double lh = mesh.GetH(p); - if (lh < loch) - loch = lh; - } - - steplen = 0.1 * loch; - - do - { - if (multithread.terminate) - return; - - if (fabs (p(0)) + fabs (p(1)) + fabs (p(2)) > 10000) - { - ep = 0; - PrintWarning ("Give up line"); - break; - } - - if (steplen > 0.1 * loch) steplen = 0.1 * loch; - - steplen *= 2; - do - { - steplen *= 0.5; - np = p + steplen * t; - pnp = np; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), pnp); - } - while (Dist (np, pnp) > 0.1 * steplen); - - cursteplen = steplen; - if (Dist (np, pnp) < 0.01 * steplen) steplen *= 2; - - - np = pnp; - -#ifdef MYGRAPH - if (silentflag <= 2) - { - MyLine3D (p, np, rot); - MyDraw (); - } -#endif - - ep = 0; - - double hvtmin = 1.5 * cursteplen; - - Box<3> boxp (p - (2 * cursteplen) * Vec<3> (1, 1, 1), - p + (2 * cursteplen) * Vec<3> (1, 1, 1)); - - for (i = 1; i <= hsp.Size(); i++) - // if ( i != pi1 && hsp.Get(i).HasSurfaces (s1, s2) ) - { - if (!boxp.IsIn (hsp.Get(i).p)) - continue; - - Vec<3> hv = hsp.Get(i).p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - /* - if (!hsp.Get(i).HasSurfaces (s1, s2)) - continue; // test for dalibor-problem - */ - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - hsp.Get(i).unconditional == 1 && - (hsp.Get(i).v + t).Length() < 0.4 ) - { - Point<3> hep = hsp.Get(i).p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, hsp.Get(i).p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (hsp.Get(i).v + ept).Length() < 1e-4 ) - { - np = hsp.Get(i).p; - ep = i; - hvtmin = hvt; - // break; - } - } - } - } - - loch = min2 (geometry.GetSurface(s1) -> LocH (np, 3, 1, h), - geometry.GetSurface(s2) -> LocH (np, 3, 1, h)); - - if (uselocalh) - { - double lh = mesh.GetH(np); - if (lh < loch) - loch = lh; - } - - - len += Dist (p, np) / loch; - edgepoints.Append (np); - curvelength.Append (len); - - p = np; - - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - } - while (! ep); - } - - - - - - - - void EdgeCalculation :: - AnalyzeEdge (int s1, int s2, int pos, int layer, - const ARRAY<Point<3> > & edgepoints, - ARRAY<Segment> & refedges, - ARRAY<int> & refedgesinv) - { - int i, j, k, l; - int hi; - Point<3> hp; - Vec<3> t, a1, a2, m, n; - Segment seg; - Solid * locsol; - ARRAY<int> locsurfind; - - /* - int pi1 = 0, pi2 = 0; - extern Mesh * mesh; - for (i = 1; i <= mesh->GetNP(); i++) - { - if (Dist2 (edgepoints.Get(1), mesh->Point(i)) < 1e-12) - pi1 = i; - if (Dist2 (edgepoints.Last(), mesh->Point(i)) < 1e-12) - pi2 = i; - } - (*testout) << "Analyze edge: " << pi1 << " - " << pi2 << ", pts = " << edgepoints.Size() << endl; - (*testout) << "p1 = " << edgepoints.Get(1) << " pl = " << edgepoints.Last() << endl; - */ - int debug = 0; - /* - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Get(1)) < 1e-6 || - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Last()) < 1e-6; - */ - - if (debug) - { - // (*testout) << "tubious edge !!!" << endl; - (*testout) << "s1, s2 = " << s1 << " - " << s2 << endl; - } - - refedges.SetSize(0); - refedgesinv.SetSize(0); - hp = Center (edgepoints.Get(1), edgepoints.Get(2)); - ProjectToEdge (geometry.GetSurface(s1), geometry.GetSurface(s2), hp); - - geometry.GetSurface(s1) -> CalcGradient (hp, a1); - geometry.GetSurface(s2) -> CalcGradient (hp, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - - (*testout) << "t = " << t << endl; - - for (i = 0; i < geometry.GetNTopLevelObjects(); i++) - { - (*testout) << "layer = " << layer - << ", tlo-layer = " << geometry.GetTopLevelObject(i)->GetLayer() << endl; - if (geometry.GetTopLevelObject(i)->GetLayer() != layer) - continue; - - const Solid * sol = geometry.GetTopLevelObject(i)->GetSolid(); - const Surface * surf = geometry.GetTopLevelObject(i)->GetSurface(); - - sol -> TangentialSolid (hp, locsol); - if (!locsol) continue; - - BoxSphere<3> boxp (hp, hp); - boxp.Increase (1e-5); - boxp.CalcDiamCenter(); - - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)locsol) -> IterateSolid (rpi); - - locsol -> CalcSurfaceInverse (); - - - if (!surf) - { - locsol -> GetSurfaceIndices (locsurfind); - } - else - { - /* - if (fabs (surf->CalcFunctionValue (hp)) < 1e-6) - continue; - */ - locsurfind.SetSize(1); - locsurfind[0] = -1; - for (j = 0; j < geometry.GetNSurf(); j++) - if (geometry.GetSurface(j) == surf) - { - locsurfind[0] = j; - // geometry.GetSurfaceClassRepresentant(j); - break; - } - } - - ((Solid*)locsol) -> IterateSolid (urpi); - - - if (debug) - (*testout) << "edge of tlo " << i << ", has " << locsurfind.Size() << " faces." << endl; - - - for (j = locsurfind.Size()-1; j >= 0; j--) - if (fabs (geometry.GetSurface(locsurfind[j]) - ->CalcFunctionValue (hp) ) > 1e-6) - locsurfind.DeleteElement(j+1); - - if (debug) - (*testout) << locsurfind.Size() << " faces on hp" << endl; - - for (j = 0; j < locsurfind.Size(); j++) - { - int lsi = locsurfind[j]; - int rlsi = geometry.GetSurfaceClassRepresentant(lsi); - - Vec<3> rn; - - // n is outer normal to solid - geometry.GetSurface(lsi) -> GetNormalVector (hp, n); - if (geometry.GetSurface (lsi)->Inverse()) - n *= -1; - - if (fabs (t * n) > 1e-4) continue; - if (debug) - { - (*testout) << "face " << locsurfind.Get(j) << ", rep = " << rlsi - << " has (t*n) = " << (t*n) << endl; - (*testout) << "n = " << n << endl; - } - - // rn is normal to class representant - geometry.GetSurface(rlsi) -> GetNormalVector (hp, rn); - - int sameasref = ((n * rn) > 0); - - m = Cross (t, rn); - m.Normalize(); - - - for (k = 1; k <= 2; k ++) - { - bool edgeinv = (k == 2); - - if (debug) - { - (*testout) << "onface(" << hp << ", " << m << ")= " - << locsol->OnFace (hp, m); - (*testout) << " vec2in = " - << locsol -> VectorIn2 (hp, m, n) << " and " - << locsol -> VectorIn2 (hp, m, -1 * n) << endl; - } - - // if (locsol -> OnFace (hp, m)) - if (locsol -> VectorIn2 (hp, m, n) == 0 && - locsol -> VectorIn2 (hp, m, -1 * n) == 1) - { - hi = 0; - for (l = 1; l <= refedges.Size(); l++) - { - if (refedges.Get(l).si == rlsi && - refedgesinv.Get(l) == edgeinv) - hi = l; - } - - if (!hi) - { - seg.si = rlsi; - seg.domin = -1; - seg.domout = -1; - seg.tlosurf = -1; - seg.surfnr1 = s1; - seg.surfnr2 = s2; - hi = refedges.Append (seg); - refedgesinv.Append (edgeinv); - } - - if (!surf) - { - if (sameasref) - refedges.Elem(hi).domin = i; - else - refedges.Elem(hi).domout = i; - } - else - refedges.Elem(hi).tlosurf = i; - - if (debug) - (*testout) << "add ref seg:" - << "si = " << refedges.Get(hi).si - << ", domin = " << refedges.Get(hi).domin - << ", domout = " << refedges.Get(hi).domout - << ", surfnr1/2 = " << refedges.Get(hi).surfnr1 - << ", " << refedges.Get(hi).surfnr2 - << ", inv = " << refedgesinv.Get(hi) - << ", refedgenr = " << hi - << endl; - } - m *= -1; - } - } - delete locsol; - } - } - - - - void EdgeCalculation :: - StoreEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - - double len, corr, lam; - PointIndex thispi, lastpi; - Point<3> p, np; - Segment seg; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints.Get(1), edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - - // generate initial point - p = edgepoints.Get(1); - lastpi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist (mesh[pi], p) < 1e-6) - { - lastpi = pi; - break; - } - - if (lastpi == -1) - lastpi = mesh.AddPoint (p, layer); - - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength.Get(j) < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength.Get(j-1)) / - (curvelength.Get(j) - curvelength.Get(j-1)); - - np(0) = (1-lam) * edgepoints.Get(j-1)(0) + lam * edgepoints.Get(j)(0); - np(1) = (1-lam) * edgepoints.Get(j-1)(1) + lam * edgepoints.Get(j)(1); - np(2) = (1-lam) * edgepoints.Get(j-1)(2) + lam * edgepoints.Get(j)(2); - - - thispi = -1; - if (i == ne) - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist(mesh[pi], np) < 1e-6) - thispi = pi; - - if (thispi == -1) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np, layer); - } - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = lastpi; - seg.p2 = thispi; - } - else - { - seg.p1 = thispi; - seg.p2 = lastpi; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - - double maxh = min2 (geometry.GetSurface(seg.surfnr1)->GetMaxH(), - geometry.GetSurface(seg.surfnr2)->GetMaxH()); - - if (seg.domin != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domin) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domin)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.domout != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domout) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domout)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.tlosurf != -1) - { - double hi = geometry.GetTopLevelObject(seg.tlosurf) -> GetMaxH(); - maxh = min2 (maxh, hi); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - } - - p = np; - lastpi = thispi; - } - -#ifdef DEVELOP - (*testout) << " eplast = " << lastpi << " = " << p << endl; -#endif - } - - - - - - - void EdgeCalculation :: - StoreShortEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - Segment seg; - - /* - double len, corr, lam; - int thispi, lastpi; - Point<3> p, np; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints[1], edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - */ - - // generate initial point - Point<3> p = edgepoints[0]; - PointIndex pi1 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi1 = pi; - break; - } - - if (pi1 == -1) pi1 = mesh.AddPoint (p, layer); - - p = edgepoints.Last(); - PointIndex pi2 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi2 = pi; - break; - } - if (pi2==-1) pi2 = mesh.AddPoint (p, layer); - - /* - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength[j] < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength[j-1]) / - (curvelength[j] - curvelength[j-1]); - - np(0) = (1-lam) * edgepoints[j-1](0) + lam * edgepoints[j](0); - np(1) = (1-lam) * edgepoints[j-1](1) + lam * edgepoints[j](1); - np(2) = (1-lam) * edgepoints[j-1](2) + lam * edgepoints[j](2); - - - thispi = 0; - if (i == ne) - for (j = 1; j <= mesh.GetNP(); j++) - if (Dist(mesh.Point(j), np) < 1e-6) - thispi = j; - - if (!thispi) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np); - } - */ - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = pi1; - seg.p2 = pi2; - } - else - { - seg.p1 = pi2; - seg.p2 = pi1; - } - - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - } - } - - - - - - - - void EdgeCalculation :: - CopyEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & 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) - { - int i, j, k; - PointIndex pi; - - // copy start and end points - for (i = 1; i <= 2; i++) - { - Point<3> fromp = - (i == 1) ? fromstart : fromend; - Point<3> top = - (i == 1) ? tostart : toend; - - PointIndex frompi = -1; - PointIndex topi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - { - if (Dist2 (mesh[pi], fromp) <= 1e-16) - frompi = pi; - if (Dist2 (mesh[pi], top) <= 1e-16) - topi = pi; - } - - if (topi == -1) - topi = mesh.AddPoint (top, layer); - - const Identification & csi = - (*geometry.identifications.Get(copyedgeidentification)); - - if (csi.Identifyable (mesh[frompi], mesh[topi])) - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - else if (csi.Identifyable (mesh[topi], mesh[frompi])) - mesh.GetIdentifications().Add(topi, frompi, copyedgeidentification); - else - { - cerr << "edgeflw.cpp: should identify, but cannot"; - exit(1); - } - /* - (*testout) << "Add Identification from CopyEdge, p1 = " - << mesh[PointIndex(frompi)] << ", p2 = " - << mesh[PointIndex(topi)] << endl; - - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - */ - } - - int oldns = mesh.GetNSeg(); - for (i = 1; i <= oldns; i++) - { - // real copy, since array might be reallocated !! - const Segment oldseg = mesh.LineSegment(i); - if (oldseg.edgenr != copyfromedge) - continue; - if (oldseg.seginfo == 0) - continue; - - int pi1 = oldseg.p1; - int pi2 = oldseg.p2; - - int npi1 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi1); - int npi2 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi2); - - Segment seg; - - for (k = 1; k <= refedges.Size(); k++) - { - int inv = refedgesinv.Get(k); - - // other edge is inverse - if (oldseg.seginfo == 1) - inv = !inv; - - // (*testout) << "inv, now = " << inv << endl; - - if (inv) - { - seg.p1 = npi1; - seg.p2 = npi2; - } - else - { - seg.p1 = npi2; - seg.p2 = npi1; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "copy seg " << seg.p1 << "-" << seg.p2 << endl; -#ifdef DEVELOP - - (*testout) << "copy seg, face = " << seg.si << ": " - << " inv = " << inv << ", refinv = " << refedgesinv.Get(k) - << mesh.Point(seg.p1) << ", " << mesh.Point(seg.p2) << endl; -#endif - - } - - } - } - - - - - - - - void EdgeCalculation :: - FindClosedSurfaces (double h, Mesh & mesh) - { - // if there is no special point at a sphere, one has to add a segment pair - - int i, j; - int nsol; - int nsurf = geometry.GetNSurf(); - int layer; - - BitArray pointatsurface (nsurf); - Point<3> p1, p2; - Vec<3> nv, tv; - Solid * tansol; - ARRAY<int> tansurfind; - // const Solid * sol; - - nsol = geometry.GetNTopLevelObjects(); - - - pointatsurface.Clear(); - - /* - for (i = 1; i <= specpoints.Size(); i++) - { - int classrep; - - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s1); - pointatsurface.Set (classrep); - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s2); - pointatsurface.Set (classrep); - // pointatsurface.Set (specpoints[i].s1); - // pointatsurface.Set (specpoints[i].s2); - } - */ - for (i = 1; i <= mesh.GetNSeg(); i++) - { - const Segment & seg = mesh.LineSegment(i); - int classrep; - -#ifdef DEVELOP - (*testout) << seg.surfnr1 << ", " << seg.surfnr2 << ", si = " << seg.si << endl; -#endif - classrep = geometry.GetSurfaceClassRepresentant (seg.si); - - pointatsurface.Set (classrep); - } - - - for (i = 0; i < nsurf; i++) - { - int classrep = geometry.GetSurfaceClassRepresentant (i); - - if (!pointatsurface.Test(classrep)) - { - const Surface * s = geometry.GetSurface(i); - p1 = s -> GetSurfacePoint(); - s -> GetNormalVector (p1, nv); - - double hloc = - min2 (s->LocH (p1, 3, 1, h), mesh.GetH(p1)); - - tv = nv.GetNormal (); - tv *= (hloc / tv.Length()); - p2 = p1 + tv; - s->Project (p2); - - - Segment seg1; - seg1.si = i; - seg1.domin = -1; - seg1.domout = -1; - - Segment seg2; - seg2.si = i; - seg2.domin = -1; - seg2.domout = -1; - - seg1.surfnr1 = i; - seg2.surfnr1 = i; - seg1.surfnr2 = i; - seg2.surfnr2 = i; - - for (j = 0; j < nsol; j++) - { - if (geometry.GetTopLevelObject(j)->GetSurface()) - continue; - - const Solid * sol = geometry.GetTopLevelObject(j)->GetSolid(); - sol -> TangentialSolid (p1, tansol); - layer = geometry.GetTopLevelObject(j)->GetLayer(); - - if (tansol) - { - tansol -> GetSurfaceIndices (tansurfind); - - if (tansurfind.Size() == 1 && tansurfind.Get(1) == i) - { - if (!tansol->VectorIn(p1, nv)) - { - seg1.domin = j; - seg2.domin = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - else - { - seg1.domout = j; - seg2.domout = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - // seg.s2 = i; - // seg.invs1 = surfaces[i] -> Inverse(); - // seg.invs2 = ! (surfaces[i] -> Inverse()); - } - delete tansol; - } - } - - - if (seg1.domin != -1 || seg1.domout != -1) - { - mesh.AddPoint (p1, layer); - mesh.AddPoint (p2, layer); - seg1.p1 = mesh.GetNP()-1; - seg1.p2 = mesh.GetNP(); - seg2.p2 = mesh.GetNP()-1; - seg2.p1 = mesh.GetNP(); - seg1.geominfo[0].trignum = 1; - seg1.geominfo[1].trignum = 1; - seg2.geominfo[0].trignum = 1; - seg2.geominfo[1].trignum = 1; - mesh.AddSegment (seg1); - mesh.AddSegment (seg2); - - PrintMessage (5, "Add line segment to smooth surface"); - -#ifdef DEVELOP - (*testout) << "Add segment at smooth surface " << i; - if (i != classrep) (*testout) << ", classrep = " << classrep; - (*testout) << ": " - << mesh.Point (mesh.GetNP()-1) << " - " - << mesh.Point (mesh.GetNP()) << endl; -#endif - } - } - } - } - -} diff --git a/contrib/Netgen/libsrc/csg/edgeflw_new.cpp b/contrib/Netgen/libsrc/csg/edgeflw_new.cpp deleted file mode 100644 index 8aa9f0263b55adde958b0569f08a3180ff57b542..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/edgeflw_new.cpp +++ /dev/null @@ -1,1553 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - -#undef DEVELOP - -namespace netgen -{ - - EdgeCalculation :: - EdgeCalculation (const CSGeometry & ageometry, - ARRAY<SpecialPoint> & aspecpoints) - : geometry(ageometry), specpoints(aspecpoints) - { - Box<3> bbox; - if (specpoints.Size() >= 1) - bbox.Set (specpoints[0].p); - for (int i = 1; i < specpoints.Size(); i++) - bbox.Add (specpoints[i].p); - - searchtree = new Point3dTree (bbox.PMin(), bbox.PMax()); - meshpoint_tree = new Point3dTree (bbox.PMin(), bbox.PMax()); - - for (int i = 0; i < specpoints.Size(); i++) - searchtree->Insert (specpoints[i].p, i); - } - - EdgeCalculation :: ~EdgeCalculation() - { - delete searchtree; - delete meshpoint_tree; - } - - - void EdgeCalculation :: Calc(double h, Mesh & mesh) - { - (*testout) << "Find edges" << endl; - PrintMessage (1, "Find edges"); - PushStatus ("Find edges"); - - CalcEdges1 (h, mesh); - SplitEqualOneSegEdges (mesh); - FindClosedSurfaces (h, mesh); - PrintMessage (3, cntedge, " edges found"); - - for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++) - (*testout) << "seg " << si << " = " << mesh[si] << endl; - PopStatus (); - } - - - - - - void EdgeCalculation :: CalcEdges1 (double h, Mesh & mesh) - { - ARRAY<int> hsp(specpoints.Size()); - ARRAY<int> glob2hsp(specpoints.Size()); - ARRAY<int> startpoints, endpoints; - - int i, j, k, l, hi, pos, ep, ne; - int layer; - - Vec<3> a1, a2, t, n, m; - Point<3> p, np, pnp, hp; - - Segment seg; - int pi1, s1, s2; - int lastpi, thispi; - - ARRAY<Point<3> > edgepoints; - ARRAY<double> curvelength; - int copyedge, copyfromedge, copyedgeidentification; - - ARRAY<int> locsurfind, locind; - - double len, corr, lam; - double steplen, cursteplen, loch, hd; - - int checkedcopy = 0; - - double size = geometry.MaxSize(); // globflags.GetNumFlag ("maxsize", 500); - double epspointdist2 = size * 1e-6; // globflags.GetNumFlag ("epspointdist", size * 1e-6); - epspointdist2 = sqr (epspointdist2); - - - - Solid * locsol; - - - // copy special points to work with - for (i = 0; i < specpoints.Size(); i++) - { - hsp[i] = i; - glob2hsp[i] = i; - } - - - cntedge = 0; - - while (hsp.Size()) - { - SetThreadPercent(100 - 100 * double (hsp.Size()) / specpoints.Size()); - - edgepoints.SetSize (0); - curvelength.SetSize (0); - - - pi1 = 0; - copyedge = 0; - // identifyable point available ? - - // (*testout) << endl; - - for (i = 1; i <= geometry.identifications.Size() && !pi1; i++) - { - for (j = checkedcopy+1; j <= startpoints.Size() && !pi1; j++) - { - - if (geometry.identifications.Get(i)->IdentifyableCandidate (specpoints[startpoints.Get(j)])) - - { - int pi1cand = 0; - double mindist = 1e10; - - for (k = 1; k <= hsp.Size() && !pi1; k++) - { -#ifdef DEVELOP - (*testout) << "check kand = " << hsp.Get(k).p - << ", v = " << hsp.Get(k).v - << endl; -#endif - if (geometry.identifications.Get(i) - ->Identifyable(specpoints[startpoints.Get(j)], specpoints[hsp.Get(k)]) || - geometry.identifications.Get(i) - ->Identifyable(specpoints[hsp.Get(k)], specpoints[startpoints.Get(j)])) - { - -#ifdef DEVELOP - (*testout) << "identifiable, dist = " - << Dist (startpoints.Get(j).p, hsp.Get(k).p) << endl; -#endif - - if (Dist (specpoints[startpoints.Get(j)].p, specpoints[hsp.Get(k)].p) < mindist) - { - mindist = Dist (specpoints[startpoints.Get(j)].p, specpoints[hsp.Get(k)].p); - pi1cand = k; - } - /* - pi1 = k; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; - - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << hsp.Get(k).p << " - " << hsp.Get(k).v << endl; - */ - } - } - - if (pi1cand) - { - pi1 = pi1cand; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; -#ifdef DEVELOP - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << specpoints[hsp.Get(pi1)].p << " - " << hsp.Get(pi1).v << endl; -#endif - } - } - } - } - - - // cannot copy from other ege ? - if (!pi1) - checkedcopy = startpoints.Size(); - - // unconditional special point available ? - if (!pi1) - for (i = 1; i <= hsp.Size(); i++) - if (specpoints[hsp.Get(i)].unconditional == 1) - { - pi1 = i; - break; - } - - - if (!pi1) - { - // only unconditional points available, choose first - pi1 = 1; - } - - layer = specpoints[hsp.Get(pi1)].GetLayer(); - - - if (!specpoints[hsp.Get(pi1)].unconditional) - { - specpoints[hsp.Elem(pi1)].unconditional = 1; - for (i = 1; i <= hsp.Size(); i++) - if (i != pi1 && - Dist (specpoints[hsp.Get(pi1)].p, specpoints[hsp.Get(i)].p) < 1e-8 && - (specpoints[hsp.Get(pi1)].v + specpoints[hsp.Get(i)].v).Length() < 1e-4) - { - // opposite direction - specpoints[hsp.Elem(i)].unconditional = 1; - } - } - - cntedge++; - startpoints.Append (hsp.Get(pi1)); - -#ifdef DEVELOP - (*testout) << "edge nr " << cntedge << endl; - (*testout) << "start followedge: p1 = " << hsp.Get(pi1).p << ", v = " << hsp.Get(pi1).v << endl; -#endif - - FollowEdge (pi1, ep, pos, hsp, h, mesh, - edgepoints, curvelength); - - - if (multithread.terminate) - return; - - if (!ep) - { - // ignore starting point - hsp.DeleteElement (pi1); - cout << "yes, this happens" << endl; - continue; - } - - - - endpoints.Append (hsp.Get(ep)); - - - double elen = 0; - for (i = 1; i <= edgepoints.Size()-1; i++) - elen += Dist (edgepoints.Get(i), edgepoints.Get(i+1)); - - - int shortedge = 0; - for (i = 1; i <= geometry.identifications.Size(); i++) - if (geometry.identifications.Get(i)->ShortEdge(specpoints[hsp.Get(pi1)], specpoints[hsp.Get(ep)])) - shortedge = 1; - // (*testout) << "shortedge = " << shortedge << endl; - - - if (!shortedge) - { - mesh.RestrictLocalHLine (Point3d (specpoints[hsp.Get(pi1)].p), - Point3d (specpoints[hsp.Get(ep)].p), - elen / mparam.segmentsperedge); - } - - s1 = specpoints[hsp.Get(pi1)].s1; - s2 = specpoints[hsp.Get(pi1)].s2; - - - // delete initial, terminal and conditional points - -#ifdef DEVELOP - (*testout) << "terminal point: p = " << hsp.Get(ep).p << ", v = " << hsp.Get(ep).v << endl; -#endif - - searchtree -> DeleteElement (hsp.Get(ep)); - searchtree -> DeleteElement (hsp.Get(pi1)); - - if (ep > pi1) - { - glob2hsp[hsp[ep-1]] = -1; - glob2hsp[hsp.Last()] = ep-1; - hsp.DeleteElement (ep); - - glob2hsp[hsp[pi1-1]] = -1; - glob2hsp[hsp.Last()] = pi1-1; - hsp.DeleteElement (pi1); - } - else - { - glob2hsp[hsp[pi1-1]] = -1; - glob2hsp[hsp.Last()] = pi1-1; - hsp.DeleteElement (pi1); - - glob2hsp[hsp[ep-1]] = -1; - glob2hsp[hsp.Last()] = ep-1; - hsp.DeleteElement (ep); - } - - - for (j = 1; j <= edgepoints.Size()-1; j++) - { - p = edgepoints.Get(j); - np = Center (p, edgepoints.Get(j+1)); - hd = Dist (p, np); - - - Box<3> boxp (np - (1.2 * hd) * Vec<3> (1, 1, 1), - np + (1.2 * hd) * Vec<3> (1, 1, 1)); - searchtree -> GetIntersecting (boxp.PMin(), boxp.PMax(), locind); - - for (i = 0; i < locind.Size(); i++) - { - if ( specpoints[locind[i]].HasSurfaces (s1, s2) && - specpoints[locind[i]].unconditional == 0) - { - searchtree -> DeleteElement (locind[i]); - - int li = glob2hsp[locind[i]]; - glob2hsp[locind[i]] = -1; - glob2hsp[hsp.Last()] = li; - hsp.Delete (li); - } - } - - - /* - for (i = 1; i <= hsp.Size(); i++) - if ( specpoints[hsp.Get(i)].HasSurfaces (s1, s2) && - specpoints[hsp.Get(i)].unconditional == 0 && - Dist2 (np, specpoints[hsp.Get(i)].p) < 1.2 * hd) - { - searchtree -> DeleteElement (hsp.Get(i)+1); - hsp.DeleteElement (i); - i--; - } - */ - } - - - ARRAY<Segment> refedges; - ARRAY<int> refedgesinv; - - - AnalyzeEdge (s1, s2, pos, layer, - edgepoints, - refedges, refedgesinv); - - for (i = 1; i <= refedges.Size(); i++) - refedges.Elem(i).edgenr = cntedge; - - -#ifdef DEVELOP - (*testout) << "edge " << cntedge << endl - << "startp: " << startpoints.Last().p - << ", v = " << startpoints.Last().v << endl - << "copy = " << copyedge << endl - << refedges.Size() << " refedges: "; - for (i = 1; i <= refedges.Size(); i++) - (*testout) << " " << refedges.Get(i).si; - (*testout) << endl; - (*testout) << "inv[1] = " << refedgesinv.Get(1) << endl; -#endif - - if (!copyedge) - { - int oldnseg = mesh.GetNSeg(); - - if (!shortedge) - StoreEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - else - StoreShortEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - - - /* - for (i = oldnseg+1; i <= mesh.GetNSeg(); i++) - for (j = 1; j <= oldnseg; j++) - { - const Point<3> & l1p1 = mesh.Point (mesh.LineSegment(i).p1); - const Point<3> & l1p2 = mesh.Point (mesh.LineSegment(i).p2); - const Point<3> & l2p1 = mesh.Point (mesh.LineSegment(j).p1); - const Point<3> & l2p2 = mesh.Point (mesh.LineSegment(j).p2); - Vec<3> vl1(l1p1, l1p2); - for (double lamk = 0; lamk <= 1; lamk += 0.1) - { - Point<3> l2p = l1p1 + lamk * vl1; - double dist = sqrt (MinDistLP2 (l2p1, l2p2, l2p)); - if (dist > 1e-12) - mesh.RestrictLocalH (l2p, 3*dist); - } - } - */ - } - else - { - CopyEdge (refedges, refedgesinv, - copyfromedge, - specpoints[startpoints.Get(copyfromedge)].p, - specpoints[endpoints.Get(copyfromedge)].p, - edgepoints.Get(1), edgepoints.Last(), - copyedgeidentification, - layer, - mesh); - } - - } - } - - - - /* - If two or more edges share the same initial and end-points, - then they need at least two segments - */ - void EdgeCalculation :: - SplitEqualOneSegEdges (Mesh & mesh) - { - int i, j; - SegmentIndex si; - PointIndex pi; - - ARRAY<int> osedges(cntedge); - INDEX_2_HASHTABLE<int> osedgesht (cntedge+1); - - osedges = 2; - - // count segments on edges - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - osedges.Elem(seg.edgenr)--; - } - - (*testout) << "osedges = " << osedges << endl; - - // flag one segment edges - for (i = 0; i < cntedge; i++) - osedges[i] = (osedges[i] > 0) ? 1 : 0; - - (*testout) << "osedges, now = " << osedges << endl; - - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr)) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2)) - osedgesht.Set (i2, 2); - else - osedgesht.Set (i2, 1); - } - } - } - - - // one edge 1 segment, other 2 segments - // yes, it happens ! - - for (i = 1; i <= osedgesht.GetNBags(); i++) - for (j = 1; j <= osedgesht.GetBagSize(i); j++) - { - INDEX_2 i2; - int val; - osedgesht.GetData (i, j, i2, val); - - const Point<3> & p1 = mesh[PointIndex(i2.I1())]; - const Point<3> & p2 = mesh[PointIndex(i2.I2())]; - Vec<3> v = p2 - p1; - double vlen = v.Length(); - v /= vlen; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (pi != i2.I1() && pi != i2.I2()) - { - const Point<3> & p = mesh[pi]; - Vec<3> v2 = p - p1; - double lam = (v2 * v); - if (lam > 0 && lam < vlen) - { - Point<3> hp = p1 + lam * v; - if (Dist (p, hp) < 1e-4 * vlen) - { - PrintSysError ("Point on edge !!!"); - cout << "seg: " << i2 << ", p = " << pi << endl; - osedgesht.Set (i2, 2); - } - } - } - } - - - // insert new points - osedges = -1; - - int nseg = mesh.GetNSeg(); - for (si = 0; si < nseg; si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2) && - osedgesht.Get (i2) == 2 && - osedges.Elem(seg.edgenr) == -1) - { - Point<3> newp = Center (mesh[PointIndex(seg.p1)], - mesh[PointIndex(seg.p2)]); - - ProjectToEdge (geometry.GetSurface(seg.surfnr1), - geometry.GetSurface(seg.surfnr2), - newp); - - osedges.Elem(seg.edgenr) = - mesh.AddPoint (newp, mesh[PointIndex(seg.p1)].GetLayer()); - meshpoint_tree -> Insert (newp, osedges.Elem(seg.edgenr)); - } - } - } - - - for (i = 1; i <= nseg; i++) - { - Segment & seg = mesh.LineSegment (i); - if (seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr) != -1) - { - Segment newseg = seg; - newseg.p1 = osedges.Get(seg.edgenr); - seg.p2 = osedges.Get(seg.edgenr); - mesh.AddSegment (newseg); - } - } - } - - } - - - - void EdgeCalculation :: - FollowEdge (int pi1, int & ep, int & pos, - const ARRAY<int> & hsp, - double h, const Mesh & mesh, - ARRAY<Point<3> > & edgepoints, - ARRAY<double> & curvelength) - { - int i, j, s1, s2; - double len, steplen, cursteplen, loch; - Point<3> p, np, pnp; - Vec<3> a1, a2, t; - - ARRAY<int> locind; - - double size = geometry.MaxSize(); - double epspointdist2 = size * 1e-6; - epspointdist2 = sqr (epspointdist2); - int uselocalh = mparam.uselocalh; - - - s1 = specpoints[hsp.Get(pi1)].s1; - s2 = specpoints[hsp.Get(pi1)].s2; - - p = specpoints[hsp.Get(pi1)].p; - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - - t = Cross (a1, a2); - t.Normalize(); - - pos = (specpoints[hsp.Get(pi1)].v * t) > 0; - if (!pos) t *= -1; - - - edgepoints.Append (p); - curvelength.Append (0); - len = 0; - - loch = min2 (geometry.GetSurface(s1) -> LocH (p, 3, 1, h), - geometry.GetSurface(s2) -> LocH (p, 3, 1, h)); - - - - if (uselocalh) - { - double lh = mesh.GetH(p); - if (lh < loch) - loch = lh; - } - - steplen = 0.1 * loch; - - do - { - if (multithread.terminate) - return; - - if (fabs (p(0)) + fabs (p(1)) + fabs (p(2)) > 10000) - { - ep = 0; - PrintWarning ("Give up line"); - break; - } - - if (steplen > 0.1 * loch) steplen = 0.1 * loch; - - steplen *= 2; - do - { - steplen *= 0.5; - np = p + steplen * t; - pnp = np; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), pnp); - } - while (Dist (np, pnp) > 0.1 * steplen); - - cursteplen = steplen; - if (Dist (np, pnp) < 0.01 * steplen) steplen *= 2; - - - np = pnp; - -#ifdef MYGRAPH - if (silentflag <= 2) - { - MyLine3D (p, np, rot); - MyDraw (); - } -#endif - - ep = 0; - - double hvtmin = 1.5 * cursteplen; - - Box<3> boxp (p - (2 * cursteplen) * Vec<3> (1, 1, 1), - p + (2 * cursteplen) * Vec<3> (1, 1, 1)); - - searchtree -> GetIntersecting (boxp.PMin(), boxp.PMax(), locind); - - for (i = 0; i < locind.Size(); i++) - { - Vec<3> hv = specpoints[locind[i]].p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - specpoints[locind[i]].unconditional == 1 && - (specpoints[locind[i]].v + t).Length() < 0.4 ) - { - Point<3> hep = specpoints[locind[i]].p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, specpoints[locind[i]].p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (specpoints[locind[i]].v + ept).Length() < 1e-4 ) - { - np = specpoints[locind[i]].p; - - for (int jj = 0; jj < hsp.Size(); jj++) - if (hsp[jj] == locind[i]) - ep = jj+1; - - if (!ep) - cerr << "endpoint not found" << endl; - // ep = i; - hvtmin = hvt; - // break; - } - } - } - } - - - - - /* - for (i = 1; i <= hsp.Size(); i++) - { - if (!boxp.IsIn (specpoints[hsp.Get(i)].p)) - continue; - - Vec<3> hv = specpoints[hsp.Get(i)].p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - specpoints[hsp.Get(i)].unconditional == 1 && - (specpoints[hsp.Get(i)].v + t).Length() < 0.4 ) - { - Point<3> hep = specpoints[hsp.Get(i)].p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, specpoints[hsp.Get(i)].p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (specpoints[hsp.Get(i)].v + ept).Length() < 1e-4 ) - { - np = specpoints[hsp.Get(i)].p; - ep = i; - hvtmin = hvt; - // break; - } - } - } - } - */ - - loch = min2 (geometry.GetSurface(s1) -> LocH (np, 3, 1, h), - geometry.GetSurface(s2) -> LocH (np, 3, 1, h)); - - if (uselocalh) - { - double lh = mesh.GetH(np); - if (lh < loch) - loch = lh; - } - - - len += Dist (p, np) / loch; - edgepoints.Append (np); - curvelength.Append (len); - - p = np; - - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - } - while (! ep); - } - - - - - - - - void EdgeCalculation :: - AnalyzeEdge (int s1, int s2, int pos, int layer, - const ARRAY<Point<3> > & edgepoints, - ARRAY<Segment> & refedges, - ARRAY<int> & refedgesinv) - { - int i, j, k, l; - int hi; - Point<3> hp; - Vec<3> t, a1, a2, m, n; - Segment seg; - Solid * locsol; - ARRAY<int> locsurfind; - - /* - int pi1 = 0, pi2 = 0; - extern Mesh * mesh; - for (i = 1; i <= mesh->GetNP(); i++) - { - if (Dist2 (edgepoints.Get(1), mesh->Point(i)) < 1e-12) - pi1 = i; - if (Dist2 (edgepoints.Last(), mesh->Point(i)) < 1e-12) - pi2 = i; - } - (*testout) << "Analyze edge: " << pi1 << " - " << pi2 << ", pts = " << edgepoints.Size() << endl; - (*testout) << "p1 = " << edgepoints.Get(1) << " pl = " << edgepoints.Last() << endl; - */ - int debug = 0; - /* - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Get(1)) < 1e-6 || - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Last()) < 1e-6; - */ - - if (debug) - { - // (*testout) << "tubious edge !!!" << endl; - (*testout) << "s1, s2 = " << s1 << " - " << s2 << endl; - } - - refedges.SetSize(0); - refedgesinv.SetSize(0); - hp = Center (edgepoints.Get(1), edgepoints.Get(2)); - ProjectToEdge (geometry.GetSurface(s1), geometry.GetSurface(s2), hp); - - geometry.GetSurface(s1) -> CalcGradient (hp, a1); - geometry.GetSurface(s2) -> CalcGradient (hp, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - - (*testout) << "t = " << t << endl; - - for (i = 0; i < geometry.GetNTopLevelObjects(); i++) - { - (*testout) << "layer = " << layer - << ", tlo-layer = " << geometry.GetTopLevelObject(i)->GetLayer() << endl; - if (geometry.GetTopLevelObject(i)->GetLayer() != layer) - continue; - - const Solid * sol = geometry.GetTopLevelObject(i)->GetSolid(); - const Surface * surf = geometry.GetTopLevelObject(i)->GetSurface(); - - sol -> TangentialSolid (hp, locsol); - if (!locsol) continue; - - BoxSphere<3> boxp (hp, hp); - boxp.Increase (1e-5); - boxp.CalcDiamCenter(); - - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)locsol) -> IterateSolid (rpi); - - locsol -> CalcSurfaceInverse (); - - - if (!surf) - { - locsol -> GetSurfaceIndices (locsurfind); - } - else - { - /* - if (fabs (surf->CalcFunctionValue (hp)) < 1e-6) - continue; - */ - locsurfind.SetSize(1); - locsurfind[0] = -1; - for (j = 0; j < geometry.GetNSurf(); j++) - if (geometry.GetSurface(j) == surf) - { - locsurfind[0] = j; - // geometry.GetSurfaceClassRepresentant(j); - break; - } - } - - ((Solid*)locsol) -> IterateSolid (urpi); - - - if (debug) - (*testout) << "edge of tlo " << i << ", has " << locsurfind.Size() << " faces." << endl; - - - for (j = locsurfind.Size()-1; j >= 0; j--) - if (fabs (geometry.GetSurface(locsurfind[j]) - ->CalcFunctionValue (hp) ) > 1e-6) - locsurfind.DeleteElement(j+1); - - if (debug) - (*testout) << locsurfind.Size() << " faces on hp" << endl; - - for (j = 0; j < locsurfind.Size(); j++) - { - int lsi = locsurfind[j]; - int rlsi = geometry.GetSurfaceClassRepresentant(lsi); - - Vec<3> rn; - - // n is outer normal to solid - geometry.GetSurface(lsi) -> GetNormalVector (hp, n); - if (geometry.GetSurface (lsi)->Inverse()) - n *= -1; - - if (fabs (t * n) > 1e-4) continue; - if (debug) - { - (*testout) << "face " << locsurfind.Get(j) << ", rep = " << rlsi - << " has (t*n) = " << (t*n) << endl; - (*testout) << "n = " << n << endl; - } - - // rn is normal to class representant - geometry.GetSurface(rlsi) -> GetNormalVector (hp, rn); - - int sameasref = ((n * rn) > 0); - - m = Cross (t, rn); - m.Normalize(); - - - for (k = 1; k <= 2; k ++) - { - bool edgeinv = (k == 2); - - if (debug) - { - (*testout) << "onface(" << hp << ", " << m << ")= " - << locsol->OnFace (hp, m); - (*testout) << " vec2in = " - << locsol -> VectorIn2 (hp, m, n) << " and " - << locsol -> VectorIn2 (hp, m, -1 * n) << endl; - } - - // if (locsol -> OnFace (hp, m)) - if (locsol -> VectorIn2 (hp, m, n) == 0 && - locsol -> VectorIn2 (hp, m, -1 * n) == 1) - { - hi = 0; - for (l = 1; l <= refedges.Size(); l++) - { - if (refedges.Get(l).si == rlsi && - refedgesinv.Get(l) == edgeinv) - hi = l; - } - - if (!hi) - { - seg.si = rlsi; - seg.domin = -1; - seg.domout = -1; - seg.tlosurf = -1; - seg.surfnr1 = s1; - seg.surfnr2 = s2; - hi = refedges.Append (seg); - refedgesinv.Append (edgeinv); - } - - if (!surf) - { - if (sameasref) - refedges.Elem(hi).domin = i; - else - refedges.Elem(hi).domout = i; - } - else - refedges.Elem(hi).tlosurf = i; - - if (debug) - (*testout) << "add ref seg:" - << "si = " << refedges.Get(hi).si - << ", domin = " << refedges.Get(hi).domin - << ", domout = " << refedges.Get(hi).domout - << ", surfnr1/2 = " << refedges.Get(hi).surfnr1 - << ", " << refedges.Get(hi).surfnr2 - << ", inv = " << refedgesinv.Get(hi) - << ", refedgenr = " << hi - << endl; - } - m *= -1; - } - } - delete locsol; - } - } - - - - void EdgeCalculation :: - StoreEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - - double len, corr, lam; - PointIndex thispi, lastpi; - Point<3> p, np; - Segment seg; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints.Get(1), edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - - // generate initial point - p = edgepoints.Get(1); - lastpi = -1; - - /* - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist (mesh[pi], p) < 1e-6) - { - lastpi = pi; - break; - } - */ - ARRAY<int> locsearch; - meshpoint_tree -> GetIntersecting (p-Vec<3> (1e-6, 1e-6, 1e-6), - p+Vec<3> (1e-6, 1e-6, 1e-6), locsearch); - if (locsearch.Size()) - lastpi = locsearch[0]; - - - - if (lastpi == -1) - { - lastpi = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, lastpi); - } - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength.Get(j) < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength.Get(j-1)) / - (curvelength.Get(j) - curvelength.Get(j-1)); - - np(0) = (1-lam) * edgepoints.Get(j-1)(0) + lam * edgepoints.Get(j)(0); - np(1) = (1-lam) * edgepoints.Get(j-1)(1) + lam * edgepoints.Get(j)(1); - np(2) = (1-lam) * edgepoints.Get(j-1)(2) + lam * edgepoints.Get(j)(2); - - - thispi = -1; - if (i == ne) - { - /* - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist(mesh[pi], np) < 1e-6) - thispi = pi; - */ - - meshpoint_tree -> GetIntersecting (np-Vec<3> (1e-6, 1e-6, 1e-6), - np+Vec<3> (1e-6, 1e-6, 1e-6), locsearch); - if (locsearch.Size()) - thispi = locsearch[0]; - } - - if (thispi == -1) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np, layer); - meshpoint_tree -> Insert (np, thispi); - } - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = lastpi; - seg.p2 = thispi; - } - else - { - seg.p1 = thispi; - seg.p2 = lastpi; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - - double maxh = min2 (geometry.GetSurface(seg.surfnr1)->GetMaxH(), - geometry.GetSurface(seg.surfnr2)->GetMaxH()); - - if (seg.domin != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domin) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domin)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.domout != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domout) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domout)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.tlosurf != -1) - { - double hi = geometry.GetTopLevelObject(seg.tlosurf) -> GetMaxH(); - maxh = min2 (maxh, hi); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - } - - p = np; - lastpi = thispi; - } - -#ifdef DEVELOP - (*testout) << " eplast = " << lastpi << " = " << p << endl; -#endif - } - - - - - - - void EdgeCalculation :: - StoreShortEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - Segment seg; - - /* - double len, corr, lam; - int thispi, lastpi; - Point<3> p, np; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints[1], edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - */ - - // generate initial point - Point<3> p = edgepoints[0]; - PointIndex pi1 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi1 = pi; - break; - } - - if (pi1 == -1) - { - pi1 = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, pi1); - } - - p = edgepoints.Last(); - PointIndex pi2 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi2 = pi; - break; - } - if (pi2==-1) - { - pi2 = mesh.AddPoint (p, layer); - meshpoint_tree -> Insert (p, pi2); - } - - /* - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength[j] < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength[j-1]) / - (curvelength[j] - curvelength[j-1]); - - np(0) = (1-lam) * edgepoints[j-1](0) + lam * edgepoints[j](0); - np(1) = (1-lam) * edgepoints[j-1](1) + lam * edgepoints[j](1); - np(2) = (1-lam) * edgepoints[j-1](2) + lam * edgepoints[j](2); - - - thispi = 0; - if (i == ne) - for (j = 1; j <= mesh.GetNP(); j++) - if (Dist(mesh.Point(j), np) < 1e-6) - thispi = j; - - if (!thispi) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np); - } - */ - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = pi1; - seg.p2 = pi2; - } - else - { - seg.p1 = pi2; - seg.p2 = pi1; - } - - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - } - } - - - - - - - - void EdgeCalculation :: - CopyEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & 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) - { - int i, j, k; - PointIndex pi; - - // copy start and end points - for (i = 1; i <= 2; i++) - { - Point<3> fromp = - (i == 1) ? fromstart : fromend; - Point<3> top = - (i == 1) ? tostart : toend; - - PointIndex frompi = -1; - PointIndex topi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - { - if (Dist2 (mesh[pi], fromp) <= 1e-16) - frompi = pi; - if (Dist2 (mesh[pi], top) <= 1e-16) - topi = pi; - } - - if (topi == -1) - { - topi = mesh.AddPoint (top, layer); - meshpoint_tree -> Insert (top, topi); - } - - const Identification & csi = - (*geometry.identifications.Get(copyedgeidentification)); - - if (csi.Identifyable (mesh[frompi], mesh[topi])) - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - else if (csi.Identifyable (mesh[topi], mesh[frompi])) - mesh.GetIdentifications().Add(topi, frompi, copyedgeidentification); - else - { - cerr << "edgeflw.cpp: should identify, but cannot"; - exit(1); - } - /* - (*testout) << "Add Identification from CopyEdge, p1 = " - << mesh[PointIndex(frompi)] << ", p2 = " - << mesh[PointIndex(topi)] << endl; - - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - */ - } - - int oldns = mesh.GetNSeg(); - for (i = 1; i <= oldns; i++) - { - // real copy, since array might be reallocated !! - const Segment oldseg = mesh.LineSegment(i); - if (oldseg.edgenr != copyfromedge) - continue; - if (oldseg.seginfo == 0) - continue; - - int pi1 = oldseg.p1; - int pi2 = oldseg.p2; - - int npi1 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi1); - int npi2 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi2); - - Segment seg; - - for (k = 1; k <= refedges.Size(); k++) - { - int inv = refedgesinv.Get(k); - - // other edge is inverse - if (oldseg.seginfo == 1) - inv = !inv; - - // (*testout) << "inv, now = " << inv << endl; - - if (inv) - { - seg.p1 = npi1; - seg.p2 = npi2; - } - else - { - seg.p1 = npi2; - seg.p2 = npi1; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "copy seg " << seg.p1 << "-" << seg.p2 << endl; -#ifdef DEVELOP - - (*testout) << "copy seg, face = " << seg.si << ": " - << " inv = " << inv << ", refinv = " << refedgesinv.Get(k) - << mesh.Point(seg.p1) << ", " << mesh.Point(seg.p2) << endl; -#endif - - } - - } - } - - - - - - - - void EdgeCalculation :: - FindClosedSurfaces (double h, Mesh & mesh) - { - // if there is no special point at a sphere, one has to add a segment pair - - int i, j; - int nsol; - int nsurf = geometry.GetNSurf(); - int layer; - - BitArray pointatsurface (nsurf); - Point<3> p1, p2; - Vec<3> nv, tv; - Solid * tansol; - ARRAY<int> tansurfind; - // const Solid * sol; - - nsol = geometry.GetNTopLevelObjects(); - - - pointatsurface.Clear(); - - /* - for (i = 1; i <= specpoints.Size(); i++) - { - int classrep; - - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s1); - pointatsurface.Set (classrep); - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s2); - pointatsurface.Set (classrep); - // pointatsurface.Set (specpoints[i].s1); - // pointatsurface.Set (specpoints[i].s2); - } - */ - for (i = 1; i <= mesh.GetNSeg(); i++) - { - const Segment & seg = mesh.LineSegment(i); - int classrep; - -#ifdef DEVELOP - (*testout) << seg.surfnr1 << ", " << seg.surfnr2 << ", si = " << seg.si << endl; -#endif - classrep = geometry.GetSurfaceClassRepresentant (seg.si); - - pointatsurface.Set (classrep); - } - - - for (i = 0; i < nsurf; i++) - { - int classrep = geometry.GetSurfaceClassRepresentant (i); - - if (!pointatsurface.Test(classrep)) - { - const Surface * s = geometry.GetSurface(i); - p1 = s -> GetSurfacePoint(); - s -> GetNormalVector (p1, nv); - - double hloc = - min2 (s->LocH (p1, 3, 1, h), mesh.GetH(p1)); - - tv = nv.GetNormal (); - tv *= (hloc / tv.Length()); - p2 = p1 + tv; - s->Project (p2); - - - Segment seg1; - seg1.si = i; - seg1.domin = -1; - seg1.domout = -1; - - Segment seg2; - seg2.si = i; - seg2.domin = -1; - seg2.domout = -1; - - seg1.surfnr1 = i; - seg2.surfnr1 = i; - seg1.surfnr2 = i; - seg2.surfnr2 = i; - - for (j = 0; j < nsol; j++) - { - if (geometry.GetTopLevelObject(j)->GetSurface()) - continue; - - const Solid * sol = geometry.GetTopLevelObject(j)->GetSolid(); - sol -> TangentialSolid (p1, tansol); - layer = geometry.GetTopLevelObject(j)->GetLayer(); - - if (tansol) - { - tansol -> GetSurfaceIndices (tansurfind); - - if (tansurfind.Size() == 1 && tansurfind.Get(1) == i) - { - if (!tansol->VectorIn(p1, nv)) - { - seg1.domin = j; - seg2.domin = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - else - { - seg1.domout = j; - seg2.domout = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - // seg.s2 = i; - // seg.invs1 = surfaces[i] -> Inverse(); - // seg.invs2 = ! (surfaces[i] -> Inverse()); - } - delete tansol; - } - } - - - if (seg1.domin != -1 || seg1.domout != -1) - { - mesh.AddPoint (p1, layer); - mesh.AddPoint (p2, layer); - seg1.p1 = mesh.GetNP()-1; - seg1.p2 = mesh.GetNP(); - seg2.p2 = mesh.GetNP()-1; - seg2.p1 = mesh.GetNP(); - seg1.geominfo[0].trignum = 1; - seg1.geominfo[1].trignum = 1; - seg2.geominfo[0].trignum = 1; - seg2.geominfo[1].trignum = 1; - mesh.AddSegment (seg1); - mesh.AddSegment (seg2); - - PrintMessage (5, "Add line segment to smooth surface"); - -#ifdef DEVELOP - (*testout) << "Add segment at smooth surface " << i; - if (i != classrep) (*testout) << ", classrep = " << classrep; - (*testout) << ": " - << mesh.Point (mesh.GetNP()-1) << " - " - << mesh.Point (mesh.GetNP()) << endl; -#endif - } - } - } - } - -} diff --git a/contrib/Netgen/libsrc/csg/edgeflw_old.cpp b/contrib/Netgen/libsrc/csg/edgeflw_old.cpp deleted file mode 100644 index 5321dfd17d83aa667887f877d4cdc74d89c156ea..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/edgeflw_old.cpp +++ /dev/null @@ -1,1405 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - -#undef DEVELOP - -namespace netgen -{ - - EdgeCalculation :: - EdgeCalculation (const CSGeometry & ageometry, - ARRAY<SpecialPoint> & aspecpoints) - : geometry(ageometry), specpoints(aspecpoints) - { - ; - } - - EdgeCalculation :: ~EdgeCalculation () - { ; } - - void EdgeCalculation :: Calc(double h, Mesh & mesh) - { - PrintMessage (1, "Find edges"); - PushStatus ("Find edges"); - - CalcEdges1 (h, mesh); - SplitEqualOneSegEdges (mesh); - FindClosedSurfaces (h, mesh); - PrintMessage (3, cntedge, " edges found"); - - PopStatus (); - } - - - - - void EdgeCalculation :: CalcEdges1 (double h, Mesh & mesh) - { - ARRAY<SpecialPoint> hsp(specpoints.Size()); - ARRAY<SpecialPoint> startpoints, endpoints; - - int i, j, k, l, hi, pos, ep, ne; - int layer; - - Vec<3> a1, a2, t, n, m; - Point<3> p, np, pnp, hp; - - Segment seg; - int pi1, s1, s2; - int lastpi, thispi; - - ARRAY<Point<3> > edgepoints; - ARRAY<double> curvelength; - int copyedge, copyfromedge, copyedgeidentification; - - ARRAY<int> locsurfind; - - double len, corr, lam; - double steplen, cursteplen, loch, hd; - - int checkedcopy = 0; - - double size = geometry.MaxSize(); // globflags.GetNumFlag ("maxsize", 500); - double epspointdist2 = size * 1e-6; // globflags.GetNumFlag ("epspointdist", size * 1e-6); - epspointdist2 = sqr (epspointdist2); - - - Solid * locsol; - - - // copy special points to work with - for (i = 0; i < specpoints.Size(); i++) - hsp[i] = specpoints[i]; - - - cntedge = 0; - - while (hsp.Size()) - { - SetThreadPercent(100 - 100 * double (hsp.Size()) / specpoints.Size()); - - edgepoints.SetSize (0); - curvelength.SetSize (0); - - - pi1 = 0; - copyedge = 0; - // identifyable point available ? - - // (*testout) << endl; - - for (i = 1; i <= geometry.identifications.Size() && !pi1; i++) - { - for (j = checkedcopy+1; j <= startpoints.Size() && !pi1; j++) - { - - if (geometry.identifications.Get(i)->IdentifyableCandidate (startpoints.Get(j))) - - { - int pi1cand = 0; - double mindist = 1e10; - - for (k = 1; k <= hsp.Size() && !pi1; k++) - { -#ifdef DEVELOP - (*testout) << "check kand = " << hsp.Get(k).p - << ", v = " << hsp.Get(k).v - << endl; -#endif - if (geometry.identifications.Get(i) - ->Identifyable(startpoints.Get(j), hsp.Get(k)) || - geometry.identifications.Get(i) - ->Identifyable(hsp.Get(k), startpoints.Get(j))) - { - -#ifdef DEVELOP - (*testout) << "identifiable, dist = " - << Dist (startpoints.Get(j).p, hsp.Get(k).p) << endl; -#endif - - if (Dist (startpoints.Get(j).p, hsp.Get(k).p) < mindist) - { - mindist = Dist (startpoints.Get(j).p, hsp.Get(k).p); - pi1cand = k; - } - /* - pi1 = k; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; - - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << hsp.Get(k).p << " - " << hsp.Get(k).v << endl; - */ - } - } - - if (pi1cand) - { - pi1 = pi1cand; - copyedge = 1; - copyfromedge = j; - copyedgeidentification = i; -#ifdef DEVELOP - (*testout) << "copy edge startpoint from " - << startpoints.Get(j).p << " - " - << startpoints.Get(j).v - << " to " - << hsp.Get(pi1).p << " - " << hsp.Get(pi1).v << endl; -#endif - } - } - } - } - - - // cannot copy from other ege ? - if (!pi1) - checkedcopy = startpoints.Size(); - - // unconditional special point available ? - if (!pi1) - for (i = 1; i <= hsp.Size() && pi1 == 0; i++) - if (hsp.Get(i).unconditional == 1) - pi1 = i; - - - if (!pi1) - { - // only unconditional points available, choose first - pi1 = 1; - } - - layer = hsp.Get(pi1).GetLayer(); - - - if (!hsp.Get(pi1).unconditional) - { - hsp.Elem(pi1).unconditional = 1; - for (i = 1; i <= hsp.Size(); i++) - if (i != pi1 && Dist (hsp.Get(pi1).p, hsp.Get(i).p) < 1e-8 && - (hsp.Get(pi1).v + hsp.Get(i).v).Length() < 1e-4) - { - // opposite direction - hsp.Elem(i).unconditional = 1; - } - } - - cntedge++; - startpoints.Append (hsp.Get(pi1)); - -#ifdef DEVELOP - (*testout) << "edge nr " << cntedge << endl; - (*testout) << "start followedge: p1 = " << hsp.Get(pi1).p << ", v = " << hsp.Get(pi1).v << endl; -#endif - - FollowEdge (pi1, ep, pos, hsp, h, mesh, - edgepoints, curvelength); - - - if (multithread.terminate) - return; - - if (!ep) - { - // ignore starting point - hsp.DeleteElement (pi1); - continue; - } - - - - endpoints.Append (hsp.Get(ep)); - - - double elen = 0; - for (i = 1; i <= edgepoints.Size()-1; i++) - elen += Dist (edgepoints.Get(i), edgepoints.Get(i+1)); - - - int shortedge = 0; - for (i = 1; i <= geometry.identifications.Size(); i++) - if (geometry.identifications.Get(i)->ShortEdge(hsp.Get(pi1), hsp.Get(ep))) - shortedge = 1; - (*testout) << "shortedge = " << shortedge << endl; - - - if (!shortedge) - { - mesh.RestrictLocalHLine (Point3d (hsp.Get(pi1).p), - Point3d (hsp.Get(ep).p), - elen / mparam.segmentsperedge); - } - - s1 = hsp.Get(pi1).s1; - s2 = hsp.Get(pi1).s2; - - - // delete initial, terminal and conditional points - -#ifdef DEVELOP - (*testout) << "terminal point: p = " << hsp.Get(ep).p << ", v = " << hsp.Get(ep).v << endl; -#endif - if (ep > pi1) - { - hsp.DeleteElement (ep); - hsp.DeleteElement (pi1); - } - else - { - hsp.DeleteElement (pi1); - hsp.DeleteElement (ep); - } - - - for (j = 1; j <= edgepoints.Size()-1; j++) - { - p = edgepoints.Get(j); - np = Center (p, edgepoints.Get(j+1)); - hd = Dist2 (p, np); - - for (i = 1; i <= hsp.Size(); i++) - if ( hsp.Get(i).HasSurfaces (s1, s2) && - hsp.Get(i).unconditional == 0 && - Dist2 (np, hsp.Get(i).p) < 1.2 * hd) - { - hsp.DeleteElement (i); - i--; - } - } - - - ARRAY<Segment> refedges; - ARRAY<int> refedgesinv; - - - AnalyzeEdge (s1, s2, pos, layer, - edgepoints, - refedges, refedgesinv); - - for (i = 1; i <= refedges.Size(); i++) - refedges.Elem(i).edgenr = cntedge; - - -#ifdef DEVELOP - (*testout) << "edge " << cntedge << endl - << "startp: " << startpoints.Last().p - << ", v = " << startpoints.Last().v << endl - << "copy = " << copyedge << endl - << refedges.Size() << " refedges: "; - for (i = 1; i <= refedges.Size(); i++) - (*testout) << " " << refedges.Get(i).si; - (*testout) << endl; - (*testout) << "inv[1] = " << refedgesinv.Get(1) << endl; -#endif - - if (!copyedge) - { - int oldnseg = mesh.GetNSeg(); - - if (!shortedge) - StoreEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - else - StoreShortEdge (refedges, refedgesinv, - edgepoints, curvelength, layer, mesh); - - - /* - for (i = oldnseg+1; i <= mesh.GetNSeg(); i++) - for (j = 1; j <= oldnseg; j++) - { - const Point<3> & l1p1 = mesh.Point (mesh.LineSegment(i).p1); - const Point<3> & l1p2 = mesh.Point (mesh.LineSegment(i).p2); - const Point<3> & l2p1 = mesh.Point (mesh.LineSegment(j).p1); - const Point<3> & l2p2 = mesh.Point (mesh.LineSegment(j).p2); - Vec<3> vl1(l1p1, l1p2); - for (double lamk = 0; lamk <= 1; lamk += 0.1) - { - Point<3> l2p = l1p1 + lamk * vl1; - double dist = sqrt (MinDistLP2 (l2p1, l2p2, l2p)); - if (dist > 1e-12) - mesh.RestrictLocalH (l2p, 3*dist); - } - } - */ - } - else - { - CopyEdge (refedges, refedgesinv, - copyfromedge, - startpoints.Get(copyfromedge).p, - endpoints.Get(copyfromedge).p, - edgepoints.Get(1), edgepoints.Last(), - copyedgeidentification, - layer, - mesh); - } - - } - } - - - - /* - If two or more edges share the same initial and end-points, - then they need at least two segments - */ - void EdgeCalculation :: - SplitEqualOneSegEdges (Mesh & mesh) - { - int i, j; - SegmentIndex si; - PointIndex pi; - - ARRAY<int> osedges(cntedge); - INDEX_2_HASHTABLE<int> osedgesht (cntedge+1); - - osedges = 2; - - // count segments on edges - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - osedges.Elem(seg.edgenr)--; - } - - (*testout) << "osedges = " << osedges << endl; - - // flag one segment edges - for (i = 0; i < cntedge; i++) - osedges[i] = (osedges[i] > 0) ? 1 : 0; - - (*testout) << "osedges, now = " << osedges << endl; - - for (si = 0; si < mesh.GetNSeg(); si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr)) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2)) - osedgesht.Set (i2, 2); - else - osedgesht.Set (i2, 1); - } - } - } - - - // one edge 1 segment, other 2 segments - // yes, it happens ! - - for (i = 1; i <= osedgesht.GetNBags(); i++) - for (j = 1; j <= osedgesht.GetBagSize(i); j++) - { - INDEX_2 i2; - int val; - osedgesht.GetData (i, j, i2, val); - - const Point<3> & p1 = mesh[PointIndex(i2.I1())]; - const Point<3> & p2 = mesh[PointIndex(i2.I2())]; - Vec<3> v = p2 - p1; - double vlen = v.Length(); - v /= vlen; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (pi != i2.I1() && pi != i2.I2()) - { - const Point<3> & p = mesh[pi]; - Vec<3> v2 = p - p1; - double lam = (v2 * v); - if (lam > 0 && lam < vlen) - { - Point<3> hp = p1 + lam * v; - if (Dist (p, hp) < 1e-4 * vlen) - { - PrintSysError ("Point on edge !!!"); - cout << "seg: " << i2 << ", p = " << pi << endl; - osedgesht.Set (i2, 2); - } - } - } - } - - - // insert new points - osedges = -1; - - int nseg = mesh.GetNSeg(); - for (si = 0; si < nseg; si++) - { - const Segment & seg = mesh[si]; - if (seg.seginfo && seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - INDEX_2 i2(seg.p1, seg.p2); - i2.Sort (); - if (osedgesht.Used (i2) && - osedgesht.Get (i2) == 2 && - osedges.Elem(seg.edgenr) == -1) - { - Point<3> newp = Center (mesh[PointIndex(seg.p1)], - mesh[PointIndex(seg.p2)]); - - ProjectToEdge (geometry.GetSurface(seg.surfnr1), - geometry.GetSurface(seg.surfnr2), - newp); - - osedges.Elem(seg.edgenr) = - mesh.AddPoint (newp, mesh[PointIndex(seg.p1)].GetLayer()); - } - } - } - - - for (i = 1; i <= nseg; i++) - { - Segment & seg = mesh.LineSegment (i); - if (seg.edgenr >= 1 && seg.edgenr <= cntedge) - { - if (osedges.Get(seg.edgenr) != -1) - { - Segment newseg = seg; - newseg.p1 = osedges.Get(seg.edgenr); - seg.p2 = osedges.Get(seg.edgenr); - mesh.AddSegment (newseg); - } - } - } - - } - - - - void EdgeCalculation :: - FollowEdge (int pi1, int & ep, int & pos, - const ARRAY<SpecialPoint> & hsp, - double h, const Mesh & mesh, - ARRAY<Point<3> > & edgepoints, - ARRAY<double> & curvelength) - { - int i, j, s1, s2; - double len, steplen, cursteplen, loch; - Point<3> p, np, pnp; - Vec<3> a1, a2, t; - - - double size = geometry.MaxSize(); - double epspointdist2 = size * 1e-6; - epspointdist2 = sqr (epspointdist2); - int uselocalh = mparam.uselocalh; - - - s1 = hsp.Get(pi1).s1; - s2 = hsp.Get(pi1).s2; - - p = hsp.Get(pi1).p; - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - - t = Cross (a1, a2); - t.Normalize(); - - pos = (hsp.Get(pi1).v * t) > 0; - if (!pos) t *= -1; - - - edgepoints.Append (p); - curvelength.Append (0); - len = 0; - - loch = min2 (geometry.GetSurface(s1) -> LocH (p, 3, 1, h), - geometry.GetSurface(s2) -> LocH (p, 3, 1, h)); - - - - if (uselocalh) - { - double lh = mesh.GetH(p); - if (lh < loch) - loch = lh; - } - - steplen = 0.1 * loch; - - do - { - if (multithread.terminate) - return; - - if (fabs (p(0)) + fabs (p(1)) + fabs (p(2)) > 10000) - { - ep = 0; - PrintWarning ("Give up line"); - break; - } - - if (steplen > 0.1 * loch) steplen = 0.1 * loch; - - steplen *= 2; - do - { - steplen *= 0.5; - np = p + steplen * t; - pnp = np; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), pnp); - } - while (Dist (np, pnp) > 0.1 * steplen); - - cursteplen = steplen; - if (Dist (np, pnp) < 0.01 * steplen) steplen *= 2; - - - np = pnp; - -#ifdef MYGRAPH - if (silentflag <= 2) - { - MyLine3D (p, np, rot); - MyDraw (); - } -#endif - - ep = 0; - - double hvtmin = 1.5 * cursteplen; - - Box<3> boxp (p - (2 * cursteplen) * Vec<3> (1, 1, 1), - p + (2 * cursteplen) * Vec<3> (1, 1, 1)); - - for (i = 1; i <= hsp.Size(); i++) - // if ( i != pi1 && hsp.Get(i).HasSurfaces (s1, s2) ) - { - if (!boxp.IsIn (hsp.Get(i).p)) - continue; - - Vec<3> hv = hsp.Get(i).p - p; - if (hv.Length2() > 9 * cursteplen * cursteplen) - continue; - - /* - if (!hsp.Get(i).HasSurfaces (s1, s2)) - continue; // test for dalibor-problem - */ - - double hvt = hv * t; - hv -= hvt * t; - - if (hv.Length() < 0.2 * cursteplen && - hvt > 0 && - // hvt < 1.5 * cursteplen && - hvt < hvtmin && - hsp.Get(i).unconditional == 1 && - (hsp.Get(i).v + t).Length() < 0.4 ) - { - Point<3> hep = hsp.Get(i).p; - ProjectToEdge (geometry.GetSurface(s1), - geometry.GetSurface(s2), hep); - - - if (Dist2 (hep, hsp.Get(i).p) < epspointdist2 ) - { - geometry.GetSurface(s1) -> CalcGradient (hep, a1); - geometry.GetSurface(s2) -> CalcGradient (hep, a2); - Vec<3> ept = Cross (a1, a2); - ept /= ept.Length(); - if (!pos) ept *= -1; - - if ( (hsp.Get(i).v + ept).Length() < 1e-4 ) - { - np = hsp.Get(i).p; - ep = i; - hvtmin = hvt; - // break; - } - } - } - } - - loch = min2 (geometry.GetSurface(s1) -> LocH (np, 3, 1, h), - geometry.GetSurface(s2) -> LocH (np, 3, 1, h)); - - if (uselocalh) - { - double lh = mesh.GetH(np); - if (lh < loch) - loch = lh; - } - - - len += Dist (p, np) / loch; - edgepoints.Append (np); - curvelength.Append (len); - - p = np; - - geometry.GetSurface(s1) -> CalcGradient (p, a1); - geometry.GetSurface(s2) -> CalcGradient (p, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - } - while (! ep); - } - - - - - - - - void EdgeCalculation :: - AnalyzeEdge (int s1, int s2, int pos, int layer, - const ARRAY<Point<3> > & edgepoints, - ARRAY<Segment> & refedges, - ARRAY<int> & refedgesinv) - { - int i, j, k, l; - int hi; - Point<3> hp; - Vec<3> t, a1, a2, m, n; - Segment seg; - Solid * locsol; - ARRAY<int> locsurfind; - - /* - int pi1 = 0, pi2 = 0; - extern Mesh * mesh; - for (i = 1; i <= mesh->GetNP(); i++) - { - if (Dist2 (edgepoints.Get(1), mesh->Point(i)) < 1e-12) - pi1 = i; - if (Dist2 (edgepoints.Last(), mesh->Point(i)) < 1e-12) - pi2 = i; - } - (*testout) << "Analyze edge: " << pi1 << " - " << pi2 << ", pts = " << edgepoints.Size() << endl; - (*testout) << "p1 = " << edgepoints.Get(1) << " pl = " << edgepoints.Last() << endl; - */ - int debug = 0; - /* - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Get(1)) < 1e-6 || - Dist2 (Point<3> (2.69642, 1.1866, 2.03), edgepoints.Last()) < 1e-6; - */ - - if (debug) - { - // (*testout) << "tubious edge !!!" << endl; - (*testout) << "s1, s2 = " << s1 << " - " << s2 << endl; - } - - refedges.SetSize(0); - refedgesinv.SetSize(0); - hp = Center (edgepoints.Get(1), edgepoints.Get(2)); - ProjectToEdge (geometry.GetSurface(s1), geometry.GetSurface(s2), hp); - - geometry.GetSurface(s1) -> CalcGradient (hp, a1); - geometry.GetSurface(s2) -> CalcGradient (hp, a2); - t = Cross (a1, a2); - t.Normalize(); - if (!pos) t *= -1; - - (*testout) << "t = " << t << endl; - - for (i = 0; i < geometry.GetNTopLevelObjects(); i++) - { - (*testout) << "layer = " << layer - << ", tlo-layer = " << geometry.GetTopLevelObject(i)->GetLayer() << endl; - if (geometry.GetTopLevelObject(i)->GetLayer() != layer) - continue; - - const Solid * sol = geometry.GetTopLevelObject(i)->GetSolid(); - const Surface * surf = geometry.GetTopLevelObject(i)->GetSurface(); - - sol -> TangentialSolid (hp, locsol); - if (!locsol) continue; - - BoxSphere<3> boxp (hp, hp); - boxp.Increase (1e-5); - boxp.CalcDiamCenter(); - - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)locsol) -> IterateSolid (rpi); - - locsol -> CalcSurfaceInverse (); - - - if (!surf) - { - locsol -> GetSurfaceIndices (locsurfind); - } - else - { - /* - if (fabs (surf->CalcFunctionValue (hp)) < 1e-6) - continue; - */ - locsurfind.SetSize(1); - locsurfind[0] = -1; - for (j = 0; j < geometry.GetNSurf(); j++) - if (geometry.GetSurface(j) == surf) - { - locsurfind[0] = j; - // geometry.GetSurfaceClassRepresentant(j); - break; - } - } - - ((Solid*)locsol) -> IterateSolid (urpi); - - - if (debug) - (*testout) << "edge of tlo " << i << ", has " << locsurfind.Size() << " faces." << endl; - - - for (j = locsurfind.Size()-1; j >= 0; j--) - if (fabs (geometry.GetSurface(locsurfind[j]) - ->CalcFunctionValue (hp) ) > 1e-6) - locsurfind.DeleteElement(j+1); - - if (debug) - (*testout) << locsurfind.Size() << " faces on hp" << endl; - - for (j = 0; j < locsurfind.Size(); j++) - { - int lsi = locsurfind[j]; - int rlsi = geometry.GetSurfaceClassRepresentant(lsi); - - Vec<3> rn; - - // n is outer normal to solid - geometry.GetSurface(lsi) -> GetNormalVector (hp, n); - if (geometry.GetSurface (lsi)->Inverse()) - n *= -1; - - if (fabs (t * n) > 1e-4) continue; - if (debug) - { - (*testout) << "face " << locsurfind.Get(j) << ", rep = " << rlsi - << " has (t*n) = " << (t*n) << endl; - (*testout) << "n = " << n << endl; - } - - // rn is normal to class representant - geometry.GetSurface(rlsi) -> GetNormalVector (hp, rn); - - int sameasref = ((n * rn) > 0); - - m = Cross (t, rn); - m.Normalize(); - - - for (k = 1; k <= 2; k ++) - { - bool edgeinv = (k == 2); - - if (debug) - { - (*testout) << "onface(" << hp << ", " << m << ")= " - << locsol->OnFace (hp, m); - (*testout) << " vec2in = " - << locsol -> VectorIn2 (hp, m, n) << " and " - << locsol -> VectorIn2 (hp, m, -1 * n) << endl; - } - - // if (locsol -> OnFace (hp, m)) - if (locsol -> VectorIn2 (hp, m, n) == 0 && - locsol -> VectorIn2 (hp, m, -1 * n) == 1) - { - hi = 0; - for (l = 1; l <= refedges.Size(); l++) - { - if (refedges.Get(l).si == rlsi && - refedgesinv.Get(l) == edgeinv) - hi = l; - } - - if (!hi) - { - seg.si = rlsi; - seg.domin = -1; - seg.domout = -1; - seg.tlosurf = -1; - seg.surfnr1 = s1; - seg.surfnr2 = s2; - hi = refedges.Append (seg); - refedgesinv.Append (edgeinv); - } - - if (!surf) - { - if (sameasref) - refedges.Elem(hi).domin = i; - else - refedges.Elem(hi).domout = i; - } - else - refedges.Elem(hi).tlosurf = i; - - if (debug) - (*testout) << "add ref seg:" - << "si = " << refedges.Get(hi).si - << ", domin = " << refedges.Get(hi).domin - << ", domout = " << refedges.Get(hi).domout - << ", surfnr1/2 = " << refedges.Get(hi).surfnr1 - << ", " << refedges.Get(hi).surfnr2 - << ", inv = " << refedgesinv.Get(hi) - << ", refedgenr = " << hi - << endl; - } - m *= -1; - } - } - delete locsol; - } - } - - - - void EdgeCalculation :: - StoreEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - - double len, corr, lam; - PointIndex thispi, lastpi; - Point<3> p, np; - Segment seg; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints.Get(1), edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - - // generate initial point - p = edgepoints.Get(1); - lastpi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist (mesh[pi], p) < 1e-6) - { - lastpi = pi; - break; - } - - if (lastpi == -1) - lastpi = mesh.AddPoint (p, layer); - - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength.Get(j) < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength.Get(j-1)) / - (curvelength.Get(j) - curvelength.Get(j-1)); - - np(0) = (1-lam) * edgepoints.Get(j-1)(0) + lam * edgepoints.Get(j)(0); - np(1) = (1-lam) * edgepoints.Get(j-1)(1) + lam * edgepoints.Get(j)(1); - np(2) = (1-lam) * edgepoints.Get(j-1)(2) + lam * edgepoints.Get(j)(2); - - - thispi = -1; - if (i == ne) - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist(mesh[pi], np) < 1e-6) - thispi = pi; - - if (thispi == -1) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np, layer); - } - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = lastpi; - seg.p2 = thispi; - } - else - { - seg.p1 = thispi; - seg.p2 = lastpi; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - - double maxh = min2 (geometry.GetSurface(seg.surfnr1)->GetMaxH(), - geometry.GetSurface(seg.surfnr2)->GetMaxH()); - - if (seg.domin != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domin) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domin)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.domout != -1) - { - const Solid * s1 = - geometry.GetTopLevelObject(seg.domout) -> GetSolid(); - maxh = min2 (maxh, s1->GetMaxH()); - maxh = min2 (maxh, geometry.GetTopLevelObject(seg.domout)->GetMaxH()); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - if (seg.tlosurf != -1) - { - double hi = geometry.GetTopLevelObject(seg.tlosurf) -> GetMaxH(); - maxh = min2 (maxh, hi); - mesh.RestrictLocalH (p, maxh); - mesh.RestrictLocalH (np, maxh); - } - } - - p = np; - lastpi = thispi; - } - -#ifdef DEVELOP - (*testout) << " eplast = " << lastpi << " = " << p << endl; -#endif - } - - - - - - - void EdgeCalculation :: - StoreShortEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & refedgesinv, - const ARRAY<Point<3> > & edgepoints, - const ARRAY<double> & curvelength, - int layer, - Mesh & mesh) - { - - // Calculate optimal element-length - int i, j, k; - PointIndex pi; - int ne; - Segment seg; - - /* - double len, corr, lam; - int thispi, lastpi; - Point<3> p, np; - - - const Surface * surf1 = geometry.GetSurface (refedges.Get(1).surfnr1); - const Surface * surf2 = geometry.GetSurface (refedges.Get(1).surfnr2); - - len = curvelength.Last(); - ne = int (len + 0.5); - if (ne == 0) ne = 1; - if (Dist2 (edgepoints[1], edgepoints.Last()) < 1e-8 && - ne <= 6) - ne = 6; - corr = len / ne; - */ - - // generate initial point - Point<3> p = edgepoints[0]; - PointIndex pi1 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi1 = pi; - break; - } - - if (pi1 == -1) pi1 = mesh.AddPoint (p, layer); - - p = edgepoints.Last(); - PointIndex pi2 = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - - if (Dist (mesh[pi], p) < 1e-6) - { - pi2 = pi; - break; - } - if (pi2==-1) pi2 = mesh.AddPoint (p, layer); - - /* - - j = 1; - for (i = 1; i <= ne; i++) - { - while (curvelength[j] < i * corr && j < curvelength.Size()) j++; - - lam = (i * corr - curvelength[j-1]) / - (curvelength[j] - curvelength[j-1]); - - np(0) = (1-lam) * edgepoints[j-1](0) + lam * edgepoints[j](0); - np(1) = (1-lam) * edgepoints[j-1](1) + lam * edgepoints[j](1); - np(2) = (1-lam) * edgepoints[j-1](2) + lam * edgepoints[j](2); - - - thispi = 0; - if (i == ne) - for (j = 1; j <= mesh.GetNP(); j++) - if (Dist(mesh.Point(j), np) < 1e-6) - thispi = j; - - if (!thispi) - { - ProjectToEdge (surf1, surf2, np); - thispi = mesh.AddPoint (np); - } - */ - - for (k = 1; k <= refedges.Size(); k++) - { - if (refedgesinv.Get(k)) - { - seg.p1 = pi1; - seg.p2 = pi2; - } - else - { - seg.p1 = pi2; - seg.p2 = pi1; - } - - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = (refedgesinv.Get(k)) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "add seg " << seg.p1 << "-" << seg.p2 << endl; - } - } - - - - - - - - void EdgeCalculation :: - CopyEdge (const ARRAY<Segment> & refedges, - const ARRAY<int> & 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) - { - int i, j, k; - PointIndex pi; - - // copy start and end points - for (i = 1; i <= 2; i++) - { - Point<3> fromp = - (i == 1) ? fromstart : fromend; - Point<3> top = - (i == 1) ? tostart : toend; - - PointIndex frompi = -1; - PointIndex topi = -1; - for (pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - { - if (Dist2 (mesh[pi], fromp) <= 1e-16) - frompi = pi; - if (Dist2 (mesh[pi], top) <= 1e-16) - topi = pi; - } - - if (topi == -1) - topi = mesh.AddPoint (top, layer); - - const Identification & csi = - (*geometry.identifications.Get(copyedgeidentification)); - - if (csi.Identifyable (mesh[frompi], mesh[topi])) - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - else if (csi.Identifyable (mesh[topi], mesh[frompi])) - mesh.GetIdentifications().Add(topi, frompi, copyedgeidentification); - else - { - cerr << "edgeflw.cpp: should identify, but cannot"; - exit(1); - } - /* - (*testout) << "Add Identification from CopyEdge, p1 = " - << mesh[PointIndex(frompi)] << ", p2 = " - << mesh[PointIndex(topi)] << endl; - - mesh.GetIdentifications().Add(frompi, topi, copyedgeidentification); - */ - } - - int oldns = mesh.GetNSeg(); - for (i = 1; i <= oldns; i++) - { - // real copy, since array might be reallocated !! - const Segment oldseg = mesh.LineSegment(i); - if (oldseg.edgenr != copyfromedge) - continue; - if (oldseg.seginfo == 0) - continue; - - int pi1 = oldseg.p1; - int pi2 = oldseg.p2; - - int npi1 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi1); - int npi2 = geometry.identifications.Get(copyedgeidentification) - -> GetIdentifiedPoint (mesh, pi2); - - Segment seg; - - for (k = 1; k <= refedges.Size(); k++) - { - int inv = refedgesinv.Get(k); - - // other edge is inverse - if (oldseg.seginfo == 1) - inv = !inv; - - // (*testout) << "inv, now = " << inv << endl; - - if (inv) - { - seg.p1 = npi1; - seg.p2 = npi2; - } - else - { - seg.p1 = npi2; - seg.p2 = npi1; - } - seg.si = refedges.Get(k).si; - seg.domin = refedges.Get(k).domin; - seg.domout = refedges.Get(k).domout; - seg.tlosurf = refedges.Get(k).tlosurf; - seg.edgenr = refedges.Get(k).edgenr; - seg.surfnr1 = refedges.Get(k).surfnr1; - seg.surfnr2 = refedges.Get(k).surfnr2; - seg.seginfo = 0; - if (k == 1) seg.seginfo = refedgesinv.Get(k) ? 2 : 1; - mesh.AddSegment (seg); - // (*testout) << "copy seg " << seg.p1 << "-" << seg.p2 << endl; -#ifdef DEVELOP - - (*testout) << "copy seg, face = " << seg.si << ": " - << " inv = " << inv << ", refinv = " << refedgesinv.Get(k) - << mesh.Point(seg.p1) << ", " << mesh.Point(seg.p2) << endl; -#endif - - } - - } - } - - - - - - - - void EdgeCalculation :: - FindClosedSurfaces (double h, Mesh & mesh) - { - // if there is no special point at a sphere, one has to add a segment pair - - int i, j; - int nsol; - int nsurf = geometry.GetNSurf(); - int layer; - - BitArray pointatsurface (nsurf); - Point<3> p1, p2; - Vec<3> nv, tv; - Solid * tansol; - ARRAY<int> tansurfind; - // const Solid * sol; - - nsol = geometry.GetNTopLevelObjects(); - - - pointatsurface.Clear(); - - /* - for (i = 1; i <= specpoints.Size(); i++) - { - int classrep; - - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s1); - pointatsurface.Set (classrep); - classrep = geometry.GetSurfaceClassRepresentant (specpoints[i].s2); - pointatsurface.Set (classrep); - // pointatsurface.Set (specpoints[i].s1); - // pointatsurface.Set (specpoints[i].s2); - } - */ - for (i = 1; i <= mesh.GetNSeg(); i++) - { - const Segment & seg = mesh.LineSegment(i); - int classrep; - -#ifdef DEVELOP - (*testout) << seg.surfnr1 << ", " << seg.surfnr2 << ", si = " << seg.si << endl; -#endif - classrep = geometry.GetSurfaceClassRepresentant (seg.si); - - pointatsurface.Set (classrep); - } - - - for (i = 0; i < nsurf; i++) - { - int classrep = geometry.GetSurfaceClassRepresentant (i); - - if (!pointatsurface.Test(classrep)) - { - const Surface * s = geometry.GetSurface(i); - p1 = s -> GetSurfacePoint(); - s -> GetNormalVector (p1, nv); - - double hloc = - min2 (s->LocH (p1, 3, 1, h), mesh.GetH(p1)); - - tv = nv.GetNormal (); - tv *= (hloc / tv.Length()); - p2 = p1 + tv; - s->Project (p2); - - - Segment seg1; - seg1.si = i; - seg1.domin = -1; - seg1.domout = -1; - - Segment seg2; - seg2.si = i; - seg2.domin = -1; - seg2.domout = -1; - - seg1.surfnr1 = i; - seg2.surfnr1 = i; - seg1.surfnr2 = i; - seg2.surfnr2 = i; - - for (j = 0; j < nsol; j++) - { - if (geometry.GetTopLevelObject(j)->GetSurface()) - continue; - - const Solid * sol = geometry.GetTopLevelObject(j)->GetSolid(); - sol -> TangentialSolid (p1, tansol); - layer = geometry.GetTopLevelObject(j)->GetLayer(); - - if (tansol) - { - tansol -> GetSurfaceIndices (tansurfind); - - if (tansurfind.Size() == 1 && tansurfind.Get(1) == i) - { - if (!tansol->VectorIn(p1, nv)) - { - seg1.domin = j; - seg2.domin = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - else - { - seg1.domout = j; - seg2.domout = j; - seg1.tlosurf = j; - seg2.tlosurf = j; - } - // seg.s2 = i; - // seg.invs1 = surfaces[i] -> Inverse(); - // seg.invs2 = ! (surfaces[i] -> Inverse()); - } - delete tansol; - } - } - - - if (seg1.domin != -1 || seg1.domout != -1) - { - mesh.AddPoint (p1, layer); - mesh.AddPoint (p2, layer); - seg1.p1 = mesh.GetNP()-1; - seg1.p2 = mesh.GetNP(); - seg2.p2 = mesh.GetNP()-1; - seg2.p1 = mesh.GetNP(); - seg1.geominfo[0].trignum = 1; - seg1.geominfo[1].trignum = 1; - seg2.geominfo[0].trignum = 1; - seg2.geominfo[1].trignum = 1; - mesh.AddSegment (seg1); - mesh.AddSegment (seg2); - - PrintMessage (5, "Add line segment to smooth surface"); - -#ifdef DEVELOP - (*testout) << "Add segment at smooth surface " << i; - if (i != classrep) (*testout) << ", classrep = " << classrep; - (*testout) << ": " - << mesh.Point (mesh.GetNP()-1) << " - " - << mesh.Point (mesh.GetNP()) << endl; -#endif - } - } - } - } - -} diff --git a/contrib/Netgen/libsrc/csg/explicitcurve2d.cpp b/contrib/Netgen/libsrc/csg/explicitcurve2d.cpp deleted file mode 100644 index b1eef537c8aaed38008691437880786810e04be5..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/explicitcurve2d.cpp +++ /dev/null @@ -1,160 +0,0 @@ -#include <mystdlib.h> -#include <csg.hpp> - -namespace netgen -{ -ExplicitCurve2d :: ExplicitCurve2d () - { - ; - } - - -void ExplicitCurve2d :: Project (Point<2> & p) const - { - double t; - t = ProjectParam (p); - p = Eval (t); - } - -double ExplicitCurve2d :: NumericalProjectParam (const Point<2> & p, double lb, double ub) const - { - double t; - Vec<2> tan; - Vec<2> curv; - Point<2> cp; - double f, fl, fu; - int cnt; - - tan = EvalPrime (lb); - cp = Eval (lb); - fl = tan * (cp - p); - if (fl > 0) // changed by wmf, originally fl >= 0 - { - // cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl; - // cerr << "ExplicitCurve2d::NumericalProject: lb wrong" << endl; - return 0; - } - - tan = EvalPrime (ub); - cp = Eval (ub); - fu = tan * (cp - p); - if (fu < 0) // changed by wmf, originally fu <= 0 - { - // cerr << "tan = " << tan << " cp - p = " << (cp - p) << endl; - // cerr << "ExplicitCurve2d::NumericalProject: ub wrong" << endl; - return 0; - } - - cnt = 0; - while (ub - lb > 1e-12 && fu - fl > 1e-12) - { - cnt++; - if (cnt > 50) - { - (*testout) << "Num Proj, cnt = " << cnt << endl; - } - - t = (lb * fu - ub * fl) / (fu - fl); - if (t > 0.9 * ub + 0.1 * lb) t = 0.9 * ub + 0.1 * lb; - if (t < 0.1 * ub + 0.9 * lb) t = 0.1 * ub + 0.9 * lb; - - tan = EvalPrime (t); - cp = Eval (t); - f = tan * (cp - p); - - if (f >= 0) - { - ub = t; - fu = f; - } - else - { - lb = t; - fl = f; - } - } - - return t; - } - - -Vec<2> ExplicitCurve2d :: Normal (double t) const -{ - Vec<2> tan = EvalPrime (t); - tan.Normalize(); - return Vec<2> (tan(1), -tan(0)); -} - - -void ExplicitCurve2d :: NormalVector (const Point<2> & p, Vec<2> & n) const - { - double t = ProjectParam (p); - n = Normal (t); - } - - -Point<2> ExplicitCurve2d :: CurvCircle (double t) const - { - Point<2> cp; - Vec<2> tan, n, curv; - double den; - - cp = Eval (t); - tan = EvalPrime (t); - n = Normal (t); - curv = EvalPrimePrime (t); - - den = n * curv; - if (fabs (den) < 1e-12) - return cp + 1e12 * n; - - return cp + (tan.Length2() / den) * n; - } - - -double ExplicitCurve2d :: MaxCurvature () const - { - double t, tmin, tmax, dt; - double curv; - Vec<2> tan; - double maxcurv; - - maxcurv = 0; - - tmin = MinParam (); - tmax = MaxParam (); - dt = (tmax - tmin) / 1000; - for (t = tmin; t <= tmax+dt; t += dt) - if (SectionUsed (t)) - { - tan = EvalPrime (t); - curv = fabs ( (Normal(t) * EvalPrimePrime(t)) / tan.Length2()); - if (curv > maxcurv) maxcurv = curv; - } - return maxcurv; - } - -double ExplicitCurve2d :: MaxCurvatureLoc (const Point<2> & p, double rad) const - { - double t, tmin, tmax, dt; - double curv; - Vec<2> tan; - double maxcurv; - - maxcurv = 0; - - tmin = MinParam (); - tmax = MaxParam (); - dt = (tmax - tmin) / 1000; - for (t = tmin; t <= tmax+dt; t += dt) - if (Dist (Eval(t), p) < rad) - { - tan = EvalPrime (t); - curv = fabs ( (Normal(t) * EvalPrimePrime(t)) / tan.Length2()); - if (curv > maxcurv) maxcurv = curv; - } - - return maxcurv; - } - -} diff --git a/contrib/Netgen/libsrc/csg/explicitcurve2d.hpp b/contrib/Netgen/libsrc/csg/explicitcurve2d.hpp deleted file mode 100644 index af405aed3cb4d306f1d34c12dca2af27d4995ee1..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/explicitcurve2d.hpp +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef FILE_EXPLICITCURVE2D -#define FILE_EXPLICITCURVE2D - -/**************************************************************************/ -/* File: explicitcurve2d.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 14. Oct. 96 */ -/**************************************************************************/ - -/* - - Explicit 2D Curve repesentation - -*/ - - - -/// -class ExplicitCurve2d : public Curve2d -{ -public: - /// - ExplicitCurve2d (); - - /// - virtual void Project (Point<2> & p) const; - /// - virtual double ProjectParam (const Point<2> & p) const = 0; - /// - virtual double NumericalProjectParam (const Point<2> & p, double lb, double ub) const; - /// - virtual double MinParam () const = 0; - /// - virtual double MaxParam () const = 0; - /// - virtual Point<2> Eval (double t) const = 0; - /// - virtual Vec<2> EvalPrime (double t) const = 0; - /// - virtual Vec<2> Normal (double t) const; - /// - virtual void NormalVector (const Point<2> & p, Vec<2> & n) const; - /// - virtual Vec<2> EvalPrimePrime (double t) const = 0; - - /// - virtual double MaxCurvature () const; - /// - virtual double MaxCurvatureLoc (const Point<2> & p, double rad) const; - - /// - virtual Point<2> CurvCircle (double t) const; - /// - virtual void Print (ostream & /* str */) const { }; - - /// - virtual int SectionUsed (double /* t */) const { return 1; } - /// - virtual void Reduce (const Point<2> & /* p */, double /* rad */) { }; - /// - virtual void UnReduce () { }; -}; - - -/// -class BSplineCurve2d : public ExplicitCurve2d -{ - /// - ARRAY<Point<2> > points; - /// - ARRAY<int> intervallused; - /// - int redlevel; - -public: - /// - BSplineCurve2d (); - /// - void AddPoint (const Point<2> & apoint); - - bool Inside (const Point<2> & p, double & dist) const; - - /// - virtual double ProjectParam (const Point<2> & p) const; - /// - virtual double MinParam () const { return 0; } - /// - virtual double MaxParam () const { return points.Size(); } - /// - virtual Point<2> Eval (double t) const; - /// - virtual Vec<2> EvalPrime (double t) const; - /// - virtual Vec<2> EvalPrimePrime (double t) const; - /// - virtual void Print (ostream & str) const; - - /// - virtual int SectionUsed (double t) const; - /// - virtual void Reduce (const Point<2> & p, double rad); - /// - virtual void UnReduce (); -}; - - - - -#endif diff --git a/contrib/Netgen/libsrc/csg/extrusion.cpp b/contrib/Netgen/libsrc/csg/extrusion.cpp deleted file mode 100644 index acf9b863bc82fce2ad9398186e7055b5b805899a..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/extrusion.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include <mystdlib.h> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ - - - - ExtrusionSurface :: ExtrusionSurface (const Point<3> & ap0, - const Vec<3> & aex, - const Vec<3> & aey, - BSplineCurve2d * acurve, - int asegnr) - : p0(ap0), ex(aex), ey(aey), curve(acurve), segnr(asegnr) - { - ; - } - - ExtrusionSurface :: ~ExtrusionSurface () - { - ; - } - - void ExtrusionSurface :: DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2) - { - ; - } - - void ExtrusionSurface :: ToPlane (const Point<3> & p3d, Point<2> & pplane, - double h, int & zone) const - { - ; - } - - void ExtrusionSurface :: FromPlane (const Point<2> & pplane, - Point<3> & p3d, double h) const - { - ; - } - - - void ExtrusionSurface :: Project (Point<3> & p) const - { - ; - } - - - double ExtrusionSurface :: CalcFunctionValue (const Point<3> & point) const - { - return 0; - } - - void ExtrusionSurface :: CalcGradient (const Point<3> & point, Vec<3> & grad) const - { - ; - } - - Point<3> ExtrusionSurface :: GetSurfacePoint () const - { - return Point<3> (0,0,0); - } - - double ExtrusionSurface :: HesseNorm () const - { - return 1; - } - - void ExtrusionSurface :: Print (ostream & str) const - { - ; - } - - void ExtrusionSurface :: GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const - { - Point<2> p2d; - Point<3> p; - int n = int(facets)+1; - Vec<3> ez = Cross (ex, ey); - cout << "ex = " << ex << endl; - cout << "ey = " << ey << endl; - for (double t = 0; t < 1.0001; t += 1.0 / n) - { - cout << "t = " << t << endl; - p2d = curve -> Eval (segnr+t); - p = p0 + p2d(0) * ex + p2d(1) * ey; - cout << "p2d = " << p2d << endl; - cout << "add point " << p << endl; - tas.AddPoint (p); - tas.AddPoint (p + ez); - } - - for (int i = 0; i < n; i++) - { - cout << "add trig " << endl; - tas.AddTriangle (TATriangle (0, 2*i, 2*i+2, 2*i+1)); - tas.AddTriangle (TATriangle (0, 2*i+2, 2*i+3, 2*i+1)); - } - } - - - - -Extrusion :: Extrusion (const Point<3> & ap0, - const Vec<3> & aex, - const Vec<3> & aey, - const ARRAY< Point<2> > & points) - : p0(ap0), ex(aex), ey(aey) -{ - int i; - - ex.Normalize(); - ey -= (ex*ey) * ex; - ey.Normalize(); - - for (i = 0; i < points.Size(); i++) - curve.AddPoint (points[i]); - - surfs.SetSize (points.Size()/2); - for (i = 0; i < surfs.Size(); i++) - surfs = new ExtrusionSurface (p0, ex, ey, &curve, i); -} - -Extrusion :: ~Extrusion () -{ - int i; - for (i = 0; i < surfs.Size(); i++) - delete surfs[i]; -} - - -INSOLID_TYPE Extrusion :: BoxInSolid (const BoxSphere<3> & box) const -{ - Vec<3> p0c = box.Center() - p0; - Point<2> p2d (ex*p0c, ey*p0c); - double r = box.Diam() / 2; - double dist; - bool inside = - curve.Inside (p2d, dist); - - if (inside && dist > r) return IS_INSIDE; - if (!inside && dist > r) return IS_OUTSIDE; - return DOES_INTERSECT; -} - - -INSOLID_TYPE Extrusion :: PointInSolid (const Point<3> & p, - double eps) const -{ - Vec<3> p0c = p - p0; - Point<2> p2d (ex*p0c, ey*p0c); - double dist; - bool inside = - curve.Inside (p2d, dist); - - if (dist < eps) return DOES_INTERSECT; - if (inside) return IS_INSIDE; - return IS_OUTSIDE; -} - - -INSOLID_TYPE Extrusion :: VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const -{ - Point<3> p2 = p + (1e-3/(v.Length()+1e-16)) * v; - return PointInSolid (p2, eps); -} - - -} diff --git a/contrib/Netgen/libsrc/csg/extrusion.hpp b/contrib/Netgen/libsrc/csg/extrusion.hpp deleted file mode 100644 index ff5a47b4e14572fe75440590a79f9446b2d4c793..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/extrusion.hpp +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef FILE_EXTRUSION -#define FILE_EXTRUSION - -/**************************************************************************/ -/* File: extrusion.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 17. Mar. 2003 */ -/**************************************************************************/ - -/* - -extrusion of 2D curve - -*/ - - -class ExtrusionSurface : public Surface -{ -protected: - BSplineCurve2d * curve; - int segnr; - Point<3> p0; - Vec<3> ex, ey; -public: - ExtrusionSurface (const Point<3> & ap0, - const Vec<3> & aex, - const Vec<3> & aey, - BSplineCurve2d * acurve, - int asegnr); - virtual ~ExtrusionSurface (); - - 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 double CalcFunctionValue (const Point<3> & point) const; - - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - - virtual Point<3> GetSurfacePoint () const; - - virtual double HesseNorm () const; - - virtual void Print (ostream & str) const; - virtual void GetTriangleApproximation (TriangleApproximation & tas, - const Box<3> & boundingbox, - double facets) const; -}; - - -class Extrusion : public Primitive -{ -protected: - Point<3> p0; - Vec<3> ex, ey; - BSplineCurve2d curve; - ARRAY<ExtrusionSurface*> surfs; - -public: - Extrusion (const Point<3> & ap0, - const Vec<3> & aex, - const Vec<3> & aey, - const ARRAY< Point<2> > & points); - virtual ~Extrusion (); - - - - 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; - - virtual int GetNSurfaces() const { return surfs.Size(); } - virtual Surface & GetSurface (int i) { return *surfs[i]; } - virtual const Surface & GetSurface (int i) const { return *surfs[i]; } -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/gencyl.cpp b/contrib/Netgen/libsrc/csg/gencyl.cpp deleted file mode 100644 index 01c893d4a38b5035cb636b232ee095017d5d668d..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/gencyl.cpp +++ /dev/null @@ -1,209 +0,0 @@ -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - -GeneralizedCylinder :: GeneralizedCylinder (ExplicitCurve2d & acrosssection, - Point<3> ap, Vec<3> ae1, Vec<3> ae2) - : crosssection(acrosssection) -{ - planep = ap; - planee1 = ae1; - planee2 = ae2; - planee3 = Cross (planee1, planee2); - (*testout) << "Vecs = " << planee1 << " " << planee2 << " " << planee3 << endl; -} - - -void GeneralizedCylinder :: Project (Point<3> & p) const -{ - Point<2> p2d; - double z; - - p2d = Point<2> (planee1 * (p - planep), planee2 * (p - planep)); - z = planee3 * (p - planep); - - crosssection.Project (p2d); - - p = planep + p2d(0) * planee1 + p2d(1) * planee2 + z * planee3; -} - -int GeneralizedCylinder ::BoxInSolid (const BoxSphere<3> & box) const -{ - Point<3> p3d; - Point<2> p2d, projp; - double t; - Vec<2> tan, n; - - p3d = box.Center(); - - p2d = Point<2> (planee1 * (p3d - planep), planee2 * (p3d - planep)); - t = crosssection.ProjectParam (p2d); - - projp = crosssection.Eval (t); - tan = crosssection.EvalPrime (t); - n(0) = tan(1); - n(1) = -tan(0); - - if (Dist (p2d, projp) < box.Diam()/2) - return 2; - - if (n * (p2d - projp) > 0) - { - return 0; - } - - return 1; -} - -double GeneralizedCylinder :: CalcFunctionValue (const Point<3> & point) const -{ - Point<2> p2d, projp; - double t; - Vec<2> tan, n; - - - p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep)); - t = crosssection.ProjectParam (p2d); - - projp = crosssection.Eval (t); - tan = crosssection.EvalPrime (t); - n(0) = tan(1); - n(1) = -tan(0); - - n /= n.Length(); - return n * (p2d - projp); -} - -void GeneralizedCylinder :: CalcGradient (const Point<3> & point, Vec<3> & grad) const -{ - Point<2> p2d, projp; - double t; - Vec<2> tan, n; - - - p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep)); - t = crosssection.ProjectParam (p2d); - - projp = crosssection.Eval (t); - tan = crosssection.EvalPrime (t); - n(0) = tan(1); - n(1) = -tan(0); - - n /= n.Length(); - grad = n(0) * planee1 + n(1) * planee2; -} - - -void GeneralizedCylinder :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const -{ - Point<2> p2d, projp; - double t, dist, val; - Point<2> curvp; - Vec<2> curvpp; - Mat<2> h2d; - Mat<3,2> vmat; - int i, j, k, l; - - p2d = Point<2> (planee1 * (point - planep), planee2 * (point - planep)); - t = crosssection.ProjectParam (p2d); - - curvp = crosssection.CurvCircle (t); - curvpp = p2d-curvp; - dist = curvpp.Length(); - curvpp /= dist; - - h2d(1, 1) = (1 - curvpp(0) * curvpp(0) ) / dist; - h2d(1, 2) = h2d(2, 1) = (- curvpp(0) * curvpp(1) ) / dist; - h2d(2, 2) = (1 - curvpp(1) * curvpp(1) ) / dist; - - vmat(0,0) = planee1(0); - vmat(1,0) = planee1(1); - vmat(2,0) = planee1(2); - vmat(0,1) = planee2(0); - vmat(1,1) = planee2(1); - vmat(2,1) = planee2(2); - - for (i = 0; i < 3; i++) - for (j = 0; j < 3; j++) - { - val = 0; - for (k = 0; k < 2; k++) - for (l = 0; l < 2; l++) - val += vmat(i,k) * h2d(k,l) * vmat(j,l); - hesse(i,j) = val; - } -} - - -double GeneralizedCylinder :: HesseNorm () const -{ - return crosssection.MaxCurvature(); -} - -double GeneralizedCylinder :: MaxCurvatureLoc (const Point<3> & c, double rad) const -{ - Point<2> c2d = Point<2> (planee1 * (c - planep), planee2 * (c - planep)); - return crosssection.MaxCurvatureLoc(c2d, rad); -} - - - -Point<3> GeneralizedCylinder :: GetSurfacePoint () const -{ - Point<2> p2d; - p2d = crosssection.Eval(0); - return planep + p2d(0) * planee1 + p2d(1) * planee2; -} - -void GeneralizedCylinder :: Reduce (const BoxSphere<3> & box) -{ - Point<2> c2d = Point<2> (planee1 * (box.Center() - planep), - planee2 * (box.Center() - planep)); - crosssection.Reduce (c2d, box.Diam()/2); -} - -void GeneralizedCylinder :: UnReduce () -{ - crosssection.UnReduce (); -} - -void GeneralizedCylinder :: Print (ostream & str) const -{ - str << "Generalized Cylinder" << endl; - crosssection.Print (str); -} - -#ifdef MYGRAPH -void GeneralizedCylinder :: Plot (const class ROT3D & rot) const -{ - Point<2> p2d; - Point<3> p, oldp; - double t, tmin, tmax, dt; - - tmin = crosssection.MinParam(); - tmax = crosssection.MaxParam(); - dt = (tmax - tmin)/ 500; - - p2d = crosssection.Eval(tmin); - p = planep + p2d(0) * planee1 + p2d(1) * planee2; - - for (t = tmin; t <= tmax+dt; t += dt) - { - if (crosssection.SectionUsed (t)) - MySetColor (RED); - else - MySetColor (BLUE); - - oldp = p; - p2d = crosssection.Eval(t); - p = planep + p2d(0) * planee1 + p2d(1) * planee2; - MyLine3D (p, oldp, rot); - } - -} - -#endif -} diff --git a/contrib/Netgen/libsrc/csg/gencyl.hpp b/contrib/Netgen/libsrc/csg/gencyl.hpp deleted file mode 100644 index 424c867a9291fa6ad02547ef54eba5c0872d952f..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/gencyl.hpp +++ /dev/null @@ -1,64 +0,0 @@ -#ifndef FILE_GENCYL -#define FILE_GENCYL - -/**************************************************************************/ -/* File: gencyl.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 14. Oct. 96 */ -/**************************************************************************/ - -/* - - Generalized Cylinder - -*/ - - -/// -class GeneralizedCylinder : public Surface -{ - /// - ExplicitCurve2d & crosssection; - /// - Point<3> planep; - /// - Vec<3> planee1, planee2, planee3; - - /// Vec<3> ex, ey, ez; - Vec2d e2x, e2y; - /// - Point<3> cp; - -public: - /// - GeneralizedCylinder (ExplicitCurve2d & acrosssection, - Point<3> ap, Vec<3> ae1, Vec<3> ae2); - - /// - virtual void Project (Point<3> & p) const; - - /// - virtual int BoxInSolid (const BoxSphere<3> & box) const; - /// 0 .. no, 1 .. yes, 2 .. maybe - - virtual double CalcFunctionValue (const Point<3> & point) const; - /// - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - /// - virtual void CalcHesse (const Point<3> & point, Mat<3> & hesse) const; - /// - virtual double HesseNorm () const; - /// - virtual double MaxCurvatureLoc (const Point<3> & c, double rad) const; - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void Print (ostream & str) const; - - /// - virtual void Reduce (const BoxSphere<3> & box); - /// - virtual void UnReduce (); -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/genmesh.cpp b/contrib/Netgen/libsrc/csg/genmesh.cpp deleted file mode 100644 index c052624a42f7a2aa3c8b5365658cbf0089ab3d65..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/genmesh.cpp +++ /dev/null @@ -1,684 +0,0 @@ -#include <mystdlib.h> - - -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> -#include <meshing.hpp> - - -namespace netgen -{ - ARRAY<SpecialPoint> specpoints; - static ARRAY<MeshPoint> spoints; - -#define TCL_OK 0 -#define TCL_ERROR 1 - - - - static void FindPoints (CSGeometry & geom, Mesh & mesh) - { - PrintMessage (1, "Start Findpoints"); - - char * savetask = multithread.task; - multithread.task = "Find points"; - - for (int i = 0; i < geom.GetNUserPoints(); i++) - { - mesh.AddPoint (geom.GetUserPoint (i)); - mesh.AddLockedPoint (PointIndex (i+1)); - } - - SpecialPointCalculation spc; - - if (spoints.Size() == 0) - spc.CalcSpecialPoints (geom, spoints); - - PrintMessage (2, "Analyze spec points"); - spc.AnalyzeSpecialPoints (geom, spoints, specpoints); - - PrintMessage (5, "done"); - - (*testout) << specpoints.Size() << " special points:" << endl; - for (int i = 0; i < specpoints.Size(); i++) - specpoints[i].Print (*testout); - - /* - for (int i = 1; i <= geom.identifications.Size(); i++) - geom.identifications.Elem(i)->IdentifySpecialPoints (specpoints); - */ - multithread.task = savetask; - } - - - - - - - static void FindEdges (CSGeometry & geom, Mesh & mesh) - { - EdgeCalculation ec (geom, specpoints); - ec.Calc (mparam.maxh, mesh); - - for (int i = 0; i < geom.singedges.Size(); i++) - geom.singedges[i]->FindPointsOnEdge (mesh); - for (int i = 0; i < geom.singpoints.Size(); i++) - geom.singpoints[i]->FindPoints (mesh); - - for (int i = 1; i <= mesh.GetNSeg(); i++) - { - int ok = 0; - for (int k = 1; k <= mesh.GetNFD(); k++) - if (mesh.GetFaceDescriptor(k).SegmentFits (mesh.LineSegment(i))) - ok = k; - - if (!ok) - ok = mesh.AddFaceDescriptor (FaceDescriptor (mesh.LineSegment(i))); - - mesh.LineSegment(i).si = ok; - } - - for (int i = 0; i < geom.identifications.Size(); i++) - geom.identifications[i]->IdentifyPoints (mesh); - for (int i = 0; i < geom.identifications.Size(); i++) - geom.identifications[i]->IdentifyFaces (mesh); - - - - // find intersecting segments - PrintMessage (3, "Check intersecting edges"); - - if (!ec.point_on_edge_problem) - for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++) - for (SegmentIndex sj = 0; sj < si; sj++) - { - if (!mesh[si].seginfo || !mesh[sj].seginfo) continue; - if (mesh[mesh[si].p1].GetLayer() != mesh[mesh[sj].p2].GetLayer()) continue; - - Point<3> pi1 = mesh[mesh[si].p1]; - Point<3> pi2 = mesh[mesh[si].p2]; - Point<3> pj1 = mesh[mesh[sj].p1]; - Point<3> pj2 = mesh[mesh[sj].p2]; - Vec<3> vi = pi2 - pi1; - Vec<3> vj = pj2 - pj1; - - if (sqr (vi * vj) > (1-1e-6) * Abs2 (vi) * Abs2 (vj)) continue; - - // pi1 + vi t = pj1 + vj s - Mat<3,2> mat; - Vec<3> rhs; - Vec<2> sol; - - for (int j = 0; j < 3; j++) - { - mat(j,0) = vi(j); - mat(j,1) = -vj(j); - rhs(j) = pj1(j)-pi1(j); - } - - mat.Solve (rhs, sol); - - if (sol(0) > 1e-6 && sol(0) < 1-1e-6 && - sol(1) > 1e-6 && sol(1) < 1-1e-6 && - Abs (rhs - mat*sol) < 1e-6) - { - Point<3> ip = pi1 + sol(0) * vi; - cout << "Intersection at " << ip << endl; - - geom.AddUserPoint (ip); - spoints.Append (MeshPoint (ip, mesh[mesh[si].p1].GetLayer())); - mesh.AddPoint (ip); - } - } - } - - - - - - - static void MeshSurface (CSGeometry & geom, Mesh & mesh) - { - char * savetask = multithread.task; - multithread.task = "Surface meshing"; - - ARRAY<Segment> segments; - int noldp = mesh.GetNP(); - - double starttime = GetTime(); - - // find master faces from identified - ARRAY<int> masterface(mesh.GetNFD()); - for (int i = 1; i <= mesh.GetNFD(); i++) - masterface.Elem(i) = i; - - ARRAY<INDEX_2> fpairs; - bool changed; - do - { - changed = 0; - for (int i = 0; i < geom.identifications.Size(); i++) - { - geom.identifications[i]->GetIdentifiedFaces (fpairs); - - for (int j = 0; j < fpairs.Size(); j++) - { - if (masterface.Get(fpairs[j].I1()) < - masterface.Get(fpairs[j].I2())) - { - changed = 1; - masterface.Elem(fpairs[j].I2()) = - masterface.Elem(fpairs[j].I1()); - } - if (masterface.Get(fpairs[j].I2()) < - masterface.Get(fpairs[j].I1())) - { - changed = 1; - masterface.Elem(fpairs[j].I1()) = - masterface.Elem(fpairs[j].I2()); - } - } - } - } - while (changed); - - - int bccnt=0; - for (int k = 0; k < geom.GetNSurf(); k++) - bccnt = max2 (bccnt, geom.GetSurface(k)->GetBCProperty()); - - for (int k = 1; k <= mesh.GetNFD(); k++) - { - FaceDescriptor & fd = mesh.GetFaceDescriptor(k); - const Surface * surf = geom.GetSurface(fd.SurfNr()); - - if (fd.TLOSurface() && - geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetBCProp() > 0) - fd.SetBCProperty (geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetBCProp()); - else if (surf -> GetBCProperty() != -1) - fd.SetBCProperty (surf->GetBCProperty()); - else - { - bccnt++; - fd.SetBCProperty (bccnt); - } - - for (int l = 0; l < geom.bcmodifications.Size(); l++) - { - if (geom.GetSurfaceClassRepresentant (fd.SurfNr()) == - geom.GetSurfaceClassRepresentant (geom.bcmodifications[l].si) && - (fd.DomainIn() == geom.bcmodifications[l].tlonr+1 || - fd.DomainOut() == geom.bcmodifications[l].tlonr+1)) - { - fd.SetBCProperty (geom.bcmodifications[l].bcnr); - } - } - } - - - for (int j = 0; j < geom.singfaces.Size(); j++) - { - ARRAY<int> surfs; - geom.GetIndependentSurfaceIndices (geom.singfaces[j]->GetSolid(), - geom.BoundingBox(), surfs); - for (int k = 1; k <= mesh.GetNFD(); k++) - { - FaceDescriptor & fd = mesh.GetFaceDescriptor(k); - for (int l = 0; l < surfs.Size(); l++) - if (surfs[l] == fd.SurfNr()) - { - if (geom.singfaces[j]->GetDomainNr() == fd.DomainIn()) - fd.domin_singular = 1; - if (geom.singfaces[j]->GetDomainNr() == fd.DomainOut()) - fd.domout_singular = 1; - } - } - } - - - // assemble edge hash-table - mesh.CalcSurfacesOfNode(); - - for (int k = 1; k <= mesh.GetNFD(); k++) - { - multithread.percent = 100.0 * k / (mesh.GetNFD()+1e-10); - - if (masterface.Get(k) != k) - continue; - - FaceDescriptor & fd = mesh.GetFaceDescriptor(k); - - (*testout) << "Surface " << k << endl; - (*testout) << "Face Descriptor: " << fd << endl; - PrintMessage (1, "Surface ", k, " / ", mesh.GetNFD()); - - int oldnf = mesh.GetNSE(); - - const Surface * surf = - geom.GetSurface((mesh.GetFaceDescriptor(k).SurfNr())); - - - Meshing2Surfaces meshing(*surf, geom.BoundingBox()); - meshing.SetStartTime (starttime); - - for (PointIndex pi = PointIndex::BASE; pi < noldp+PointIndex::BASE; pi++) - meshing.AddPoint (mesh[pi], pi); - - segments.SetSize (0); - - for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++) - if (mesh[si].si == k) - segments.Append (mesh[si]); - - for (int i = 1; i <= geom.identifications.Size(); i++) - geom.identifications.Get(i)-> - BuildSurfaceElements(segments, mesh, surf); - - for (int si = 0; si < segments.Size(); si++) - { - PointGeomInfo gi; - gi.trignum = k; - meshing.AddBoundaryElement (segments[si].p1 + 1 - PointIndex::BASE, - segments[si].p2 + 1 - PointIndex::BASE, - gi, gi); - } - - double maxh = mparam.maxh; - if (fd.DomainIn() != 0) - { - const Solid * s1 = - geom.GetTopLevelObject(fd.DomainIn()-1) -> GetSolid(); - if (s1->GetMaxH() < maxh) - maxh = s1->GetMaxH(); - maxh = min2(maxh, geom.GetTopLevelObject(fd.DomainIn()-1)->GetMaxH()); - } - if (fd.DomainOut() != 0) - { - const Solid * s1 = - geom.GetTopLevelObject(fd.DomainOut()-1) -> GetSolid(); - if (s1->GetMaxH() < maxh) - maxh = s1->GetMaxH(); - maxh = min2(maxh, geom.GetTopLevelObject(fd.DomainOut()-1)->GetMaxH()); - } - if (fd.TLOSurface() != 0) - { - double hi = geom.GetTopLevelObject(fd.TLOSurface()-1) -> GetMaxH(); - if (hi < maxh) maxh = hi; - } - - (*testout) << "domin = " << fd.DomainIn() << ", domout = " << fd.DomainOut() - << ", tlo-surf = " << fd.TLOSurface() - << " mpram.maxh = " << mparam.maxh << ", maxh = " << maxh << endl; - - mparam.checkoverlap = 0; - - MESHING2_RESULT res = - meshing.GenerateMesh (mesh, maxh, k); - - if (res != MESHING2_OK) - { - PrintError ("Problem in Surface mesh generation"); - throw NgException ("Problem in Surface mesh generation"); - } - - if (multithread.terminate) return; - - for (int i = oldnf+1; i <= mesh.GetNSE(); i++) - mesh.SurfaceElement(i).SetIndex (k); - - - // mesh.CalcSurfacesOfNode(); - if (segments.Size()) - { - // surface was meshed, not copied - PrintMessage (2, "Optimize Surface"); - for (int i = 1; i <= mparam.optsteps2d; i++) - { - if (multithread.terminate) return; - - { - MeshOptimize2dSurfaces meshopt(geom); - meshopt.SetFaceIndex (k); - meshopt.SetImproveEdges (0); - meshopt.SetMetricWeight (0.2); - meshopt.SetWriteStatus (0); - - meshopt.EdgeSwapping (mesh, (i > mparam.optsteps2d/2)); - } - - if (multithread.terminate) return; - { - // mesh.CalcSurfacesOfNode(); - - MeshOptimize2dSurfaces meshopt(geom); - meshopt.SetFaceIndex (k); - meshopt.SetImproveEdges (0); - meshopt.SetMetricWeight (0.2); - meshopt.SetWriteStatus (0); - - meshopt.ImproveMesh (mesh); - } - - { - MeshOptimize2dSurfaces meshopt(geom); - meshopt.SetFaceIndex (k); - meshopt.SetImproveEdges (0); - meshopt.SetMetricWeight (0.2); - meshopt.SetWriteStatus (0); - - meshopt.CombineImprove (mesh); - // mesh.CalcSurfacesOfNode(); - } - - if (multithread.terminate) return; - { - MeshOptimize2dSurfaces meshopt(geom); - meshopt.SetFaceIndex (k); - meshopt.SetImproveEdges (0); - meshopt.SetMetricWeight (0.2); - meshopt.SetWriteStatus (0); - - meshopt.ImproveMesh (mesh); - } - } - } - - - PrintMessage (3, (mesh.GetNSE() - oldnf), " elements, ", mesh.GetNP(), " points"); - -#ifdef OPENGL - extern void Render(); - Render(); -#endif - } - - mesh.Compress(); - - do - { - changed = 0; - for (int k = 1; k <= mesh.GetNFD(); k++) - { - multithread.percent = 100.0 * k / (mesh.GetNFD()+1e-10); - - if (masterface.Get(k) == k) - continue; - - FaceDescriptor & fd = mesh.GetFaceDescriptor(k); - - (*testout) << "Surface " << k << endl; - (*testout) << "Face Descriptor: " << fd << endl; - PrintMessage (2, "Surface ", k); - - int oldnf = mesh.GetNSE(); - - const Surface * surf = - geom.GetSurface((mesh.GetFaceDescriptor(k).SurfNr())); - - /* - if (surf -> GetBCProperty() != -1) - fd.SetBCProperty (surf->GetBCProperty()); - else - { - bccnt++; - fd.SetBCProperty (bccnt); - } - */ - - segments.SetSize (0); - for (int i = 1; i <= mesh.GetNSeg(); i++) - { - Segment * seg = &mesh.LineSegment(i); - if (seg->si == k) - segments.Append (*seg); - } - - for (int i = 1; i <= geom.identifications.Size(); i++) - { - geom.identifications.Elem(i)->GetIdentifiedFaces (fpairs); - int found = 0; - for (int j = 1; j <= fpairs.Size(); j++) - if (fpairs.Get(j).I1() == k || fpairs.Get(j).I2() == k) - found = 1; - - if (!found) - continue; - - geom.identifications.Get(i)-> - BuildSurfaceElements(segments, mesh, surf); - if (!segments.Size()) - break; - } - - - if (multithread.terminate) return; - - for (int i = oldnf+1; i <= mesh.GetNSE(); i++) - mesh.SurfaceElement(i).SetIndex (k); - - - if (!segments.Size()) - { - masterface.Elem(k) = k; - changed = 1; - } - - PrintMessage (3, (mesh.GetNSE() - oldnf), " elements, ", mesh.GetNP(), " points"); - } - -#ifdef OPENGL - extern void Render(); - Render(); -#endif - } - while (changed); - - mesh.SplitSeparatedFaces(); - mesh.CalcSurfacesOfNode(); - - multithread.task = savetask; - } - - - - - - - - int GenerateMesh (CSGeometry & geom, - Mesh *& mesh, - int perfstepsstart, int perfstepsend, - const char * optstr) - { - - if (mesh && mesh->GetNSE() && - !geom.GetNSolids()) - { - if (perfstepsstart < MESHCONST_MESHVOLUME) - perfstepsstart = MESHCONST_MESHVOLUME; - } - - - - if (perfstepsstart <= MESHCONST_ANALYSE) - { - delete mesh; - mesh = new Mesh(); - - mesh->SetGlobalH (mparam.maxh); - - ARRAY<double> maxhdom(geom.GetNTopLevelObjects()); - for (int i = 0; i < maxhdom.Size(); i++) - maxhdom[i] = geom.GetTopLevelObject(i)->GetMaxH(); - - mesh->SetMaxHDomain (maxhdom); - - if (mparam.uselocalh) - { - double maxsize = geom.MaxSize(); - mesh->SetLocalH (Point<3>(-maxsize, -maxsize, -maxsize), - Point<3>(maxsize, maxsize, maxsize), - mparam.grading); - - mesh -> LoadLocalMeshSize (mparam.meshsizefilename); - } - - spoints.SetSize(0); - FindPoints (geom, *mesh); - - PrintMessage (5, "find points done"); - -#ifdef LOG_STREAM - (*logout) << "Special points found" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl << endl; -#endif - } - - - if (multithread.terminate || perfstepsend <= MESHCONST_ANALYSE) - return TCL_OK; - - - if (perfstepsstart <= MESHCONST_MESHEDGES) - { - FindEdges (geom, *mesh); - if (multithread.terminate) return TCL_OK; -#ifdef LOG_STREAM - (*logout) << "Edges meshed" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl; -#endif - - - if (multithread.terminate) - return TCL_OK; - - if (mparam.uselocalh) - { - mesh->CalcLocalH(); - mesh->DeleteMesh(); - - FindPoints (geom, *mesh); - if (multithread.terminate) return TCL_OK; - FindEdges (geom, *mesh); - if (multithread.terminate) return TCL_OK; - - mesh->DeleteMesh(); - - FindPoints (geom, *mesh); - if (multithread.terminate) return TCL_OK; - FindEdges (geom, *mesh); - if (multithread.terminate) return TCL_OK; - } - } - - if (multithread.terminate || perfstepsend <= MESHCONST_MESHEDGES) - return TCL_OK; - - - if (perfstepsstart <= MESHCONST_MESHSURFACE) - { - MeshSurface (geom, *mesh); - if (multithread.terminate) return TCL_OK; - -#ifdef LOG_STREAM - (*logout) << "Surfaces meshed" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl; -#endif - - if (mparam.uselocalh && 0) - { - mesh->CalcLocalH(); - mesh->DeleteMesh(); - - FindPoints (geom, *mesh); - if (multithread.terminate) return TCL_OK; - FindEdges (geom, *mesh); - if (multithread.terminate) return TCL_OK; - - MeshSurface (geom, *mesh); - if (multithread.terminate) return TCL_OK; - } - -#ifdef LOG_STREAM - (*logout) << "Surfaces remeshed" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl; -#endif - -#ifdef STAT_STREAM - (*statout) << mesh->GetNSeg() << " & " - << mesh->GetNSE() << " & - &" - << GetTime() << " & " << endl; -#endif - - MeshQuality2d (*mesh); - mesh->CalcSurfacesOfNode(); - } - - if (multithread.terminate || perfstepsend <= MESHCONST_OPTSURFACE) - return TCL_OK; - - - if (perfstepsstart <= MESHCONST_MESHVOLUME) - { - multithread.task = "Volume meshing"; - - MESHING3_RESULT res = - MeshVolume (mparam, *mesh); - - if (res != MESHING3_OK) return TCL_ERROR; - - if (multithread.terminate) return TCL_OK; - - RemoveIllegalElements (*mesh); - if (multithread.terminate) return TCL_OK; - - MeshQuality3d (*mesh); - - for (int i = 0; i < geom.GetNTopLevelObjects(); i++) - mesh->SetMaterial (i+1, geom.GetTopLevelObject(i)->GetMaterial().c_str()); - - -#ifdef STAT_STREAM - (*statout) << GetTime() << " & "; -#endif - -#ifdef LOG_STREAM - (*logout) << "Volume meshed" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl; -#endif - } - - if (multithread.terminate || perfstepsend <= MESHCONST_MESHVOLUME) - return TCL_OK; - - - if (perfstepsstart <= MESHCONST_OPTVOLUME) - { - multithread.task = "Volume optimization"; - - OptimizeVolume (mparam, *mesh); - if (multithread.terminate) return TCL_OK; - -#ifdef STAT_STREAM - (*statout) << GetTime() << " & " - << mesh->GetNE() << " & " - << mesh->GetNP() << " " << '\\' << '\\' << " \\" << "hline" << endl; -#endif - -#ifdef LOG_STREAM - (*logout) << "Volume optimized" << endl - << "time = " << GetTime() << " sec" << endl - << "points: " << mesh->GetNP() << endl; -#endif - } - - return TCL_OK; - } -} diff --git a/contrib/Netgen/libsrc/csg/geometry.cpp b/contrib/Netgen/libsrc/csg/geometry.cpp deleted file mode 100644 index 14806ee9cb3c0769f0c3bb58b35e9e26772959a5..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/geometry.cpp +++ /dev/null @@ -1,1792 +0,0 @@ -/* A Bison parser, made from geometry.yy - by GNU bison 1.35. */ - -#define YYBISON 1 /* Identify Bison output. */ - -# define NUM 257 -# define TOK_SOLID 258 -# define TOK_RECO 259 -# define TOK_TLO 260 -# define TOK_BOUNDINGBOX 261 -# define IDENT 262 -# define IDENTSOLID 263 -# define TOK_SPHERE 264 -# define TOK_CYLINDER 265 -# define TOK_CONE 266 -# define TOK_PLAIN 267 -# define TOK_TUBE 268 -# define TOK_GENCYL 269 -# define TOK_ORTHOBRICK 270 -# define TOK_POLYHEDRON 271 -# define TOK_REVOLUTION 272 -# define TOK_OR 273 -# define TOK_AND 274 -# define TOK_NOT 275 -# define TOK_TRANSLATE 276 -# define TOK_MULTITRANSLATE 277 -# define TOK_ROTATE 278 -# define TOK_MULTIROTATE 279 -# define TOK_SINGULAR 280 -# define TOK_EDGE 281 -# define TOK_POINT 282 -# define TOK_IDENTIFY 283 -# define TOK_CLOSESURFACES 284 -# define TOK_CLOSEEDGES 285 -# define TOK_PERIODIC 286 -# define TOK_BOUNDARYCONDITION 287 - -#line 1 "geometry.yy" - -//define YYDEBUG 1 - -extern int yylex (); - -#include <mystdlib.h> - -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ -netgen::CSGeometry * parsegeom; -} - -using namespace netgen; - -// extern ARRAY<Surface*> surfaces; -// extern SYMBOLTABLE<Solid*> solids; - - -int yyerror (char * s); -splinetube * tube; -spline3d * middlecurve; -Point<3> splinep1; -BSplineCurve2d *bspline; -Flags parseflags; -extern int linenum; -ARRAY<double> doublearray; -ARRAY<char*> stringarray; - -Polyhedra * polyhedron; -// Revolution * revolution; - -#line 38 "geometry.yy" -#ifndef YYSTYPE -typedef union { -double val; -char * chptr; -Solid * solidtype; -} yystype; -# define YYSTYPE yystype -# define YYSTYPE_IS_TRIVIAL 1 -#endif -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif - - - -#define YYFINAL 260 -#define YYFLAG -32768 -#define YYNTBASE 42 - -/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 287 ? yytranslate[x] : 67) - -/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ -static const char yytranslate[] = -{ - 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 36, 37, 2, 2, 38, 39, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 34, - 2, 35, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 40, 2, 41, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33 -}; - -#if YYDEBUG -static const short yyprhs[] = -{ - 0, 0, 1, 6, 7, 11, 12, 19, 21, 23, - 27, 31, 34, 38, 49, 66, 85, 100, 115, 116, - 125, 136, 149, 166, 185, 189, 191, 195, 197, 203, - 209, 217, 221, 223, 227, 229, 233, 245, 246, 252, - 253, 254, 261, 262, 266, 272, 279, 285, 291, 296, - 300, 305, 320, 329, 334, 335, 338, 339, 342, 345, - 350, 355, 360, 365, 366, 371, 373, 377, 378, 383, - 385, 389, 391 -}; -static const short yyrhs[] = -{ - -1, 43, 5, 44, 54, 0, 0, 44, 45, 34, - 0, 0, 4, 8, 35, 47, 46, 56, 0, 48, - 0, 9, 0, 47, 19, 47, 0, 47, 20, 47, - 0, 21, 47, 0, 36, 47, 37, 0, 10, 36, - 3, 38, 3, 38, 3, 34, 3, 37, 0, 11, - 36, 3, 38, 3, 38, 3, 34, 3, 38, 3, - 38, 3, 34, 3, 37, 0, 12, 36, 3, 38, - 3, 38, 3, 34, 3, 34, 3, 38, 3, 38, - 3, 34, 3, 37, 0, 13, 36, 3, 38, 3, - 38, 3, 34, 3, 38, 3, 38, 3, 37, 0, - 16, 36, 3, 38, 3, 38, 3, 34, 3, 38, - 3, 38, 3, 37, 0, 0, 17, 36, 49, 50, - 34, 34, 51, 37, 0, 22, 36, 3, 38, 3, - 38, 3, 34, 47, 37, 0, 23, 36, 3, 38, - 3, 38, 3, 34, 3, 34, 47, 37, 0, 24, - 36, 3, 38, 3, 38, 3, 34, 3, 38, 3, - 38, 3, 34, 47, 37, 0, 25, 36, 3, 38, - 3, 38, 3, 34, 3, 38, 3, 38, 3, 34, - 3, 34, 47, 37, 0, 50, 34, 52, 0, 52, - 0, 51, 34, 53, 0, 53, 0, 3, 38, 3, - 38, 3, 0, 3, 38, 3, 38, 3, 0, 3, - 38, 3, 38, 3, 38, 3, 0, 67, 34, 68, - 0, 68, 0, 3, 38, 3, 0, 70, 0, 70, - 38, 69, 0, 3, 38, 3, 38, 3, 38, 3, - 38, 3, 38, 3, 0, 0, 3, 38, 3, 72, - 73, 0, 0, 0, 38, 3, 38, 3, 74, 73, - 0, 0, 54, 55, 34, 0, 26, 27, 3, 9, - 9, 0, 26, 28, 3, 9, 9, 9, 0, 29, - 30, 9, 9, 56, 0, 29, 31, 9, 9, 9, - 0, 29, 32, 9, 9, 0, 6, 9, 56, 0, - 6, 9, 9, 56, 0, 7, 36, 3, 38, 3, - 38, 3, 34, 3, 38, 3, 38, 3, 37, 0, - 28, 36, 3, 38, 3, 38, 3, 37, 0, 33, - 9, 9, 3, 0, 0, 57, 58, 0, 0, 59, - 58, 0, 39, 66, 0, 39, 66, 35, 66, 0, - 39, 66, 35, 3, 0, 39, 66, 35, 60, 0, - 39, 66, 35, 63, 0, 0, 40, 61, 62, 41, - 0, 3, 0, 62, 38, 3, 0, 0, 40, 64, - 65, 41, 0, 66, 0, 65, 38, 66, 0, 8, - 0, 9, 0 -}; - -#endif - -#if YYDEBUG -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const short yyrline[] = -{ - 0, 61, 61, 79, 81, 84, 84, 94, 96, 97, - 98, 99, 100, 103, 112, 123, 135, 144, 158, 158, - 197, 206, 222, 231, 285, 287, 289, 291, 293, 300, - 306, 315, 317, 319, 331, 333, 335, 345, 345, 354, - 356, 356, 372, 374, 377, 385, 394, 409, 425, 439, - 453, 470, 477, 482, 511, 511, 516, 518, 521, 524, - 526, 528, 530, 535, 535, 540, 542, 545, 545, 556, - 563, 574, 576 -}; -#endif - - -#if (YYDEBUG) || defined YYERROR_VERBOSE - -/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */ -static const char *const yytname[] = -{ - "$", "error", "$undefined.", "NUM", "TOK_SOLID", "TOK_RECO", "TOK_TLO", - "TOK_BOUNDINGBOX", "IDENT", "IDENTSOLID", "TOK_SPHERE", "TOK_CYLINDER", - "TOK_CONE", "TOK_PLAIN", "TOK_TUBE", "TOK_GENCYL", "TOK_ORTHOBRICK", - "TOK_POLYHEDRON", "TOK_REVOLUTION", "TOK_OR", "TOK_AND", "TOK_NOT", - "TOK_TRANSLATE", "TOK_MULTITRANSLATE", "TOK_ROTATE", "TOK_MULTIROTATE", - "TOK_SINGULAR", "TOK_EDGE", "TOK_POINT", "TOK_IDENTIFY", - "TOK_CLOSESURFACES", "TOK_CLOSEEDGES", "TOK_PERIODIC", - "TOK_BOUNDARYCONDITION", "';'", "'='", "'('", "')'", "','", "'-'", - "'['", "']'", "input", "@1", "recsoliddef", "soliddef", "@2", "solid", - "solidprimitive", "@3", "polyhedronpoints", "polyhedronfaces", - "polyhedronpoint", "polyhedronface", "recadddef", "adddef", "flaglist", - "@6", "recflaglist", "flag", "numlistbrack", "@7", "numlist", - "stringlistbrack", "@8", "stringlist", "anyident", 0 -}; -#endif - -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const short yyr1[] = -{ - 0, 43, 42, 44, 44, 46, 45, 47, 47, 47, - 47, 47, 47, 48, 48, 48, 48, 48, 49, 48, - 48, 48, 48, 48, 50, 50, 51, 51, 52, 53, - 53, 67, 67, 68, 69, 69, 70, 72, 71, 73, - 74, 73, 54, 54, 55, 55, 55, 55, 55, 55, - 55, 55, 55, 55, 57, 56, 58, 58, 59, 59, - 59, 59, 59, 61, 60, 62, 62, 64, 63, 65, - 65, 66, 66 -}; - -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const short yyr2[] = -{ - 0, 0, 4, 0, 3, 0, 6, 1, 1, 3, - 3, 2, 3, 10, 16, 18, 14, 14, 0, 8, - 10, 12, 16, 18, 3, 1, 3, 1, 5, 5, - 7, 3, 1, 3, 1, 3, 11, 0, 5, 0, - 0, 6, 0, 3, 5, 6, 5, 5, 4, 3, - 4, 14, 8, 4, 0, 2, 0, 2, 2, 4, - 4, 4, 4, 0, 4, 1, 3, 0, 4, 1, - 3, 1, 1 -}; - -/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. */ -static const short yydefact[] = -{ - 1, 0, 3, 42, 0, 0, 2, 0, 4, 0, - 0, 0, 0, 0, 0, 0, 0, 54, 0, 0, - 0, 0, 0, 0, 0, 0, 43, 8, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 5, 7, 54, 49, 56, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 18, 11, - 0, 0, 0, 0, 0, 0, 0, 54, 50, 0, - 55, 56, 0, 0, 0, 0, 54, 0, 48, 53, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 12, 9, 10, 6, 71, 72, 58, 57, 0, 44, - 0, 0, 46, 47, 0, 0, 0, 0, 0, 0, - 0, 25, 0, 0, 0, 0, 0, 0, 45, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 60, 67, 61, 62, 59, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, - 0, 0, 0, 52, 0, 0, 0, 0, 0, 0, - 0, 0, 27, 0, 0, 0, 0, 65, 0, 0, - 69, 0, 0, 0, 0, 0, 0, 28, 0, 0, - 19, 0, 0, 0, 0, 0, 64, 0, 68, 0, - 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, - 0, 66, 70, 0, 13, 0, 0, 0, 0, 0, - 20, 0, 0, 0, 0, 0, 0, 0, 0, 29, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, - 0, 0, 51, 0, 0, 0, 0, 30, 0, 0, - 0, 0, 16, 17, 0, 0, 0, 0, 0, 0, - 14, 0, 22, 0, 0, 0, 15, 23, 0, 0, - 0 -}; - -static const short yydefgoto[] = -{ - 258, 1, 3, 5, 67, 40, 41, 85, 110, 161, - 111, 162, 6, 15, 43, 44, 70, 71, 133, 150, - 168, 134, 151, 169, 96 -}; - -static const short yypact[] = -{ - -32768, 5,-32768, 18, 21, 7, 14, 11,-32768, 52, - 35, 36, 39, 28, 56, 42, 2, 58, 66, 74, - 75, 76, 71, 72, 73, 77,-32768,-32768, 48, 49, - 51, 53, 55, 57, 2, 59, 60, 61, 62, 2, - 54,-32768,-32768,-32768, 44, 50, 81, 83, 63, 85, - 90, 91, 99, 100, 101, 102, 103, 104,-32768,-32768, - 105, 106, 107, 108, -3, 2, 2,-32768,-32768, 47, - -32768, 44, 109, 110, 111, 112,-32768, 113,-32768,-32768, - 78, 79, 80, 86, 87, 118, 88, 89, 92, 93, - -32768,-32768,-32768,-32768,-32768,-32768, 94,-32768, 95,-32768, - 114, 96,-32768,-32768, 125, 129, 132, 133, 134, 115, - 116,-32768, 135, 136, 137, 138, -1, 139,-32768, 140, - 117, 119, 120, 121, 122, 141, 1, 123, 124, 126, - 127,-32768, 142,-32768,-32768,-32768, 144, 130, 143, 145, - 146, 148, 149, 128, 151,-32768, 153, 160, 165, 166, - 167, 47, 168,-32768, 147, 150, 152, 154, 155, 169, - 156, -28,-32768, 157, 158, 159, 161,-32768, -8, 16, - -32768, 162, 170, 171, 172, 173, 176,-32768, 177, 151, - -32768, 2, 179, 180, 182, 184,-32768, 47,-32768, 187, - 164, 174, 163, 175, 178, 183,-32768, 25, 181, 185, - 186,-32768,-32768, 188,-32768, 193, 195, 196, 199, 200, - -32768, 2, 201, 202, 203, 189, 190, 191, 192, 194, - 29, 197, 198, 204, 205, 206, 208, 211, 214,-32768, - 215, 217,-32768, 209, 207, 210, 212,-32768, 216, 218, - 219, 222,-32768,-32768, 2, 228, 220, 221, 31, 224, - -32768, 230,-32768, 2, 223, 33,-32768,-32768, 234, 237, - -32768 -}; - -static const short yypgoto[] = -{ - -32768,-32768,-32768,-32768,-32768, -34,-32768,-32768,-32768,-32768, - -13, -65,-32768,-32768, -39,-32768, 213,-32768,-32768,-32768, - -32768,-32768,-32768,-32768, -115 -}; - - -#define YYLAST 284 - - -static const short yytable[] = -{ - 59, 135, 131, 68, 109, 64, 179, 94, 95, 180, - 2, 27, 28, 29, 30, 31, 65, 66, 32, 33, - 9, 10, 4, 34, 35, 36, 37, 38, 93, 7, - 185, 91, 92, 186, 90, 144, 170, 102, 39, 132, - 11, 8, 12, 13, 65, 66, 16, 14, 65, 66, - 65, 66, 65, 66, 187, 94, 95, 188, 22, 23, - 24, 17, 210, 19, 20, 25, 229, 42, 252, 45, - 257, 18, 202, 65, 66, 21, 26, 46, 47, 48, - 49, 50, 51, 69, 53, 54, 52, 55, 72, 56, - 73, 57, 74, 58, 76, 60, 61, 62, 63, 77, - 78, 75, 79, 80, 81, 82, 83, 84, 86, 87, - 88, 89, 98, 145, 196, 101, 104, 105, 106, 99, - 100, 109, 103, 118, 107, 108, 112, 113, 120, 116, - 114, 115, 121, 117, 119, 122, 123, 124, 127, 128, - 129, 130, 136, 137, 143, -63, 154, 197, 155, 156, - 126, 157, 158, 125, 160, 138, 163, 139, 140, 141, - 142, 146, 147, 164, 148, 149, 159, 153, 165, 166, - 167, 171, 177, 190, 191, 192, 193, 220, 152, 194, - 195, 172, 198, 199, 173, 200, 174, 201, 175, 176, - 203, 181, 182, 183, 178, 184, 215, 206, 216, 217, - 189, 204, 218, 219, 221, 222, 223, 0, 233, 234, - 248, 235, 205, 207, 236, 211, 208, 237, 238, 255, - 239, 209, 246, 212, 213, 247, 214, 224, 225, 226, - 227, 249, 228, 254, 259, 230, 231, 260, 0, 0, - 0, 232, 0, 240, 0, 241, 0, 242, 0, 243, - 244, 0, 245, 0, 0, 251, 0, 250, 253, 0, - 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 97 -}; - -static const short yycheck[] = -{ - 34, 116, 3, 42, 3, 39, 34, 8, 9, 37, - 5, 9, 10, 11, 12, 13, 19, 20, 16, 17, - 6, 7, 4, 21, 22, 23, 24, 25, 67, 8, - 38, 65, 66, 41, 37, 34, 151, 76, 36, 40, - 26, 34, 28, 29, 19, 20, 35, 33, 19, 20, - 19, 20, 19, 20, 38, 8, 9, 41, 30, 31, - 32, 9, 37, 27, 28, 9, 37, 9, 37, 3, - 37, 36, 187, 19, 20, 36, 34, 3, 3, 3, - 9, 9, 9, 39, 36, 36, 9, 36, 38, 36, - 9, 36, 9, 36, 9, 36, 36, 36, 36, 9, - 9, 38, 3, 3, 3, 3, 3, 3, 3, 3, - 3, 3, 3, 126, 179, 3, 38, 38, 38, 9, - 9, 3, 9, 9, 38, 38, 38, 38, 3, 35, - 38, 38, 3, 38, 38, 3, 3, 3, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 181, 3, 3, - 34, 3, 3, 38, 3, 38, 3, 38, 38, 38, - 38, 38, 38, 3, 38, 38, 38, 37, 3, 3, - 3, 3, 3, 3, 3, 3, 3, 211, 34, 3, - 3, 34, 3, 3, 34, 3, 34, 3, 34, 34, - 3, 34, 34, 34, 38, 34, 3, 34, 3, 3, - 38, 37, 3, 3, 3, 3, 3, -1, 3, 3, - 244, 3, 38, 38, 3, 34, 38, 3, 3, 253, - 3, 38, 3, 38, 38, 3, 38, 38, 38, 38, - 38, 3, 38, 3, 0, 38, 38, 0, -1, -1, - -1, 37, -1, 34, -1, 38, -1, 37, -1, 37, - 34, -1, 34, -1, -1, 34, -1, 37, 34, -1, - 37, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, 71 -}; -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison/bison.simple" - -/* Skeleton output parser for bison, - - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software - Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser when - the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -/* All symbols defined below should begin with yy or YY, to avoid - infringing on user name space. This should be done even for local - variables, as they might otherwise be expanded by user macros. - There are some unavoidable exceptions within include files to - define necessary library symbols; they are noted "INFRINGES ON - USER NAME SPACE" below. */ - -#ifndef YYPARSE_RETURN_TYPE -#define YYPARSE_RETURN_TYPE int -#endif - -#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE) - -/* The parser invokes alloca or malloc; define the necessary symbols. */ - -# if YYSTACK_USE_ALLOCA -# define YYSTACK_ALLOC alloca -# else -# ifndef YYSTACK_USE_ALLOCA -# if defined (alloca) || defined (_ALLOCA_H) -# define YYSTACK_ALLOC alloca -# else -# ifdef __GNUC__ -# define YYSTACK_ALLOC __builtin_alloca -# endif -# endif -# endif -# endif - -# ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) -# else -# if defined (__STDC__) || defined (__cplusplus) -# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -# define YYSTACK_ALLOC malloc -# define YYSTACK_FREE free -# endif -#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */ - - -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || ((YYLTYPE_IS_TRIVIAL || ! YYLSP_NEEDED) && YYSTYPE_IS_TRIVIAL))) - -/* A type that is properly aligned for any stack member. */ -union yyalloc -{ - short yyss; - YYSTYPE yyvs; -# if YYLSP_NEEDED - YYLTYPE yyls; -# endif -}; - -/* The size of the maximum gap between one aligned stack and the next. */ -# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1) - -/* The size of an array large to enough to hold all stacks, each with - N elements. */ -# if YYLSP_NEEDED -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ - + 2 * YYSTACK_GAP_MAX) -# else -# define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ - + YYSTACK_GAP_MAX) -# endif - -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - register YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (0) -# endif -# endif - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack, Stack, yysize); \ - Stack = &yyptr->Stack; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (0) - -#endif - - -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ -#endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t -#endif -#if ! defined (YYSIZE_T) -# if defined (__STDC__) || defined (__cplusplus) -# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t -# endif -#endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int -#endif - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror ("syntax error: cannot back up"); \ - YYERROR; \ - } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Compute the default location (before the actions - are run). - - When YYLLOC_DEFAULT is run, CURRENT is set the location of the - first token. By default, to implement support for ranges, extend - its range to the last symbol. */ - -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - Current.last_line = Rhs[N].last_line; \ - Current.last_column = Rhs[N].last_column; -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#if YYPURE -# if YYLSP_NEEDED -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval, &yylloc) -# endif -# else /* !YYLSP_NEEDED */ -# ifdef YYLEX_PARAM -# define YYLEX yylex (&yylval, YYLEX_PARAM) -# else -# define YYLEX yylex (&yylval) -# endif -# endif /* !YYLSP_NEEDED */ -#else /* !YYPURE */ -# define YYLEX yylex () -#endif /* !YYPURE */ - - -/* Enable debugging if requested. */ -#if YYDEBUG - -# ifndef YYFPRINTF -# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ -# define YYFPRINTF fprintf -# endif - -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (0) -/* Nonzero means print parse trace. It is left uninitialized so that - multiple parsers can coexist. */ -int yydebug; -#else /* !YYDEBUG */ -# define YYDPRINTF(Args) -#endif /* !YYDEBUG */ - -/* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH -# define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only - if the built-in stack extension method is used). - - Do not make this value too large; the results are undefined if - SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) - evaluated with infinite-precision integer arithmetic. */ - -#if YYMAXDEPTH == 0 -# undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -# define YYMAXDEPTH 10000 -#endif - -#ifdef YYERROR_VERBOSE - -# ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) -# define yystrlen strlen -# else -/* Return the length of YYSTR. */ -static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) -yystrlen (const char *yystr) -# else -yystrlen (yystr) - const char *yystr; -# endif -{ - register const char *yys = yystr; - - while (*yys++ != '\0') - continue; - - return yys - yystr - 1; -} -# endif -# endif - -# ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) -# define yystpcpy stpcpy -# else -/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in - YYDEST. */ -static char * -# if defined (__STDC__) || defined (__cplusplus) -yystpcpy (char *yydest, const char *yysrc) -# else -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif -{ - register char *yyd = yydest; - register const char *yys = yysrc; - - while ((*yyd++ = *yys++) != '\0') - continue; - - return yyd - 1; -} -# endif -# endif -#endif - -#line 319 "/usr/share/bison/bison.simple" - - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -# define YYPARSE_PARAM_DECL -# else -# define YYPARSE_PARAM_ARG YYPARSE_PARAM -# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -# endif -#else /* !YYPARSE_PARAM */ -# define YYPARSE_PARAM_ARG -# define YYPARSE_PARAM_DECL -#endif /* !YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -# ifdef YYPARSE_PARAM -YYPARSE_RETURN_TYPE yyparse (void *); -# else -YYPARSE_RETURN_TYPE yyparse (void); -# endif -#endif - -/* YY_DECL_VARIABLES -- depending whether we use a pure parser, - variables are global, or local to YYPARSE. */ - -#define YY_DECL_NON_LSP_VARIABLES \ -/* The lookahead symbol. */ \ -int yychar; \ - \ -/* The semantic value of the lookahead symbol. */ \ -YYSTYPE yylval; \ - \ -/* Number of parse errors so far. */ \ -int yynerrs; - -#if YYLSP_NEEDED -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES \ - \ -/* Location data for the lookahead symbol. */ \ -YYLTYPE yylloc; -#else -# define YY_DECL_VARIABLES \ -YY_DECL_NON_LSP_VARIABLES -#endif - - -/* If nonreentrant, generate the variables here. */ - -#if !YYPURE -YY_DECL_VARIABLES -#endif /* !YYPURE */ - -YYPARSE_RETURN_TYPE -yyparse (YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - /* If reentrant, generate the variables here. */ -#if YYPURE - YY_DECL_VARIABLES -#endif /* !YYPURE */ - - register int yystate; - register int yyn; - int yyresult; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - /* Lookahead token as an internal (translated) token number. */ - int yychar1 = 0; - - /* Three stacks and their tools: - `yyss': related to states, - `yyvs': related to semantic values, - `yyls': related to locations. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - short yyssa[YYINITDEPTH]; - short *yyss = yyssa; - register short *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs = yyvsa; - register YYSTYPE *yyvsp; - -#if YYLSP_NEEDED - /* The location stack. */ - YYLTYPE yylsa[YYINITDEPTH]; - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; -#endif - -#if YYLSP_NEEDED -# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -# define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - YYSIZE_T yystacksize = YYINITDEPTH; - - - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; -#if YYLSP_NEEDED - YYLTYPE yyloc; -#endif - - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; - - YYDPRINTF ((stderr, "Starting parse\n")); - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss; - yyvsp = yyvs; -#if YYLSP_NEEDED - yylsp = yyls; -#endif - goto yysetstate; - -/*------------------------------------------------------------. -| yynewstate -- Push a new state, which is found in yystate. | -`------------------------------------------------------------*/ - yynewstate: - /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ - yyssp++; - - yysetstate: - *yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = yyssp - yyss + 1; - -#ifdef yyoverflow - { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; - - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. */ -# if YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yyls1, yysize * sizeof (*yylsp), - &yystacksize); - yyls = yyls1; -# else - yyoverflow ("parser stack overflow", - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); -# endif - yyss = yyss1; - yyvs = yyvs1; - } -#else /* no yyoverflow */ -# ifndef YYSTACK_RELOCATE - goto yyoverflowlab; -# else - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - goto yyoverflowlab; - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; - - { - short *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyoverflowlab; - YYSTACK_RELOCATE (yyss); - YYSTACK_RELOCATE (yyvs); -# if YYLSP_NEEDED - YYSTACK_RELOCATE (yyls); -# endif -# undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); - } -# endif -#endif /* no yyoverflow */ - - yyssp = yyss + yysize - 1; - yyvsp = yyvs + yysize - 1; -#if YYLSP_NEEDED - yylsp = yyls + yysize - 1; -#endif - - YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - - goto yybackup; - - -/*-----------. -| yybackup. | -`-----------*/ -yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { - YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - - YYDPRINTF ((stderr, "Now at end of input.\n")); - } - else - { - yychar1 = YYTRANSLATE (yychar); - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables - which are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - YYFPRINTF (stderr, "Next token is %d (%s", - yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise - meaning of a token, for further debugging info. */ -# ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -# endif - YYFPRINTF (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - YYDPRINTF ((stderr, "Shifting token %d (%s), ", - yychar, yytname[yychar1])); - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; - goto yynewstate; - - -/*-----------------------------------------------------------. -| yydefault -- do the default action for the current state. | -`-----------------------------------------------------------*/ -yydefault: - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - goto yyreduce; - - -/*-----------------------------. -| yyreduce -- Do a reduction. | -`-----------------------------*/ -yyreduce: - /* yyn is the number of a rule to reduce with. */ - yylen = yyr2[yyn]; - - /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. - - Otherwise, the following line sets YYVAL to the semantic value of - the lookahead token. This behavior is undocumented and Bison - users should not rely upon it. Assigning to YYVAL - unconditionally makes the parser a bit smaller, and it avoids a - GCC warning that YYVAL may be used uninitialized. */ - yyval = yyvsp[1-yylen]; - -#if YYLSP_NEEDED - /* Similarly for the default location. Let the user run additional - commands if for instance locations are ranges. */ - yyloc = yylsp[1-yylen]; - YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen); -#endif - -#if YYDEBUG - /* We have to keep this `#if YYDEBUG', since we use variables which - are defined only if `YYDEBUG' is set. */ - if (yydebug) - { - int yyi; - - YYFPRINTF (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - - switch (yyn) { - -case 1: -#line 62 "geometry.yy" -{ - linenum = 1; - ; - break;} -case 2: -#line 69 "geometry.yy" -{ - int i; - extern ARRAY<char*> parsestrings; - for (i = 0; i < parsestrings.Size(); i++) - delete [] parsestrings[i]; - parsestrings.SetSize(0); - ; - break;} -case 5: -#line 86 "geometry.yy" -{ parsegeom->SetSolid(yyvsp[-2].chptr, new Solid (Solid::ROOT, yyvsp[0].solidtype)); - ; - break;} -case 6: -#line 89 "geometry.yy" -{ - parsegeom->SetFlags(yyvsp[-4].chptr, parseflags); - ; - break;} -case 8: -#line 96 "geometry.yy" -{ yyval.solidtype = (Solid*)parsegeom->GetSolid(yyvsp[0].chptr); ; - break;} -case 9: -#line 97 "geometry.yy" -{ yyval.solidtype = new Solid (Solid::UNION, yyvsp[-2].solidtype, yyvsp[0].solidtype); ; - break;} -case 10: -#line 98 "geometry.yy" -{ yyval.solidtype = new Solid (Solid::SECTION, yyvsp[-2].solidtype, yyvsp[0].solidtype); ; - break;} -case 11: -#line 99 "geometry.yy" -{ yyval.solidtype = new Solid (Solid::SUB, yyvsp[0].solidtype); ; - break;} -case 12: -#line 100 "geometry.yy" -{ yyval.solidtype = yyvsp[-1].solidtype; ; - break;} -case 13: -#line 106 "geometry.yy" -{ - OneSurfacePrimitive * surf = new Sphere (Point<3> (yyvsp[-7].val, yyvsp[-5].val, yyvsp[-3].val), yyvsp[-1].val); - parsegeom -> AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (surf); - ; - break;} -case 14: -#line 116 "geometry.yy" -{ - OneSurfacePrimitive * surf = new Cylinder (Point<3> (yyvsp[-13].val, yyvsp[-11].val, yyvsp[-9].val), - Point<3> (yyvsp[-7].val, yyvsp[-5].val, yyvsp[-3].val), yyvsp[-1].val); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (surf); - ; - break;} -case 15: -#line 128 "geometry.yy" -{ - OneSurfacePrimitive * surf = new Cone (Point<3> (yyvsp[-15].val, yyvsp[-13].val, yyvsp[-11].val), - Point<3> (yyvsp[-7].val, yyvsp[-5].val, yyvsp[-3].val), yyvsp[-9].val, yyvsp[-1].val); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (surf); - ; - break;} -case 16: -#line 137 "geometry.yy" -{ - OneSurfacePrimitive * surf = new Plane ( Point<3> (yyvsp[-11].val, yyvsp[-9].val, yyvsp[-7].val), - Vec<3> (yyvsp[-5].val, yyvsp[-3].val, yyvsp[-1].val) ); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (surf); - ; - break;} -case 17: -#line 146 "geometry.yy" -{ - Primitive * nprim = new OrthoBrick (Point<3> (yyvsp[-11].val, yyvsp[-9].val, yyvsp[-7].val), - Point<3> (yyvsp[-5].val, yyvsp[-3].val, yyvsp[-1].val)); - for (int j = 0; j < nprim->GetNSurfaces(); j++) - { - parsegeom->AddSurface (&nprim->GetSurface(j)); - nprim->SetSurfaceId (j, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (nprim); - } - ; - break;} -case 18: -#line 159 "geometry.yy" -{ - polyhedron = new Polyhedra (); - ; - break;} -case 19: -#line 164 "geometry.yy" -{ - int j; - for (j = 0; j < polyhedron->GetNSurfaces(); j++) - { - parsegeom->AddSurface (&polyhedron->GetSurface(j)); - polyhedron->SetSurfaceId (j, parsegeom->GetNSurf()-1); - yyval.solidtype = new Solid (polyhedron); - } - ; - break;} -case 20: -#line 198 "geometry.yy" -{ - Solid * nsol = yyvsp[-1].solidtype -> Copy(*parsegeom); - Vec<3> v(yyvsp[-7].val, yyvsp[-5].val, yyvsp[-3].val); - Transformation<3> trans(v); - nsol -> Transform (trans); - yyval.solidtype = nsol; - ; - break;} -case 21: -#line 207 "geometry.yy" -{ - int i; - Solid * hsol = yyvsp[-1].solidtype; - for (i = 1; i <= yyvsp[-3].val; i++) - { - Solid * nsol = yyvsp[-1].solidtype -> Copy(*parsegeom); - Vec<3> v(yyvsp[-9].val, yyvsp[-7].val, yyvsp[-5].val); - v *= i; - Transformation<3> trans(v); - nsol -> Transform (trans); - hsol = new Solid (Solid::UNION, hsol, nsol); - } - yyval.solidtype = hsol; - ; - break;} -case 22: -#line 223 "geometry.yy" -{ - Solid * nsol = yyvsp[-1].solidtype -> Copy(*parsegeom); - Point<3> c(yyvsp[-13].val, yyvsp[-11].val, yyvsp[-9].val); - Transformation<3> rot(c, yyvsp[-7].val, yyvsp[-5].val, yyvsp[-3].val); - nsol -> Transform (rot); - yyval.solidtype = nsol; - ; - break;} -case 23: -#line 234 "geometry.yy" -{ - int i; - Solid * hsol = yyvsp[-1].solidtype; - - Point<3> c(yyvsp[-15].val, yyvsp[-13].val, yyvsp[-11].val); - Transformation<3> trans(c, yyvsp[-9].val, yyvsp[-7].val, yyvsp[-5].val); - Transformation<3> multi(Vec<3>(0,0,0)); - Transformation<3> ht; - - for (i = 1; i <= yyvsp[-3].val; i++) - { - Solid * nsol = yyvsp[-1].solidtype -> Copy(*parsegeom); - nsol -> Transform (multi); - hsol = new Solid (Solid::UNION, hsol, nsol); - - ht=multi; - multi.Combine (trans, ht); - } - yyval.solidtype = hsol; - ; - break;} -case 28: -#line 295 "geometry.yy" -{ - polyhedron->AddPoint (Point<3> (yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val)); - cout << " " << yyvsp[-4].val << " " << yyvsp[-2].val << " " << yyvsp[0].val << endl; - ; - break;} -case 29: -#line 302 "geometry.yy" -{ - polyhedron->AddFace (int(yyvsp[-4].val)-1, int(yyvsp[-2].val)-1, int(yyvsp[0].val)-1); - cout << yyvsp[-4].val << " " << yyvsp[-2].val << " " << yyvsp[0].val << endl; - ; - break;} -case 30: -#line 307 "geometry.yy" -{ - cout << "face, 1 = " << yyvsp[-6].val << " " << yyvsp[-4].val << " " << yyvsp[-2].val << " " << yyvsp[0].val << endl; - polyhedron->AddFace (int(yyvsp[-6].val)-1, int(yyvsp[-4].val)-1, int(yyvsp[-2].val)-1); - polyhedron->AddFace (int(yyvsp[-6].val)-1, int(yyvsp[-2].val)-1, int(yyvsp[0].val)-1); - cout << yyvsp[-6].val << yyvsp[-4].val << yyvsp[-2].val << yyvsp[0].val << endl; - ; - break;} -case 33: -#line 321 "geometry.yy" -{ -// revolution->AddPoint (Point<2> ($1, $3)); - cout << " " << yyvsp[-2].val << " " << yyvsp[0].val << endl; - ; - break;} -case 36: -#line 338 "geometry.yy" -{ - middlecurve->AddSegment (splinep1, Point<3> (yyvsp[-10].val, yyvsp[-8].val, yyvsp[-6].val), Point<3> (yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val)); - splinep1(0) = yyvsp[-4].val; splinep1(1) = yyvsp[-2].val; splinep1(2) = yyvsp[0].val; - ; - break;} -case 37: -#line 347 "geometry.yy" -{ - bspline = new BSplineCurve2d; - bspline -> AddPoint (Point<2> (yyvsp[-2].val, yyvsp[0].val)); - cout << "first point" << endl; - ; - break;} -case 39: -#line 355 "geometry.yy" -{ ; - break;} -case 40: -#line 357 "geometry.yy" -{ - bspline -> AddPoint (Point<2> (yyvsp[-2].val, yyvsp[0].val)); - cout << "Add Point: " << yyvsp[-2].val << "-" << yyvsp[0].val << endl; - ; - break;} -case 44: -#line 379 "geometry.yy" -{ cout << "singular edge:" << yyvsp[-2].val << " between " - << yyvsp[-1].chptr << " and " << yyvsp[0].chptr << endl; - parsegeom->singedges.Append - (new SingularEdge (yyvsp[-2].val, parsegeom->GetSolid(yyvsp[-1].chptr), - parsegeom->GetSolid(yyvsp[0].chptr))); - ; - break;} -case 45: -#line 387 "geometry.yy" -{ cout << "singular point:" << yyvsp[-3].val << " between " - << yyvsp[-2].chptr << ", " << yyvsp[-1].chptr << " and " << yyvsp[0].chptr << endl; - parsegeom->singpoints.Append - (new SingularPoint (yyvsp[-3].val, parsegeom->GetSolid(yyvsp[-2].chptr), - parsegeom->GetSolid(yyvsp[-1].chptr), - parsegeom->GetSolid(yyvsp[0].chptr))); - ; - break;} -case 46: -#line 396 "geometry.yy" -{ - ARRAY<int> si1, si2; - parsegeom->GetSolid(yyvsp[-2].chptr)->GetSurfaceIndices(si1); - parsegeom->GetSolid(yyvsp[-1].chptr)->GetSurfaceIndices(si2); - - parsegeom->AddIdentification ( - new CloseSurfaceIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1[0]), - parsegeom->GetSurface (si2[0]), - parseflags)); - ; - break;} -case 47: -#line 411 "geometry.yy" -{ - ARRAY<int> si1, si2, si3; - parsegeom->GetSolid(yyvsp[-2].chptr)->GetSurfaceIndices(si1); - parsegeom->GetSolid(yyvsp[-1].chptr)->GetSurfaceIndices(si2); - parsegeom->GetSolid(yyvsp[0].chptr)->GetSurfaceIndices(si3); - - parsegeom->AddIdentification ( - new CloseEdgesIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1.Get(1)), - parsegeom->GetSurface (si2.Get(1)), - parsegeom->GetSurface (si3.Get(1)))); - ; - break;} -case 48: -#line 427 "geometry.yy" -{ - ARRAY<int> si1, si2; - parsegeom->GetSolid(yyvsp[-1].chptr)->GetSurfaceIndices(si1); - parsegeom->GetSolid(yyvsp[0].chptr)->GetSurfaceIndices(si2); - - parsegeom->AddIdentification ( - new PeriodicIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1.Get(1)), - parsegeom->GetSurface (si2.Get(1)))); - ; - break;} -case 49: -#line 441 "geometry.yy" -{ - int tlonr = - parsegeom->SetTopLevelObject ((Solid*)parsegeom->GetSolid(yyvsp[-1].chptr)); - TopLevelObject * tlo = parsegeom->GetTopLevelObject (tlonr); - if (parseflags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = parseflags.GetNumListFlag ("col"); - tlo->SetRGB (col[0], col[1], col[2]); - } - if (parseflags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - ; - break;} -case 50: -#line 455 "geometry.yy" -{ - ARRAY<int> si; - parsegeom->GetSolid(yyvsp[-1].chptr)->GetSurfaceIndices(si); - int tlonr = - parsegeom->SetTopLevelObject ((Solid*)parsegeom->GetSolid(yyvsp[-2].chptr), - (Surface*)parsegeom->GetSurface(si.Get(1))); - TopLevelObject * tlo = parsegeom->GetTopLevelObject (tlonr); - if (parseflags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = parseflags.GetNumListFlag ("col"); - tlo->SetRGB (col.Get(1), col.Get(2), col.Get(3)); - } - if (parseflags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - ; - break;} -case 51: -#line 473 "geometry.yy" -{ - parsegeom->SetBoundingBox (Box<3> (Point<3> (yyvsp[-11].val, yyvsp[-9].val, yyvsp[-7].val), - Point<3> (yyvsp[-5].val, yyvsp[-3].val, yyvsp[-1].val))); - ; - break;} -case 52: -#line 479 "geometry.yy" -{ - parsegeom->AddUserPoint (Point<3> (yyvsp[-5].val, yyvsp[-3].val, yyvsp[-1].val)); - ; - break;} -case 53: -#line 484 "geometry.yy" -{ - CSGeometry::BCModification bcm; - ARRAY<int> si; - - parsegeom->GetSolid(yyvsp[-2].chptr)->GetSurfaceIndices(si); - - bcm.tlonr = -1; - int i; - for (i = 0; i < parsegeom->GetNTopLevelObjects(); i++) - if (strcmp (parsegeom->GetTopLevelObject(i)->GetSolid()->Name(), yyvsp[-1].chptr) == 0) - { - bcm.tlonr = i; - break; - } - - bcm.bcnr = int(yyvsp[0].val); - for (i = 0; i < si.Size(); i++) - { - bcm.si = si[i]; - parsegeom->bcmodifications.Append (bcm); - } - ; - break;} -case 54: -#line 512 "geometry.yy" -{ parseflags.DeleteFlags (); ; - break;} -case 58: -#line 523 "geometry.yy" -{ parseflags.SetFlag (yyvsp[0].chptr); ; - break;} -case 59: -#line 525 "geometry.yy" -{ parseflags.SetFlag (yyvsp[-2].chptr, yyvsp[0].chptr); ; - break;} -case 60: -#line 527 "geometry.yy" -{ parseflags.SetFlag (yyvsp[-2].chptr, yyvsp[0].val); ; - break;} -case 61: -#line 529 "geometry.yy" -{ parseflags.SetFlag (yyvsp[-2].chptr, doublearray); ; - break;} -case 62: -#line 531 "geometry.yy" -{ parseflags.SetFlag (yyvsp[-2].chptr, stringarray); ; - break;} -case 63: -#line 536 "geometry.yy" -{ doublearray.SetSize (0); ; - break;} -case 65: -#line 541 "geometry.yy" -{ doublearray.Append (yyvsp[0].val); ; - break;} -case 66: -#line 542 "geometry.yy" -{ doublearray.Append (yyvsp[0].val); ; - break;} -case 67: -#line 547 "geometry.yy" -{ - int i; - for (i = 0; i < stringarray.Size(); i++) - delete stringarray[i]; - stringarray.SetSize (0); - ; - break;} -case 69: -#line 558 "geometry.yy" -{ - stringarray.Append (new char[strlen(yyvsp[0].chptr)+1]); - strcpy (stringarray.Last(), yyvsp[0].chptr); - ; - break;} -case 70: -#line 564 "geometry.yy" -{ - stringarray.Append (new char[strlen(yyvsp[0].chptr)+1]); - strcpy (stringarray.Last(), yyvsp[0].chptr); - ; - break;} -case 71: -#line 575 "geometry.yy" -{ yyval.chptr = yyvsp[0].chptr; ; - break;} -case 72: -#line 576 "geometry.yy" -{ yyval.chptr = yyvsp[0].chptr; ; - break;} -} - -#line 709 "/usr/share/bison/bison.simple" - - - yyvsp -= yylen; - yyssp -= yylen; -#if YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; -#if YYLSP_NEEDED - *++yylsp = yyloc; -#endif - - /* Now `shift' the result of the reduction. Determine what state - that goes to, based on the state we popped back to and the rule - number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - - -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ -yyerrlab: - /* If not already recovering from an error, report this error. */ - if (!yyerrstatus) - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - YYSIZE_T yysize = 0; - char *yymsg; - int yyx, yycount; - - yycount = 0; - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++) - if (yycheck[yyx + yyn] == yyx) - yysize += yystrlen (yytname[yyx]) + 15, yycount++; - yysize += yystrlen ("parse error, unexpected ") + 1; - yysize += yystrlen (yytname[YYTRANSLATE (yychar)]); - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg != 0) - { - char *yyp = yystpcpy (yymsg, "parse error, unexpected "); - yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]); - - if (yycount < 5) - { - yycount = 0; - for (yyx = yyn < 0 ? -yyn : 0; - yyx < (int) (sizeof (yytname) / sizeof (char *)); - yyx++) - if (yycheck[yyx + yyn] == yyx) - { - const char *yyq = ! yycount ? ", expecting " : " or "; - yyp = yystpcpy (yyp, yyq); - yyp = yystpcpy (yyp, yytname[yyx]); - yycount++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - yyerror ("parse error; also virtual memory exhausted"); - } - else -#endif /* defined (YYERROR_VERBOSE) */ - yyerror ("parse error"); - } - goto yyerrlab1; - - -/*--------------------------------------------------. -| yyerrlab1 -- error raised explicitly by an action | -`--------------------------------------------------*/ -yyerrlab1: - if (yyerrstatus == 3) - { - /* If just tried and failed to reuse lookahead token after an - error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - YYDPRINTF ((stderr, "Discarding token %d (%s).\n", - yychar, yytname[yychar1])); - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token after shifting the error - token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - - -/*-------------------------------------------------------------------. -| yyerrdefault -- current state does not do anything special for the | -| error token. | -`-------------------------------------------------------------------*/ -yyerrdefault: -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - - /* If its default is to accept any token, ok. Otherwise pop it. */ - yyn = yydefact[yystate]; - if (yyn) - goto yydefault; -#endif - - -/*---------------------------------------------------------------. -| yyerrpop -- pop the current state because it cannot handle the | -| error token | -`---------------------------------------------------------------*/ -yyerrpop: - if (yyssp == yyss) - YYABORT; - yyvsp--; - yystate = *--yyssp; -#if YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG - if (yydebug) - { - short *yyssp1 = yyss - 1; - YYFPRINTF (stderr, "Error: state stack now"); - while (yyssp1 != yyssp) - YYFPRINTF (stderr, " %d", *++yyssp1); - YYFPRINTF (stderr, "\n"); - } -#endif - -/*--------------. -| yyerrhandle. | -`--------------*/ -yyerrhandle: - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - - YYDPRINTF ((stderr, "Shifting error token, ")); - - *++yyvsp = yylval; -#if YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - -/*-------------------------------------. -| yyacceptlab -- YYACCEPT comes here. | -`-------------------------------------*/ -yyacceptlab: - yyresult = 0; - goto yyreturn; - -/*-----------------------------------. -| yyabortlab -- YYABORT comes here. | -`-----------------------------------*/ -yyabortlab: - yyresult = 1; - goto yyreturn; - -/*---------------------------------------------. -| yyoverflowab -- parser overflow comes here. | -`---------------------------------------------*/ -yyoverflowlab: - yyerror ("parser stack overflow"); - yyresult = 2; - /* Fall through. */ - -yyreturn: -#ifndef yyoverflow - if (yyss != yyssa) - YYSTACK_FREE (yyss); -#endif - return yyresult; -} -#line 577 "geometry.yy" - - - -int yyerror (char * s) -{ - cerr << s << " in line " << linenum << endl; - return 0; -} - diff --git a/contrib/Netgen/libsrc/csg/geometry.h b/contrib/Netgen/libsrc/csg/geometry.h deleted file mode 100644 index d84e8db183070de3879e4b415edaa89f16fe7d36..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/geometry.h +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef BISON_GEOMETRY_H -# define BISON_GEOMETRY_H - -#ifndef YYSTYPE -typedef union { -double val; -char * chptr; -Solid * solidtype; -} yystype; -# define YYSTYPE yystype -# define YYSTYPE_IS_TRIVIAL 1 -#endif -# define NUM 257 -# define TOK_SOLID 258 -# define TOK_RECO 259 -# define TOK_TLO 260 -# define TOK_BOUNDINGBOX 261 -# define IDENT 262 -# define IDENTSOLID 263 -# define TOK_SPHERE 264 -# define TOK_CYLINDER 265 -# define TOK_CONE 266 -# define TOK_PLAIN 267 -# define TOK_TUBE 268 -# define TOK_GENCYL 269 -# define TOK_ORTHOBRICK 270 -# define TOK_POLYHEDRON 271 -# define TOK_REVOLUTION 272 -# define TOK_OR 273 -# define TOK_AND 274 -# define TOK_NOT 275 -# define TOK_TRANSLATE 276 -# define TOK_MULTITRANSLATE 277 -# define TOK_ROTATE 278 -# define TOK_MULTIROTATE 279 -# define TOK_SINGULAR 280 -# define TOK_EDGE 281 -# define TOK_POINT 282 -# define TOK_IDENTIFY 283 -# define TOK_CLOSESURFACES 284 -# define TOK_CLOSEEDGES 285 -# define TOK_PERIODIC 286 -# define TOK_BOUNDARYCONDITION 287 - - -extern YYSTYPE yylval; - -#endif /* not BISON_GEOMETRY_H */ diff --git a/contrib/Netgen/libsrc/csg/geometry.ll b/contrib/Netgen/libsrc/csg/geometry.ll deleted file mode 100644 index bb2edbc9f540860bd05d7b003ea3bb4f79a9aa80..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/geometry.ll +++ /dev/null @@ -1,94 +0,0 @@ -%{ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - - - -// extern SYMBOLTABLE<Solid*> solids; -namespace netgen { -extern CSGeometry * parsegeom; -} -using namespace netgen; - -#include "geometry.h" - - -ARRAY<char*> parsestrings; -int linenum; -%} - -dig [0-9] -id [a-zA-Z][a-zA-Z0-9]* -num1 [-+]?{dig}+\.?([eE][-+]?{dig}+)? -num2 [-+]?{dig}*\.{dig}+([eE][-+]?{dig}+)? -number {num1}|{num2} -%x incl -%x comment - -%% -algebraic3d { return TOK_RECO; } -solid { return TOK_SOLID; } -tlo { return TOK_TLO; } -and { return TOK_AND; } -or { return TOK_OR; } -not { return TOK_NOT; } -translate { return TOK_TRANSLATE; } -multitranslate { return TOK_MULTITRANSLATE; } -rotate { return TOK_ROTATE; } -multirotate { return TOK_MULTIROTATE; } -sphere { return TOK_SPHERE; } -cylinder { return TOK_CYLINDER; } -cone { return TOK_CONE; } -plain { return TOK_PLAIN; } -plane { return TOK_PLAIN; } -tube { return TOK_TUBE; } -gencyl { return TOK_GENCYL; } -orthobrick { return TOK_ORTHOBRICK; } -polyhedron { return TOK_POLYHEDRON; } -revolution { return TOK_REVOLUTION; } - -singular { return TOK_SINGULAR; } -edge { return TOK_EDGE; } -point { return TOK_POINT; } - -identify { return TOK_IDENTIFY; } -closesurfaces { return TOK_CLOSESURFACES; } -closeedges { return TOK_CLOSEEDGES; } -periodic { return TOK_PERIODIC; } -boundarycondition { return TOK_BOUNDARYCONDITION; } -boundingbox { return TOK_BOUNDINGBOX; } - -{number} { yylval.val = atof (YYText()); return NUM; } -{id}+ { - yylval.chptr = new char [YYLeng()+1]; - parsestrings.Append (yylval.chptr); - strcpy (yylval.chptr, YYText()); - if (parsegeom->GetSolid (yylval.chptr)) - return IDENTSOLID; - else - return IDENT; - } -[ \t] /* eat up ws */ -. { return int(*YYText()); } -\n { linenum++; } -"##".*\n { linenum++; cout << (YYText()+2) ; } /* line comment */ -"#".*\n { linenum++; } /* line comment */ - - -%% - -extern FlexLexer * lexer; - -int yylex () - { - return lexer -> yylex(); - } - -extern "C" int yywrap () - { - return 1; - } diff --git a/contrib/Netgen/libsrc/csg/geometry.yy b/contrib/Netgen/libsrc/csg/geometry.yy deleted file mode 100644 index 49dd63a53a11b076649a54dcd133c10a34a7d56c..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/geometry.yy +++ /dev/null @@ -1,585 +0,0 @@ -%{ -//define YYDEBUG 1 - -extern int yylex (); - -#include <mystdlib.h> - -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ -netgen::CSGeometry * parsegeom; -} - -using namespace netgen; - -// extern ARRAY<Surface*> surfaces; -// extern SYMBOLTABLE<Solid*> solids; - - -int yyerror (char * s); -splinetube * tube; -spline3d * middlecurve; -Point<3> splinep1; -BSplineCurve2d *bspline; -Flags parseflags; -extern int linenum; -ARRAY<double> doublearray; -ARRAY<char*> stringarray; - -Polyhedra * polyhedron; -// Revolution * revolution; -%} - -%union { -double val; -char * chptr; -Solid * solidtype; -} - -%token <val> NUM -%token TOK_SOLID, TOK_RECO, TOK_TLO, TOK_BOUNDINGBOX -%token <chptr> IDENT IDENTSOLID -%token <solidtype> TOK_SPHERE TOK_CYLINDER TOK_CONE TOK_PLAIN TOK_TUBE TOK_GENCYL TOK_ORTHOBRICK TOK_POLYHEDRON TOK_REVOLUTION -%left <solidtype> TOK_OR TOK_AND TOK_NOT -%token <solidtype> TOK_TRANSLATE TOK_MULTITRANSLATE TOK_ROTATE TOK_MULTIROTATE -%type <solidtype> solid solidprimitive -%type <void> splinesegmentlist splinesegment readbspline bsplinepointlist -%type <chptr> anyident -%token TOK_SINGULAR TOK_EDGE TOK_POINT -%token TOK_IDENTIFY TOK_CLOSESURFACES TOK_CLOSEEDGES TOK_PERIODIC -%token TOK_BOUNDARYCONDITION -%type <void> polyhedronpoints polyhedronfaces polyhedronpoint polyhedronface -%type <void> revolutionpoints revolutionpoint - - -%% -input: - { - linenum = 1; - } - TOK_RECO - recsoliddef - recadddef - - { - int i; - extern ARRAY<char*> parsestrings; - for (i = 0; i < parsestrings.Size(); i++) - delete [] parsestrings[i]; - parsestrings.SetSize(0); - } - ; - - -recsoliddef: - /* empty */ - | recsoliddef soliddef ';' - ; - -soliddef: - TOK_SOLID IDENT '=' solid - { parsegeom->SetSolid($2, new Solid (Solid::ROOT, $4)); - } - flaglist - { - parsegeom->SetFlags($2, parseflags); - } - ; - -solid: - solidprimitive - | IDENTSOLID { $$ = (Solid*)parsegeom->GetSolid($1); } - | solid TOK_OR solid { $$ = new Solid (Solid::UNION, $1, $3); } - | solid TOK_AND solid { $$ = new Solid (Solid::SECTION, $1, $3); } - | TOK_NOT solid { $$ = new Solid (Solid::SUB, $2); } - | '(' solid ')' { $$ = $2; } - ; - -solidprimitive: - TOK_SPHERE '(' NUM ',' NUM ',' NUM ';' - NUM ')' - { - OneSurfacePrimitive * surf = new Sphere (Point<3> ($3, $5, $7), $9); - parsegeom -> AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - $$ = new Solid (surf); - } - | TOK_CYLINDER '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ';' - NUM ')' - - { - OneSurfacePrimitive * surf = new Cylinder (Point<3> ($3, $5, $7), - Point<3> ($9, $11, $13), $15); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - $$ = new Solid (surf); - } - | TOK_CONE '(' NUM ',' NUM ',' NUM ';' - NUM ';' - NUM ',' NUM ',' NUM ';' - NUM ')' - - { - OneSurfacePrimitive * surf = new Cone (Point<3> ($3, $5, $7), - Point<3> ($11, $13, $15), $9, $17); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - $$ = new Solid (surf); - } - | TOK_PLAIN '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ')' - { - OneSurfacePrimitive * surf = new Plane ( Point<3> ($3, $5, $7), - Vec<3> ($9, $11, $13) ); - parsegeom->AddSurface (surf); - surf->SetSurfaceId (0, parsegeom->GetNSurf()-1); - $$ = new Solid (surf); - } - | TOK_ORTHOBRICK '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ')' - { - Primitive * nprim = new OrthoBrick (Point<3> ($3, $5, $7), - Point<3> ($9, $11, $13)); - for (int j = 0; j < nprim->GetNSurfaces(); j++) - { - parsegeom->AddSurface (&nprim->GetSurface(j)); - nprim->SetSurfaceId (j, parsegeom->GetNSurf()-1); - $$ = new Solid (nprim); - } - } - - - | TOK_POLYHEDRON '(' - { - polyhedron = new Polyhedra (); - } - polyhedronpoints ';' ';' - polyhedronfaces ')' - { - int j; - for (j = 0; j < polyhedron->GetNSurfaces(); j++) - { - parsegeom->AddSurface (&polyhedron->GetSurface(j)); - polyhedron->SetSurfaceId (j, parsegeom->GetNSurf()-1); - $$ = new Solid (polyhedron); - } - } - - -/* - | TOK_REVOLUTION '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ';' - { - revolution = new Revolution (Point<3> ($3, $5, $7), - Point<3> ($9, $11, $13)); - } - revolutionpoints - ')' - { - revolution -> Finish (); - int j; - for (j = 0; j < revolution->GetNSurfaces(); j++) - { - parsegeom->AddSurface (&revolution->GetSurface(j)); - revolution->SetSurfaceId (j, parsegeom->GetNSurf()-1); - $$ = new Solid (revolution); - } - } -*/ - - - | TOK_TRANSLATE '(' NUM ',' NUM ',' NUM ';' solid ')' - { - Solid * nsol = $9 -> Copy(*parsegeom); - Vec<3> v($3, $5, $7); - Transformation<3> trans(v); - nsol -> Transform (trans); - $$ = nsol; - } - - | TOK_MULTITRANSLATE '(' NUM ',' NUM ',' NUM ';' NUM ';' solid ')' - { - int i; - Solid * hsol = $11; - for (i = 1; i <= $9; i++) - { - Solid * nsol = $11 -> Copy(*parsegeom); - Vec<3> v($3, $5, $7); - v *= i; - Transformation<3> trans(v); - nsol -> Transform (trans); - hsol = new Solid (Solid::UNION, hsol, nsol); - } - $$ = hsol; - } - - | TOK_ROTATE '(' NUM ',' NUM ',' NUM ';' NUM ',' NUM ',' NUM ';' solid ')' - { - Solid * nsol = $15 -> Copy(*parsegeom); - Point<3> c($3, $5, $7); - Transformation<3> rot(c, $9, $11, $13); - nsol -> Transform (rot); - $$ = nsol; - } - - | TOK_MULTIROTATE '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ';' - NUM ';' solid ')' - { - int i; - Solid * hsol = $17; - - Point<3> c($3, $5, $7); - Transformation<3> trans(c, $9, $11, $13); - Transformation<3> multi(Vec<3>(0,0,0)); - Transformation<3> ht; - - for (i = 1; i <= $15; i++) - { - Solid * nsol = $17 -> Copy(*parsegeom); - nsol -> Transform (multi); - hsol = new Solid (Solid::UNION, hsol, nsol); - - ht=multi; - multi.Combine (trans, ht); - } - $$ = hsol; - } - - -/* - | TOK_TUBE '(' NUM ',' NUM ',' NUM ',' - { - middlecurve = new spline3d; - splinep1.X() = $3; splinep1.Y() = $5; splinep1.Z() = $7; - } - splinesegmentlist ';' NUM ')' - { - Surface * surf = new splinetube (*middlecurve, $12); - parsegeom->AddSurface (surf); - $$ = new Solid (surf, parsegeom->GetNSurf()); - } - - | TOK_GENCYL '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ';' - readbspline - ')' - { - Surface * surf = new GeneralizedCylinder - (*bspline, Point<3> ($3, $5, $7), Vec<3> ($9, $11, $13), - Vec<3> ($15, $17, $19) ); - parsegeom->AddSurface (surf); - $$ = new Solid (surf, parsegeom->GetNSurf()); - } -*/ - ; - - -polyhedronpoints: - polyhedronpoints ';' polyhedronpoint - | polyhedronpoint - ; -polyhedronfaces: - polyhedronfaces ';' polyhedronface - | polyhedronface - ; -polyhedronpoint: - NUM ',' NUM ',' NUM - { - polyhedron->AddPoint (Point<3> ($1, $3, $5)); - cout << " " << $1 << " " << $3 << " " << $5 << endl; - } - ; -polyhedronface: - NUM ',' NUM ',' NUM - { - polyhedron->AddFace (int($1)-1, int($3)-1, int($5)-1); - cout << $1 << " " << $3 << " " << $5 << endl; - } - | NUM ',' NUM ',' NUM ',' NUM - { - cout << "face, 1 = " << $1 << " " << $3 << " " << $5 << " " << $7 << endl; - polyhedron->AddFace (int($1)-1, int($3)-1, int($5)-1); - polyhedron->AddFace (int($1)-1, int($5)-1, int($7)-1); - cout << $1 << $3 << $5 << $7 << endl; - } - ; - -revolutionpoints: - revolutionpoints ';' revolutionpoint - | revolutionpoint - ; -revolutionpoint: - NUM ',' NUM - { -// revolution->AddPoint (Point<2> ($1, $3)); - cout << " " << $1 << " " << $3 << endl; - } - ; - - - - - -splinesegmentlist: - splinesegment - | splinesegment ',' splinesegmentlist - ; -splinesegment: - NUM ',' NUM ',' NUM ',' - NUM ',' NUM ',' NUM - { - middlecurve->AddSegment (splinep1, Point<3> ($1, $3, $5), Point<3> ($7, $9, $11)); - splinep1(0) = $7; splinep1(1) = $9; splinep1(2) = $11; - } - ; - - -readbspline: - NUM ',' NUM - { - bspline = new BSplineCurve2d; - bspline -> AddPoint (Point<2> ($1, $3)); - cout << "first point" << endl; - } - bsplinepointlist - ; -bsplinepointlist: - /* empty */ { } - | ',' NUM ',' NUM - { - bspline -> AddPoint (Point<2> ($2, $4)); - cout << "Add Point: " << $2 << "-" << $4 << endl; - } - bsplinepointlist - ; - - - - - - - - - -recadddef: - /* empty */ - | recadddef adddef ';' - ; - -adddef: - TOK_SINGULAR TOK_EDGE NUM IDENTSOLID IDENTSOLID - { cout << "singular edge:" << $3 << " between " - << $4 << " and " << $5 << endl; - parsegeom->singedges.Append - (new SingularEdge ($3, parsegeom->GetSolid($4), - parsegeom->GetSolid($5))); - } - | - TOK_SINGULAR TOK_POINT NUM IDENTSOLID IDENTSOLID IDENTSOLID - { cout << "singular point:" << $3 << " between " - << $4 << ", " << $5 << " and " << $6 << endl; - parsegeom->singpoints.Append - (new SingularPoint ($3, parsegeom->GetSolid($4), - parsegeom->GetSolid($5), - parsegeom->GetSolid($6))); - } - | - TOK_IDENTIFY TOK_CLOSESURFACES IDENTSOLID IDENTSOLID flaglist - { - ARRAY<int> si1, si2; - parsegeom->GetSolid($3)->GetSurfaceIndices(si1); - parsegeom->GetSolid($4)->GetSurfaceIndices(si2); - - parsegeom->AddIdentification ( - new CloseSurfaceIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1[0]), - parsegeom->GetSurface (si2[0]), - parseflags)); - } - | - TOK_IDENTIFY TOK_CLOSEEDGES IDENTSOLID IDENTSOLID IDENTSOLID - { - ARRAY<int> si1, si2, si3; - parsegeom->GetSolid($3)->GetSurfaceIndices(si1); - parsegeom->GetSolid($4)->GetSurfaceIndices(si2); - parsegeom->GetSolid($5)->GetSurfaceIndices(si3); - - parsegeom->AddIdentification ( - new CloseEdgesIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1.Get(1)), - parsegeom->GetSurface (si2.Get(1)), - parsegeom->GetSurface (si3.Get(1)))); - } - | - TOK_IDENTIFY TOK_PERIODIC IDENTSOLID IDENTSOLID - { - ARRAY<int> si1, si2; - parsegeom->GetSolid($3)->GetSurfaceIndices(si1); - parsegeom->GetSolid($4)->GetSurfaceIndices(si2); - - parsegeom->AddIdentification ( - new PeriodicIdentification ( - parsegeom->GetNIdentifications()+1, - *parsegeom, - parsegeom->GetSurface (si1.Get(1)), - parsegeom->GetSurface (si2.Get(1)))); - } - | - TOK_TLO IDENTSOLID flaglist - { - int tlonr = - parsegeom->SetTopLevelObject ((Solid*)parsegeom->GetSolid($2)); - TopLevelObject * tlo = parsegeom->GetTopLevelObject (tlonr); - if (parseflags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = parseflags.GetNumListFlag ("col"); - tlo->SetRGB (col[0], col[1], col[2]); - } - if (parseflags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - } - | - TOK_TLO IDENTSOLID IDENTSOLID flaglist - { - ARRAY<int> si; - parsegeom->GetSolid($3)->GetSurfaceIndices(si); - int tlonr = - parsegeom->SetTopLevelObject ((Solid*)parsegeom->GetSolid($2), - (Surface*)parsegeom->GetSurface(si.Get(1))); - TopLevelObject * tlo = parsegeom->GetTopLevelObject (tlonr); - if (parseflags.NumListFlagDefined ("col")) - { - const ARRAY<double> & col = parseflags.GetNumListFlag ("col"); - tlo->SetRGB (col.Get(1), col.Get(2), col.Get(3)); - } - if (parseflags.GetDefineFlag ("transparent")) - tlo->SetTransparent (1); - } - | - TOK_BOUNDINGBOX '(' NUM ',' NUM ',' NUM ';' - NUM ',' NUM ',' NUM ')' - { - parsegeom->SetBoundingBox (Box<3> (Point<3> ($3, $5, $7), - Point<3> ($9, $11, $13))); - } - | - TOK_POINT '(' NUM ',' NUM ',' NUM ')' - { - parsegeom->AddUserPoint (Point<3> ($3, $5, $7)); - } - | - TOK_BOUNDARYCONDITION IDENTSOLID IDENTSOLID NUM - { - CSGeometry::BCModification bcm; - ARRAY<int> si; - - parsegeom->GetSolid($2)->GetSurfaceIndices(si); - - bcm.tlonr = -1; - int i; - for (i = 0; i < parsegeom->GetNTopLevelObjects(); i++) - if (strcmp (parsegeom->GetTopLevelObject(i)->GetSolid()->Name(), $3) == 0) - { - bcm.tlonr = i; - break; - } - - bcm.bcnr = int($4); - for (i = 0; i < si.Size(); i++) - { - bcm.si = si[i]; - parsegeom->bcmodifications.Append (bcm); - } - } - ; - - - - -flaglist: - { parseflags.DeleteFlags (); } - recflaglist - ; - -recflaglist: - /* empty */ - | flag recflaglist - ; - -flag: - '-' anyident - { parseflags.SetFlag ($2); } - | '-' anyident '=' anyident - { parseflags.SetFlag ($2, $4); } - | '-' anyident '=' NUM - { parseflags.SetFlag ($2, $4); } - | '-' anyident '=' numlistbrack - { parseflags.SetFlag ($2, doublearray); } - | '-' anyident '=' stringlistbrack - { parseflags.SetFlag ($2, stringarray); } - ; - - -numlistbrack: - '[' { doublearray.SetSize (0); } - numlist ']' - ; - -numlist: - NUM { doublearray.Append ($1); } - | numlist ',' NUM { doublearray.Append ($3); } - ; - -stringlistbrack: - '[' - { - int i; - for (i = 0; i < stringarray.Size(); i++) - delete stringarray[i]; - stringarray.SetSize (0); - } - stringlist ']' - ; - -stringlist: - anyident - { - stringarray.Append (new char[strlen($1)+1]); - strcpy (stringarray.Last(), $1); - } - - | stringlist ',' anyident - { - stringarray.Append (new char[strlen($3)+1]); - strcpy (stringarray.Last(), $3); - } - ; - - - - - -anyident: - IDENT { $$ = $1; } - | IDENTSOLID { $$ = $1; } -%% - - -int yyerror (char * s) -{ - cerr << s << " in line " << linenum << endl; - return 0; -} - diff --git a/contrib/Netgen/libsrc/csg/geoml.hpp b/contrib/Netgen/libsrc/csg/geoml.hpp deleted file mode 100644 index e7974ad2063427561cb6c46ce3295321ce09fc17..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/geoml.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FILE_GEOML -#define FILE_GEOML - -/* *************************************************************************/ -/* File: geoml.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 21. Jun. 98 */ -/* *************************************************************************/ - -#include <geom/geom.hh> - -#include <geom/solid.hh> -#include <geom/algprim.hh> -#include <geom/adtree.hh> -#include <geom/csgeom.hh> -#endif diff --git a/contrib/Netgen/libsrc/csg/identify.cpp b/contrib/Netgen/libsrc/csg/identify.cpp deleted file mode 100644 index 4622ee42bb47c315b08e5ec93a1fe0da5a01ee63..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/identify.cpp +++ /dev/null @@ -1,1508 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> -#include <meshing.hpp> - - -namespace netgen -{ -Identification :: Identification (int anr, const CSGeometry & ageom) - : geom(ageom), identfaces(10) -{ - nr = anr; -} - -Identification :: ~Identification () -{ - ; -} - - -ostream & operator<< (ostream & ost, Identification & ident) -{ - ident.Print (ost); - return ost; -} - - -/* -void Identification :: IdentifySpecialPoints (ARRAY<class SpecialPoint> & points) -{ - ; -} -*/ - - -int Identification :: -Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - cout << "Identification::Identifyable called for base-class" << endl; - return 0; -} - -int Identification :: -Identifyable (const Point<3> & p1, const Point<3> & sp2) const -{ - cout << "Identification::Identifyable called for base-class" << endl; - return 0; -} - - -int Identification :: -IdentifyableCandidate (const SpecialPoint & sp1) const -{ - return 1; -} - - -int Identification :: -ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - return 0; -} - -int Identification :: GetIdentifiedPoint (class Mesh & mesh, int pi) -{ - cout << "Identification::GetIdentifiedPoint called for base-class" << endl; - return -1; -} - -void Identification :: IdentifyPoints (Mesh & mesh) -{ - cout << "Identification::IdentifyPoints called for base-class" << endl; - ; -} - -void Identification :: IdentifyFaces (class Mesh & mesh) -{ - cout << "Identification::IdentifyFaces called for base-class" << endl; - ; -} - -void Identification :: -BuildSurfaceElements (ARRAY<Segment> & segs, - Mesh & mesh, const Surface * surf) -{ - cout << "Identification::BuildSurfaceElements called for base-class" << endl; - ; -} - - -void Identification :: -BuildVolumeElements (ARRAY<class Element2d> & surfels, - class Mesh & mesh) -{ - ; -} - -void Identification :: -GetIdentifiedFaces (ARRAY<INDEX_2> & idfaces) const -{ - idfaces.SetSize(0); - for (int i = 1; i <= identfaces.GetNBags(); i++) - for (int j = 1; j <= identfaces.GetBagSize(i); j++) - { - INDEX_2 i2; - int val; - identfaces.GetData (i, j, i2, val); - idfaces.Append (i2); - } -} - - - - -PeriodicIdentification :: -PeriodicIdentification (int anr, - const CSGeometry & ageom, - const Surface * as1, - const Surface * as2) - : Identification(anr, ageom) -{ - s1 = as1; - s2 = as2; -} - -PeriodicIdentification :: ~PeriodicIdentification () -{ - ; -} - -/* -void PeriodicIdentification :: IdentifySpecialPoints -(ARRAY<class SpecialPoint> & points) -{ - int i, j; - int bestj; - double bestval, val; - - for (i = 1; i <= points.Size(); i++) - { - Point<3> p1 = points.Get(i).p; - Point<3> hp1 = p1; - s1->Project (hp1); - if (Dist (p1, hp1) > 1e-6) continue; - - Vec<3> n1; - s1->GetNormalVector (p1, n1); - n1 /= n1.Length(); - if ( fabs(n1 * points.Get(i).v) > 1e-3) - continue; - - bestval = 1e8; - bestj = 1; - for (j = 1; j <= points.Size(); j++) - { - Point<3> p2= points.Get(j).p; - Point<3> hp2 = p2; - s2->Project (hp2); - if (Dist (p2, hp2) > 1e-6) continue; - - Vec<3> n2; - s2->GetNormalVector (p2, n2); - n2 /= n2.Length(); - if ( fabs(n2 * points.Get(j).v) > 1e-3) - continue; - - - Vec<3> v(p1, p2); - double vl = v.Length(); - double cl = fabs (v*n1); - - val = 1 - cl*cl/(vl*vl); - - val += (points.Get(i).v - points.Get(j).v).Length(); - - if (val < bestval) - { - bestj = j; - bestval = val; - } - } - - (*testout) << "Identify Periodic special points: pi = " - << points.Get(i).p << ", vi = " << points.Get(i).v - << " pj = " << points.Get(bestj).p - << ", vj = " << points.Get(bestj).v - << " bestval = " << bestval << endl; - } -} -*/ - -int PeriodicIdentification :: -Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - int i; - double val; - - SpecialPoint hsp1 = sp1; - SpecialPoint hsp2 = sp2; - - for (i = 1; i <= 1; i++) - { - // Swap (hsp1, hsp2); - - if (!s1->PointOnSurface (hsp1.p)) - continue; - - Vec<3> n1; - n1 = s1->GetNormalVector (hsp1.p); - n1 /= n1.Length(); - if ( fabs(n1 * hsp1.v) > 1e-3) - continue; - - - if (!s2->PointOnSurface(hsp2.p)) - continue; - - Vec<3> n2; - n2 = s2->GetNormalVector (hsp2.p); - n2 /= n2.Length(); - if ( fabs(n2 * hsp2.v) > 1e-3) - continue; - - - Vec<3> v = hsp2.p - hsp1.p; - double vl = v.Length(); - double cl = fabs (v*n1); - - - val = 1 - cl*cl/(vl*vl); - val += (hsp1.v - hsp2.v).Length(); - - if (val < 1e-3) - { - return 1; - } - } - - return 0; -} - -int PeriodicIdentification :: -Identifyable (const Point<3> & p1, const Point<3> & p2) const -{ - return (s1->PointOnSurface (p1) && - s2->PointOnSurface (p2)); -} - - - - -int PeriodicIdentification :: -GetIdentifiedPoint (class Mesh & mesh, int pi) -{ - const Surface * sold, *snew; - const Point<3> & p = mesh.Point (pi); - - if (s1->PointOnSurface (p)) - { - snew = s2; - } - else - { - if (s2->PointOnSurface (p)) - { - snew = s1; - } - else - { - cerr << "GetIdenfifiedPoint: Not possible" << endl; - exit (1); - } - } - - // project to other surface - Point<3> hp = p; - snew->Project (hp); - - int i; - int newpi = 0; - for (i = 1; i <= mesh.GetNP(); i++) - if (Dist2 (mesh.Point(i), hp) < 1e-12) - { - newpi = i; - break; - } - if (!newpi) - newpi = mesh.AddPoint (hp); - - if (snew == s2) - mesh.GetIdentifications().Add (pi, newpi, nr); - else - mesh.GetIdentifications().Add (newpi, pi, nr); - - /* - (*testout) << "Identify points(periodic), nr = " << nr << ": " << mesh.Point(pi) - << " and " << mesh.Point(newpi) - << ((snew == s2) ? "" : " inverse") - << endl; - */ - return newpi; -} - - -void PeriodicIdentification :: IdentifyPoints (class Mesh & mesh) -{ - int i, j; - for (i = 1; i <= mesh.GetNP(); i++) - { - Point<3> p = mesh.Point(i); - if (s1->PointOnSurface (p)) - { - Point<3> pp = p; - s2->Project (pp); - for (j = 1; j <= mesh.GetNP(); j++) - if (Dist2(mesh.Point(j), pp) < 1e-6) - { - mesh.GetIdentifications().Add (i, j, nr); - /* - (*testout) << "Identify points(periodic:), nr = " << nr << ": " - << mesh.Point(i) << " - " << mesh.Point(j) << endl; - */ - } - } - } -} - - -void PeriodicIdentification :: IdentifyFaces (class Mesh & mesh) -{ - int i, j, k, l; - int fi1, fi2, side; - for (i = 1; i <= mesh.GetNFD(); i++) - for (j = 1; j <= mesh.GetNFD(); j++) - { - int surfi = mesh.GetFaceDescriptor(i).SurfNr(); - int surfj = mesh.GetFaceDescriptor(j).SurfNr(); - if (surfi == surfj) - continue; - - if (geom.GetSurface (surfi) != s1 || - geom.GetSurface (surfj) != s2) - continue; - - int idok = 1; - - - // (*testout) << "check faces " << i << " and " << j << endl; - for (side = 1; side <= 2 && idok; side++) - { - if (side == 1) - { - fi1 = i; - fi2 = j; - } - else - { - fi1 = j; - fi2 = i; - } - - for (k = 1; k <= mesh.GetNSeg(); k++) - { - const Segment & seg1 = mesh.LineSegment(k); - if (seg1.si != fi1) - continue; - - int foundother = 0; - for (l = 1; l <= mesh.GetNSeg(); l++) - { - const Segment & seg2 = mesh.LineSegment(l); - if (seg2.si != fi2) - continue; - - // (*testout) << "seg1 = " << seg1.p1 << "-" << seg1.p2 << ", seg2 = " << seg2.p1 << "-" << seg2.p2; - - if (side == 1) - { - if (mesh.GetIdentifications().Get (seg1.p1, seg2.p1) && - mesh.GetIdentifications().Get (seg1.p2, seg2.p2)) - { - foundother = 1; - break; - } - - if (mesh.GetIdentifications().Get (seg1.p1, seg2.p2) && - mesh.GetIdentifications().Get (seg1.p2, seg2.p1)) - { - foundother = 1; - break; - } - } - else - { - if (mesh.GetIdentifications().Get (seg2.p1, seg1.p1) && - mesh.GetIdentifications().Get (seg2.p2, seg1.p2)) - { - foundother = 1; - break; - } - - if (mesh.GetIdentifications().Get (seg2.p1, seg1.p2) && - mesh.GetIdentifications().Get (seg2.p2, seg1.p1)) - { - foundother = 1; - break; - } - } - } - - if (!foundother) - { - idok = 0; - break; - } - } - } - - - if (idok) - { - // (*testout) << "Identify faces " << i << " and " << j << endl; - INDEX_2 fpair(i,j); - fpair.Sort(); - identfaces.Set (fpair, 1); - } - } -} - - - -void PeriodicIdentification :: -BuildSurfaceElements (ARRAY<Segment> & segs, - Mesh & mesh, const Surface * surf) -{ - int i1, i2; - int found = 0; - int i, j, k; - int fother; - - - int facei = segs.Get(1).si; - int surfnr = mesh.GetFaceDescriptor(facei).SurfNr(); - - - if (geom.GetSurface(surfnr) == s1 || - geom.GetSurface(surfnr) == s2) - { - // (*testout) << "surfs found !" << endl; - - for (i = 1; i <= mesh.GetNSE(); i++) - { - const Element2d & sel = mesh.SurfaceElement(i); - INDEX_2 fpair (facei, sel.GetIndex()); - fpair.Sort(); - if (identfaces.Used (fpair)) - { - found = 1; - fother = sel.GetIndex(); - - // copy element - Element2d newel(3); - newel.SetIndex (facei); - for (k = 1; k <= 3; k++) - { - newel.PNum(k) = - GetIdentifiedPoint (mesh, sel.PNum(k)); - } - - Vec<3> nt = Cross (Point<3> (mesh.Point (newel.PNum(2)))- - Point<3> (mesh.Point (newel.PNum(1))), - Point<3> (mesh.Point (newel.PNum(3)))- - Point<3> (mesh.Point (newel.PNum(1)))); - - Vec<3> nsurf; - nsurf = geom.GetSurface (surfnr)->GetNormalVector (mesh.Point(newel.PNum(1))); - if (nsurf * nt < 0) - Swap (newel.PNum(2), newel.PNum(3)); - - mesh.AddSurfaceElement (newel); - } - } - } - - if (found) - { - (*mycout) << " copy face " << facei << " from face " << fother; - segs.SetSize(0); - } -} - - - - - - - - -void PeriodicIdentification :: Print (ostream & ost) const -{ - ost << "Periodic Identifiaction, surfaces: " - << s1->Name() << " - " << s2->Name() << endl; - s1->Print (ost); - ost << " - "; - s2->Print (ost); - ost << endl; -} - - -void PeriodicIdentification :: GetData (ostream & ost) const -{ - ost << "periodic " << s1->Name() << " " << s2->Name(); -} - - - - - - - -CloseSurfaceIdentification :: -CloseSurfaceIdentification (int anr, - const CSGeometry & ageom, - const Surface * as1, - const Surface * as2, - const TopLevelObject * adomain, - const Flags & flags) - : Identification(anr, ageom) -{ - s1 = as1; - s2 = as2; - domain = adomain; - ref_levels = int (flags.GetNumFlag ("reflevels", 2)); - ref_levels_s1 = int (flags.GetNumFlag ("reflevels1", 0)); - ref_levels_s2 = int (flags.GetNumFlag ("reflevels2", 0)); - slices = flags.GetNumListFlag ("slices"); - // eps_n = 1e-3; - eps_n = 1e-6; - - dom_surf_valid = 0; -} - -CloseSurfaceIdentification :: ~CloseSurfaceIdentification () -{ - ; -} - -void CloseSurfaceIdentification :: Print (ostream & ost) const -{ - ost << "CloseSurface Identifiaction, surfaces: " - << s1->Name() << " - " << s2->Name() << endl; - s1->Print (ost); - s2->Print (ost); - ost << endl; -} - - -void CloseSurfaceIdentification :: GetData (ostream & ost) const -{ - ost << "close surface " << s1->Name() << " " << s2->Name(); -} - - -/* -void CloseSurfaceIdentification :: IdentifySpecialPoints -(ARRAY<class SpecialPoint> & points) -{ - int i, j; - int bestj; - double bestval, val; - - for (i = 1; i <= points.Size(); i++) - { - Point<3> p1 = points.Get(i).p; - Vec<3> n1; - - if (!s1->PointOnSurface (p1)) - continue; - - s1->GetNormalVector (p1, n1); - n1 /= n1.Length(); - if ( fabs(n1 * points.Get(i).v) > 1e-3) - continue; - - bestval = 1e8; - bestj = 1; - for (j = 1; j <= points.Size(); j++) - { - Point<3> p2= points.Get(j).p; - if (!s2->PointOnSurface (p2)) - continue; - - Vec<3> n2; - s2->GetNormalVector (p2, n2); - n2 /= n2.Length(); - if ( fabs(n2 * points.Get(j).v) > 1e-3) - continue; - - - Vec<3> v(p1, p2); - double vl = v.Length(); - double cl = fabs (v*n1); - - val = 1 - cl*cl/(vl*vl); - - val += (points.Get(i).v - points.Get(j).v).Length(); - - if (val < bestval) - { - bestj = j; - bestval = val; - } - } - - (*testout) << "Identify close surfaces special points: pi = " - << points.Get(i).p << ", vi = " << points.Get(i).v - << " pj = " << points.Get(bestj).p - << ", vj = " << points.Get(bestj).v - << " bestval = " << bestval << endl; - } -} -*/ - -int CloseSurfaceIdentification :: -Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - - if (!dom_surf_valid) - { - const_cast<bool&> (dom_surf_valid) = 1; - ARRAY<int> & hsurf = const_cast<ARRAY<int>&> (domain_surfaces); - - if (domain) - { - BoxSphere<3> hbox (geom.BoundingBox()); - geom.GetIndependentSurfaceIndices (domain->GetSolid(), hbox, - hsurf); - } - else - { - hsurf.SetSize (geom.GetNSurf()); - for (int j = 0; j < hsurf.Size(); j++) - hsurf[j] = j; - } - } - - - - if (!s1->PointOnSurface (sp1.p)) - return 0; - - Vec<3> n1 = s1->GetNormalVector (sp1.p); - n1.Normalize(); - if ( fabs(n1 * sp1.v) > eps_n) - return 0; - - if (!s2->PointOnSurface(sp2.p)) - return 0; - - Vec<3> n2 = s2->GetNormalVector (sp2.p); - n2.Normalize(); - if ( fabs(n2 * sp2.v) > eps_n) - return 0; - - // must have joint surface - bool joint = 0; - // for (int j = 0; j < geom.GetNSurf(); j++) - for (int jj = 0; jj < domain_surfaces.Size(); jj++) - { - int j = domain_surfaces[jj]; - if (geom.GetSurface(j) -> PointOnSurface(sp1.p) && - geom.GetSurface(j) -> PointOnSurface(sp2.p) ) - { - Vec<3> hn1 = geom.GetSurface(j)->GetNormalVector (sp1.p); - Vec<3> hn2 = geom.GetSurface(j)->GetNormalVector (sp2.p); - - if (hn1 * hn2 > 0) - { - joint = 1; - break; - } - } - } - if (!joint) return 0; - - Vec<3> v = sp2.p - sp1.p; - double vl = v.Length(); - double cl = fabs (v*n1); - - if (cl > (1-eps_n*eps_n) * vl && (sp1.v - sp2.v).Length() < 0.1) - return 1; - - return 0; -} - -int CloseSurfaceIdentification :: -Identifyable (const Point<3> & p1, const Point<3> & p2) const -{ - return (s1->PointOnSurface (p1) && s2->PointOnSurface (p2)); -} - - - - -int CloseSurfaceIdentification :: -IdentifyableCandidate (const SpecialPoint & sp1) const -{ - if (s1->PointOnSurface (sp1.p)) - { - Vec<3> n1; - n1 = s1->GetNormalVector (sp1.p); - n1.Normalize(); - if ( fabs(n1 * sp1.v) > eps_n) - return 0; - return 1; - } - - if (s2->PointOnSurface (sp1.p)) - { - Vec<3> n1; - n1 = s2->GetNormalVector (sp1.p); - n1.Normalize(); - if ( fabs(n1 * sp1.v) > eps_n) - return 0; - return 1; - } - return 0; -} - - - -int CloseSurfaceIdentification :: -ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - if ( (s1->PointOnSurface (sp1.p) && s2->PointOnSurface (sp2.p)) || - (s1->PointOnSurface (sp2.p) && s2->PointOnSurface (sp1.p)) ) - { - return 1; - } - return 0; -} - - - -int CloseSurfaceIdentification :: -GetIdentifiedPoint (class Mesh & mesh, int pi) -{ - const Surface * sold, *snew; - const Point<3> & p = mesh.Point (pi); - - ARRAY<int,PointIndex::BASE> identmap(mesh.GetNP()); - mesh.GetIdentifications().GetMap (nr, identmap); - if (identmap.Get(pi)) - return identmap.Get(pi); - - if (s1->PointOnSurface (p)) - { - snew = s2; - } - else - { - if (s2->PointOnSurface (p)) - { - snew = s1; - } - else - { - (*testout) << "GetIdenfifiedPoint: Not possible" << endl; - (*testout) << "p = " << p << endl; - (*testout) << "surf1: "; - s1->Print (*testout); - (*testout) << endl; - (*testout) << "surf2: "; - s2->Print (*testout); - (*testout) << endl; - - cerr << "GetIdenfifiedPoint: Not possible" << endl; - exit (1); - } - } - - // project to other surface - Point<3> hp = p; - snew->Project (hp); - - int i; - int newpi = 0; - for (i = 1; i <= mesh.GetNP(); i++) - if (Dist2 (mesh.Point(i), hp) < 1e-12) - // if (Dist2 (mesh.Point(i), hp) < 1 * Dist2 (hp, p)) - { - newpi = i; - break; - } - if (!newpi) - newpi = mesh.AddPoint (hp); - - if (snew == s2) - mesh.GetIdentifications().Add (pi, newpi, nr); - else - mesh.GetIdentifications().Add (newpi, pi, nr); - - /* - (*testout) << "Identify points(closesurface), nr = " << nr << ": " << mesh.Point(pi) - << " and " << mesh.Point(newpi) - << ((snew == s2) ? "" : " inverse") - << endl; - */ - return newpi; -} - - - - - -void CloseSurfaceIdentification :: IdentifyPoints (Mesh & mesh) -{ - int i, j; - int i1, i2; - - int np = mesh.GetNP(); - BitArray ons2(np); - ons2.Clear(); - for (i2 = 1; i2 <= np; i2++) - if (s2->PointOnSurface (mesh.Point(i2))) - ons2.Set (i2); - - for (i1 = 1; i1 <= np; i1++) - { - const Point<3> p1 = mesh.Point(i1); - if (s1->PointOnSurface (p1)) - { - int candi2 = 0; - double mindist = 1e10; - - Vec<3> n1; - n1 = s1->GetNormalVector (p1); - n1.Normalize(); - - for (i2 = 1; i2 <= np; i2++) - { - if (i2 == i1) - continue; - - const Point<3> p2 = mesh.Point(i2); - - if (!ons2.Test(i2)) - continue; - /* - if (!s2->PointOnSurface (p2)) - continue; - */ - Vec<3> n = p2 - p1; - n.Normalize(); - - - bool joint = 0; - for (int jj = 0; jj < domain_surfaces.Size(); jj++) - { - int j = domain_surfaces[jj]; - if (geom.GetSurface(j) -> PointOnSurface(p1) && - geom.GetSurface(j) -> PointOnSurface(p2) ) - { - Vec<3> hn1 = geom.GetSurface(j)->GetNormalVector (p1); - Vec<3> hn2 = geom.GetSurface(j)->GetNormalVector (p2); - - if (hn1 * hn2 > 0) - { - joint = 1; - break; - } - } - } - if (!joint) continue; - - - - - if (fabs (n * n1) > 0.9 && - Dist (p1, p2) < mindist) - { - candi2 = i2; - mindist = Dist (p1, p2); - } - } - - if (candi2) - { - // (*testout) << "identify points " << p1 << " - " << mesh.Point(candi2) << endl; - (*testout) << "Add Identification from CSI2, p1 = " - << mesh[PointIndex(i1)] << ", p2 = " - << mesh[PointIndex(candi2)] << endl; - - mesh.GetIdentifications().Add (i1, candi2, nr); - } - } - } -} - - - -void CloseSurfaceIdentification :: IdentifyFaces (class Mesh & mesh) -{ - int i, j, k, l; - int fi1, fi2, side; - - int s1rep, s2rep; - for (i = 0; i < geom.GetNSurf(); i++) - { - if (geom.GetSurface (i) == s1) - s1rep = geom.GetSurfaceClassRepresentant(i); - if (geom.GetSurface (i) == s2) - s2rep = geom.GetSurfaceClassRepresentant(i); - } - - for (i = 1; i <= mesh.GetNFD(); i++) - for (j = 1; j <= mesh.GetNFD(); j++) - { - int surfi = mesh.GetFaceDescriptor(i).SurfNr(); - int surfj = mesh.GetFaceDescriptor(j).SurfNr(); - if (surfi == surfj) - continue; - - if (s1rep != surfi || s2rep != surfj) - continue; - - /* - if (geom.GetSurface (surfi) != s1 || - geom.GetSurface (surfj) != s2) - continue; - */ - - int idok = 1; - - - // (*testout) << "check faces " << i << " and " << j << endl; - for (side = 1; side <= 2 && idok; side++) - { - if (side == 1) - { - fi1 = i; - fi2 = j; - } - else - { - fi1 = j; - fi2 = i; - } - - for (k = 1; k <= mesh.GetNSeg(); k++) - { - const Segment & seg1 = mesh.LineSegment(k); - if (seg1.si != fi1) - continue; - - int foundother = 0; - for (l = 1; l <= mesh.GetNSeg(); l++) - { - const Segment & seg2 = mesh.LineSegment(l); - if (seg2.si != fi2) - continue; - - // (*testout) << "seg1 = " << seg1.p1 << "-" << seg1.p2 << ", seg2 = " << seg2.p1 << "-" << seg2.p2; - - if (side == 1) - { - if (mesh.GetIdentifications().Get (seg1.p1, seg2.p1) && - mesh.GetIdentifications().Get (seg1.p2, seg2.p2)) - { - foundother = 1; - break; - } - - if (mesh.GetIdentifications().Get (seg1.p1, seg2.p2) && - mesh.GetIdentifications().Get (seg1.p2, seg2.p1)) - { - foundother = 1; - break; - } - } - else - { - if (mesh.GetIdentifications().Get (seg2.p1, seg1.p1) && - mesh.GetIdentifications().Get (seg2.p2, seg1.p2)) - { - foundother = 1; - break; - } - - if (mesh.GetIdentifications().Get (seg2.p1, seg1.p2) && - mesh.GetIdentifications().Get (seg2.p2, seg1.p1)) - { - foundother = 1; - break; - } - } - } - - if (!foundother) - { - idok = 0; - break; - } - } - } - - - if (idok) - { - // (*testout) << "Identify faces " << i << " and " << j << endl; - INDEX_2 fpair(i,j); - fpair.Sort(); - identfaces.Set (fpair, 1); - } - } -} - - - -void CloseSurfaceIdentification :: -BuildSurfaceElements (ARRAY<Segment> & segs, - Mesh & mesh, const Surface * surf) -{ - int i1, i2; - int found = 0, cntquads = 0; - int i, j, k; - - // insert quad layer: - for (i1 = 1; i1 <= segs.Size(); i1++) - for (i2 = 1; i2 < i1; i2++) - { - const Segment & s1 = segs.Get(i1); - const Segment & s2 = segs.Get(i2); - if ( (mesh.GetIdentifications().Get (s1.p1, s2.p2) == nr && - mesh.GetIdentifications().Get (s1.p2, s2.p1) == nr) || - (mesh.GetIdentifications().Get (s2.p1, s1.p2) == nr && - mesh.GetIdentifications().Get (s2.p2, s1.p1) == nr) - ) - { - Element2d el(4); - el.PNum(1) = s1.p1; - el.PNum(2) = s1.p2; - el.PNum(3) = s2.p1; - el.PNum(4) = s2.p2; - - Vec<3> n = Cross (Point<3> (mesh.Point(el.PNum(2)))- - Point<3> (mesh.Point(el.PNum(1))), - Point<3> (mesh.Point(el.PNum(4)))- - Point<3> (mesh.Point(el.PNum(1)))); - - Vec<3> ns; - ns = surf->GetNormalVector (mesh.Point(el.PNum(1))); - // (*testout) << "n = " << n << " ns = " << ns << endl; - if (n * ns < 0) - { - // (*testout) << "Swap the quad" << endl; - Swap (el.PNum(1), el.PNum(2)); - Swap (el.PNum(3), el.PNum(4)); - } - - mesh.AddSurfaceElement (el); - (*testout) << "add rect element: " - << mesh.Point (el.PNum(1)) << " - " - << mesh.Point (el.PNum(2)) << " - " - << mesh.Point (el.PNum(3)) << " - " - << mesh.Point (el.PNum(4)) << endl; - found = 1; - cntquads++; - } - } - - if (found) - { - (*mycout) << " insert quad layer of " << cntquads - << " elements at face " << segs.Get(1).si << endl; - segs.SetSize(0); - } - else - { - BuildSurfaceElements2 (segs, mesh, surf); - } - - /* - int fother; - int facei = segs.Get(1).si; - int surfnr = mesh.GetFaceDescriptor(facei).SurfNr(); - - int foundid = 0; - for (i = 1; i <= identfaces.GetNBags(); i++) - for (j = 1; j <= identfaces.GetBagSize(i); j++) - { - INDEX_2 i2; - int data; - identfaces.GetData (i, j, i2, data); - if (i2.I1() == facei || i2.I2() == facei) - foundid = 1; - } - - // (*testout) << "facei = " << facei << ", surfnr = " << surfnr << endl; - - if (foundid) - { - // (*testout) << "surfaces found" << endl; - // copy surface - for (i = 1; i <= mesh.GetNSE(); i++) - { - const Element2d & sel = mesh.SurfaceElement(i); - INDEX_2 fpair (facei, sel.GetIndex()); - fpair.Sort(); - if (identfaces.Used (fpair)) - { - found = 1; - fother = sel.GetIndex(); - - // copy element - Element2d newel(3); - newel.SetIndex (facei); - for (k = 1; k <= 3; k++) - { - newel.PNum(k) = - GetIdentifiedPoint (mesh, sel.PNum(k)); - // cout << "id-point = " << sel.PNum(k) << ", np = " << newel.PNum(k) << endl; - } - - Vec<3> nt = Cross (Vec<3> (mesh.Point (newel.PNum(1)), mesh.Point (newel.PNum(2))), - Vec<3> (mesh.Point (newel.PNum(1)), mesh.Point (newel.PNum(3)))); - Vec<3> nsurf; - nsurf = geom.GetSurface (surfnr)->GetNormalVector (mesh.Point(newel.PNum(1))); - if (nsurf * nt < 0) - Swap (newel.PNum(2), newel.PNum(3)); - - mesh.AddSurfaceElement (newel); - } - } - } - - if (found) - (*mycout) << " copy face " << facei << " from face " << fother; - } - - if (found) - segs.SetSize(0); - */ -} - - - - - - -void CloseSurfaceIdentification :: -BuildSurfaceElements2 (ARRAY<Segment> & segs, - Mesh & mesh, const Surface * surf) -{ - int i1, i2; - int found = 0, cntquads = 0; - int i, j, k; - - int fother; - int facei = segs.Get(1).si; - int surfnr = mesh.GetFaceDescriptor(facei).SurfNr(); - - int foundid = 0; - for (i = 1; i <= identfaces.GetNBags(); i++) - for (j = 1; j <= identfaces.GetBagSize(i); j++) - { - INDEX_2 i2; - int data; - identfaces.GetData (i, j, i2, data); - if (i2.I1() == facei || i2.I2() == facei) - foundid = 1; - } - - // (*testout) << "facei = " << facei << ", surfnr = " << surfnr << endl; - - /* - if (geom.GetSurface(surfnr) == s1 || - geom.GetSurface(surfnr) == s2) - */ - if (foundid) - { - // (*testout) << "surfaces found" << endl; - // copy surface - for (i = 1; i <= mesh.GetNSE(); i++) - { - const Element2d & sel = mesh.SurfaceElement(i); - INDEX_2 fpair (facei, sel.GetIndex()); - fpair.Sort(); - if (identfaces.Used (fpair)) - { - found = 1; - fother = sel.GetIndex(); - - // copy element - Element2d newel(3); - newel.SetIndex (facei); - for (k = 1; k <= 3; k++) - { - newel.PNum(k) = - GetIdentifiedPoint (mesh, sel.PNum(k)); - // cout << "id-point = " << sel.PNum(k) << ", np = " << newel.PNum(k) << endl; - } - - Vec<3> nt = Cross (Point<3> (mesh.Point (newel.PNum(2)))- - Point<3> (mesh.Point (newel.PNum(1))), - Point<3> (mesh.Point (newel.PNum(3)))- - Point<3> (mesh.Point (newel.PNum(1)))); - Vec<3> nsurf; - nsurf = geom.GetSurface (surfnr)->GetNormalVector (mesh.Point(newel.PNum(1))); - if (nsurf * nt < 0) - Swap (newel.PNum(2), newel.PNum(3)); - - mesh.AddSurfaceElement (newel); - } - } - } - - if (found) - { - (*mycout) << " copy face " << facei << " from face " << fother; - segs.SetSize(0); - } -} - - - - - - - - - - - - - - -void CloseSurfaceIdentification :: -BuildVolumeElements (ARRAY<class Element2d> & surfels, - class Mesh & mesh) -{ - ; -} - - - - - - - - - - - - - -/* ***************** Close Edges Identification ********** */ - - - -CloseEdgesIdentification :: -CloseEdgesIdentification (int anr, - const CSGeometry & ageom, - const Surface * afacet, - const Surface * as1, - const Surface * as2) - : Identification(anr, ageom) -{ - facet = afacet; - s1 = as1; - s2 = as2; -} - -CloseEdgesIdentification :: ~CloseEdgesIdentification () -{ - ; -} - -void CloseEdgesIdentification :: Print (ostream & ost) const -{ - ost << "CloseEdges Identifiaction, facet = " - << facet->Name() << ", surfaces: " - << s1->Name() << " - " << s2->Name() << endl; - facet->Print (ost); - s1->Print (ost); - s2->Print (ost); - ost << endl; -} - - -void CloseEdgesIdentification :: GetData (ostream & ost) const -{ - ost << "closeedges " << facet->Name() << " " - << s1->Name() << " " << s2->Name(); -} - - -/* -void CloseEdgesIdentification :: IdentifySpecialPoints -(ARRAY<class SpecialPoint> & points) -{ - int i, j; - int bestj; - double bestval, val; - - for (i = 1; i <= points.Size(); i++) - { - Point<3> p1 = points.Get(i).p; - Vec<3> n1; - - if (!s1->PointOnSurface (p1)) - continue; - - s1->GetNormalVector (p1, n1); - n1 /= n1.Length(); - if ( fabs(n1 * points.Get(i).v) > 1e-3) - continue; - - bestval = 1e8; - bestj = 1; - for (j = 1; j <= points.Size(); j++) - { - Point<3> p2= points.Get(j).p; - if (!s2->PointOnSurface (p2)) - continue; - - Vec<3> n2; - s2->GetNormalVector (p2, n2); - n2 /= n2.Length(); - if ( fabs(n2 * points.Get(j).v) > 1e-3) - continue; - - - Vec<3> v(p1, p2); - double vl = v.Length(); - double cl = fabs (v*n1); - - val = 1 - cl*cl/(vl*vl); - - val += (points.Get(i).v - points.Get(j).v).Length(); - - if (val < bestval) - { - bestj = j; - bestval = val; - } - } - - (*testout) << "Identify close surfaces special points: pi = " - << points.Get(i).p << ", vi = " << points.Get(i).v - << " pj = " << points.Get(bestj).p - << ", vj = " << points.Get(bestj).v - << " bestval = " << bestval << endl; - } -} -*/ - -int CloseEdgesIdentification :: -Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) const -{ - int i; - double val; - - SpecialPoint hsp1 = sp1; - SpecialPoint hsp2 = sp2; - - for (i = 1; i <= 1; i++) - { - if (!s1->PointOnSurface (hsp1.p)) - continue; - - Vec<3> n1; - n1 = s1->GetNormalVector (hsp1.p); - n1 /= n1.Length(); - if ( fabs(n1 * hsp1.v) > 1e-3) - continue; - - - if (!s2->PointOnSurface(hsp2.p)) - continue; - - Vec<3> n2; - n2 = s2->GetNormalVector (hsp2.p); - n2 /= n2.Length(); - if ( fabs(n2 * hsp2.v) > 1e-3) - continue; - - - Vec<3> v = hsp2.p - hsp1.p; - double vl = v.Length(); - double cl = fabs (v*n1); - - - val = 1 - cl*cl/(vl*vl); - val += (hsp1.v - hsp2.v).Length(); - - if (val < 1e-3) - { - return 1; - } - } - - return 0; -} - - - - -void CloseEdgesIdentification :: IdentifyPoints (Mesh & mesh) -{ - int i, j; - int i1, i2; - - int np = mesh.GetNP(); - for (i1 = 1; i1 <= np; i1++) - for (i2 = 1; i2 <= np; i2++) - { - if (i2 == i1) - continue; - - const Point<3> p1 = mesh.Point(i1); - const Point<3> p2 = mesh.Point(i2); - Point<3> pp1 = p1; - Point<3> pp2 = p2; - - s1->Project (pp1); - facet->Project (pp1); - s2->Project (pp2); - facet->Project (pp2); - - if (Dist (p1, pp1) > 1e-6 || Dist (p2, pp2) > 1e-6) - continue; - - Vec<3> n1, nf, t; - Vec<3> n = p2 - p1; - n.Normalize(); - - n1 = s1->GetNormalVector (p1); - nf = facet->GetNormalVector (p1); - t = Cross (n1, nf); - t /= t.Length(); - - if (fabs (n * t) < 0.5) - { - (*testout) << "close edges identify points " << p1 << " - " << p2 << endl; - mesh.GetIdentifications().Add (i1, i2, nr); - } - } -} - -void CloseEdgesIdentification :: -BuildSurfaceElements (ARRAY<Segment> & segs, - Mesh & mesh, const Surface * surf) -{ - int i1, i2; - int found = 0; - int i, j, k; - - if (surf != facet) - return; - - for (i1 = 1; i1 <= segs.Size(); i1++) - for (i2 = 1; i2 < i1; i2++) - { - const Segment & s1 = segs.Get(i1); - const Segment & s2 = segs.Get(i2); - if (mesh.GetIdentifications().Get (s1.p1, s2.p2) && - mesh.GetIdentifications().Get (s1.p2, s2.p1)) - { - Element2d el(4); - el.PNum(1) = s1.p1; - el.PNum(2) = s1.p2; - el.PNum(3) = s2.p2; - el.PNum(4) = s2.p1; - - Vec<3> n = Cross (Point<3> (mesh.Point(el.PNum(2)))- - Point<3> (mesh.Point(el.PNum(1))), - Point<3> (mesh.Point(el.PNum(3)))- - Point<3> (mesh.Point(el.PNum(1)))); - Vec<3> ns; - ns = surf->GetNormalVector (mesh.Point(el.PNum(1))); - (*testout) << "n = " << n << " ns = " << ns << endl; - if (n * ns < 0) - { - (*testout) << "Swap the quad" << endl; - Swap (el.PNum(1), el.PNum(2)); - Swap (el.PNum(3), el.PNum(4)); - } - - - Swap (el.PNum(3), el.PNum(4)); - mesh.AddSurfaceElement (el); - (*testout) << "add rect element: " - << mesh.Point (el.PNum(1)) << " - " - << mesh.Point (el.PNum(2)) << " - " - << mesh.Point (el.PNum(3)) << " - " - << mesh.Point (el.PNum(4)) << endl; - found = 1; - } - } - - if (found) - segs.SetSize(0); -} - -} diff --git a/contrib/Netgen/libsrc/csg/identify.hpp b/contrib/Netgen/libsrc/csg/identify.hpp deleted file mode 100644 index 16e371b2002eb5f3dbb592d5ccbda82c64f4c4c7..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/identify.hpp +++ /dev/null @@ -1,180 +0,0 @@ - -#ifndef FILE_IDENTIFY -#define FILE_IDENTIFY - -/**************************************************************************/ -/* File: identify.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 1. Aug. 99 */ -/**************************************************************************/ - -/** - Identify surfaces for periodic b.c. or - thin domains -*/ - - -class SpecialPoint; -class Identification -{ -protected: - const CSGeometry & geom; - // identified faces, index sorted - INDEX_2_HASHTABLE<int> identfaces; - int nr; - -public: - Identification (int anr, const CSGeometry & ageom); - virtual ~Identification (); - virtual void Print (ostream & ost) const = 0; - virtual void GetData (ostream & ost) const = 0; - - /// obsolete - // virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points); - - /// can identify both special points (fixed direction) - /// (identified points, same tangent) - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) const; - /// - virtual int Identifyable (const Point<3> & p1, const Point<3> & sp2) const; - /// is it possible to identify sp1 with some other ? - virtual int IdentifyableCandidate (const SpecialPoint & sp1) const; - - /// are points (if connected) by a short edge (direction anyhow) ? - virtual int ShortEdge (const SpecialPoint & sp1, const SpecialPoint & sp2) const; - - /// add entries in mesh identification tables - virtual void IdentifyPoints (class Mesh & mesh); - - /// add entries to identified faces (based on segment infos) - virtual void IdentifyFaces (class Mesh & mesh); - - /// get point on other surface, add entry in mesh identifications - virtual int GetIdentifiedPoint (class Mesh & mesh, int pi1); - - /// copy surfaces, or fill rectangles - virtual void BuildSurfaceElements (ARRAY<class Segment> & segs, - class Mesh & mesh, - const Surface * surf); - - /// insert volume elements in thin layers - virtual void BuildVolumeElements (ARRAY<class Element2d> & surfels, - class Mesh & mesh); - - /// get list of identified faces - virtual void GetIdentifiedFaces (ARRAY<INDEX_2> & idfaces) const; - - friend ostream & operator<< (ostream & ost, Identification & ident); -}; - - -class PeriodicIdentification : public Identification -{ - const Surface * s1; - const Surface * s2; -public: - PeriodicIdentification (int anr, - const CSGeometry & ageom, - const Surface * as1, - const Surface * as2); - virtual ~PeriodicIdentification (); - virtual void Print (ostream & ost) const; - virtual void GetData (ostream & ost) const; - - - // virtual void IdentifySpecialPoints (ARRAY<class SpecialPoint> & points); - virtual int Identifyable (const SpecialPoint & sp1, const SpecialPoint & sp2) 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; - /// 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; -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; - 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; } -}; - - -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; - - - virtual void IdentifyPoints (class Mesh & mesh); - virtual void BuildSurfaceElements (ARRAY<class Segment> & segs, - class Mesh & mesh, - const Surface * surf); -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/lex.yy.cpp b/contrib/Netgen/libsrc/csg/lex.yy.cpp deleted file mode 100644 index e5c4e6f614d4d35410c2df8358adee7d6899ec32..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/lex.yy.cpp +++ /dev/null @@ -1,1834 +0,0 @@ -/* A lexical scanner generated by flex */ - -/* Scanner skeleton version: - * $Header: /cvsroot/gmsh/contrib/Netgen/libsrc/csg/lex.yy.cpp,v 1.1 2005-09-21 17:29:38 geuzaine Exp $ - */ - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 - - - -/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ -#ifdef c_plusplus -#ifndef __cplusplus -#define __cplusplus -#endif -#endif - - -#ifdef __cplusplus - -#include <stdlib.h> -#include <iostream.h> -#include <unistd.h> - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -#if __STDC__ - -#define YY_USE_PROTOS -#define YY_USE_CONST - -#endif /* __STDC__ */ -#endif /* ! __cplusplus */ - -#ifdef __TURBOC__ - #pragma warn -rch - #pragma warn -use -#include <io.h> -#include <stdlib.h> -#define YY_USE_CONST -#define YY_USE_PROTOS -#endif - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - - -#ifdef YY_USE_PROTOS -#define YY_PROTO(proto) proto -#else -#define YY_PROTO(proto) () -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN yy_start = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START ((yy_start - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE yyrestart( yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#define YY_BUF_SIZE 16384 - -typedef struct yy_buffer_state *YY_BUFFER_STATE; - -extern int yyleng; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - -/* The funky do-while in the following #define is used to turn the definition - * int a single C statement (which needs a semi-colon terminator). This - * avoids problems with code like: - * - * if ( condition_holds ) - * yyless( 5 ); - * else - * do_something_else(); - * - * Prior to using the do-while the compiler would get upset at the - * "else" because it interpreted the "if" statement as being all - * done when it reached the ';' after the yyless() call. - */ - -/* Return all but the first 'n' matched characters back to the input stream. */ - -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - *yy_cp = yy_hold_char; \ - YY_RESTORE_YY_MORE_OFFSET \ - yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, yytext_ptr ) - -/* The following is because we cannot portably get our hands on size_t - * (without autoconf's help, which isn't available because we want - * flex-generated scanners to compile on their own). - */ -typedef unsigned int yy_size_t; - - -struct yy_buffer_state - { - istream* yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - int yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via yyrestart()), so that the user can continue scanning by - * just pointing yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - }; - - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - */ -#define YY_CURRENT_BUFFER yy_current_buffer - - - -static void *yy_flex_alloc YY_PROTO(( yy_size_t )); -static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); -static void yy_flex_free YY_PROTO(( void * )); - -#define yy_new_buffer yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! yy_current_buffer ) \ - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ - yy_current_buffer->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) - - -#define FLEX_DEBUG -typedef unsigned char YY_CHAR; -#define yytext_ptr yytext -#define YY_INTERACTIVE - -#define FLEX_DEBUG - -#include <FlexLexer.h> - - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up yytext. - */ -#define YY_DO_BEFORE_ACTION \ - yytext_ptr = yy_bp; \ - yyleng = (int) (yy_cp - yy_bp); \ - yy_hold_char = *yy_cp; \ - *yy_cp = '\0'; \ - yy_c_buf_p = yy_cp; - -#define YY_NUM_RULES 37 -#define YY_END_OF_BUFFER 38 -static yyconst short int yy_accept[222] = - { 0, - 0, 0, 0, 0, 0, 0, 38, 33, 32, 34, - 33, 33, 33, 30, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 37, 0, - 36, 0, 0, 30, 30, 30, 0, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 5, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 0, 35, 0, 0, 30, 31, 4, 31, - 31, 31, 31, 31, 31, 31, 31, 6, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 3, 31, - 31, 0, 30, 31, 31, 31, 13, 31, 22, 31, - - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 16, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 14, 15, 23, 31, 31, 31, - 31, 2, 31, 31, 31, 31, 31, 31, 31, 31, - 17, 31, 31, 31, 31, 31, 31, 31, 9, 31, - 11, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 12, 24, 31, 31, 31, 27, 31, 31, - 21, 31, 31, 31, 31, 31, 31, 31, 31, 31, - 31, 31, 7, 31, 31, 31, 26, 31, 31, 31, - - 18, 19, 20, 1, 31, 29, 31, 10, 31, 31, - 31, 31, 31, 25, 31, 31, 8, 31, 31, 28, - 0 - } ; - -static yyconst int yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 1, 4, 1, 1, 1, 1, 1, - 1, 1, 5, 1, 5, 6, 1, 7, 7, 7, - 8, 7, 7, 7, 7, 7, 7, 1, 1, 1, - 1, 1, 1, 1, 9, 9, 9, 9, 10, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 1, 1, 1, 1, 1, 1, 11, 12, 13, 14, - - 15, 16, 17, 18, 19, 9, 20, 21, 22, 23, - 24, 25, 9, 26, 27, 28, 29, 30, 9, 31, - 32, 9, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst int yy_meta[33] = - { 0, - 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2 - } ; - -static yyconst short int yy_base[226] = - { 0, - 0, 0, 0, 0, 0, 0, 77, 706, 706, 706, - 30, 29, 31, 34, 38, 40, 43, 61, 45, 47, - 50, 58, 64, 66, 87, 76, 105, 124, 706, 67, - 706, 57, 68, 0, 71, 89, 98, 82, 102, 108, - 112, 110, 114, 120, 126, 129, 133, 144, 141, 147, - 150, 153, 156, 161, 158, 163, 166, 169, 176, 178, - 185, 191, 53, 706, 199, 193, 201, 203, 205, 207, - 209, 212, 214, 216, 221, 218, 230, 232, 235, 237, - 240, 242, 244, 247, 253, 260, 262, 265, 267, 271, - 275, 277, 279, 281, 284, 288, 292, 294, 297, 299, - - 301, 303, 306, 308, 311, 313, 316, 318, 330, 332, - 334, 338, 340, 342, 346, 348, 351, 357, 368, 360, - 370, 372, 378, 380, 384, 388, 394, 396, 398, 400, - 402, 405, 409, 411, 414, 421, 423, 426, 428, 430, - 434, 436, 441, 443, 446, 448, 452, 454, 456, 463, - 468, 470, 472, 476, 478, 480, 485, 491, 482, 493, - 495, 497, 502, 505, 511, 515, 517, 519, 521, 528, - 531, 535, 540, 542, 545, 547, 550, 552, 554, 557, - 559, 561, 564, 566, 572, 575, 577, 579, 584, 586, - 590, 592, 596, 602, 610, 612, 614, 616, 619, 623, - - 628, 630, 632, 634, 638, 640, 642, 646, 648, 653, - 655, 657, 659, 661, 663, 667, 669, 672, 676, 681, - 706, 699, 701, 41, 703 - } ; - -static yyconst short int yy_def[226] = - { 0, - 221, 1, 222, 222, 222, 222, 221, 221, 221, 221, - 223, 221, 221, 221, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 221, 223, - 221, 225, 221, 14, 221, 221, 221, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 225, 221, 221, 221, 221, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 221, 221, 224, 224, 224, 224, 224, 224, 224, - - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, - 0, 221, 221, 221, 221 - } ; - -static yyconst short int yy_nxt[739] = - { 0, - 8, 9, 10, 11, 12, 13, 14, 14, 15, 15, - 16, 17, 18, 15, 19, 15, 20, 15, 21, 15, - 15, 22, 23, 24, 25, 26, 27, 28, 15, 15, - 15, 15, 31, 32, 33, 34, 34, 35, 35, 36, - 34, 34, 39, 37, 38, 38, 38, 38, 37, 38, - 38, 38, 38, 38, 38, 64, 38, 38, 46, 64, - 40, 47, 41, 48, 38, 38, 42, 38, 38, 31, - 38, 38, 38, 38, 35, 35, 221, 35, 35, 221, - 65, 43, 38, 38, 44, 65, 49, 50, 38, 38, - 55, 51, 45, 38, 38, 35, 35, 221, 37, 56, - - 221, 52, 66, 37, 67, 67, 221, 53, 38, 38, - 54, 38, 38, 221, 38, 38, 38, 38, 38, 38, - 38, 38, 221, 57, 68, 69, 38, 38, 58, 59, - 38, 38, 38, 38, 221, 38, 38, 71, 70, 38, - 38, 221, 72, 221, 60, 74, 73, 38, 38, 61, - 38, 38, 62, 38, 38, 75, 38, 38, 76, 38, - 38, 77, 38, 38, 38, 38, 81, 38, 38, 38, - 38, 221, 38, 38, 78, 38, 38, 79, 80, 82, - 221, 83, 38, 38, 38, 38, 221, 84, 86, 87, - 85, 38, 38, 88, 221, 90, 221, 38, 38, 67, - - 67, 89, 91, 92, 221, 93, 93, 67, 67, 38, - 38, 38, 38, 38, 38, 38, 38, 94, 38, 38, - 38, 38, 38, 38, 38, 38, 97, 38, 38, 95, - 99, 221, 98, 100, 221, 96, 38, 38, 38, 38, - 101, 38, 38, 38, 38, 221, 38, 38, 38, 38, - 38, 38, 103, 38, 38, 104, 221, 102, 105, 38, - 38, 221, 106, 110, 107, 221, 38, 38, 38, 38, - 109, 38, 38, 38, 38, 108, 111, 38, 38, 113, - 112, 38, 38, 93, 93, 93, 93, 38, 38, 115, - 38, 38, 116, 114, 38, 38, 221, 117, 38, 38, - - 38, 38, 118, 38, 38, 38, 38, 38, 38, 38, - 38, 221, 38, 38, 38, 38, 119, 38, 38, 38, - 38, 122, 38, 38, 38, 38, 221, 126, 121, 123, - 120, 124, 221, 125, 221, 128, 38, 38, 38, 38, - 38, 38, 221, 127, 38, 38, 38, 38, 38, 38, - 129, 132, 38, 38, 38, 38, 221, 38, 38, 130, - 221, 136, 131, 38, 38, 133, 38, 38, 134, 137, - 221, 138, 221, 135, 38, 38, 38, 38, 38, 38, - 141, 140, 221, 139, 38, 38, 38, 38, 142, 145, - 38, 38, 221, 146, 38, 38, 221, 143, 221, 144, - - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 147, 38, 38, 221, 149, 38, 38, 38, 38, 221, - 38, 38, 150, 151, 153, 221, 148, 38, 38, 38, - 38, 152, 38, 38, 38, 38, 38, 38, 221, 156, - 38, 38, 38, 38, 158, 155, 154, 38, 38, 38, - 38, 159, 38, 38, 38, 38, 157, 221, 38, 38, - 38, 38, 38, 38, 160, 164, 163, 221, 161, 38, - 38, 162, 221, 166, 38, 38, 38, 38, 38, 38, - 167, 165, 38, 38, 38, 38, 38, 38, 38, 38, - 168, 38, 38, 221, 170, 221, 171, 38, 38, 38, - - 38, 38, 38, 38, 38, 176, 221, 169, 38, 38, - 172, 38, 38, 174, 178, 177, 173, 38, 38, 221, - 175, 38, 38, 38, 38, 38, 38, 38, 38, 180, - 179, 183, 221, 184, 38, 38, 221, 38, 38, 185, - 181, 38, 38, 221, 182, 186, 38, 38, 38, 38, - 187, 38, 38, 38, 38, 188, 38, 38, 38, 38, - 38, 38, 190, 38, 38, 38, 38, 38, 38, 189, - 38, 194, 38, 38, 221, 193, 221, 191, 38, 38, - 192, 38, 38, 38, 38, 38, 38, 198, 221, 195, - 38, 38, 38, 38, 221, 196, 38, 38, 38, 38, - - 221, 197, 38, 38, 221, 201, 199, 221, 38, 38, - 200, 221, 202, 221, 203, 204, 38, 38, 38, 38, - 38, 38, 38, 38, 221, 38, 38, 221, 207, 38, - 38, 221, 205, 208, 38, 38, 38, 38, 38, 38, - 38, 38, 206, 209, 38, 38, 38, 38, 38, 38, - 221, 210, 38, 38, 38, 38, 211, 221, 212, 38, - 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, - 38, 213, 221, 38, 38, 38, 38, 217, 38, 38, - 221, 214, 38, 38, 215, 218, 216, 38, 38, 221, - 221, 221, 221, 221, 221, 219, 221, 221, 220, 29, - - 29, 30, 30, 63, 63, 7, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221 - } ; - -static yyconst short int yy_chk[739] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 11, 11, 12, 12, 12, 13, 13, 14, - 14, 14, 224, 14, 15, 15, 16, 16, 14, 17, - 17, 19, 19, 20, 20, 63, 21, 21, 19, 32, - 16, 20, 16, 21, 22, 22, 17, 18, 18, 30, - 23, 23, 24, 24, 33, 33, 7, 35, 35, 0, - 35, 18, 26, 26, 18, 35, 22, 23, 38, 38, - 26, 24, 18, 25, 25, 36, 36, 0, 36, 26, - - 0, 25, 37, 36, 37, 37, 0, 25, 39, 39, - 25, 27, 27, 0, 40, 40, 42, 42, 41, 41, - 43, 43, 0, 27, 40, 41, 44, 44, 27, 27, - 28, 28, 45, 45, 0, 46, 46, 43, 42, 47, - 47, 0, 44, 0, 28, 46, 45, 49, 49, 28, - 48, 48, 28, 50, 50, 47, 51, 51, 48, 52, - 52, 49, 53, 53, 55, 55, 53, 54, 54, 56, - 56, 0, 57, 57, 50, 58, 58, 51, 52, 54, - 0, 54, 59, 59, 60, 60, 0, 55, 57, 58, - 56, 61, 61, 59, 0, 61, 0, 62, 62, 66, - - 66, 60, 62, 65, 0, 65, 65, 67, 67, 68, - 68, 69, 69, 70, 70, 71, 71, 68, 72, 72, - 73, 73, 74, 74, 76, 76, 72, 75, 75, 70, - 74, 0, 73, 75, 0, 71, 77, 77, 78, 78, - 76, 79, 79, 80, 80, 0, 81, 81, 82, 82, - 83, 83, 79, 84, 84, 80, 0, 77, 81, 85, - 85, 0, 81, 85, 82, 0, 86, 86, 87, 87, - 84, 88, 88, 89, 89, 83, 86, 90, 90, 88, - 87, 91, 91, 92, 92, 93, 93, 94, 94, 91, - 95, 95, 94, 90, 96, 96, 0, 95, 97, 97, - - 98, 98, 96, 99, 99, 100, 100, 101, 101, 102, - 102, 0, 103, 103, 104, 104, 98, 105, 105, 106, - 106, 102, 107, 107, 108, 108, 0, 106, 101, 103, - 100, 104, 0, 105, 0, 108, 109, 109, 110, 110, - 111, 111, 0, 107, 112, 112, 113, 113, 114, 114, - 109, 112, 115, 115, 116, 116, 0, 117, 117, 110, - 0, 117, 111, 118, 118, 113, 120, 120, 114, 117, - 0, 118, 0, 116, 119, 119, 121, 121, 122, 122, - 120, 119, 0, 118, 123, 123, 124, 124, 121, 123, - 125, 125, 0, 124, 126, 126, 0, 122, 0, 122, - - 127, 127, 128, 128, 129, 129, 130, 130, 131, 131, - 128, 132, 132, 0, 130, 133, 133, 134, 134, 0, - 135, 135, 131, 133, 135, 0, 129, 136, 136, 137, - 137, 134, 138, 138, 139, 139, 140, 140, 0, 138, - 141, 141, 142, 142, 140, 137, 136, 143, 143, 144, - 144, 142, 145, 145, 146, 146, 139, 0, 147, 147, - 148, 148, 149, 149, 143, 147, 146, 0, 144, 150, - 150, 145, 0, 150, 151, 151, 152, 152, 153, 153, - 152, 148, 154, 154, 155, 155, 156, 156, 159, 159, - 153, 157, 157, 0, 155, 0, 156, 158, 158, 160, - - 160, 161, 161, 162, 162, 161, 0, 154, 163, 163, - 157, 164, 164, 159, 163, 162, 158, 165, 165, 0, - 160, 166, 166, 167, 167, 168, 168, 169, 169, 165, - 164, 168, 0, 169, 170, 170, 0, 171, 171, 170, - 166, 172, 172, 0, 167, 171, 173, 173, 174, 174, - 172, 175, 175, 176, 176, 175, 177, 177, 178, 178, - 179, 179, 177, 180, 180, 181, 181, 182, 182, 176, - 183, 183, 184, 184, 0, 182, 0, 179, 185, 185, - 180, 186, 186, 187, 187, 188, 188, 187, 0, 184, - 189, 189, 190, 190, 0, 185, 191, 191, 192, 192, - - 0, 186, 193, 193, 0, 190, 188, 0, 194, 194, - 189, 0, 191, 0, 192, 194, 195, 195, 196, 196, - 197, 197, 198, 198, 0, 199, 199, 0, 198, 200, - 200, 0, 195, 199, 201, 201, 202, 202, 203, 203, - 204, 204, 196, 200, 205, 205, 206, 206, 207, 207, - 0, 205, 208, 208, 209, 209, 207, 0, 209, 210, - 210, 211, 211, 212, 212, 213, 213, 214, 214, 215, - 215, 210, 0, 216, 216, 217, 217, 215, 218, 218, - 0, 211, 219, 219, 212, 216, 213, 220, 220, 0, - 0, 0, 0, 0, 0, 218, 0, 0, 219, 222, - - 222, 223, 223, 225, 225, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, - 221, 221, 221, 221, 221, 221, 221, 221 - } ; - -static yyconst short int yy_rule_linenum[37] = - { 0, - 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 54, 55, 56, 58, 59, 60, 61, 62, 63, 65, - 66, 75, 76, 77, 78, 79 - } ; - -/* The intent behind this definition is that it'll catch - * any uses of REJECT which flex missed. - */ -#define REJECT reject_used_but_not_detected -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -#line 1 "geometry.ll" -#define INITIAL 0 -#line 2 "geometry.ll" -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - - - -// extern SYMBOLTABLE<Solid*> solids; -namespace netgen { -extern CSGeometry * parsegeom; -} -using namespace netgen; - -#include "geometry.h" - - -ARRAY<char*> parsestrings; -int linenum; -#define incl 1 - -#define comment 2 - -#line 594 "lex.yy.cc" - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int yywrap YY_PROTO(( void )); -#else -extern int yywrap YY_PROTO(( void )); -#endif -#endif - - -#ifndef yytext_ptr -static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen YY_PROTO(( yyconst char * )); -#endif - -#ifndef YY_NO_INPUT -#endif - -#if YY_STACK_USED -static int yy_start_stack_ptr = 0; -static int yy_start_stack_depth = 0; -static int *yy_start_stack = 0; -#ifndef YY_NO_PUSH_STATE -static void yy_push_state YY_PROTO(( int new_state )); -#endif -#ifndef YY_NO_POP_STATE -static void yy_pop_state YY_PROTO(( void )); -#endif -#ifndef YY_NO_TOP_STATE -static int yy_top_state YY_PROTO(( void )); -#endif - -#else -#define YY_NO_PUSH_STATE 1 -#define YY_NO_POP_STATE 1 -#define YY_NO_TOP_STATE 1 -#endif - -#ifdef YY_MALLOC_DECL -YY_MALLOC_DECL -#else -#if __STDC__ -#ifndef __cplusplus -#include <stdlib.h> -#endif -#else -/* Just try to get by without declaring the routines. This will fail - * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) - * or sizeof(void*) != sizeof(int). - */ -#endif -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ - -#ifndef ECHO -#define ECHO LexerOutput( yytext, yyleng ) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) LexerError( msg ) -#endif - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL int yyFlexLexer::yylex() -#endif - -/* Code executed at the beginning of each rule, after yytext and yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -YY_DECL - { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 32 "geometry.ll" - -#line 723 "lex.yy.cc" - - if ( yy_init ) - { - yy_init = 0; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - if ( ! yy_start ) - yy_start = 1; /* first start state */ - - if ( ! yyin ) - yyin = &cin; - - if ( ! yyout ) - yyout = &cout; - - if ( ! yy_current_buffer ) - yy_current_buffer = - yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_load_buffer_state(); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = yy_c_buf_p; - - /* Support of yytext. */ - *yy_cp = yy_hold_char; - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = yy_start; -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 706 ); - -yy_find_action: - yy_act = yy_accept[yy_current_state]; - if ( yy_act == 0 ) - { /* have to back up */ - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - yy_act = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - -do_action: /* This label is used only to access EOF actions. */ - - if ( yy_flex_debug ) - { - if ( yy_act == 0 ) - cerr << "--scanner backing up\n"; - else if ( yy_act < 37 ) - cerr << "--accepting rule at line " << yy_rule_linenum[yy_act] << - "(\"" << yytext << "\")\n"; - else if ( yy_act == 37 ) - cerr << "--accepting default rule (\"" << yytext << "\")\n"; - else if ( yy_act == 38 ) - cerr << "--(end of buffer or a NUL)\n"; - else - cerr << "--EOF (start condition " << YY_START << ")\n"; - } - - switch ( yy_act ) - { /* beginning of action switch */ - case 0: /* must back up */ - /* undo the effects of YY_DO_BEFORE_ACTION */ - *yy_cp = yy_hold_char; - yy_cp = yy_last_accepting_cpos; - yy_current_state = yy_last_accepting_state; - goto yy_find_action; - -case 1: -YY_RULE_SETUP -#line 33 "geometry.ll" -{ return TOK_RECO; } - YY_BREAK -case 2: -YY_RULE_SETUP -#line 34 "geometry.ll" -{ return TOK_SOLID; } - YY_BREAK -case 3: -YY_RULE_SETUP -#line 35 "geometry.ll" -{ return TOK_TLO; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 36 "geometry.ll" -{ return TOK_AND; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 37 "geometry.ll" -{ return TOK_OR; } - YY_BREAK -case 6: -YY_RULE_SETUP -#line 38 "geometry.ll" -{ return TOK_NOT; } - YY_BREAK -case 7: -YY_RULE_SETUP -#line 39 "geometry.ll" -{ return TOK_TRANSLATE; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 40 "geometry.ll" -{ return TOK_MULTITRANSLATE; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 41 "geometry.ll" -{ return TOK_ROTATE; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 42 "geometry.ll" -{ return TOK_MULTIROTATE; } - YY_BREAK -case 11: -YY_RULE_SETUP -#line 43 "geometry.ll" -{ return TOK_SPHERE; } - YY_BREAK -case 12: -YY_RULE_SETUP -#line 44 "geometry.ll" -{ return TOK_CYLINDER; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 45 "geometry.ll" -{ return TOK_CONE; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 46 "geometry.ll" -{ return TOK_PLAIN; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 47 "geometry.ll" -{ return TOK_PLAIN; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 48 "geometry.ll" -{ return TOK_TUBE; } - YY_BREAK -case 17: -YY_RULE_SETUP -#line 49 "geometry.ll" -{ return TOK_GENCYL; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 50 "geometry.ll" -{ return TOK_ORTHOBRICK; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 51 "geometry.ll" -{ return TOK_POLYHEDRON; } - YY_BREAK -case 20: -YY_RULE_SETUP -#line 52 "geometry.ll" -{ return TOK_REVOLUTION; } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 54 "geometry.ll" -{ return TOK_SINGULAR; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 55 "geometry.ll" -{ return TOK_EDGE; } - YY_BREAK -case 23: -YY_RULE_SETUP -#line 56 "geometry.ll" -{ return TOK_POINT; } - YY_BREAK -case 24: -YY_RULE_SETUP -#line 58 "geometry.ll" -{ return TOK_IDENTIFY; } - YY_BREAK -case 25: -YY_RULE_SETUP -#line 59 "geometry.ll" -{ return TOK_CLOSESURFACES; } - YY_BREAK -case 26: -YY_RULE_SETUP -#line 60 "geometry.ll" -{ return TOK_CLOSEEDGES; } - YY_BREAK -case 27: -YY_RULE_SETUP -#line 61 "geometry.ll" -{ return TOK_PERIODIC; } - YY_BREAK -case 28: -YY_RULE_SETUP -#line 62 "geometry.ll" -{ return TOK_BOUNDARYCONDITION; } - YY_BREAK -case 29: -YY_RULE_SETUP -#line 63 "geometry.ll" -{ return TOK_BOUNDINGBOX; } - YY_BREAK -case 30: -YY_RULE_SETUP -#line 65 "geometry.ll" -{ yylval.val = atof (YYText()); return NUM; } - YY_BREAK -case 31: -YY_RULE_SETUP -#line 66 "geometry.ll" -{ - yylval.chptr = new char [YYLeng()+1]; - parsestrings.Append (yylval.chptr); - strcpy (yylval.chptr, YYText()); - if (parsegeom->GetSolid (yylval.chptr)) - return IDENTSOLID; - else - return IDENT; - } - YY_BREAK -case 32: -YY_RULE_SETUP -#line 75 "geometry.ll" -/* eat up ws */ - YY_BREAK -case 33: -YY_RULE_SETUP -#line 76 "geometry.ll" -{ return int(*YYText()); } - YY_BREAK -case 34: -YY_RULE_SETUP -#line 77 "geometry.ll" -{ linenum++; } - YY_BREAK -case 35: -YY_RULE_SETUP -#line 78 "geometry.ll" -{ linenum++; cout << (YYText()+2) ; } /* line comment */ - YY_BREAK -case 36: -YY_RULE_SETUP -#line 79 "geometry.ll" -{ linenum++; } /* line comment */ - YY_BREAK -case 37: -YY_RULE_SETUP -#line 82 "geometry.ll" -ECHO; - YY_BREAK -#line 1013 "lex.yy.cc" -case YY_STATE_EOF(INITIAL): -case YY_STATE_EOF(incl): -case YY_STATE_EOF(comment): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = yy_hold_char; - YY_RESTORE_YY_MORE_OFFSET - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed yyin at a new source and called - * yylex(). If so, then we have to assure - * consistency between yy_current_buffer and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - yy_n_chars = yy_current_buffer->yy_n_chars; - yy_current_buffer->yy_input_file = yyin; - yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = yytext_ptr + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++yy_c_buf_p; - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = yy_c_buf_p; - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer() ) - { - case EOB_ACT_END_OF_FILE: - { - yy_did_buffer_switch_on_eof = 0; - - if ( yywrap() ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = - yytext_ptr + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - yy_c_buf_p = - &yy_current_buffer->yy_ch_buf[yy_n_chars]; - - yy_current_state = yy_get_previous_state(); - - yy_cp = yy_c_buf_p; - yy_bp = yytext_ptr + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ - } /* end of yylex */ - -yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout ) - { - yyin = arg_yyin; - yyout = arg_yyout; - yy_c_buf_p = 0; - yy_init = 1; - yy_start = 0; - yy_flex_debug = 0; - yylineno = 1; // this will only get updated if %option yylineno - - yy_did_buffer_switch_on_eof = 0; - - yy_looking_for_trail_begin = 0; - yy_more_flag = 0; - yy_more_len = 0; - yy_more_offset = yy_prev_more_offset = 0; - - yy_start_stack_ptr = yy_start_stack_depth = 0; - yy_start_stack = 0; - - yy_current_buffer = 0; - -#ifdef YY_USES_REJECT - yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2]; -#else - yy_state_buf = 0; -#endif - } - -yyFlexLexer::~yyFlexLexer() - { - delete yy_state_buf; - yy_delete_buffer( yy_current_buffer ); - } - -void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out ) - { - if ( new_in ) - { - yy_delete_buffer( yy_current_buffer ); - yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) ); - } - - if ( new_out ) - yyout = new_out; - } - -#ifdef YY_INTERACTIVE -int yyFlexLexer::LexerInput( char* buf, int /* max_size */ ) -#else -int yyFlexLexer::LexerInput( char* buf, int max_size ) -#endif - { - if ( yyin->eof() || yyin->fail() ) - return 0; - -#ifdef YY_INTERACTIVE - yyin->get( buf[0] ); - - if ( yyin->eof() ) - return 0; - - if ( yyin->bad() ) - return -1; - - return 1; - -#else - (void) yyin->read( buf, max_size ); - - if ( yyin->bad() ) - return -1; - else - return yyin->gcount(); -#endif - } - -void yyFlexLexer::LexerOutput( const char* buf, int size ) - { - (void) yyout->write( buf, size ); - } - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ - -int yyFlexLexer::yy_get_next_buffer() - { - register char *dest = yy_current_buffer->yy_ch_buf; - register char *source = yytext_ptr; - register int number_to_move, i; - int ret_val; - - if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( yy_current_buffer->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - yy_current_buffer->yy_n_chars = yy_n_chars = 0; - - else - { - int num_to_read = - yy_current_buffer->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ -#ifdef YY_USES_REJECT - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); -#else - - /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = yy_current_buffer; - - int yy_c_buf_p_offset = - (int) (yy_c_buf_p - b->yy_ch_buf); - - if ( b->yy_is_our_buffer ) - { - int new_size = b->yy_buf_size * 2; - - if ( new_size <= 0 ) - b->yy_buf_size += b->yy_buf_size / 8; - else - b->yy_buf_size *= 2; - - b->yy_ch_buf = (char *) - /* Include room in for 2 EOB chars. */ - yy_flex_realloc( (void *) b->yy_ch_buf, - b->yy_buf_size + 2 ); - } - else - /* Can't grow it, we don't own it. */ - b->yy_ch_buf = 0; - - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( - "fatal error - scanner input buffer overflow" ); - - yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; - - num_to_read = yy_current_buffer->yy_buf_size - - number_to_move - 1; -#endif - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), - yy_n_chars, num_to_read ); - - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - if ( yy_n_chars == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - yyrestart( yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - yy_current_buffer->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - yy_n_chars += number_to_move; - yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; - yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; - - yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; - - return ret_val; - } - - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - -yy_state_type yyFlexLexer::yy_get_previous_state() - { - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = yy_start; - - for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - } - - return yy_current_state; - } - - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - -yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state ) - { - register int yy_is_jam; - register char *yy_cp = yy_c_buf_p; - - register YY_CHAR yy_c = 1; - if ( yy_accept[yy_current_state] ) - { - yy_last_accepting_state = yy_current_state; - yy_last_accepting_cpos = yy_cp; - } - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 222 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 221); - - return yy_is_jam ? 0 : yy_current_state; - } - - -void yyFlexLexer::yyunput( int c, register char* yy_bp ) - { - register char *yy_cp = yy_c_buf_p; - - /* undo effects of setting up yytext */ - *yy_cp = yy_hold_char; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - { /* need to shift things up to make room */ - /* +2 for EOB chars. */ - register int number_to_move = yy_n_chars + 2; - register char *dest = &yy_current_buffer->yy_ch_buf[ - yy_current_buffer->yy_buf_size + 2]; - register char *source = - &yy_current_buffer->yy_ch_buf[number_to_move]; - - while ( source > yy_current_buffer->yy_ch_buf ) - *--dest = *--source; - - yy_cp += (int) (dest - source); - yy_bp += (int) (dest - source); - yy_current_buffer->yy_n_chars = - yy_n_chars = yy_current_buffer->yy_buf_size; - - if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) - YY_FATAL_ERROR( "flex scanner push-back overflow" ); - } - - *--yy_cp = (char) c; - - - yytext_ptr = yy_bp; - yy_hold_char = *yy_cp; - yy_c_buf_p = yy_cp; - } - - -int yyFlexLexer::yyinput() - { - int c; - - *yy_c_buf_p = yy_hold_char; - - if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) - /* This was really a NUL. */ - *yy_c_buf_p = '\0'; - - else - { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; - ++yy_c_buf_p; - - switch ( yy_get_next_buffer() ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - yyrestart( yyin ); - - /* fall through */ - - case EOB_ACT_END_OF_FILE: - { - if ( yywrap() ) - return EOF; - - if ( ! yy_did_buffer_switch_on_eof ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - yy_c_buf_p = yytext_ptr + offset; - break; - } - } - } - - c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ - *yy_c_buf_p = '\0'; /* preserve yytext */ - yy_hold_char = *++yy_c_buf_p; - - - return c; - } - - -void yyFlexLexer::yyrestart( istream* input_file ) - { - if ( ! yy_current_buffer ) - yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); - - yy_init_buffer( yy_current_buffer, input_file ); - yy_load_buffer_state(); - } - - -void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) - { - if ( yy_current_buffer == new_buffer ) - return; - - if ( yy_current_buffer ) - { - /* Flush out information for old buffer. */ - *yy_c_buf_p = yy_hold_char; - yy_current_buffer->yy_buf_pos = yy_c_buf_p; - yy_current_buffer->yy_n_chars = yy_n_chars; - } - - yy_current_buffer = new_buffer; - yy_load_buffer_state(); - - /* We don't actually know whether we did this switch during - * EOF (yywrap()) processing, but the only time this flag - * is looked at is after yywrap() is called, so it's safe - * to go ahead and always set it. - */ - yy_did_buffer_switch_on_eof = 1; - } - - -void yyFlexLexer::yy_load_buffer_state() - { - yy_n_chars = yy_current_buffer->yy_n_chars; - yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; - yyin = yy_current_buffer->yy_input_file; - yy_hold_char = *yy_c_buf_p; - } - - -YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size ) - { - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - yy_init_buffer( b, file ); - - return b; - } - - -void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b ) - { - if ( ! b ) - return; - - if ( b == yy_current_buffer ) - yy_current_buffer = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - yy_flex_free( (void *) b->yy_ch_buf ); - - yy_flex_free( (void *) b ); - } - - -#include<unistd.h> -void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file ) - - { - yy_flush_buffer( b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - b->yy_is_interactive = 0; - } - - -void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b ) - { - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == yy_current_buffer ) - yy_load_buffer_state(); - } - - -#ifndef YY_NO_SCAN_BUFFER -#endif - - -#ifndef YY_NO_SCAN_STRING -#endif - - -#ifndef YY_NO_SCAN_BYTES -#endif - - -#ifndef YY_NO_PUSH_STATE -void yyFlexLexer::yy_push_state( int new_state ) - { - if ( yy_start_stack_ptr >= yy_start_stack_depth ) - { - yy_size_t new_size; - - yy_start_stack_depth += YY_START_STACK_INCR; - new_size = yy_start_stack_depth * sizeof( int ); - - if ( ! yy_start_stack ) - yy_start_stack = (int *) yy_flex_alloc( new_size ); - - else - yy_start_stack = (int *) yy_flex_realloc( - (void *) yy_start_stack, new_size ); - - if ( ! yy_start_stack ) - YY_FATAL_ERROR( - "out of memory expanding start-condition stack" ); - } - - yy_start_stack[yy_start_stack_ptr++] = YY_START; - - BEGIN(new_state); - } -#endif - - -#ifndef YY_NO_POP_STATE -void yyFlexLexer::yy_pop_state() - { - if ( --yy_start_stack_ptr < 0 ) - YY_FATAL_ERROR( "start-condition stack underflow" ); - - BEGIN(yy_start_stack[yy_start_stack_ptr]); - } -#endif - - -#ifndef YY_NO_TOP_STATE -int yyFlexLexer::yy_top_state() - { - return yy_start_stack[yy_start_stack_ptr - 1]; - } -#endif - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - - -void yyFlexLexer::LexerError( yyconst char msg[] ) - { - cerr << msg << '\n'; - exit( YY_EXIT_FAILURE ); - } - - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up yytext. */ \ - yytext[yyleng] = yy_hold_char; \ - yy_c_buf_p = yytext + n; \ - yy_hold_char = *yy_c_buf_p; \ - *yy_c_buf_p = '\0'; \ - yyleng = n; \ - } \ - while ( 0 ) - - -/* Internal utility routines. */ - -#ifndef yytext_ptr -#ifdef YY_USE_PROTOS -static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) -#else -static void yy_flex_strncpy( s1, s2, n ) -char *s1; -yyconst char *s2; -int n; -#endif - { - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; - } -#endif - -#ifdef YY_NEED_STRLEN -#ifdef YY_USE_PROTOS -static int yy_flex_strlen( yyconst char *s ) -#else -static int yy_flex_strlen( s ) -yyconst char *s; -#endif - { - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; - } -#endif - - -#ifdef YY_USE_PROTOS -static void *yy_flex_alloc( yy_size_t size ) -#else -static void *yy_flex_alloc( size ) -yy_size_t size; -#endif - { - return (void *) malloc( size ); - } - -#ifdef YY_USE_PROTOS -static void *yy_flex_realloc( void *ptr, yy_size_t size ) -#else -static void *yy_flex_realloc( ptr, size ) -void *ptr; -yy_size_t size; -#endif - { - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); - } - -#ifdef YY_USE_PROTOS -static void yy_flex_free( void *ptr ) -#else -static void yy_flex_free( ptr ) -void *ptr; -#endif - { - free( ptr ); - } - -#if YY_MAIN -int main() - { - yylex(); - return 0; - } -#endif -#line 82 "geometry.ll" - - -extern FlexLexer * lexer; - -int yylex () - { - return lexer -> yylex(); - } - -extern "C" int yywrap () - { - return 1; - } diff --git a/contrib/Netgen/libsrc/csg/manifold.cpp b/contrib/Netgen/libsrc/csg/manifold.cpp deleted file mode 100644 index 9733389d670b4b764beac4586d3d37d800d4bb83..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/manifold.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include <csg.hpp> - -namespace netgen -{ -Manifold :: Manifold () -{ - ; -} - -Manifold :: ~Manifold () -{ - ; -} -} diff --git a/contrib/Netgen/libsrc/csg/manifold.hpp b/contrib/Netgen/libsrc/csg/manifold.hpp deleted file mode 100644 index 5deb7236a7223d4a3b8ac1bee3ce57df8db86b03..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/manifold.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef FILE_MANIFOLD -#define FILE_MANIFOLD - -/**************************************************************************/ -/* File: manifold.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 7. Aug. 96 */ -/**************************************************************************/ - -/** - Basis class for manifolds in 2d and 3d -*/ -class Manifold -{ -public: - /// - Manifold (); - /// - virtual ~Manifold (); -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/meshsurf.cpp b/contrib/Netgen/libsrc/csg/meshsurf.cpp deleted file mode 100644 index 0a7d7c74a0e9438e7d3345df2d2dbfc287b729b5..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/meshsurf.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include <mystdlib.h> - -#include <csg.hpp> -#include <meshing.hpp> - - - -namespace netgen -{ - /* -Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurface) - : surface(asurface) -{ - ; -} - */ -Meshing2Surfaces :: Meshing2Surfaces (const Surface & asurf, - const Box<3> & abb) - : Meshing2(Box3d(abb.PMin(), abb.PMax())), surface(asurf) -{ - ; -} - - -void Meshing2Surfaces :: DefineTransformation (Point3d & p1, Point3d & p2, - const PointGeomInfo * geominfo1, - const PointGeomInfo * geominfo2) -{ - ((Surface&)surface).DefineTangentialPlane (p1, p2); -} - -void Meshing2Surfaces :: TransformToPlain (const Point3d & locpoint, - const MultiPointGeomInfo & geominfo, - Point2d & planepoint, - double h, int & zone) -{ - Point<2> hp; - surface.ToPlane (locpoint, hp, h, zone); - planepoint.X() = hp(0); - planepoint.Y() = hp(1); -} - -int Meshing2Surfaces :: TransformFromPlain (Point2d & planepoint, - Point3d & locpoint, - PointGeomInfo & gi, - double h) -{ - Point<3> hp; - Point<2> hp2 (planepoint.X(), planepoint.Y()); - surface.FromPlane (hp2, hp, h); - locpoint = hp; - gi.trignum = 1; - return 0; -} - - - -double Meshing2Surfaces :: CalcLocalH (const Point3d & p, double gh) const -{ - return surface.LocH (p, 3, 1, gh); - /* - double loch = mesh.lochfunc->GetH(p); - if (gh < loch) loch = gh; - return loch; - */ -} - - - - - - -MeshOptimize2dSurfaces :: MeshOptimize2dSurfaces (const CSGeometry & ageometry) - : MeshOptimize2d(), geometry(ageometry) -{ - ; -} - - -void MeshOptimize2dSurfaces :: ProjectPoint (INDEX surfind, Point3d & p) const -{ - Point<3> hp = p; - geometry.GetSurface(surfind)->Project (hp); - p = hp; -} - -void MeshOptimize2dSurfaces :: ProjectPoint2 (INDEX surfind, INDEX surfind2, - Point3d & p) const -{ - Point<3> hp = p; - ProjectToEdge ( geometry.GetSurface(surfind), - geometry.GetSurface(surfind2), hp); - p = hp; -} - - -void MeshOptimize2dSurfaces :: -GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const -{ - Vec<3> hn = n; - geometry.GetSurface(surfind)->CalcGradient (p, hn); - hn.Normalize(); - n = hn; - - /* - if (geometry.GetSurface(surfind)->Inverse()) - n *= -1; - */ -} - - - - - - - -RefinementSurfaces :: RefinementSurfaces (const CSGeometry & ageometry) - : Refinement(), geometry(ageometry) -{ - ; -} - -RefinementSurfaces :: ~RefinementSurfaces () -{ - ; -} - -void RefinementSurfaces :: -PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point3d & newp, PointGeomInfo & newgi) -{ - Point<3> hnewp; - hnewp = p1+secpoint*(p2-p1); - - if (surfi != -1) - { - geometry.GetSurface (surfi) -> Project (hnewp); - newgi.trignum = 1; - } - - newp = hnewp; -} - -void RefinementSurfaces :: -PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point3d & newp, EdgePointGeomInfo & newgi) -{ - Point<3> hnewp = p1+secpoint*(p2-p1); - if (surfi1 != -1 && surfi2 != -1 && surfi1 != surfi2) - { - ProjectToEdge (geometry.GetSurface(surfi1), - geometry.GetSurface(surfi2), - hnewp); - // (*testout) << "Pointbetween, newp = " << hnewp << endl - // << ", err = " << sqrt (sqr (hnewp(0))+ sqr(hnewp(1)) + sqr (hnewp(2))) - 1 << endl; - newgi.edgenr = 1; - } - else if (surfi1 != -1) - { - geometry.GetSurface (surfi1) -> Project (hnewp); - } - - newp = hnewp; -} - - -void RefinementSurfaces :: ProjectToSurface (Point<3> & p, int surfi) -{ - if (surfi != -1) - geometry.GetSurface (surfi) -> Project (p); -} -} diff --git a/contrib/Netgen/libsrc/csg/meshsurf.hpp b/contrib/Netgen/libsrc/csg/meshsurf.hpp deleted file mode 100644 index 023c2eef709360e970261b3f29c21df35b8105be..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/meshsurf.hpp +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef FILE_MESHSURF -#define FILE_MESHSURF - -/// -class Meshing2Surfaces : public Meshing2 -{ - /// - const Surface & surface; - -public: - /// - // Meshing2Surfaces (const Surface & asurf); - /// - Meshing2Surfaces (const Surface & asurf, const Box<3> & aboundingbox); - -protected: - /// - virtual void DefineTransformation (Point3d & p1, 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); - - /// - virtual void ProjectPoint (INDEX surfind, Point3d & p) const; - /// - virtual void ProjectPoint2 (INDEX surfind, INDEX surfind2, Point3d & p) const; - /// - virtual void GetNormalVector(INDEX surfind, const Point3d & p, Vec3d & n) const; -}; - - - - - -class RefinementSurfaces : public Refinement -{ - const CSGeometry & geometry; - -public: - RefinementSurfaces (const CSGeometry & ageometry); - virtual ~RefinementSurfaces (); - - virtual void PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point3d & newp, PointGeomInfo & newgi); - - virtual void PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point3d & newp, EdgePointGeomInfo & newgi); - - virtual void ProjectToSurface (Point<3> & p, int surfi); -}; - - - -#endif - diff --git a/contrib/Netgen/libsrc/csg/polyhedra.cpp b/contrib/Netgen/libsrc/csg/polyhedra.cpp deleted file mode 100644 index f0ce2f63f51944ef643abbedf76c8773afcfec3c..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/polyhedra.cpp +++ /dev/null @@ -1,358 +0,0 @@ -#include <mystdlib.h> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ - -Polyhedra::Face::Face (int pi1, int pi2, int pi3, const ARRAY<Point<3> > & points) -{ - pnums[0] = pi1; - pnums[1] = pi2; - pnums[2] = pi3; - - bbox.Set (points[pi1]); - bbox.Add (points[pi2]); - bbox.Add (points[pi3]); - - v1 = points[pi2] - points[pi1]; - v2 = points[pi3] - points[pi1]; - - n = Cross (v1, v2); - nn = n; - nn.Normalize(); - // PseudoInverse (v1, v2, w1, w2); - - Mat<2,3> mat; - Mat<3,2> inv; - for (int i = 0; i < 3; i++) - { - mat(0,i) = v1(i); - mat(1,i) = v2(i); - } - CalcInverse (mat, inv); - for (int i = 0; i < 3; i++) - { - w1(i) = inv(i,0); - w2(i) = inv(i,1); - } -} - - -Polyhedra :: Polyhedra () -{ - surfaceactive.SetSize(0); - surfaceids.SetSize(0); -} - -Polyhedra :: ~Polyhedra () -{ - ; -} - -Primitive * Polyhedra :: CreateDefault () -{ - return new Polyhedra(); -} - -INSOLID_TYPE Polyhedra :: BoxInSolid (const BoxSphere<3> & box) const -{ - /* - for (i = 1; i <= faces.Size(); i++) - if (FaceBoxIntersection (i, box)) - return DOES_INTERSECT; - */ - for (int i = 0; i < faces.Size(); i++) - { - if (!faces[i].bbox.Intersect (box)) - continue; - - const Point<3> & p1 = points[faces[i].pnums[0]]; - const Point<3> & p2 = points[faces[i].pnums[1]]; - const Point<3> & p3 = points[faces[i].pnums[2]]; - - if (fabs (faces[i].nn * (p1 - box.Center())) > box.Diam()/2) - continue; - - double dist2 = MinDistTP2 (p1, p2, p3, box.Center()); - if (dist2 < sqr (box.Diam()/2)) - return DOES_INTERSECT; - }; - - return PointInSolid (box.Center(), 1e-3 * box.Diam()); -} - - -INSOLID_TYPE Polyhedra :: PointInSolid (const Point<3> & p, - double eps) const -{ - Vec<3> n, v1, v2; - - // random (?) numbers: - n(0) = 0.123871; - n(1) = 0.15432; - n(2) = 0.43989; - - int cnt = 0; - Point<3> pmeps (p(0) - eps, p(1) - eps, p(2) - eps); - - for (int i = 0; i < faces.Size(); i++) - { - const Point<3> & fpmax = faces[i].bbox.PMax(); - if (fpmax(0) < pmeps(0) || - fpmax(1) < pmeps(1) || - fpmax(2) < pmeps(2)) continue; - - const Point<3> & p1 = points[faces[i].pnums[0]]; - - Vec<3> v0 = p - p1; - double lam3 = -(faces[i].n * v0) / (faces[i].n * n); - - if (lam3 < -eps) continue; - Vec<3> rs = v0 + lam3 * n; - - double lam1 = (faces[i].w1 * rs); - double lam2 = (faces[i].w2 * rs); - - if (lam3 < eps) - { - if (lam1 >= -eps && lam2 >= -eps && lam1+lam2 <= 1+eps) - return DOES_INTERSECT; - } - else if (lam1 >= 0 && lam2 >= 0 && lam1+lam2 <= 1) - { // lam3 > 0 - cnt++; - } - - } - - // (*testout) << " inside = " << (cnt % 2) << endl; - return (cnt % 2) ? IS_INSIDE : IS_OUTSIDE; -} - - - -INSOLID_TYPE Polyhedra :: VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const -{ - int point_on_n_faces = 0; - INSOLID_TYPE res; - - Vec<3> vn = v; - vn.Normalize(); - for (int i = 0; i < faces.Size(); i++) - { - const Point<3> & p1 = points[faces[i].pnums[0]]; - - Vec<3> v0 = p - p1; - double lam3 = -(faces[i].n * v0); - - if (fabs (lam3) > eps) continue; - - double lam1 = (faces[i].w1 * v0); - double lam2 = (faces[i].w2 * v0); - - if (lam1 >= -eps && lam2 >= -eps && lam1+lam2 <= 1+eps) - { - point_on_n_faces++; - - double scal = vn * faces[i].n; - - res = DOES_INTERSECT; - if (scal > eps) res = IS_OUTSIDE; - if (scal < -eps) res = IS_INSIDE; - } - } - - if (point_on_n_faces == 1) - return res; - - - Point<3> p2 = p + (1e-3/(v.Length()+1e-16)) * v; - res = PointInSolid (p2, eps); - // (*testout) << "p = " << p << " v = " << v << " p2 = " << p2 << endl; - // (*testout) << "polyeder::vecinsolid = " << int(res) << endl; - return res; -} - - -INSOLID_TYPE Polyhedra :: VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const -{ - int point_on_n_faces = 0; - INSOLID_TYPE res; - - Vec<3> v1n = v1; - v1n.Normalize(); - Vec<3> v2n = v2; - v2n.Normalize(); - - - for (int i = 0; i < faces.Size(); i++) - { - const Point<3> & p1 = points[faces[i].pnums[0]]; - - Vec<3> v0 = p - p1; - double lam3 = -(faces[i].n * v0); - - if (fabs (lam3) > eps) continue; - - double lam1 = (faces[i].w1 * v0); - double lam2 = (faces[i].w2 * v0); - - if (lam1 >= -eps && lam2 >= -eps && lam1+lam2 <= 1+eps) - { - double scal1 = v1n * faces[i].n; - if (fabs (scal1) > eps) continue; - - - point_on_n_faces++; - - double scal2 = v2n * faces[i].n; - res = DOES_INTERSECT; - if (scal2 > eps) res = IS_OUTSIDE; - if (scal2 < -eps) res = IS_INSIDE; - } - } - - if (point_on_n_faces == 1) - return res; - - - - - return Primitive :: VecInSolid2 (p, v1, v2, eps); -} - - - - -void Polyhedra :: GetPrimitiveData (char *& classname, - ARRAY<double> & coeffs) const -{ - classname = "Polyhedra"; - coeffs.SetSize(0); - coeffs.Append (points.Size()); - coeffs.Append (faces.Size()); - coeffs.Append (planes.Size()); - - /* - int i, j; - for (i = 1; i <= planes.Size(); i++) - { - planes.Elem(i)->Print (*testout); - } - for (i = 1; i <= faces.Size(); i++) - { - (*testout) << "face " << i << " has plane " << faces.Get(i).planenr << endl; - for (j = 1; j <= 3; j++) - (*testout) << points.Get(faces.Get(i).pnums[j-1]); - (*testout) << endl; - } - */ -} - -void Polyhedra :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - ; -} - -void Polyhedra :: Reduce (const BoxSphere<3> & box) -{ - for (int i = 0; i < planes.Size(); i++) - surfaceactive[i] = 0; - - for (int i = 0; i < faces.Size(); i++) - if (FaceBoxIntersection (i, box)) - surfaceactive[faces[i].planenr] = 1; -} - -void Polyhedra :: UnReduce () -{ - for (int i = 0; i < planes.Size(); i++) - surfaceactive[i] = 1; -} - -int Polyhedra :: AddPoint (const Point<3> & p) -{ - return points.Append (p); -} - -int Polyhedra :: AddFace (int pi1, int pi2, int pi3) -{ - faces.Append (Face (pi1, pi2, pi3, points)); - - Point<3> p1 = points[pi1]; - Point<3> p2 = points[pi2]; - Point<3> p3 = points[pi3]; - - Vec<3> v1 = p2 - p1; - Vec<3> v2 = p3 - p1; - - Vec<3> n = Cross (v1, v2); - n.Normalize(); - - Plane pl (p1, n); - int inverse; - int identicto = -1; - for (int i = 0; i < planes.Size(); i++) - if (pl.IsIdentic (*planes[i], inverse, 1e-6)) - { - if (!inverse) - identicto = i; - } - // cout << "is identic = " << identicto << endl; - - if (identicto != -1) - faces.Last().planenr = identicto; - else - { - planes.Append (new Plane (p1, n)); - surfaceactive.Append (1); - surfaceids.Append (0); - faces.Last().planenr = planes.Size()-1; - } - - return faces.Size(); -} - - - -int Polyhedra :: FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const -{ - /* - (*testout) << "check face box intersection, fnr = " << fnr << endl; - (*testout) << "box = " << box << endl; - (*testout) << "face-box = " << faces[fnr].bbox << endl; - */ - - if (!faces[fnr].bbox.Intersect (box)) - return 0; - - const Point<3> & p1 = points[faces[fnr].pnums[0]]; - const Point<3> & p2 = points[faces[fnr].pnums[1]]; - const Point<3> & p3 = points[faces[fnr].pnums[2]]; - - double dist2 = MinDistTP2 (p1, p2, p3, box.Center()); - /* - (*testout) << "p1 = " << p1 << endl; - (*testout) << "p2 = " << p2 << endl; - (*testout) << "p3 = " << p3 << endl; - - (*testout) << "box.Center() = " << box.Center() << endl; - (*testout) << "center = " << box.Center() << endl; - (*testout) << "dist2 = " << dist2 << endl; - (*testout) << "diam = " << box.Diam() << endl; - */ - if (dist2 < sqr (box.Diam()/2)) - { - // (*testout) << "intersect" << endl; - return 1; - } - return 0; -} -} diff --git a/contrib/Netgen/libsrc/csg/polyhedra.hpp b/contrib/Netgen/libsrc/csg/polyhedra.hpp deleted file mode 100644 index 529cfff40ddb92c5749d3d6869661edc8a809b5e..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/polyhedra.hpp +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef FILE_POLYHEDRA -#define FILE_POLYHEDRA - - -/**************************************************************************/ -/* File: polyhedra.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 19. Mar. 2000 */ -/**************************************************************************/ - -/* - - Polyhedral primitive - -*/ - -class Polyhedra : public Primitive -{ - class Face { - public: - int pnums[3]; - int planenr; - - 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); - }; - - ARRAY<Point<3> > points; - ARRAY<Face> faces; - ARRAY<Plane*> planes; - -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 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 (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); - -protected: - int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const; - // void CalcData(); -}; - -#endif diff --git a/contrib/Netgen/libsrc/csg/revolution.cpp b/contrib/Netgen/libsrc/csg/revolution.cpp deleted file mode 100644 index e235012e435fc47a006597403ed57d535af35e09..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/revolution.cpp +++ /dev/null @@ -1,151 +0,0 @@ -#include <mystdlib.h> - -#include <linalg.hpp> -#include <csg.hpp> - -namespace netgen -{ - -#ifdef NONE - -Revolution :: Revolution (const Point<3> & ap1, const Point<3> & ap2) -{ - p1 = ap1; - p2 = ap2; - v12 = p2 - p1; - v12.Normalize(); -} - -Revolution :: ~Revolution () -{ - ; -} - -Primitive * Revolution :: CreateDefault () -{ - return new Revolution( Point<3> (0, 0, 0), - Point<3> (1, 0, 0)); -} - -INSOLID_TYPE Revolution :: BoxInSolid (const BoxSphere<3> & box) const -{ - int i; - - Vec<3> v = box.Center() - p1; - double x = v * v12; - double y = sqrt (v.Length2() - x*x); - - Point<2> lp1, lp2; - for (i = 1; i <= polygon.GetNP(); i++) - { - polygon.GetLine (i, lp1, lp2); - - double dist2 = MinDistLP2 (lp1, lp2, Point<2>(x,y)); - if (dist2 < sqr (box.Diam())) - return DOES_INTERSECT; - }; - - return PointInSolid (box.Center(), 1e-3 * box.Diam()); -} - - -INSOLID_TYPE Revolution :: PointInSolid (const Point<3> & p, - double eps) const -{ - int i, cnt; - - Vec<3> v(p1, p); - double x = v * v12; - double y = sqrt (v.Length2() - x*x); - - if (polygon.IsOn (Point<2> (x, y))) - return DOES_INTERSECT; - if (polygon.IsIn (Point<2> (x, y))) - return IS_INSIDE; - else - return IS_OUTSIDE; -} - - - -INSOLID_TYPE Revolution :: VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const -{ - Point<3> p2 = p + (1e-3/(v.Length()+1e-16)) * v; - return PointInSolid (p2, eps); -} - - -void Revolution :: GetPrimitiveData (char *& classname, - ARRAY<double> & coeffs) const -{ - classname = "Revolution"; - coeffs.SetSize(0); - coeffs.Append (polygon.GetNP()); -} - -void Revolution :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - ; -} - -void Revolution :: Reduce (const BoxSphere<3> & box) -{ - int i; - - for (i = 1; i <= polygon.GetNP(); i++) - surfaceactive.Elem (i) = 0; - - - Vec<3> v = box.Center() - p1; - double x = v * v12; - double y = sqrt (v.Length2() - x*x); - - Point<2> lp1, lp2; - for (i = 1; i <= polygon.GetNP(); i++) - { - polygon.GetLine (i, lp1, lp2); - - double dist2 = MinDistLP2 (lp1, lp2, Point<2>(x,y)); - if (dist2 < sqr (box.Diam()/2)) - surfaceactive.Elem(i) = 1; - }; -} - -void Revolution :: UnReduce () -{ - for (int i = 0; i < polygon.GetNP(); i++) - surfaceactive[i] = 1; -} - - -int Revolution :: AddPoint (const Point<2> & p) -{ - polygon.AddPoint (p); - return polygon.GetNP(); -} - -void Revolution :: Finish () -{ - int i; - Point<2> lp1, lp2; - Point<3> cp1, cp2; - - for (i = 1; i <= polygon.GetNP(); i++) - { - polygon.GetLine (i, lp1, lp2); - cp1 = p1 + lp1.X() * v12; - cp2 = p1 + lp2.X() * v12; - - faces.Append (new Cone (cp1, cp2, - fabs (lp1.Y()), - fabs (lp2.Y()))); - - invsurf.Append (lp1.X() < lp2.X()); - } -} - - -#endif -} diff --git a/contrib/Netgen/libsrc/csg/revolution.hpp b/contrib/Netgen/libsrc/csg/revolution.hpp deleted file mode 100644 index d57102d306b34b98d4f78f0de3c14a75a930c725..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/revolution.hpp +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef FILE_REVOLUTION -#define FILE_REVOLUTION - - -/**************************************************************************/ -/* File: revolution.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 12. Oct. 2000 */ -/**************************************************************************/ - -/* - - Primitive of revolution - -*/ - - -#ifdef NONE - -class Revolution : public Primitive -{ - Point<3> p1, p2; - Vec<3> v12; - Polygon2d polygon; - ARRAY<Cone*> faces; - ARRAY<int> invsurf; -public: - Revolution (const Point<3> & ap1, const Point<3> & ap2); - ~Revolution (); - 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; - - virtual int GetNSurfaces() const - { return faces.Size(); } - virtual Surface & GetSurface (int i) - { return *faces.Elem(i); } - virtual const Surface & GetSurface (int i = 1) const - { return *faces.Get(i); } - - virtual int SurfaceInverted (int i = 1) const - { return invsurf.Get(i); } - - virtual void GetPrimitiveData (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<2> & p); - void Finish (); -protected: - // int FaceBoxIntersection (int fnr, const BoxSphere<3> & box) const; - // void CalcData(); -}; - - -#endif - -#endif diff --git a/contrib/Netgen/libsrc/csg/singularref.cpp b/contrib/Netgen/libsrc/csg/singularref.cpp deleted file mode 100644 index add7bfdf658db0c1d568eb45e344fb7073ae6139..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/singularref.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> -#include <meshing.hpp> - -namespace netgen -{ - -SingularEdge :: SingularEdge (double abeta, - const Solid * asol1, - const Solid * asol2) -{ - beta = abeta; - - if (beta > 1) - { - beta = 1; - cout << "Warning: beta set to 1" << endl; - } - if (beta <= 1e-3) - { - beta = 1e-3; - cout << "Warning: beta set to minimal value 0.001" << endl; - } - - sol1 = asol1; - sol2 = asol2; -} - -void SingularEdge :: FindPointsOnEdge (class Mesh & mesh) -{ - (*testout) << "find points on edge" << endl; - int j; - points.SetSize(0); - segms.SetSize(0); - for (SegmentIndex si = 0; si < mesh.GetNSeg(); si++) - { - INDEX_2 i2 (mesh[si].p1, mesh[si].p2); - - bool onedge = 1; - for (j = 1; j <= 2; j++) - { - const Point<3> p = mesh[ PointIndex (i2.I(j)) ]; - if (sol1->IsIn (p, 1e-3) && sol2->IsIn(p, 1e-3) && - !sol1->IsStrictIn (p, 1e-3) && !sol2->IsStrictIn(p, 1e-3)) - { - ; - } - else - onedge = 0; - } - if (onedge) - { - segms.Append (i2); - PrintMessage (5, "sing segment ", i2.I1(), " - ", i2.I2()); - points.Append (mesh[ PointIndex (i2.I1())]); - points.Append (mesh[ PointIndex (i2.I2())]); - mesh[si].singedge_left = 1; - mesh[si].singedge_right = 1; - } - } - - /* - (*testout) << "Singular points:" << endl; - for (int i = 0; i < points.Size(); i++) - (*testout) << points[i] << endl; - */ -} - -void SingularEdge :: SetMeshSize (class Mesh & mesh, double globalh) -{ - double hloc = pow (globalh, 1/beta); - for (int i = 0; i < points.Size(); i++) - mesh.RestrictLocalH (points[i], hloc); -} - - - -SingularPoint :: SingularPoint (double abeta, - const Solid * asol1, - const Solid * asol2, - const Solid * asol3) -{ - beta = abeta; - sol1 = asol1; - sol2 = asol2; - sol3 = asol3; -} - - -void SingularPoint :: FindPoints (class Mesh & mesh) -{ - points.SetSize(0); - for (PointIndex pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - { - const Point<3> p = mesh[pi]; - if (sol1->IsIn (p) && sol2->IsIn(p) && sol3->IsIn(p) && - !sol1->IsStrictIn (p) && !sol2->IsStrictIn(p) && !sol3->IsStrictIn(p)) - { - points.Append (p); - PrintMessage (5, "Point (", p(0), ", ", p(1), ", ", p(2), ") is singular"); - mesh[pi].SetSingular(); - } - } -} - - -void SingularPoint :: SetMeshSize (class Mesh & mesh, double globalh) -{ - double hloc = pow (globalh, 1/beta); - for (int i = 1; i <= points.Size(); i++) - mesh.RestrictLocalH (points.Get(i), hloc); -} -} diff --git a/contrib/Netgen/libsrc/csg/singularref.hpp b/contrib/Netgen/libsrc/csg/singularref.hpp deleted file mode 100644 index d52dcf8f8c6d83b6220ca667961aebea5757546d..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/singularref.hpp +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef FILE_SINGULARREF -#define FILE_SINGULARREF - -/**************************************************************************/ -/* File: singularref.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 25. Sep. 99 */ -/**************************************************************************/ - -/** - Control for local refinement -*/ - - - -/** - Singular Face. - Causes a bounday layer mesh refinement. - All elements in subdomain domnr will get a boundary layer - on faces sharing the solid sol - */ -class SingularFace -{ -public: - int domnr; - const Solid *sol; - // ARRAY<Point<3> > points; - // ARRAY<INDEX_2> segms; -public: - SingularFace (int adomnr, const Solid * asol) - : domnr(adomnr), sol(asol) { ; } - const Solid * GetSolid() const { return sol; } - int GetDomainNr () const { return domnr; } -}; - - -/// -class SingularEdge -{ -public: - double beta; - const Solid *sol1, *sol2; - ARRAY<Point<3> > points; - ARRAY<INDEX_2> segms; -public: - SingularEdge (double abeta, const Solid * asol1, const Solid * asol2); - 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; - -public: - SingularPoint (double abeta, const Solid * asol1, const Solid * asol2, - const Solid * asol3); - void FindPoints (class Mesh & mesh); - void SetMeshSize (class Mesh & mesh, double globalh); -}; - - -#endif diff --git a/contrib/Netgen/libsrc/csg/solid.cpp b/contrib/Netgen/libsrc/csg/solid.cpp deleted file mode 100644 index 08d20f78a419fddd448f5236799defc5643fcd0f..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/solid.cpp +++ /dev/null @@ -1,1217 +0,0 @@ -#include <mystdlib.h> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - using namespace netgen; - - - /* - SolidIterator :: SolidIterator () - { - ; - } - - SolidIterator :: ~SolidIterator () - { - ; - } - */ - - - - // int Solid :: cntnames = 0; - - Solid :: Solid (Primitive * aprim) - { - op = TERM; - prim = aprim; - s1 = s2 = NULL; - maxh = 1e10; - name = NULL; - } - - Solid :: Solid (optyp aop, Solid * as1, Solid * as2) - { - op = aop; - s1 = as1; - s2 = as2; - prim = NULL; - name = NULL; - maxh = 1e10; - } - - Solid :: ~Solid () - { - // cout << "delete solid, op = " << int(op) << endl; - delete [] name; - - switch (op) - { - case UNION: - case SECTION: - { - if (s1->op != ROOT) delete s1; - if (s2->op != ROOT) delete s2; - break; - } - case SUB: - // case ROOT: - { - if (s1->op != ROOT) delete s1; - break; - } - case TERM: - { - // cout << "has term" << endl; - delete prim; - break; - } - default: - break; - } - } - - void Solid :: SetName (const char * aname) - { - delete [] name; - name = new char[strlen (aname)+1]; - strcpy (name, aname); - } - - - Solid * Solid :: Copy (CSGeometry & geom) const - { - Solid * nsol; - switch (op) - { - case TERM: case TERM_REF: - { - Primitive * nprim = prim->Copy(); - geom.AddSurfaces (nprim); - nsol = new Solid (nprim); - break; - } - - case SECTION: - case UNION: - { - nsol = new Solid (op, s1->Copy(geom), s2->Copy(geom)); - break; - } - - case SUB: - { - nsol = new Solid (SUB, s1 -> Copy (geom)); - break; - } - - case ROOT: - { - nsol = s1->Copy(geom); - break; - } - } - - return nsol; - } - - - void Solid :: Transform (Transformation<3> & trans) - { - switch (op) - { - case TERM: case TERM_REF: - { - prim -> Transform (trans); - break; - } - case SECTION: - case UNION: - { - s1 -> Transform (trans); - s2 -> Transform (trans); - break; - } - - case SUB: - case ROOT: - { - s1 -> Transform (trans); - break; - } - } - } - - - - void Solid :: IterateSolid (SolidIterator & it, - bool only_once) - { - if (only_once) - { - if (visited) - return; - - visited = 1; - } - - it.Do (this); - - switch (op) - { - case SECTION: - { - s1->IterateSolid (it, only_once); - s2->IterateSolid (it, only_once); - break; - } - case UNION: - { - s1->IterateSolid (it, only_once); - s2->IterateSolid (it, only_once); - break; - } - case SUB: - case ROOT: - { - s1->IterateSolid (it, only_once); - break; - } - } - } - - - - - bool Solid :: IsIn (const Point<3> & p, double eps) const - { - switch (op) - { - case TERM: case TERM_REF: - { - INSOLID_TYPE ist = prim->PointInSolid (p, eps); - return ( (ist == IS_INSIDE) || (ist == DOES_INTERSECT) ) ? 1 : 0; - } - case SECTION: - return s1->IsIn (p, eps) && s2->IsIn (p, eps); - case UNION: - return s1->IsIn (p, eps) || s2->IsIn (p, eps); - case SUB: - return !s1->IsStrictIn (p, eps); - case ROOT: - return s1->IsIn (p, eps); - } - return 0; - } - - bool Solid :: IsStrictIn (const Point<3> & p, double eps) const - { - switch (op) - { - case TERM: case TERM_REF: - { - INSOLID_TYPE ist = prim->PointInSolid (p, eps); - return (ist == IS_INSIDE) ? 1 : 0; - } - case SECTION: - return s1->IsStrictIn(p, eps) && s2->IsStrictIn(p, eps); - case UNION: - return s1->IsStrictIn(p, eps) || s2->IsStrictIn(p, eps); - case SUB: - return !s1->IsIn (p, eps); - case ROOT: - return s1->IsStrictIn (p, eps); - } - return 0; - } - - bool Solid :: VectorIn (const Point<3> & p, const Vec<3> & v, - double eps) const - { - Vec<3> hv; - switch (op) - { - case TERM: case TERM_REF: - { - INSOLID_TYPE ist = prim->VecInSolid (p, v, eps); - return (ist == IS_INSIDE || ist == DOES_INTERSECT) ? 1 : 0; - } - case SECTION: - return s1 -> VectorIn (p, v, eps) && s2 -> VectorIn (p, v, eps); - case UNION: - return s1 -> VectorIn (p, v, eps) || s2 -> VectorIn (p, v, eps); - case SUB: - return !s1->VectorStrictIn(p, v, eps); - case ROOT: - return s1->VectorIn(p, v, eps); - } - return 0; - } - - bool Solid :: VectorStrictIn (const Point<3> & p, const Vec<3> & v, - double eps) const - { - Vec<3> hv; - switch (op) - { - case TERM: case TERM_REF: - { - INSOLID_TYPE ist = prim->VecInSolid (p, v, eps); - return (ist == IS_INSIDE) ? 1 : 0; - } - case SECTION: - return s1 -> VectorStrictIn (p, v, eps) && - s2 -> VectorStrictIn (p, v, eps); - case UNION: - return s1 -> VectorStrictIn (p, v, eps) || - s2 -> VectorStrictIn (p, v, eps); - case SUB: - return !s1->VectorIn(p, v, eps); - case ROOT: - return s1->VectorStrictIn(p, v, eps); - } - return 0; - } - - - bool Solid::VectorIn2 (const Point<3> & p, const Vec<3> & v1, - const Vec<3> & v2, double eps) const - { - if (VectorStrictIn (p, v1, eps)) - return 1; - if (!VectorIn (p, v1, eps)) - return 0; - - bool res = VectorIn2Rec (p, v1, v2, eps); - return res; - } - - bool Solid::VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, - const Vec<3> & v2, double eps) const - { - switch (op) - { - case TERM: case TERM_REF: - return prim->VecInSolid2 (p, v1, v2, eps); - case SECTION: - return s1->VectorIn2Rec (p, v1, v2, eps) && - s2->VectorIn2Rec (p, v1, v2, eps); - case UNION: - return s1->VectorIn2Rec (p, v1, v2, eps) || - s2->VectorIn2Rec (p, v1, v2, eps); - case SUB: - return !s1->VectorIn2Rec (p, v1, v2, eps); - case ROOT: - return s1->VectorIn2Rec (p, v1, v2, eps); - } - return 0; - } - - - - - - - void Solid :: Print (ostream & str) const - { - switch (op) - { - case TERM: case TERM_REF: - { - str << prim->GetSurfaceId(0); - for (int i = 1; i < prim->GetNSurfaces(); i++) - str << "," << prim->GetSurfaceId(i); - break; - } - case SECTION: - { - str << "("; - s1 -> Print (str); - str << " AND "; - s2 -> Print (str); - str << ")"; - break; - } - case UNION: - { - str << "("; - s1 -> Print (str); - str << " OR "; - s2 -> Print (str); - str << ")"; - break; - } - case SUB: - { - str << " NOT "; - s1 -> Print (str); - break; - } - case ROOT: - { - str << " [" << name << "="; - s1 -> Print (str); - str << "] "; - break; - } - } - } - - - - void Solid :: GetSolidData (ostream & ost, int first) const - { - switch (op) - { - case SECTION: - { - ost << "("; - s1 -> GetSolidData (ost, 0); - ost << " AND "; - s2 -> GetSolidData (ost, 0); - ost << ")"; - break; - } - case UNION: - { - ost << "("; - s1 -> GetSolidData (ost, 0); - ost << " OR "; - s2 -> GetSolidData (ost, 0); - ost << ")"; - break; - } - case SUB: - { - ost << "NOT "; - s1 -> GetSolidData (ost, 0); - break; - } - case TERM: case TERM_REF: - { - if (name) - ost << name; - else - ost << "(noname)"; - break; - } - case ROOT: - { - if (first) - s1 -> GetSolidData (ost, 0); - else - ost << name; - break; - } - } - } - - - - static Solid * CreateSolidExpr (istream & ist, const SYMBOLTABLE<Solid*> & solids); - static Solid * CreateSolidTerm (istream & ist, const SYMBOLTABLE<Solid*> & solids); - static Solid * CreateSolidPrim (istream & ist, const SYMBOLTABLE<Solid*> & solids); - - static void ReadString (istream & ist, char * str) - { - char * hstr = str; - char ch; - - while (1) - { - ist.get(ch); - if (!ist.good()) break; - - if (!isspace (ch)) - { - ist.putback (ch); - break; - } - } - - while (1) - { - ist.get(ch); - if (!ist.good()) break; - if (isalpha(ch) || isdigit(ch)) - { - *str = ch; - str++; - } - else - { - ist.putback (ch); - break; - } - } - *str = 0; - // cout << "Read string (" << hstr << ")" - // << "put back: " << ch << endl; - } - - - Solid * CreateSolidExpr (istream & ist, const SYMBOLTABLE<Solid*> & solids) - { - // cout << "create expr" << endl; - - Solid *s1, *s2; - char str[100]; - - s1 = CreateSolidTerm (ist, solids); - ReadString (ist, str); - if (strcmp (str, "OR") == 0) - { - // cout << " OR "; - s2 = CreateSolidExpr (ist, solids); - return new Solid (Solid::UNION, s1, s2); - } - - // cout << "no OR found, put back string: " << str << endl; - int i; - for (i = strlen(str)-1; i >= 0; i--) - ist.putback (str[i]); - - return s1; - } - - Solid * CreateSolidTerm (istream & ist, const SYMBOLTABLE<Solid*> & solids) - { - // cout << "create term" << endl; - - Solid *s1, *s2; - char str[100]; - - s1 = CreateSolidPrim (ist, solids); - ReadString (ist, str); - if (strcmp (str, "AND") == 0) - { - // cout << " AND "; - s2 = CreateSolidTerm (ist, solids); - return new Solid (Solid::SECTION, s1, s2); - } - - - // cout << "no AND found, put back string: " << str << endl; - int i; - for (i = strlen(str)-1; i >= 0; i--) - ist.putback (str[i]); - - return s1; - } - - Solid * CreateSolidPrim (istream & ist, const SYMBOLTABLE<Solid*> & solids) - { - Solid * s1; - char ch; - char str[100]; - - ist >> ch; - if (ch == '(') - { - s1 = CreateSolidExpr (ist, solids); - ist >> ch; // ')' - // cout << "close back " << ch << endl; - return s1; - } - ist.putback (ch); - - ReadString (ist, str); - if (strcmp (str, "NOT") == 0) - { - // cout << " NOT "; - s1 = CreateSolidPrim (ist, solids); - return new Solid (Solid::SUB, s1); - } - - (*testout) << "get terminal " << str << endl; - s1 = solids.Get(str); - if (s1) - { - // cout << "primitive: " << str << endl; - return s1; - } - cerr << "syntax error" << endl; - - return NULL; - } - - - Solid * Solid :: CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids) - { - Solid * nsol = CreateSolidExpr (ist, solids); - nsol = new Solid (ROOT, nsol); - (*testout) << "Print new sol: "; - nsol -> Print (*testout); - (*testout) << endl; - return nsol; - } - - - - void Solid :: Boundaries (const Point<3> & p, ARRAY<int> & bounds) const - { - int in, strin; - bounds.SetSize (0); - RecBoundaries (p, bounds, in, strin); - } - - void Solid :: RecBoundaries (const Point<3> & p, ARRAY<int> & bounds, - int & in, int & strin) const - { - switch (op) - { - case TERM: case TERM_REF: - { - /* - double val; - val = surf->CalcFunctionValue (p); - in = (val < 1e-6); - strin = (val < -1e-6); - if (in && !strin) bounds.Append (id); - */ - if (prim->PointInSolid (p, 1e-6) == DOES_INTERSECT) - bounds.Append (prim->GetSurfaceId (1)); - break; - } - case SECTION: - { - int i, in1, in2, strin1, strin2; - ARRAY<int> bounds1, bounds2; - - s1 -> RecBoundaries (p, bounds1, in1, strin1); - s2 -> RecBoundaries (p, bounds2, in2, strin2); - - if (in1 && in2) - { - for (i = 1; i <= bounds1.Size(); i++) - bounds.Append (bounds1.Get(i)); - for (i = 1; i <= bounds2.Size(); i++) - bounds.Append (bounds2.Get(i)); - } - in = (in1 && in2); - strin = (strin1 && strin2); - break; - } - case UNION: - { - int i, in1, in2, strin1, strin2; - ARRAY<int> bounds1, bounds2; - - s1 -> RecBoundaries (p, bounds1, in1, strin1); - s2 -> RecBoundaries (p, bounds2, in2, strin2); - - if (!strin1 && !strin2) - { - for (i = 1; i <= bounds1.Size(); i++) - bounds.Append (bounds1.Get(i)); - for (i = 1; i <= bounds2.Size(); i++) - bounds.Append (bounds2.Get(i)); - } - in = (in1 || in2); - strin = (strin1 || strin2); - break; - } - case SUB: - { - int hin, hstrin; - s1 -> RecBoundaries (p, bounds, hin, hstrin); - in = !hstrin; - strin = !hin; - break; - } - - case ROOT: - { - s1 -> RecBoundaries (p, bounds, in, strin); - break; - } - } - } - - - - void Solid :: TangentialSolid (const Point<3> & p, Solid *& tansol) const - { - int in, strin; - RecTangentialSolid (p, tansol, in, strin); - } - - void Solid :: RecTangentialSolid (const Point<3> & p, Solid *& tansol, - int & in, int & strin) const - { - tansol = NULL; - - switch (op) - { - case TERM: case TERM_REF: - { - /* - double val; - val = surf->CalcFunctionValue (p); - in = (val < 1e-6); - strin = (val < -1e-6); - if (in && !strin) - tansol = new Solid (surf, id); - */ - - INSOLID_TYPE ist = prim->PointInSolid(p, 1e-6); - - in = (ist == IS_INSIDE || ist == DOES_INTERSECT); - strin = (ist == IS_INSIDE); - - if (ist == DOES_INTERSECT) - { - tansol = new Solid (prim); - tansol -> op = TERM_REF; - } - break; - } - case SECTION: - { - int in1, in2, strin1, strin2; - Solid * tansol1, * tansol2; - - s1 -> RecTangentialSolid (p, tansol1, in1, strin1); - s2 -> RecTangentialSolid (p, tansol2, in2, strin2); - - if (in1 && in2) - { - if (tansol1 && tansol2) - tansol = new Solid (SECTION, tansol1, tansol2); - else if (tansol1) - tansol = tansol1; - else if (tansol2) - tansol = tansol2; - } - in = (in1 && in2); - strin = (strin1 && strin2); - break; - } - case UNION: - { - int in1, in2, strin1, strin2; - Solid * tansol1, * tansol2; - - s1 -> RecTangentialSolid (p, tansol1, in1, strin1); - s2 -> RecTangentialSolid (p, tansol2, in2, strin2); - - if (!strin1 && !strin2) - { - if (tansol1 && tansol2) - tansol = new Solid (UNION, tansol1, tansol2); - else if (tansol1) - tansol = tansol1; - else if (tansol2) - tansol = tansol2; - } - in = (in1 || in2); - strin = (strin1 || strin2); - break; - } - case SUB: - { - int hin, hstrin; - Solid * tansol1; - - s1 -> RecTangentialSolid (p, tansol1, hin, hstrin); - - if (tansol1) - tansol = new Solid (SUB, tansol1); - in = !hstrin; - strin = !hin; - break; - } - case ROOT: - { - s1 -> RecTangentialSolid (p, tansol, in, strin); - break; - } - } - } - - - - - void Solid :: TangentialSolid2 (const Point<3> & p, - const Vec<3> & t, - Solid *& tansol) const - { - int in, strin; - RecTangentialSolid2 (p, t, tansol, in, strin); - } - - void Solid :: RecTangentialSolid2 (const Point<3> & p, const Vec<3> & t, - Solid *& tansol, - int & in, int & strin) const - { - tansol = NULL; - - switch (op) - { - case TERM: case TERM_REF: - { - /* - double val; - val = surf->CalcFunctionValue (p); - in = (val < 1e-6); - strin = (val < -1e-6); - if (in && !strin) - tansol = new Solid (surf, id); - */ - - INSOLID_TYPE ist = prim->PointInSolid(p, 1e-6); - if (ist == DOES_INTERSECT) - ist = prim->VecInSolid (p, t, 1e-6); - - in = (ist == IS_INSIDE || ist == DOES_INTERSECT); - strin = (ist == IS_INSIDE); - - if (ist == DOES_INTERSECT) - { - tansol = new Solid (prim); - tansol -> op = TERM_REF; - } - break; - } - case SECTION: - { - int in1, in2, strin1, strin2; - Solid * tansol1, * tansol2; - - s1 -> RecTangentialSolid2 (p, t, tansol1, in1, strin1); - s2 -> RecTangentialSolid2 (p, t, tansol2, in2, strin2); - - if (in1 && in2) - { - if (tansol1 && tansol2) - tansol = new Solid (SECTION, tansol1, tansol2); - else if (tansol1) - tansol = tansol1; - else if (tansol2) - tansol = tansol2; - } - in = (in1 && in2); - strin = (strin1 && strin2); - break; - } - case UNION: - { - int in1, in2, strin1, strin2; - Solid * tansol1, * tansol2; - - s1 -> RecTangentialSolid2 (p, t, tansol1, in1, strin1); - s2 -> RecTangentialSolid2 (p, t, tansol2, in2, strin2); - - if (!strin1 && !strin2) - { - if (tansol1 && tansol2) - tansol = new Solid (UNION, tansol1, tansol2); - else if (tansol1) - tansol = tansol1; - else if (tansol2) - tansol = tansol2; - } - in = (in1 || in2); - strin = (strin1 || strin2); - break; - } - case SUB: - { - int hin, hstrin; - Solid * tansol1; - - s1 -> RecTangentialSolid2 (p, t, tansol1, hin, hstrin); - - if (tansol1) - tansol = new Solid (SUB, tansol1); - in = !hstrin; - strin = !hin; - break; - } - case ROOT: - { - s1 -> RecTangentialSolid2 (p, t, tansol, in, strin); - break; - } - } - } - - - - - int Solid :: Edge (const Point<3> & p, const Vec<3> & v) const - { - int in, strin, faces; - RecEdge (p, v, in, strin, faces); - return faces >= 2; - } - - int Solid :: OnFace (const Point<3> & p, const Vec<3> & v) const - { - int in, strin, faces; - RecEdge (p, v, in, strin, faces); - return faces >= 1; - } - - - void Solid :: RecEdge (const Point<3> & p, const Vec<3> & v, - int & in, int & strin, int & faces) const - { - switch (op) - { - case TERM: case TERM_REF: - { - INSOLID_TYPE ist = prim->VecInSolid (p, v, 1e-6); - in = (ist == IS_INSIDE || ist == DOES_INTERSECT); - strin = (ist == IS_INSIDE); - /* - in = VectorIn (p, v); - strin = VectorStrictIn (p, v); - */ - faces = 0; - - if (in && ! strin) - { - // faces = 1; - int i; - Vec<3> grad; - for (i = 0; i < prim->GetNSurfaces(); i++) - { - double val = prim->GetSurface(i).CalcFunctionValue(p); - prim->GetSurface(i).CalcGradient (p, grad); - if (fabs (val) < 1e-6 && fabs (v * grad) < 1e-6) - faces++; - } - } - // else - // faces = 0; - break; - } - case SECTION: - { - int in1, in2, strin1, strin2, faces1, faces2; - - s1 -> RecEdge (p, v, in1, strin1, faces1); - s2 -> RecEdge (p, v, in2, strin2, faces2); - - faces = 0; - if (in1 && in2) - faces = faces1 + faces2; - in = in1 && in2; - strin = strin1 && strin2; - break; - } - case UNION: - { - int in1, in2, strin1, strin2, faces1, faces2; - - s1 -> RecEdge (p, v, in1, strin1, faces1); - s2 -> RecEdge (p, v, in2, strin2, faces2); - - faces = 0; - if (!strin1 && !strin2) - faces = faces1 + faces2; - in = in1 || in2; - strin = strin1 || strin2; - break; - } - case SUB: - { - int in1, strin1; - s1 -> RecEdge (p, v, in1, strin1, faces); - in = !strin1; - strin = !in1; - break; - } - case ROOT: - { - s1 -> RecEdge (p, v, in, strin, faces); - break; - } - } - } - - - void Solid :: CalcSurfaceInverse () - { - CalcSurfaceInverseRec (0); - } - - void Solid :: CalcSurfaceInverseRec (int inv) - { - switch (op) - { - case TERM: case TERM_REF: - { - int priminv; - for (int i = 0; i < prim->GetNSurfaces(); i++) - { - priminv = prim->SurfaceInverted(i); - if (inv) priminv = 1 - priminv; - prim->GetSurface(i).SetInverse (priminv); - } - break; - } - case UNION: - case SECTION: - { - s1 -> CalcSurfaceInverseRec (inv); - s2 -> CalcSurfaceInverseRec (inv); - break; - } - case SUB: - { - s1 -> CalcSurfaceInverseRec (1 - inv); - break; - } - case ROOT: - { - s1 -> CalcSurfaceInverseRec (inv); - break; - } - } - } - - - Solid * Solid :: GetReducedSolid (const BoxSphere<3> & box) const - { - INSOLID_TYPE in; - return RecGetReducedSolid (box, in); - } - - Solid * Solid :: RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const - { - Solid * redsol = NULL; - - switch (op) - { - case TERM: - case TERM_REF: - { - in = prim -> BoxInSolid (box); - if (in == DOES_INTERSECT) - { - redsol = new Solid (prim); - redsol -> op = TERM_REF; - } - break; - } - case SECTION: - { - INSOLID_TYPE in1, in2; - Solid * redsol1, * redsol2; - - redsol1 = s1 -> RecGetReducedSolid (box, in1); - redsol2 = s2 -> RecGetReducedSolid (box, in2); - - if (in1 == IS_OUTSIDE || in2 == IS_OUTSIDE) - { - if (in1 == DOES_INTERSECT) delete redsol1; - if (in2 == DOES_INTERSECT) delete redsol2; - in = IS_OUTSIDE; - } - else - { - if (in1 == DOES_INTERSECT || in2 == DOES_INTERSECT) - in = DOES_INTERSECT; - else - in = IS_INSIDE; - - if (in1 == DOES_INTERSECT && in2 == DOES_INTERSECT) - redsol = new Solid (SECTION, redsol1, redsol2); - else if (in1 == DOES_INTERSECT) - redsol = redsol1; - else if (in2 == DOES_INTERSECT) - redsol = redsol2; - } - break; - } - - case UNION: - { - INSOLID_TYPE in1, in2; - Solid * redsol1, * redsol2; - - redsol1 = s1 -> RecGetReducedSolid (box, in1); - redsol2 = s2 -> RecGetReducedSolid (box, in2); - - if (in1 == IS_INSIDE || in2 == IS_INSIDE) - { - if (in1 == DOES_INTERSECT) delete redsol1; - if (in2 == DOES_INTERSECT) delete redsol2; - in = IS_INSIDE; - } - else - { - if (in1 == DOES_INTERSECT || in2 == DOES_INTERSECT) in = DOES_INTERSECT; - else in = IS_OUTSIDE; - - if (in1 == DOES_INTERSECT && in2 == DOES_INTERSECT) - redsol = new Solid (UNION, redsol1, redsol2); - else if (in1 == DOES_INTERSECT) - redsol = redsol1; - else if (in2 == DOES_INTERSECT) - redsol = redsol2; - } - break; - } - - case SUB: - { - INSOLID_TYPE in1; - Solid * redsol1 = s1 -> RecGetReducedSolid (box, in1); - - switch (in1) - { - case IS_OUTSIDE: in = IS_INSIDE; break; - case IS_INSIDE: in = IS_OUTSIDE; break; - case DOES_INTERSECT: in = DOES_INTERSECT; break; - } - - if (redsol1) - redsol = new Solid (SUB, redsol1); - break; - } - - case ROOT: - { - INSOLID_TYPE in1; - redsol = s1 -> RecGetReducedSolid (box, in1); - in = in1; - break; - } - } - return redsol; - } - - - int Solid :: NumPrimitives () const - { - switch (op) - { - case TERM: case TERM_REF: - { - return 1; - } - case UNION: - case SECTION: - { - return s1->NumPrimitives () + s2 -> NumPrimitives(); - } - case SUB: - case ROOT: - { - return s1->NumPrimitives (); - } - } - return 0; - } - - void Solid :: GetSurfaceIndices (ARRAY<int> & surfind) const - { - surfind.SetSize (0); - RecGetSurfaceIndices (surfind); - } - - void Solid :: RecGetSurfaceIndices (ARRAY<int> & surfind) const - { - switch (op) - { - case TERM: case TERM_REF: - { - /* - int i; - for (i = 1; i <= surfind.Size(); i++) - if (surfind.Get(i) == prim->GetSurfaceId()) - return; - surfind.Append (prim->GetSurfaceId()); - break; - */ - for (int j = 0; j < prim->GetNSurfaces(); j++) - if (prim->SurfaceActive (j)) - { - bool found = 0; - int siprim = prim->GetSurfaceId(j); - - for (int i = 0; i < surfind.Size(); i++) - if (surfind[i] == siprim) - { - found = 1; - break; - } - if (!found) surfind.Append (siprim); - } - break; - } - case UNION: - case SECTION: - { - s1 -> RecGetSurfaceIndices (surfind); - s2 -> RecGetSurfaceIndices (surfind); - break; - } - case SUB: - case ROOT: - { - s1 -> RecGetSurfaceIndices (surfind); - break; - } - } - } - - - - void Solid :: GetSurfaceIndices (IndexSet & iset) const - { - iset.Clear(); - RecGetSurfaceIndices (iset); - } - - void Solid :: RecGetSurfaceIndices (IndexSet & iset) const - { - switch (op) - { - case TERM: case TERM_REF: - { - /* - int i; - for (i = 1; i <= surfind.Size(); i++) - if (surfind.Get(i) == prim->GetSurfaceId()) - return; - surfind.Append (prim->GetSurfaceId()); - break; - */ - for (int j = 0; j < prim->GetNSurfaces(); j++) - if (prim->SurfaceActive (j)) - { - int siprim = prim->GetSurfaceId(j); - iset.Add (siprim); - } - break; - } - case UNION: - case SECTION: - { - s1 -> RecGetSurfaceIndices (iset); - s2 -> RecGetSurfaceIndices (iset); - break; - } - case SUB: - case ROOT: - { - s1 -> RecGetSurfaceIndices (iset); - break; - } - } - } - - - - - - BlockAllocator Solid :: ball(sizeof (Solid)); -} diff --git a/contrib/Netgen/libsrc/csg/solid.hpp b/contrib/Netgen/libsrc/csg/solid.hpp deleted file mode 100644 index 796729125a0dc91677c13a7d306e1c9364d6af31..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/solid.hpp +++ /dev/null @@ -1,195 +0,0 @@ -#ifndef FILE_SOLID -#define FILE_SOLID - -/**************************************************************************/ -/* File: solid.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 1. Dez. 95 */ -/**************************************************************************/ - -/* - - 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; - -private: - char * name; - Primitive * prim; - Solid * s1, * s2; - - optyp op; - bool visited; - double maxh; - - // static int cntnames; - -public: - Solid (Primitive * aprim); - Solid (optyp aop, Solid * as1, Solid * as2 = NULL); - ~Solid (); - - const char * Name () const { return name; } - void SetName (const char * aname); - - Solid * Copy (class CSGeometry & geom) const; - void Transform (Transformation<3> & trans); - - - void IterateSolid (SolidIterator & it, bool only_once = 0); - - - void Boundaries (const Point<3> & p, ARRAY<int> & bounds) const; - int NumPrimitives () const; - void GetSurfaceIndices (ARRAY<int> & surfind) const; - void GetSurfaceIndices (IndexSet & iset) const; - - Primitive * GetPrimitive () - { return (op == TERM || op == TERM_REF) ? prim : NULL; } - const Primitive * GetPrimitive () const - { return (op == TERM || op == TERM_REF) ? prim : NULL; } - - Solid * S1() { return s1; } - Solid * S2() { return s2; } - - // geometric tests - - bool IsIn (const Point<3> & p, double eps = 1e-6) const; - bool IsStrictIn (const Point<3> & p, double eps = 1e-6) const; - bool VectorIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; - bool VectorStrictIn (const Point<3> & p, const Vec<3> & v, double eps = 1e-6) const; - - bool VectorIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - double eps = 1e-6) const; - bool VectorIn2Rec (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2, - double eps = 1e-6) const; - - - /// - void TangentialSolid (const Point<3> & p, Solid *& tansol) const; - /// - void TangentialSolid2 (const Point<3> & p, const Vec<3> & t, - Solid *& tansol) const; - /// - int Edge (const Point<3> & p, const Vec<3> & v) const; - /// - int OnFace (const Point<3> & p, const Vec<3> & v) const; - /// - void Print (ostream & str) const; - /// - void CalcSurfaceInverse (); - /// - Solid * GetReducedSolid (const BoxSphere<3> & box) const; - - - void SetMaxH (double amaxh) - { maxh = amaxh; } - double GetMaxH () const - { return maxh; } - - void GetSolidData (ostream & ost, int first = 1) const; - static Solid * CreateSolid (istream & ist, const SYMBOLTABLE<Solid*> & solids); - - - static BlockAllocator ball; - void * operator new(size_t /* s */) - { - return ball.Alloc(); - } - - void operator delete (void * p) - { - ball.Free (p); - } - - -protected: - /// - - void RecBoundaries (const Point<3> & p, ARRAY<int> & bounds, - int & in, int & strin) const; - /// - void RecTangentialSolid (const Point<3> & p, Solid *& tansol, - int & in, int & strin) const; - /// - void RecTangentialSolid2 (const Point<3> & p, const Vec<3> & vec, - Solid *& tansol, int & in, int & strin) const; - /// - void RecEdge (const Point<3> & p, const Vec<3> & v, - int & in, int & strin, int & faces) const; - /// - void CalcSurfaceInverseRec (int inv); - /// - Solid * RecGetReducedSolid (const BoxSphere<3> & box, INSOLID_TYPE & in) const; - /// - void RecGetSurfaceIndices (ARRAY<int> & surfind) const; - void RecGetSurfaceIndices (IndexSet & iset) const; - - friend class SolidIterator; - friend class ClearVisitedIt; - friend class RemoveDummyIterator; - friend class CSGeometry; -}; - - -inline ostream & operator<< (ostream & ost, const Solid & sol) -{ - sol.Print (ost); - return ost; -} - - - - - - -class ReducePrimitiveIterator : public SolidIterator -{ - const BoxSphere<3> & box; -public: - ReducePrimitiveIterator (const BoxSphere<3> & abox) - : SolidIterator(), box(abox) { ; } - virtual ~ReducePrimitiveIterator () { ; } - virtual void Do (Solid * sol) - { - if (sol -> GetPrimitive()) - sol -> GetPrimitive() -> Reduce (box); - } -}; - - -class UnReducePrimitiveIterator : public SolidIterator -{ -public: - UnReducePrimitiveIterator () { ; } - virtual ~UnReducePrimitiveIterator () { ; } - virtual void Do (Solid * sol) - { - if (sol -> GetPrimitive()) - sol -> GetPrimitive() -> UnReduce (); - } -}; - - -#endif diff --git a/contrib/Netgen/libsrc/csg/specpoin.cpp b/contrib/Netgen/libsrc/csg/specpoin.cpp deleted file mode 100644 index c9b2477bb05d9bba836deead5ac5708e084b2fab..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/specpoin.cpp +++ /dev/null @@ -1,1231 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - - -/* - Special Point calculation uses the global Flags: - - relydegtest when to rely on degeneration ? - calccp calculate points of intersection ? - cpeps1 eps for degenerated poi - calcep calculate points of extreme coordinates ? - epeps1 eps for degenerated edge - epeps2 eps for axis parallel pec - epspointdist eps for distance of special points -*/ - - -namespace netgen -{ - void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp); - - - - SpecialPoint :: SpecialPoint (const SpecialPoint & sp) - { - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; - } - - SpecialPoint & SpecialPoint :: operator= (const SpecialPoint & sp) - { - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; - return *this; - } - - - void SpecialPoint :: Print (ostream & str) - { - str << "p = " << p << " v = " << v - << " s1/s2 = " << s1 << "/" << s2 - << " layer = " << layer - << endl; - } - - - static ARRAY<int> numprim_hist; - - SpecialPointCalculation :: SpecialPointCalculation () - { - ; - } - - void SpecialPointCalculation :: - CalcSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints) - { - geometry = &ageometry; - points = &apoints; - - size = geometry->MaxSize(); - (*testout) << "Find Special Points" << endl; - (*testout) << "maxsize = " << size << endl; - - cpeps1 = 1e-6; - epeps1 = 1e-3; - epeps2 = 1e-6; - - epspointdist2 = sqr (size * 1e-8); - relydegtest = size * 1e-4; - - - BoxSphere<3> box (Point<3> (-size, -size, -size), - Point<3> ( size, size, size)); - - box.CalcDiamCenter(); - PrintMessage (3, "main-solids: ", geometry->GetNTopLevelObjects()); - - numprim_hist.SetSize (geometry->GetNSurf()+1); - numprim_hist = 0; - - for (int i = 0; i < geometry->GetNTopLevelObjects(); i++) - { - const TopLevelObject * tlo = geometry->GetTopLevelObject(i); - - (*testout) << "tlo " << i << ":" << endl - << *tlo->GetSolid() << endl; - - CalcSpecialPointsRec (tlo->GetSolid(), tlo->GetLayer(), - box, 1, 1, 1); - } - - // add user point: - for (int i = 0; i < geometry->GetNUserPoints(); i++) - AddPoint (geometry->GetUserPoint(i), 1); - - PrintMessage (3, "Found points ", apoints.Size()); - - for (int i = 0; i < boxesinlevel.Size(); i++) - (*testout) << "level " << i << " has " - << boxesinlevel[i] << " boxes" << endl; - (*testout) << "numprim_histogramm = " << endl << numprim_hist << endl; - } - - - - void SpecialPointCalculation :: - CalcSpecialPointsRec (const Solid * sol, int layer, - const BoxSphere<3> & box, - int level, bool calccp, bool calcep) - { - if (multithread.terminate) - throw NgException ("Meshing stopped"); - - - if (!sol) return; - - if (level >= 100) - { - MyStr err = - MyStr("Problems in CalcSpecialPoints\nPoint: ") + MyStr (box.Center()); - throw NgException (err.c_str()); - } - - - bool decision; - bool possiblecrossp, possibleexp; // possible cross or extremalpoint - bool surecrossp, sureexp; // sure ... - - static ARRAY<int> locsurf; // attention: array is static - - static int cntbox = 0; - cntbox++; - - if (level <= boxesinlevel.Size()) - boxesinlevel.Elem(level)++; - else - boxesinlevel.Append (1); - - /* - numprim = sol -> NumPrimitives(); - sol -> GetSurfaceIndices (locsurf); - */ - - geometry -> GetIndependentSurfaceIndices (sol, box, locsurf); - int numprim = locsurf.Size(); - - numprim_hist[numprim]++; - - Point<3> p = box.Center(); - - - possiblecrossp = (numprim >= 3) && calccp; - surecrossp = 0; - - if (possiblecrossp && (locsurf.Size() <= 5 || level > 50)) - { - decision = 1; - surecrossp = 0; - - for (int k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (int k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (int k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - int nc, deg; - nc = CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ); - - deg = CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), box ); - - if (!nc && !deg) decision = 0; - if (nc) surecrossp = 1; - } - - if (decision && surecrossp) - { - for (int k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (int k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (int k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - if (CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ) ) - { - Point<3> pp = p; - CrossPointNewton - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), pp); - - BoxSphere<3> hbox (pp, pp); - hbox.Increase (1e-8); - - if (pp(0) > box.PMin()(0) - 1e-5 && - pp(0) < box.PMax()(0) + 1e-5 && - pp(1) > box.PMin()(1) - 1e-5 && - pp(1) < box.PMax()(1) + 1e-5 && - pp(2) > box.PMin()(2) - 1e-5 && - pp(2) < box.PMax()(2) + 1e-5 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) && - !CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), hbox )) - - { - // AddCrossPoint (locsurf, sol, p); - BoxSphere<3> boxp (pp, pp); - boxp.Increase (1e-3); - boxp.CalcDiamCenter(); - ARRAY<int> locsurf2; - - geometry -> GetIndependentSurfaceIndices (sol, boxp, locsurf2); - - bool found1 = 0, found2 = 0, found3 = 0; - for (int i = 0; i < locsurf2.Size(); i++) - { - if (locsurf2[i] == locsurf.Get(k1)) found1 = 1; - if (locsurf2[i] == locsurf.Get(k2)) found2 = 1; - if (locsurf2[i] == locsurf.Get(k3)) found3 = 1; - } - - if (found1 && found2 && found3) - if (AddPoint (pp, layer)) - { - (*testout) << "Crosspoint found: " << pp - << " diam = " << box.Diam() - << ", surfs: " - << locsurf.Get(k1) << "," - << locsurf.Get(k2) << "," - << locsurf.Get(k3) << endl; - } - } - } - } - } - - if (decision) - possiblecrossp = 0; - } - - - - - possibleexp = (numprim >= 2) && calcep; - - - if (numprim == 2) - { - const Surface * surf1 = geometry->GetSurface(locsurf[0]); - const Surface * surf2 = geometry->GetSurface(locsurf[1]); - - const Plane * plane1 = dynamic_cast<const Plane*> (surf1); - const Plane * plane2 = dynamic_cast<const Plane*> (surf2); - const QuadraticSurface * quadric1 = dynamic_cast<const QuadraticSurface*> (surf1); - const QuadraticSurface * quadric2 = dynamic_cast<const QuadraticSurface*> (surf2); - - if (plane1 && plane2) - possibleexp = 0; - else - { - ARRAY<Point<3> > pts; - if (plane1 && quadric2) - { - ComputeExtremalPoints (plane1, quadric2, pts); - possibleexp = 0; - } - else if (plane2 && quadric1) - { - ComputeExtremalPoints (plane2, quadric1, pts); - possibleexp = 0; - } - - for (int j = 0; j < pts.Size(); j++) - if (Dist (pts[j], box.Center()) < box.Diam()/2 && - sol -> IsIn (pts[j]) && !sol->IsStrictIn (pts[j]) ) - { - if (AddPoint (pts[j], layer)) - (*testout) << "Extremal point found: " << pts[j] << endl; - } - } - } - - - if (possibleexp && (locsurf.Size() <= 5 || level >= 50)) - { - decision = 1; - sureexp = 0; - - /* - (*testout) << "extremal surfs = "; - for (int k5 = 0; k5 < locsurf.Size(); k5++) - (*testout) << typeid(*geometry->GetSurface(locsurf[k5])).name() << " "; - (*testout) << "\n"; - */ - - for (int k1 = 0; k1 < locsurf.Size() - 1; k1++) - for (int k2 = k1+1; k2 < locsurf.Size(); k2++) - { - const Surface * surf1 = geometry->GetSurface(locsurf[k1]); - const Surface * surf2 = geometry->GetSurface(locsurf[k2]); - /* - (*testout) << "edgecheck, types = " << typeid(*surf1).name() << ", " << typeid(*surf2).name() - << "edge-newton-conv = " << EdgeNewtonConvergence (surf1, surf2, p) - << "edge-deg = " << EdgeDegenerated (surf1, surf2, box) - << "\n"; - */ - if (EdgeNewtonConvergence (surf1, surf2, p) ) - sureexp = 1; - else - { - if (!EdgeDegenerated (surf1, surf2, box)) - decision = 0; - } - } - - if (decision && sureexp) - { - for (int k1 = 0; k1 < locsurf.Size() - 1; k1++) - for (int k2 = k1+1; k2 < locsurf.Size(); k2++) - { - const Surface * surf1 = geometry->GetSurface(locsurf[k1]); - const Surface * surf2 = geometry->GetSurface(locsurf[k2]); - - if (EdgeNewtonConvergence (surf1, surf2, p)) - { - EdgeNewton (surf1, surf2, p); - - Point<3> pp; - if (IsEdgeExtremalPoint (surf1, surf2, p, pp, box.Diam()/2)) - { - (*testout) << "extremalpoint (nearly) found:" << pp << endl; - - if (Dist (pp, box.Center()) < box.Diam()/2 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) ) - { - if (AddPoint (pp, layer)) - (*testout) << "Extremal point found: " << pp << endl; - } - } - } - } - } - if (decision) - possibleexp = 0; - } - - - - if (possiblecrossp || possibleexp) - { - BoxSphere<3> sbox; - for (int i = 0; i < 8; i++) - { - box.GetSubBox (i, sbox); - sbox.Increase (1e-4 * sbox.Diam()); - - Solid * redsol = sol -> GetReducedSolid (sbox); - - if (redsol) - { - CalcSpecialPointsRec (redsol, layer, sbox, level+1, calccp, calcep); - delete redsol; - } - } - } - } - - - - - - /******* Tests for Point of intersection **********************/ - - - - bool SpecialPointCalculation :: - CrossPointNewtonConvergence (const Surface * f1, - const Surface * f2, - const Surface * f3, - const Point<3> & p) - { - Vec<3> grad, rs, x; - Mat<3> jacobi, inv; - - f1->CalcGradient (p, grad); - jacobi(0,0) = grad(0); - jacobi(0,1) = grad(1); - jacobi(0,2) = grad(2); - - f2->CalcGradient (p, grad); - jacobi(1,0) = grad(0); - jacobi(1,1) = grad(1); - jacobi(1,2) = grad(2); - - f3->CalcGradient (p, grad); - jacobi(2,0) = grad(0); - jacobi(2,1) = grad(1); - jacobi(2,2) = grad(2); - - if (fabs (Det (jacobi)) > 1e-8) - { - double gamma = f1 -> HesseNorm() + f2 -> HesseNorm() + f3 -> HesseNorm(); - if (gamma == 0.0) return 1; - - CalcInverse (jacobi, inv); - - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - x = inv * rs; - - double beta = 0; - for (int i = 0; i < 3; i++) - { - double sum = 0; - for (int j = 0; j < 3; j++) - sum += fabs (inv(i,j)); - if (sum > beta) beta = sum; - } - double eta = Abs (x); - - return (beta * gamma * eta < 0.1); - } - return 0; - - } - - - - - bool SpecialPointCalculation :: - CrossPointDegenerated (const Surface * f1, - const Surface * f2, - const Surface * f3, - const BoxSphere<3> & box) const - { - Mat<3> mat; - Vec<3> g1, g2, g3; - double normprod; - - if (box.Diam() > relydegtest) return 0; - - f1->CalcGradient (box.Center(), g1); - normprod = Abs2 (g1); - - f2->CalcGradient (box.Center(), g2); - normprod *= Abs2 (g2); - - f3->CalcGradient (box.Center(), g3); - normprod *= Abs2 (g3); - - for (int i = 0; i < 3; i++) - { - mat(i,0) = g1(i); - mat(i,1) = g2(i); - mat(i,2) = g3(i); - } - - return sqr (Det (mat)) < sqr(cpeps1) * normprod; - } - - - - - - void SpecialPointCalculation :: CrossPointNewton (const Surface * f1, - const Surface * f2, - const Surface * f3, Point<3> & p) - { - Vec<3> g1, g2, g3; - Vec<3> rs, sol; - Mat<3> mat; - - int i = 10; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - f3->CalcGradient (p, g3); - - for (int j = 0; j < 3; j++) - { - mat(0, j) = g1(j); - mat(1, j) = g2(j); - mat(2, j) = g3(j); - } - mat.Solve (rs, sol); - if (sol.Length2() < 1e-24 && i > 1) i = 1; - - p -= sol; - } - } - - - - - /******* Tests for Point on edges **********************/ - - - - - bool SpecialPointCalculation :: - EdgeNewtonConvergence (const Surface * f1, const Surface * f2, - const Point<3> & p) - { - Vec<3> g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - Mat<3,2> inv; - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - if ( sqr(g1 * g2) < (1 - 1e-8) * Abs2 (g1) * Abs2 (g2)) - { - double gamma = f1 -> HesseNorm() + f2 -> HesseNorm(); - if (gamma < 1e-32) return 1; - gamma = sqr (gamma); - - for (int i = 0; i < 3; i++) - { - mat(0,i) = g1(i); - mat(1,i) = g2(i); - } - - CalcInverse (mat, inv); - - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - sol = inv * vrs; - - double beta = 0; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 2; j++) - beta += inv(i,j) * inv(i,j); - // beta = sqrt (beta); - - double eta = Abs2 (sol); - - // alpha = beta * gamma * eta; - return (beta * gamma * eta < 0.01); - } - return 0; - } - - - - - bool SpecialPointCalculation :: - EdgeDegenerated (const Surface * f1, - const Surface * f2, - const BoxSphere<3> & box) const - { - // perform newton steps. normals parallel ? - // if not decideable: return 0 - - Point<3> p = box.Center(); - Vec<3> g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - int i = 20; - while (i > 0) - { - if (Dist2 (p, box.Center()) > sqr(box.Diam())) - return 0; - - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - if ( sqr (g1 * g2) > (1 - 1e-10) * Abs2 (g1) * Abs2 (g2)) - return 1; - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - - if (Abs2 (sol) < 1e-24 && i > 1) i = 1; - p -= sol; - } - - return 0; - } - - - - - - - void SpecialPointCalculation :: EdgeNewton (const Surface * f1, - const Surface * f2, Point<3> & p) - { - Vec<3> g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - int i = 10; - while (i > 0) - { - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - - if (Abs2 (sol) < 1e-24 && i > 1) i = 1; - p -= sol; - } - } - - - - bool SpecialPointCalculation :: - IsEdgeExtremalPoint (const Surface * f1, const Surface * f2, - const Point<3> & p, Point<3> & pp, double rad) - { - Vec<3> g1, g2, t, t1, t2; - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - t = Cross (g1, g2); - t.Normalize(); - - Point<3> p1 = p + rad * t; - Point<3> p2 = p - rad * t; - - EdgeNewton (f1, f2, p1); - EdgeNewton (f1, f2, p2); - - f1->CalcGradient (p1, g1); - f2->CalcGradient (p1, g2); - t1 = Cross (g1, g2); - t1.Normalize(); - - f1->CalcGradient (p2, g1); - f2->CalcGradient (p2, g2); - t2 = Cross (g1, g2); - t2.Normalize(); - - double val = 1e-8 * rad * rad; - for (int j = 0; j < 3; j++) - if ( (t1(j) * t2(j) < -val) ) - { - pp = p; - ExtremalPointNewton (f1, f2, j+1, pp); - return 1; - } - - return 0; - } - - - - - - - - - - /********** Tests of Points of extremal coordinates ****************/ - - - void SpecialPointCalculation :: ExtremalPointNewton (const Surface * f1, - const Surface * f2, - int dir, Point<3> & p) - { - Vec<3> g1, g2, v, curv; - Vec<3> rs, x, y1, y2, y; - Mat<3> h1, h2; - Mat<3> jacobi; - - int i = 50; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - v = Cross (g1, g2); - - rs(2) = v(dir-1); - - jacobi(0,0) = g1(0); - jacobi(0,1) = g1(1); - jacobi(0,2) = g1(2); - - jacobi(1,0) = g2(0); - jacobi(1,1) = g2(1); - jacobi(1,2) = g2(2); - - - switch (dir) - { - case 1: - { - y1(0) = 0; - y1(1) = g2(2); - y1(2) = -g2(1); - y2(0) = 0; - y2(1) = -g1(2); - y2(2) = g1(1); - break; - } - case 2: - { - y1(0) = -g2(2); - y1(1) = 0; - y1(2) = g2(0); - y2(0) = g1(2); - y2(1) = 0; - y2(2) = -g1(0); - break; - } - case 3: - { - y1(0) = g2(1); - y1(1) = -g2(0); - y1(2) = 0; - y2(0) = -g1(1); - y2(1) = g1(0); - y2(2) = 0; - break; - } - } - - y = h1 * y1 + h2 * y2; - - jacobi(2,0) = y(0); - jacobi(2,1) = y(1); - jacobi(2,2) = y(2); - - jacobi.Solve (rs, x); - - if (Abs2 (x) < 1e-24 && i > 1) - { - i = 1; - } - - p -= x; - } - - - if (Abs2 (x) > 1e-20) - { - (*testout) << "Error: extremum Newton not convergent" << endl; - (*testout) << "dir = " << dir << endl; - (*testout) << "p = " << p << endl; - (*testout) << "x = " << x << endl; - } - } - - - - void SpecialPointCalculation :: - ComputeExtremalPoints (const Plane * plane, - const QuadraticSurface * quadric, - ARRAY<Point<3> > & pts) - { - // 3 equations: - // surf1 = 0 <===> plane_a + plane_b x = 0; - // surf2 = 0 <===> quad_a + quad_b x + x^T quad_c x = 0 - // (grad 1 x grad 2)(i) = 0 <====> (grad 1 x e_i) . grad_2 = 0 - - pts.SetSize (0); - - Point<3> p0(0,0,0); - double plane_a, quad_a; - Vec<3> plane_b, quad_b, ei; - Mat<3> quad_c; - - plane_a = plane -> CalcFunctionValue(p0); - plane -> CalcGradient (p0, plane_b); - - quad_a = quadric -> CalcFunctionValue(p0); - quadric -> CalcGradient (p0, quad_b); - quadric -> CalcHesse (p0, quad_c); - for (int i = 0; i < 3; i++) - for (int j = 0; j < 3; j++) - quad_c(i,j) *= 0.5; - - for (int dir = 0; dir <= 2; dir++) - { - ei = 0.0; ei(dir) = 1; - Vec<3> v1 = Cross (plane_b, ei); - - // grad_2 . v1 ... linear: - double g2v1_c = v1 * quad_b; - Vec<3> g2v1_l = 2.0 * (quad_c * v1); - - // find line of two linear equations: - - Vec<2> rhs; - Vec<3> sol; - Mat<2,3> mat; - - for (int j = 0; j < 3; j++) - { - mat(0,j) = plane_b(j); - mat(1,j) = g2v1_l(j); - } - rhs(0) = -plane_a; - rhs(1) = -g2v1_c; - - Vec<3> t = Cross (plane_b, g2v1_l); - if (Abs2(t) > 0) - { - mat.Solve (rhs, sol); - - // solve quadratic equation along line sol + alpha t .... - double a = quad_a + quad_b * sol + sol * (quad_c * sol); - double b = quad_b * t + 2 * (sol * (quad_c * t)); - double c = t * (quad_c * t); - - // solve a + b alpha + c alpha^2: - - if (fabs (c) > 1e-32) - { - double disc = sqr (0.5*b/c) - a/c; - if (disc > 0) - { - disc = sqrt (disc); - double alpha1 = -0.5*b/c + disc; - double alpha2 = -0.5*b/c - disc; - - pts.Append (Point<3> (sol+alpha1*t)); - pts.Append (Point<3> (sol+alpha2*t)); - /* - cout << "sol1 = " << sol + alpha1 * t - << ", sol2 = " << sol + alpha2 * t << endl; - */ - } - } - } - } - } - - - - - - - /* - bool SpecialPointCalculation :: ExtremalPointPossible (const Surface * f1, - const Surface * f2, - int dir, - const BoxSphere<3> & box) - { - double hn1, hn2, gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double f3; - double r = box.Diam()/2; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - gn1 = g1.Length(); - gn2 = g2.Length(); - - hn1 = f1 -> HesseNorm (); - hn2 = f2 -> HesseNorm (); - - v = Cross (g1, g2); - f3 = fabs (v(dir-1)); - - // (*testout) << "f3 = " << f3 << " r = " << r - // << "normbound = " - // << (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1)) << endl; - - return (f3 <= 3 * r * (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1))); - } - - - - bool SpecialPointCalculation :: - ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2, - int dir, - const BoxSphere<3> & box) - { - return box.Diam() < 1e-8; - } - - - bool SpecialPointCalculation :: - ExtremalPointDegenerated (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box) - { - double gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double maxderiv; - double minv; - Vec<3> curv, t; - Vec<2> rs, x; - Mat<3> h1, h2; - Mat<2> a, inv; - double leftside; - - if (box.Diam() > relydegtest) return 0; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - gn1 = g1.Length(); - gn2 = g2.Length(); - - v = Cross (g1, g2); - if (Abs (v) < epeps1 * gn1 * gn2) return 1; // irregular edge - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - // hn1 = f1 -> HesseNorm (); - // hn2 = f2 -> HesseNorm (); - - t = v; - a(0, 0) = g1 * g1; - a(0, 1) = - a(1, 0) = g1 * g2; - a(1, 1) = g2 * g2; - - rs(0) = g1(dir-1); - rs(1) = g2(dir-1); - - a.Solve (rs, x); - - // (*testout) << "g1 = " << g1 << " g2 = " << g2 << endl; - // (*testout) << "lam = " << x << endl; - // (*testout) << "h2 = " << h2 << endl; - - leftside = fabs (x(0) * ( t * (h1 * t)) + - x(1) * ( t * (h2 * t))); - - // (*testout) << "leftside = " << leftside << endl; - - if (leftside < epeps2 * Abs2 (v)) return 1; - - return 0; - } - */ - - - bool SpecialPointCalculation :: AddPoint (const Point<3> & p, int layer) - { - for (int i = 0; i < points->Size(); i++) - if (Dist2 ( (*points)[i], p) < epspointdist2 && - (*points)[i].GetLayer() == layer) - return 0; - - points->Append (MeshPoint(p, layer)); - PrintMessageCR (3, "Found points ", points->Size()); - return 1; - } - - - - - - - - void SpecialPointCalculation :: - AnalyzeSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints, - ARRAY<SpecialPoint> & specpoints) - { - ARRAY<int> surfind; - ARRAY<int> surfind2; - - ARRAY<Vec<3> > normalvecs; - Vec<3> t, nsurf; - Point<3> p; - - ARRAY<int> specpoint2point; - specpoints.SetSize (0); - - geometry = &ageometry; - - (*testout) << "AnalyzeSpecialPoints\n"; - - - Box<3> bbox; - if (apoints.Size()) - bbox.Set (apoints[0]); - else - { bbox.Set (Point<3> (0,0,0)); bbox.Add (Point<3> (1,1,1)); } - for (int i = 1; i < apoints.Size(); i++) - bbox.Add (apoints[i]); - bbox.Increase (0.1 * Dist (bbox.PMin(), bbox.PMax())); - - Point3dTree searchtree (bbox.PMin(), bbox.PMax()); - ARRAY<int> locsearch; - - for (int si = 0; si < ageometry.GetNTopLevelObjects(); si++) - { - // (*testout) << "main solid " << si << "\n"; - - const Solid * sol = ageometry.GetTopLevelObject(si)->GetSolid(); - const Surface * surf = ageometry.GetTopLevelObject(si)->GetSurface(); - - for (int i = 0; i < apoints.Size(); i++) - { - p = apoints[i]; - if (ageometry.GetTopLevelObject(si)->GetLayer() != - apoints[i].GetLayer()) - continue; - - // (*testout) << "Point " << apoints[i] << "\n"; - - Solid * locsol; - sol -> TangentialSolid (p, locsol); - if (!locsol) continue; - - // get all surface indices, - if (surf) - { - locsol -> GetSurfaceIndices (surfind); - bool hassurf = 0; - for (int m = 0; m < surfind.Size(); m++) - if (ageometry.GetSurface(surfind[m]) == surf) - hassurf = 1; - - if (!hassurf) - continue; - - nsurf = surf->GetNormalVector (p); - } - - // get independent surfaces of tangential solid - - BoxSphere<3> box(p,p); - box.Increase (1e-6); - box.CalcDiamCenter(); - ageometry.GetIndependentSurfaceIndices (locsol, box, surfind); - - normalvecs.SetSize(surfind.Size()); - for (int j = 0; j < surfind.Size(); j++) - normalvecs[j] = - ageometry.GetSurface(surfind[j]) -> GetNormalVector(apoints[i]); - - for (int j = 0; j < normalvecs.Size(); j++) - for (int k = j+1; k < normalvecs.Size(); k++) - for (int l = 1; l <= 2; l++) - { - t = Cross (normalvecs[j], normalvecs[k]); - if (Abs2 (t) < 1e-8) - { - cerr << "AnalyzePoint: Surfaces degenerated" << "\n"; - break; - } - t.Normalize(); - if (l == 2) t *= -1; - - // try tangential direction t - - // (*testout) << "check tangential " << t << "\n"; - - if (surf && fabs (nsurf * t) > 1e-6) - continue; - - if (!surf) - { - ageometry.GetIndependentSurfaceIndices - (locsol, p, t, surfind2); - - bool found1 = 0, found2 = 0; - for (int ii = 0; ii < surfind2.Size(); ii++) - { - if (surfind2[ii] == surfind[j]) - found1 = 1; - if (surfind2[ii] == surfind[k]) - found2 = 1; - } - if (!found1 || !found2) - continue; - } - - - bool isedge; - - // isedge = locsol -> Edge (apoints.Get(i), t); - - // edge must be on tangential surface - isedge = - locsol->VectorIn (p, t) && - !locsol->VectorStrictIn (p, t); - - // (*testout) << "isedge,1 = " << isedge << "\n"; - - // there must exist at least two different faces on edge - if (isedge) - { - int cnts = 0; - for (int m = 0; m < surfind.Size(); m++) - { - if (fabs (normalvecs[m] * t) > 1e-6) - continue; - - Vec<3> s = Cross (normalvecs[m], t); - Vec<3> t2a = t + 0.01 *s; - Vec<3> t2b = t - 0.01 *s; - - /* - (*testout) << "nv = " << normalvecs[m] << ", s = " << s << "\n"; - (*testout) << "t2a = " << t2a << ", t2b = " << t2b << "\n"; - (*testout) << "via = " - << locsol->VectorIn (p, t2a) << "/" - << locsol->VectorStrictIn (p, t2a); - (*testout) << "vib = " - << locsol->VectorIn (p, t2b) << "/" - << locsol->VectorStrictIn (p, t2b) << "\n"; - */ - - bool isface = - (locsol->VectorIn (p, t2a) && - !locsol->VectorStrictIn (p, t2a)) - || - (locsol->VectorIn (p, t2b) && - !locsol->VectorStrictIn (p, t2b)); - - if (isface) - { - cnts++; - } - } - if (cnts < 2) isedge = 0; - } - - if (isedge) - { - int spi = -1; - - searchtree.GetIntersecting (apoints[i]-Vec3d(1e-4,1e-4,1e-4), - apoints[i]+Vec3d(1e-4,1e-4,1e-4), - locsearch); - - for (int m = 0; m < locsearch.Size(); m++) - if (Dist2 (specpoints[locsearch[m]].p, apoints[i]) < 1e-8 - && Abs2(specpoints[locsearch[m]].v - t) < 1e-8) - { - spi = locsearch[m]; - break; - } - - - if (spi == -1) - { - spi = specpoints.Append (SpecialPoint()) - 1; - specpoint2point.Append (i); - specpoints.Last().unconditional = 0; - searchtree.Insert (apoints[i], spi); - } - - specpoints[spi].p = apoints[i]; - specpoints[spi].v = t; - if (surfind.Size() >= 3) - specpoints[spi].unconditional = 1; - specpoints[spi].s1 = surfind[j]; - specpoints[spi].s2 = surfind[k]; - specpoints[spi].layer = apoints[i].GetLayer(); - for (int up = 0; up < geometry->GetNUserPoints(); up++) - if (Dist (geometry->GetUserPoint(up), apoints[i]) < 1e-10) - specpoints[spi].unconditional = 1; - } - - } - delete locsol; - } - } - - // if special point is unconditional on some solid, - // it must be unconditional everywhere: - - BitArray uncond (apoints.Size()); - uncond.Clear(); - - for (int i = 0; i < specpoints.Size(); i++) - if (specpoints[i].unconditional) - uncond.Set (specpoint2point[i]); - - for (int i = 0; i < specpoints.Size(); i++) - specpoints[i].unconditional = - uncond.Test (specpoint2point[i]) ? 1 : 0; - } -} diff --git a/contrib/Netgen/libsrc/csg/specpoin.hpp b/contrib/Netgen/libsrc/csg/specpoin.hpp deleted file mode 100644 index 8fd26f3207a652cadb4c75498af6d6ea411e09b2..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/specpoin.hpp +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef FILE_SPECPOIN -#define FILE_SPECPOIN - - -/**************************************************************************/ -/* File: specpoin.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 01. Okt. 95 */ -/**************************************************************************/ - -/* - -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; - - /// - SpecialPoint () : p(0,0,0), v(0,0,0), layer(0), unconditional(0), s1(0), s2(0) - { ; } - - /// - SpecialPoint (const SpecialPoint & sp2); - - /// - SpecialPoint & operator= (const SpecialPoint & sp2); - - /// - void Print (ostream & str); - - - int GetLayer() const { return layer; } - - /// - bool HasSurfaces (int as1, int as2) const - { - return (s1 == as1 && s2 == as2 || s1 == as2 && s2 == as1); - } -}; - - - -/// -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; - -public: - - /// - SpecialPointCalculation (); - - /// - 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 Point<3> & p); - /// - 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); -}; - -#endif - - diff --git a/contrib/Netgen/libsrc/csg/specpoin_new.cpp b/contrib/Netgen/libsrc/csg/specpoin_new.cpp deleted file mode 100644 index 4ac2c130fad7ca5d36108950d34254ae13560f2d..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/specpoin_new.cpp +++ /dev/null @@ -1,1367 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - - -/* - Special Point calculation uses the global Flags: - - size .. 500 cube = [-size, size]^3 - relydegtest when to rely on degeneration ? - calccp calculate points of intersection ? - cpeps1 eps for degenerated poi - calcep calculate points of extreme coordinates ? - epeps1 eps for degenerated edge - epeps2 eps for axis parallel pec - epspointdist eps for distance of special points -*/ - - -namespace netgen -{ -void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp); - - - -SpecialPoint :: SpecialPoint (const SpecialPoint & sp) -{ - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; -} - -SpecialPoint & SpecialPoint :: operator= (const SpecialPoint & sp) -{ - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; - return *this; -} - - -void SpecialPoint :: Print (ostream & str) -{ - str << "p = " << p << " v = " << v - << " s1/s2 = " << s1 << "/" << s2 - << " layer = " << layer - << endl; -} - - - - -SpecialPointCalculation :: SpecialPointCalculation () -{ - ; -} - -void SpecialPointCalculation :: -CalcSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints) -{ - int i; - - geometry = &ageometry; - points = &apoints; - - size = geometry->MaxSize(); - (*testout) << "Find Special Points" << endl; - (*testout) << "maxsize = " << size << endl; - - cpeps1 = 1e-6; - epeps1 = 1e-3; - epeps2 = 1e-6; - - epspointdist2 = sqr (size * 1e-8); - relydegtest = size * 1e-4; - - - BoxSphere<3> box (Point<3> (-size, -size, -size), - Point<3> ( size, size, size)); - - box.CalcDiamCenter(); - PrintMessage (3, "main-solids: ", geometry->GetNTopLevelObjects()); - - for (i = 0; i < geometry->GetNTopLevelObjects(); i++) - { - (*testout) << "tlo " << i << ":" << endl; - const TopLevelObject * tlo = geometry->GetTopLevelObject(i); - tlo->GetSolid()->Print (*testout); - (*testout) << endl; - CalcSpecialPointsRec (tlo->GetSolid(), tlo->GetLayer(), - box, 1, 1, 1); - } - - PrintDot ('\n'); - - - // add user point: - for (i = 0; i < geometry->GetNUserPoints(); i++) - AddPoint (geometry->GetUserPoint(i), 1); - - PrintMessage (3, apoints.Size(), " special points"); - - for (i = 0; i < boxesinlevel.Size(); i++) - (*testout) << "level " << i << " has " - << boxesinlevel[i] << " boxes" << endl; -} - - - -// int debug; -void SpecialPointCalculation :: -CalcSpecialPointsRec (const Solid * sol, int layer, - const BoxSphere<3> & box, - int level, bool calccp, bool calcep) -{ - if (multithread.terminate) - return; - - int i; - BoxSphere<3> sbox; - Solid * redsol; - - int numprim; - - bool decision; - bool possiblecrossp, possibleexp; // possible cross or extremalpoint - bool surecrossp, sureexp; // sure ... - - static ARRAY<int> locsurf; // attention: array is static - - - Point<3> p; - int k1, k2, k3; - int extremdir; - double hd; - - if (!sol) return; - - if (level >= 100) - { - cerr << "Problems in CalcSpecialPoints" << endl; - cerr << "Point: " << box.Center() << endl; - exit (1); - } - - static int cntbox = 0; - cntbox++; - if (cntbox % 10000 == 0) - PrintDot (); - - if (level <= boxesinlevel.Size()) - boxesinlevel.Elem(level)++; - else - boxesinlevel.Append (1); - - /* - numprim = sol -> NumPrimitives(); - sol -> GetSurfaceIndices (locsurf); - */ - - // debug = 0; - // box.IsIn (Point<3> (4.9, 1.279, 2.8)); - - - geometry -> GetIndependentSurfaceIndices (sol, box, locsurf); - numprim = locsurf.Size(); - - /* - if (debug) - { - (*testout) << "box = " << box.PMin() << "-" << box.PMax() - << " np = " << numprim << " : "; - for (i = 1; i <= locsurf.Size(); i++) - (*testout) << " " << locsurf.Get(i); - (*testout) << " diam = " << box.Diam(); - (*testout) << " numprim = " << numprim; - (*testout) << endl; - } - */ - - - p = box.Center(); - - /* - (*testout) << "box = " << box.PMin() << " - " << box.PMax() - << ", lev = " << level - << ", nprim = " << sol->NumPrimitives() - << ", lsurf = " << locsurf.Size() << endl; - - for (i = 1; i <= locsurf.Size(); i++) - geometry->GetSurface (locsurf.Get(i)) -> Print (*testout); - sol -> Print (*testout); - */ - - /* - for (i = 1; i <= locsurf.Size(); i++) - (*testout) << locsurf.Get(i) << " "; - (*testout) << "C = " << box.Center() << " diam = " << box.Diam() << endl; - */ - - possiblecrossp = (numprim >= 3) && calccp; - surecrossp = 0; - - if (possiblecrossp && (locsurf.Size() <= 10)) - { - decision = 1; - surecrossp = 0; - - for (k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - int nc, deg; - nc = CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ); - - deg = CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), box ); - - if (!nc && !deg) decision = 0; - if (nc) surecrossp = 1; - } - - if (decision && surecrossp) - { - for (k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - if (CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ) ) - { - Point<3> pp = p; - CrossPointNewton - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), pp); - - BoxSphere<3> hbox (pp, pp); - hbox.Increase (1e-8); - - if (pp(0) > box.PMin()(0) - 1e-5 && - pp(0) < box.PMax()(0) + 1e-5 && - pp(1) > box.PMin()(1) - 1e-5 && - pp(1) < box.PMax()(1) + 1e-5 && - pp(2) > box.PMin()(2) - 1e-5 && - pp(2) < box.PMax()(2) + 1e-5 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) && - !CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), hbox )) - - { - // AddCrossPoint (locsurf, sol, p); - BoxSphere<3> boxp (pp, pp); - boxp.Increase (1e-3); - boxp.CalcDiamCenter(); - ARRAY<int> locsurf2; - - geometry -> GetIndependentSurfaceIndices (sol, boxp, locsurf2); - - /* - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)sol) -> IterateSolid (rpi); - sol -> GetIndependentSurfaceIndices (locsurf2); - ((Solid*)sol) -> IterateSolid (urpi); - */ - bool found1 = 0, found2 = 0, found3 = 0; - for (i = 1; i <= locsurf2.Size(); i++) - { - if (locsurf2.Get(i) == locsurf.Get(k1)) - found1 = 1; - if (locsurf2.Get(i) == locsurf.Get(k2)) - found2 = 1; - if (locsurf2.Get(i) == locsurf.Get(k3)) - found3 = 1; - } - - if (found1 && found2 && found3) - if (AddPoint (pp, layer)) - { - (*testout) << "Crosspoint found: " << pp - << " diam = " << box.Diam() << endl; - (*testout) << "surfs: " - << locsurf.Get(k1) << "," - << locsurf.Get(k2) << "," - << locsurf.Get(k3) << endl; - } - } - } - } - } - - if (decision) - possiblecrossp = 0; - } - - - - - possibleexp = (numprim >= 2) && calcep; - - if (possibleexp && (locsurf.Size() <= 10)) - { - decision = 1; - sureexp = 0; - - for (k1 = 1; k1 <= locsurf.Size() - 1; k1++) - for (k2 = k1+1; k2 <= locsurf.Size(); k2++) - { - bool nc, deg; - - nc = EdgeNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p); - - deg = EdgeDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - box); - - if (!nc && !deg) decision = 0; - if (nc) sureexp = 1; - - /* - if (debug) - { - (*testout) << "p = " << p << " s1,2 = " << locsurf.Get(k1) << ", " << locsurf.Get(k2) - << " nc = " << nc << " deg = " << deg << endl; - } - */ - } - - if (decision && sureexp) - { - for (k1 = 1; k1 <= locsurf.Size() - 1; k1++) - for (k2 = k1+1; k2 <= locsurf.Size(); k2++) - { - if ( - EdgeNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p) ) - { - EdgeNewton - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p); - - Point<3> pp; - if (IsEdgeExtremalPoint - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p, pp, box.Diam()/2)) - { - (*testout) << "extremalpoint (nearly) found:" - << pp - << endl; - if (Dist (pp, box.Center()) < box.Diam()/2 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) ) - { - // AddExtremalPoint (locsurf.Get(k1), locsurf.Get(k2), p); - if (AddPoint (pp, layer)) - (*testout) << "Extremal point found: " << pp << endl; - } - } - } - } - } - if (decision) - possibleexp = 0; - } - - - - if (possiblecrossp || possibleexp) - { - for (i = 0; i < 8; i++) - { - box.GetSubBox (i, sbox); - sbox.Increase (1e-4 * sbox.Diam()); - - redsol = sol -> GetReducedSolid (sbox); - - if (redsol) - { - CalcSpecialPointsRec (redsol, layer, sbox, level+1, calccp, calcep); - delete redsol; - } - } - } -} - - - - - -/******* Tests for Point of intersection **********************/ - - - -bool SpecialPointCalculation :: -CrossPointNewtonConvergence (const Surface * f1, - const Surface * f2, - const Surface * f3, - const Point<3> & p) -{ - int i; - Vec<3> grad; - Vec<3> rs, x; - Mat<3> jacobi, inv; - double alpha, beta, gamma, eta; - double sum; - int j; - - - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - f1->CalcGradient (p, grad); - jacobi(0,0) = grad(0); - jacobi(0,1) = grad(1); - jacobi(0,2) = grad(2); - - f2->CalcGradient (p, grad); - jacobi(1,0) = grad(0); - jacobi(1,1) = grad(1); - jacobi(1,2) = grad(2); - - f3->CalcGradient (p, grad); - jacobi(2,0) = grad(0); - jacobi(2,1) = grad(1); - jacobi(2,2) = grad(2); - - alpha = 1; - if (fabs (Det (jacobi)) > 1e-8) - { - CalcInverse (jacobi, inv); - x = inv * rs; - - gamma = f1 -> HesseNorm() + f2 -> HesseNorm() + f3 -> HesseNorm(); - beta = 0; - for (i = 0; i < 3; i++) - { - sum = 0; - for (j = 0; j < 3; j++) - sum += fabs (inv(i,j)); - beta = max2 (beta, sum); - } - eta = Abs (x); - - alpha = beta * gamma * eta; - } - - return (alpha < 0.1); -} - - - - -bool SpecialPointCalculation :: -CrossPointDegenerated (const Surface * f1, - const Surface * f2, - const Surface * f3, - const BoxSphere<3> & box) const -{ - Mat<3> mat; - Vec<3> grad, g1, g2, g3; - double normprod; - - if (box.Diam() > relydegtest) return 0; - - f1->CalcGradient (box.Center(), g1); - normprod = Abs (g1); - - f2->CalcGradient (box.Center(), g2); - normprod *= Abs (g2); - - f3->CalcGradient (box.Center(), g3); - normprod *= Abs (g3); - - for (int i = 0; i < 3; i++) - { - mat(i,0) = g1(i); - mat(i,1) = g2(i); - mat(i,2) = g3(i); - } - - if (fabs (Det (mat)) < cpeps1 * normprod) - return 1; - else - return 0; -} - - - - - -void SpecialPointCalculation :: CrossPointNewton (const Surface * f1, - const Surface * f2, - const Surface * f3, Point<3> & p) -{ - int i; - Vec<3> g1, g2, g3; - Vec<3> rs, sol; - Mat<3> mat; - - i = 10; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - f3->CalcGradient (p, g3); - - for (int j = 0; j < 3; j++) - { - mat(0, j) = g1(j); - mat(1, j) = g2(j); - mat(2, j) = g3(j); - } - mat.Solve (rs, sol); - /* - Transpose (g1, g2, g3); - SolveLinearSystem (g1, g2, g3, rs, sol); - */ - if (sol.Length() < 1e-12 && i > 1) i = 1; - - p -= sol; - } -} - - - - -/******* Tests for Point on edges **********************/ - - - - -bool SpecialPointCalculation :: -EdgeNewtonConvergence (const Surface * f1, const Surface * f2, - const Point<3> & p) -{ - int i; - Vec<3> g1, g2, sol; - Vec<2> vrs; - double alpha, beta, gamma, eta; - double sum; - Mat<2,3> mat; - Mat<3,2> inv; - int j; - - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - for (i = 0; i < 3; i++) - { - mat(0,i) = g1(i); - mat(1,i) = g2(i); - } - - alpha = 1; - - if ( fabs(g1 * g2) < (1 - 1e-8) * Abs (g1) * Abs (g2)) - { - CalcInverse (mat, inv); - sol = inv * vrs; - - // SolveLinearSystemLS (g1, g2, vrs, sol); - - gamma = f1 -> HesseNorm() + f2 -> HesseNorm(); - - /* - Vec<3> inv1, inv2; - PseudoInverse (g1, g2, inv1, inv2); - */ - - beta = 0; - for (i = 0; i < 3; i++) - for (j = 0; j < 2; j++) - beta += inv(i,j) * inv(i,j); - beta = sqrt (beta); - - // beta = inv1.Length() + inv2.Length(); - eta = Abs (sol); - alpha = beta * gamma * eta; - } - return (alpha < 0.1); -} - - - - -bool SpecialPointCalculation :: -EdgeDegenerated (const Surface * f1, - const Surface * f2, - const BoxSphere<3> & box) const -{ - // perform newton steps. normals parallel ? - // if not decideable: return 0 - - - Point<3> p = box.Center(); - int i; - Vec<3> grad, g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - i = 20; - while (i > 0) - { - if (Dist (p, box.Center()) > box.Diam()) - return 0; - - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - if ( fabs (g1 * g2) > (1 - 1e-10) * Abs (g1) * Abs (g2)) - return 1; - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - // SolveLinearSystemLS (g1, g2, vrs, sol); - - if (Abs (sol) < 1e-12 && i > 1) i = 1; - p -= sol; - } - - return 0; -} - - - - - - -void SpecialPointCalculation :: EdgeNewton (const Surface * f1, - const Surface * f2, Point<3> & p) -{ - int i; - Vec<3> grad, g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - i = 10; - while (i > 0) - { - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - // SolveLinearSystemLS (g1, g2, vrs, sol); - - if (Abs (sol) < 1e-12 && i > 1) i = 1; - p -= sol; - } -} - - - -bool SpecialPointCalculation :: -IsEdgeExtremalPoint (const Surface * f1, const Surface * f2, - const Point<3> & p, Point<3> & pp, double rad) -{ - Vec<3> g1, g2, t, t1, t2; - int j; - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - t = Cross (g1, g2); - t.Normalize(); - - Point<3> p1 = p + rad * t; - Point<3> p2 = p - rad * t; - - EdgeNewton (f1, f2, p1); - EdgeNewton (f1, f2, p2); - - - f1->CalcGradient (p1, g1); - f2->CalcGradient (p1, g2); - t1 = Cross (g1, g2); - t1.Normalize(); - - f1->CalcGradient (p2, g1); - f2->CalcGradient (p2, g2); - t2 = Cross (g1, g2); - t2.Normalize(); - - double val = 1e-8 * rad * rad; - for (j = 0; j < 3; j++) - if ( (t1(j) * t2(j) < -val) ) - { - pp = p; - ExtremalPointNewton (f1, f2, j+1, pp); - return 1; - } - - return 0; -} - - - - - - - - - -/********** Tests of Points of extremal coordinates ****************/ - - -void SpecialPointCalculation :: ExtremalPointNewton (const Surface * f1, - const Surface * f2, - int dir, Point<3> & p) -{ - int i; - - Vec<3> g1, g2, v, curv; - Vec<3> rs, x, y1, y2, y; - Mat<3> h1, h2; - Mat<3> jacobi; - - - if (dir < 1 || dir > 3) - { - cerr << "Error: Illegal extremdir" << endl; - return; - } - - i = 50; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - - v = Cross (g1, g2); - - rs(2) = v(dir-1); - - jacobi(0,0) = g1(0); - jacobi(0,1) = g1(1); - jacobi(0,2) = g1(2); - - jacobi(1,0) = g2(0); - jacobi(1,1) = g2(1); - jacobi(1,2) = g2(2); - - - switch (dir) - { - case 1: - { - y1(0) = 0; - y1(1) = g2(2); - y1(2) = -g2(1); - y2(0) = 0; - y2(1) = -g1(2); - y2(2) = g1(1); - break; - } - case 2: - { - y1(0) = -g2(2); - y1(1) = 0; - y1(2) = g2(0); - y2(0) = g1(2); - y2(1) = 0; - y2(2) = -g1(0); - break; - } - case 3: - { - y1(0) = g2(1); - y1(1) = -g2(0); - y1(2) = 0; - y2(0) = -g1(1); - y2(1) = g1(0); - y2(2) = 0; - break; - } - } - - y = h1 * y1 + h2 * y2; - - jacobi(2,0) = y(0); - jacobi(2,1) = y(1); - jacobi(2,2) = y(2); - - jacobi.Solve (rs, x); - /* - CalcInverse (jacobi, inv); - inv.Mult (rs, x); - */ - // (*testout) << "err = " << x.L2Norm() << endl; - - if (Abs (x) < 1e-12 && i > 1) - { - // (*testout) << "convergent in " << (10 - i) << " steps " << endl; - - i = 1; - } - - p -= x; - } - - if (Abs (x) > 1e-10) - { - (*testout) << "Error: extremum Newton not convergent" << endl; - (*testout) << "dir = " << dir << endl; - (*testout) << "p = " << p << endl; - (*testout) << "x = " << x << endl; - } -} - - - - -bool SpecialPointCalculation :: ExtremalPointPossible (const Surface * f1, - const Surface * f2, - int dir, - const BoxSphere<3> & box) -{ - double hn1, hn2, gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double f3; - double r = box.Diam()/2; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - gn1 = g1.Length(); - gn2 = g2.Length(); - - hn1 = f1 -> HesseNorm (); - hn2 = f2 -> HesseNorm (); - - v = Cross (g1, g2); - f3 = fabs (v(dir-1)); - - // (*testout) << "f3 = " << f3 << " r = " << r - // << "normbound = " - // << (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1)) << endl; - - return (f3 <= 3 * r * (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1))); -} - - - -bool SpecialPointCalculation :: -ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2, - int dir, - const BoxSphere<3> & box) -{ - return box.Diam() < 1e-8; -} - - -bool SpecialPointCalculation :: -ExtremalPointDegenerated (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box) -{ - double gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double maxderiv; - double minv; - Vec<3> curv, t; - Vec<2> rs, x; - Mat<3> h1, h2; - Mat<2> a, inv; - double leftside; - - if (box.Diam() > relydegtest) return 0; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - gn1 = g1.Length(); - gn2 = g2.Length(); - - v = Cross (g1, g2); - if (Abs (v) < epeps1 * gn1 * gn2) return 1; // irregular edge - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - // hn1 = f1 -> HesseNorm (); - // hn2 = f2 -> HesseNorm (); - - t = v; - a(0, 0) = g1 * g1; - a(0, 1) = - a(1, 0) = g1 * g2; - a(1, 1) = g2 * g2; - - rs(0) = g1(dir-1); - rs(1) = g2(dir-1); - - a.Solve (rs, x); - - /* - CalcInverse (a, inv); - inv.Mult (rs, x); // x .. Lagrangeparameter - */ - // (*testout) << "g1 = " << g1 << " g2 = " << g2 << endl; - // (*testout) << "lam = " << x << endl; - // (*testout) << "h2 = " << h2 << endl; - - leftside = fabs (x(0) * ( t * (h1 * t)) + - x(1) * ( t * (h2 * t))); - - // (*testout) << "leftside = " << leftside << endl; - - if (leftside < epeps2 * Abs2 (v)) return 1; - - return 0; -} - - - -bool SpecialPointCalculation :: AddPoint (const Point<3> & p, int layer) -{ - for (int i = 0; i < points->Size(); i++) - if (Dist2 ( (*points)[i], p) < epspointdist2 && - (*points)[i].GetLayer() == layer) - return 0; - - points->Append (MeshPoint(p, layer)); - return 1; -} - - - - - - - -/* -void SpecialPointCalculation :: -AnalyzeSpecialPoints (const CSGeometry & ageometry, - ARRAY<Point<3> > & apoints, - ARRAY<SpecialPoint> & specpoints) -{ - int si, i, j, k, l, m, spi; - Solid * locsol; - ARRAY<int> surfind; - ARRAY<Vec<3>> normalvecs; - const Solid * sol; - Vec<3> t; - Point<3> p; - - ARRAY<int> specpoint2point; - specpoints.SetSize (0); - - (*testout) << "AnalyzeSpecialPoints" << endl; - - for (si = 1; si <= ageometry.GetNTopLevelObjects(); si++) - { - (*testout) << "main solid " << si << endl; - - sol = ageometry.GetTopLevelObject(si)->GetSolid(); - for (i = 1; i <= apoints.Size(); i++) - { - p = apoints.Get(i); - - sol -> TangentialSolid (p, locsol); - if (!locsol) continue; - - (*testout) << "Point " << apoints.Get(i) << endl; - - locsol -> GetSurfaceIndices (surfind); - for (j = surfind.Size(); j >= 1; j--) - if (fabs (ageometry.GetSurface(surfind.Get(j))-> - CalcFunctionValue (p)) > 1e-6) - surfind.DeleteElement (j); - - - - (*testout) << "Surfaces: "; - for (j = 1; j <= surfind.Size(); j++) - (*testout) << surfind.Get(j) << " "; - (*testout) << endl; - - normalvecs.SetSize(surfind.Size()); - for (j = 1; j <= surfind.Size(); j++) - ageometry.GetSurface(surfind.Get(j)) -> - GetNormalVector(apoints.Get(i), normalvecs.Elem(j)); - - for (j = 1; j <= normalvecs.Size() - 1; j ++) - for (k = j+1; k <= normalvecs.Size(); k++) - for (l = 1; l <= 2; l++) - { - t = Cross (normalvecs.Get(j), normalvecs.Get(k)); - if (t.Length2() < 1e-8) - { - cerr << "AnalyzePoint: Surfaces degenerated" << endl; - break; - } - t /= t.Length(); - if (l == 2) t *= -1; - - if (locsol -> Edge (apoints.Get(i), t)) - { - spi = 0; - for (m = 1; m <= specpoints.Size(); m++) - if (Dist2 (specpoints.Get(m).p, apoints.Get(i)) < 1e-8 - && (specpoints.Get(m).v - t).Length2() < 1e-8) - { - spi = m; - break; - } - if (!spi) - { - spi = specpoints.Append (SpecialPoint()); - specpoint2point.Append (i); - specpoints.Last().unconditional = 0; - } - specpoints.Elem(spi).p = apoints.Get(i); - specpoints.Elem(spi).v = t; - if (surfind.Size() >= 3) - specpoints.Elem(spi).unconditional = 1; - specpoints.Elem(spi).s1 = surfind.Get(j); - specpoints.Elem(spi).s2 = surfind.Get(k); - (*testout) << "spi = " << spi - << " uncond = " << specpoints.Get(spi).unconditional - << " t = " << t << endl; - } - - } - delete locsol; - } - } - - // if special point is unconditional on some solid, - // it must be unconditional everywhere: - - BitArray uncond (apoints.Size()); - uncond.Clear(); - - for (i = 1; i <= specpoints.Size(); i++) - if (specpoints.Get(i).unconditional) - uncond.Set (specpoint2point.Get(i)); - - for (i = 1; i <= specpoints.Size(); i++) - specpoints.Elem(i).unconditional = - uncond.Test (specpoint2point.Get(i)) ? 1 : 0; -} -*/ - - - -void SpecialPointCalculation :: -AnalyzeSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints, - ARRAY<SpecialPoint> & specpoints) -{ - int si, i, j, k, l, m, spi; - - Solid * locsol; - ARRAY<int> surfind; - ARRAY<int> surfind2; - - ARRAY<Vec<3> > normalvecs; - const Solid * sol; - const Surface * surf; - - Vec<3> t, nsurf; - Point<3> p; - - ARRAY<int> specpoint2point; - specpoints.SetSize (0); - - geometry = &ageometry; - - (*testout) << "AnalyzeSpecialPoints\n"; - - - Box<3> bbox; - if (apoints.Size()) - bbox.Set (apoints[0]); - for (int i = 1; i < apoints.Size(); i++) - bbox.Add (apoints[i]); - bbox.Increase (0.1 * Dist (bbox.PMin(), bbox.PMax())); - - Point3dTree searchtree (bbox.PMin(), bbox.PMax()); - ARRAY<int> locsearch; - - for (si = 0; si < ageometry.GetNTopLevelObjects(); si++) - { - (*testout) << "main solid " << si << "\n"; - - sol = ageometry.GetTopLevelObject(si)->GetSolid(); - surf = ageometry.GetTopLevelObject(si)->GetSurface(); - - for (i = 0; i < apoints.Size(); i++) - { - p = apoints[i]; - if (ageometry.GetTopLevelObject(si)->GetLayer() != - apoints[i].GetLayer()) - continue; - - (*testout) << "Point " << apoints[i] << "\n"; - - sol -> TangentialSolid (p, locsol); - if (!locsol) continue; - - // get all surface indices, - if (surf) - { - locsol -> GetSurfaceIndices (surfind); - bool hassurf = 0; - for (m = 0; m < surfind.Size(); m++) - if (ageometry.GetSurface(surfind[m]) == surf) - hassurf = 1; - - if (!hassurf) - continue; - - surf->GetNormalVector (p, nsurf); - } - - // get independent surfaces of tangential solid - - BoxSphere<3> box(p,p); - box.Increase (1e-6); - box.CalcDiamCenter(); - ageometry.GetIndependentSurfaceIndices (locsol, box, surfind); - - - (*testout) << "surfind.size = " << surfind.Size() << endl; - - /* - locsol -> GetSurfaceIndices (surfind); - for (j = surfind.Size(); j >= 1; j--) - if (fabs (ageometry.GetSurface(surfind.Get(j))-> - CalcFunctionValue (p)) > 1e-6) - surfind.DeleteElement (j); - */ - - /* - (*testout) << "Surfaces: "; - for (j = 0; j < surfind.Size(); j++) - (*testout) << surfind[j] << " "; - (*testout) << "\n"; - */ - - - normalvecs.SetSize(surfind.Size()); - for (j = 0; j < surfind.Size(); j++) - ageometry.GetSurface(surfind[j]) -> - GetNormalVector(apoints[i], normalvecs[j]); - - for (j = 0; j < normalvecs.Size(); j++) - for (k = j+1; k < normalvecs.Size(); k++) - for (l = 1; l <= 2; l++) - { - t = Cross (normalvecs[j], normalvecs[k]); - if (Abs2 (t) < 1e-8) - { - cerr << "AnalyzePoint: Surfaces degenerated" << "\n"; - break; - } - t.Normalize(); - if (l == 2) t *= -1; - - // try tangential direction t - - // (*testout) << "check tangential " << t << "\n"; - - if (surf && fabs (nsurf * t) > 1e-6) - continue; - - if (!surf) - { - ageometry.GetIndependentSurfaceIndices - (locsol, p, t, surfind2); - - bool found1 = 0, found2 = 0; - for (int ii = 0; ii < surfind2.Size(); ii++) - { - if (surfind2[ii] == surfind[j]) - found1 = 1; - if (surfind2[ii] == surfind[k]) - found2 = 1; - } - if (!found1 || !found2) - continue; - } - - - bool isedge; - - // isedge = locsol -> Edge (apoints.Get(i), t); - - // edge must be on tangential surface - isedge = - locsol->VectorIn (p, t) && - !locsol->VectorStrictIn (p, t); - - // (*testout) << "isedge,1 = " << isedge << "\n"; - - // there must exist at least two different faces on edge - if (isedge) - { - int cnts = 0; - for (m = 0; m < surfind.Size(); m++) - { - if (fabs (normalvecs[m] * t) > 1e-6) - continue; - - Vec<3> s = Cross (normalvecs[m], t); - Vec<3> t2a = t + 0.01 *s; - Vec<3> t2b = t - 0.01 *s; - - /* - (*testout) << "nv = " << normalvecs[m] << ", s = " << s << "\n"; - (*testout) << "t2a = " << t2a << ", t2b = " << t2b << "\n"; - (*testout) << "via = " - << locsol->VectorIn (p, t2a) << "/" - << locsol->VectorStrictIn (p, t2a); - (*testout) << "vib = " - << locsol->VectorIn (p, t2b) << "/" - << locsol->VectorStrictIn (p, t2b) << "\n"; - */ - - bool isface = - (locsol->VectorIn (p, t2a) && - !locsol->VectorStrictIn (p, t2a)) - || - (locsol->VectorIn (p, t2b) && - !locsol->VectorStrictIn (p, t2b)); - - if (isface) - { - cnts++; - } - } - if (cnts < 2) isedge = 0; - } - - if (isedge) - { - spi = -1; - - searchtree.GetIntersecting (apoints[i]-Vec3d(1e-4,1e-4,1e-4), - apoints[i]+Vec3d(1e-4,1e-4,1e-4), - locsearch); - - for (m = 0; m < locsearch.Size(); m++) - if (Dist2 (specpoints[locsearch[m]].p, apoints[i]) < 1e-8 - && Abs2(specpoints[locsearch[m]].v - t) < 1e-8) - { - spi = locsearch[m]; - break; - } - - /* - for (m = 0; m < specpoints.Size(); m++) - if (Dist2 (specpoints[m].p, apoints[i]) < 1e-8 - && Abs2(specpoints[m].v - t) < 1e-8) - { - spi = m; - break; - } - */ - if (spi == -1) - { - spi = specpoints.Append (SpecialPoint()) - 1; - specpoint2point.Append (i); - specpoints.Last().unconditional = 0; - searchtree.Insert (apoints[i], spi); - } - specpoints[spi].p = apoints[i]; - specpoints[spi].v = t; - if (surfind.Size() >= 3) - specpoints[spi].unconditional = 1; - specpoints[spi].s1 = surfind[j]; - specpoints[spi].s2 = surfind[k]; - specpoints[spi].layer = apoints[i].GetLayer(); - for (int up = 0; up < geometry->GetNUserPoints(); up++) - if (Dist (geometry->GetUserPoint(up), apoints[i]) < 1e-10) - specpoints[spi].unconditional = 1; - - /* - (*testout) << "spi = " << spi - << " uncond = " << specpoints[spi].unconditional - << " t = " << t << "\n"; - */ - } - - } - delete locsol; - } - } - - // if special point is unconditional on some solid, - // it must be unconditional everywhere: - - BitArray uncond (apoints.Size()); - uncond.Clear(); - - for (i = 0; i < specpoints.Size(); i++) - if (specpoints[i].unconditional) - uncond.Set (specpoint2point[i]); - - for (i = 0; i < specpoints.Size(); i++) - specpoints[i].unconditional = - uncond.Test (specpoint2point[i]) ? 1 : 0; -} -} diff --git a/contrib/Netgen/libsrc/csg/specpoin_old.cpp b/contrib/Netgen/libsrc/csg/specpoin_old.cpp deleted file mode 100644 index 0f30ef7298a601726fcdc5ed6d053c6a18943f5e..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/specpoin_old.cpp +++ /dev/null @@ -1,1370 +0,0 @@ -#include <mystdlib.h> -#include <meshing.hpp> -#include <csg.hpp> - - -/* - - Special Point calculation uses the global Flags: - - - size .. 500 cube = [-size, size]^3 - relydegtest when to rely on degeneration ? - calccp calculate points of intersection ? - cpeps1 eps for degenerated poi - calcep calculate points of extreme coordinates ? - epeps1 eps for degenerated edge - epeps2 eps for axis parallel pec - epspointdist eps for distance of special points -*/ - - -namespace netgen -{ -void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp); - - - - /* -SpecialPoint :: SpecialPoint () - : p(), v(), layer(0) -{ - ; -} - */ - - -SpecialPoint :: SpecialPoint (const SpecialPoint & sp) -{ - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; -} - -SpecialPoint & SpecialPoint :: operator= (const SpecialPoint & sp) -{ - p = sp.p; - v = sp.v; - s1 = sp.s1; - s2 = sp.s2; - layer = sp.layer; - unconditional = sp.unconditional; - return *this; -} - -/* -bool SpecialPoint :: HasSurfaces (int as1, int as2) const -{ - return (s1 == as1 && s2 == as2 || s1 == as2 && s2 == as1); -} -*/ -void SpecialPoint :: Print (ostream & str) -{ - str << "p = " << p << " v = " << v - << " s1/s2 = " << s1 << "/" << s2 - << " layer = " << layer - << endl; -} - - - - -SpecialPointCalculation :: SpecialPointCalculation () -{ - ; -} - -void SpecialPointCalculation :: -CalcSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints) -{ - int i; - - geometry = &ageometry; - points = &apoints; - - size = geometry->MaxSize(); // globflags.GetNumFlag ("maxsize", 500); - (*testout) << "Find Special Points" << endl; - (*testout) << "maxsize = " << size << endl; - - cpeps1 = 1e-6; - epeps1 = 1e-3; - epeps2 = 1e-6; - - epspointdist2 = sqr (size * 1e-8); - relydegtest = size * 1e-4; - - - BoxSphere<3> box (Point<3> (-size, -size, -size), - Point<3> ( size, size, size)); - box.CalcDiamCenter(); - PrintMessage (3, "main-solids: ", geometry->GetNTopLevelObjects()); - - for (i = 0; i < geometry->GetNTopLevelObjects(); i++) - { - (*testout) << "tlo " << i << ":" << endl; - const TopLevelObject * tlo = geometry->GetTopLevelObject(i); - tlo->GetSolid()->Print (*testout); - (*testout) << endl; - CalcSpecialPointsRec (tlo->GetSolid(), tlo->GetLayer(), - box, 1, 1, 1); - } - - PrintDot ('\n'); - - - // add user point: - int found = 0; - for (i = 0; i < geometry->GetNUserPoints(); i++) - AddPoint (geometry->GetUserPoint(i), 1); - - PrintMessage (3, apoints.Size(), " special points"); - - for (i = 0; i < boxesinlevel.Size(); i++) - (*testout) << "level " << i << " has " - << boxesinlevel[i] << " boxes" << endl; -} - - - -int debug; -void SpecialPointCalculation :: -CalcSpecialPointsRec (const Solid * sol, int layer, - const BoxSphere<3> & box, - int level, bool calccp, bool calcep) -{ - if (multithread.terminate) - return; - - int i; - BoxSphere<3> sbox; - Solid * redsol; - - int numprim; - - bool decision; - bool possiblecrossp, possibleexp; // possible cross or extremalpoint - bool surecrossp, sureexp; // sure ... - - static ARRAY<int> locsurf; // attention: array is static - - - Point<3> p; - int k1, k2, k3; - int extremdir; - double hd; - - if (!sol) return; - - - if (level >= 100) - { - cerr << "Problems in CalcSpecialPoints" << endl; - cerr << "Point: " << box.Center() << endl; - exit (1); - } - - static int cntbox = 0; - cntbox++; - if (cntbox % 10000 == 0) - PrintDot (); - - if (level <= boxesinlevel.Size()) - boxesinlevel.Elem(level)++; - else - boxesinlevel.Append (1); - - /* - numprim = sol -> NumPrimitives(); - sol -> GetSurfaceIndices (locsurf); - */ - - debug = 0; - // box.IsIn (Point<3> (4.9, 1.279, 2.8)); - - - geometry -> GetIndependentSurfaceIndices (sol, box, locsurf); - numprim = locsurf.Size(); - - if (debug) - { - (*testout) << "box = " << box.PMin() << "-" << box.PMax() - << " np = " << numprim << " : "; - for (i = 1; i <= locsurf.Size(); i++) - (*testout) << " " << locsurf.Get(i); - (*testout) << " diam = " << box.Diam(); - (*testout) << " numprim = " << numprim; - (*testout) << endl; - } - - p = box.Center(); - - /* - (*testout) << "box = " << box.PMin() << " - " << box.PMax() - << ", lev = " << level - << ", nprim = " << sol->NumPrimitives() - << ", lsurf = " << locsurf.Size() << endl; - - for (i = 1; i <= locsurf.Size(); i++) - geometry->GetSurface (locsurf.Get(i)) -> Print (*testout); - sol -> Print (*testout); - */ - - /* - for (i = 1; i <= locsurf.Size(); i++) - (*testout) << locsurf.Get(i) << " "; - (*testout) << "C = " << box.Center() << " diam = " << box.Diam() << endl; - */ - - possiblecrossp = (numprim >= 3) && calccp; - surecrossp = 0; - - if (possiblecrossp && (locsurf.Size() <= 10)) - { - decision = 1; - surecrossp = 0; - - for (k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - int nc, deg; - nc = CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ); - - deg = CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), box ); - - if (!nc && !deg) decision = 0; - if (nc) surecrossp = 1; - } - - if (decision && surecrossp) - { - for (k1 = 1; k1 <= locsurf.Size() - 2; k1++) - for (k2 = k1 + 1; k2 <= locsurf.Size() - 1; k2++) - for (k3 = k2 + 1; k3 <= locsurf.Size(); k3++) - { - if (CrossPointNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), p ) ) - { - Point<3> pp = p; - CrossPointNewton - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), pp); - - BoxSphere<3> hbox (pp, pp); - hbox.Increase (1e-8); - - if (pp(0) > box.PMin()(0) - 1e-5 && - pp(0) < box.PMax()(0) + 1e-5 && - pp(1) > box.PMin()(1) - 1e-5 && - pp(1) < box.PMax()(1) + 1e-5 && - pp(2) > box.PMin()(2) - 1e-5 && - pp(2) < box.PMax()(2) + 1e-5 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) && - !CrossPointDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - geometry->GetSurface(locsurf.Get(k3)), hbox )) - - { - // AddCrossPoint (locsurf, sol, p); - BoxSphere<3> boxp (pp, pp); - boxp.Increase (1e-3); - boxp.CalcDiamCenter(); - ARRAY<int> locsurf2; - - geometry -> GetIndependentSurfaceIndices (sol, boxp, locsurf2); - - /* - ReducePrimitiveIterator rpi(boxp); - UnReducePrimitiveIterator urpi; - - ((Solid*)sol) -> IterateSolid (rpi); - sol -> GetIndependentSurfaceIndices (locsurf2); - ((Solid*)sol) -> IterateSolid (urpi); - */ - bool found1 = 0, found2 = 0, found3 = 0; - for (i = 1; i <= locsurf2.Size(); i++) - { - if (locsurf2.Get(i) == locsurf.Get(k1)) - found1 = 1; - if (locsurf2.Get(i) == locsurf.Get(k2)) - found2 = 1; - if (locsurf2.Get(i) == locsurf.Get(k3)) - found3 = 1; - } - - if (found1 && found2 && found3) - if (AddPoint (pp, layer)) - { - (*testout) << "Crosspoint found: " << pp - << " diam = " << box.Diam() << endl; - (*testout) << "surfs: " - << locsurf.Get(k1) << "," - << locsurf.Get(k2) << "," - << locsurf.Get(k3) << endl; - } - } - } - } - } - - if (decision) - possiblecrossp = 0; - } - - - - - possibleexp = (numprim >= 2) && calcep; - - if (possibleexp && (locsurf.Size() <= 10)) - { - decision = 1; - sureexp = 0; - - for (k1 = 1; k1 <= locsurf.Size() - 1; k1++) - for (k2 = k1+1; k2 <= locsurf.Size(); k2++) - { - bool nc, deg; - - nc = EdgeNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p); - - deg = EdgeDegenerated - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - box); - - if (!nc && !deg) decision = 0; - if (nc) sureexp = 1; - - if (debug) - { - (*testout) << "p = " << p << " s1,2 = " << locsurf.Get(k1) << ", " << locsurf.Get(k2) - << " nc = " << nc << " deg = " << deg << endl; - } - } - - if (decision && sureexp) - { - for (k1 = 1; k1 <= locsurf.Size() - 1; k1++) - for (k2 = k1+1; k2 <= locsurf.Size(); k2++) - { - if ( - EdgeNewtonConvergence - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p) ) - { - EdgeNewton - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p); - - Point<3> pp; - if (IsEdgeExtremalPoint - (geometry->GetSurface(locsurf.Get(k1)), - geometry->GetSurface(locsurf.Get(k2)), - p, pp, box.Diam()/2)) - { - (*testout) << "extremalpoint (nearly) found:" - << pp - << endl; - if (Dist (pp, box.Center()) < box.Diam()/2 && - sol -> IsIn (pp) && !sol->IsStrictIn (pp) ) - { - // AddExtremalPoint (locsurf.Get(k1), locsurf.Get(k2), p); - if (AddPoint (pp, layer)) - (*testout) << "Extremal point found: " << pp << endl; - } - } - } - } - } - if (decision) - possibleexp = 0; - } - - - - if (possiblecrossp || possibleexp) - { - for (i = 0; i < 8; i++) - { - box.GetSubBox (i, sbox); - sbox.Increase (1e-4 * sbox.Diam()); - - redsol = sol -> GetReducedSolid (sbox); - - if (redsol) - { - CalcSpecialPointsRec (redsol, layer, sbox, level+1, calccp, calcep); - delete redsol; - } - } - } -} - - - - - -/******* Tests for Point of intersection **********************/ - - - -bool SpecialPointCalculation :: -CrossPointNewtonConvergence (const Surface * f1, - const Surface * f2, - const Surface * f3, - const Point<3> & p) -{ - int i; - Vec<3> grad; - Vec<3> rs, x; - Mat<3> jacobi, inv; - double alpha, beta, gamma, eta; - double sum; - int j; - - - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - f1->CalcGradient (p, grad); - jacobi(0,0) = grad(0); - jacobi(0,1) = grad(1); - jacobi(0,2) = grad(2); - - f2->CalcGradient (p, grad); - jacobi(1,0) = grad(0); - jacobi(1,1) = grad(1); - jacobi(1,2) = grad(2); - - f3->CalcGradient (p, grad); - jacobi(2,0) = grad(0); - jacobi(2,1) = grad(1); - jacobi(2,2) = grad(2); - - alpha = 1; - if (fabs (Det (jacobi)) > 1e-8) - { - CalcInverse (jacobi, inv); - x = inv * rs; - - gamma = f1 -> HesseNorm() + f2 -> HesseNorm() + f3 -> HesseNorm(); - beta = 0; - for (i = 0; i < 3; i++) - { - sum = 0; - for (j = 0; j < 3; j++) - sum += fabs (inv(i,j)); - beta = max2 (beta, sum); - } - eta = Abs (x); - - alpha = beta * gamma * eta; - } - - return (alpha < 0.1); -} - - - - -bool SpecialPointCalculation :: -CrossPointDegenerated (const Surface * f1, - const Surface * f2, - const Surface * f3, - const BoxSphere<3> & box) const -{ - Mat<3> mat; - Vec<3> grad, g1, g2, g3; - double normprod; - - if (box.Diam() > relydegtest) return 0; - - f1->CalcGradient (box.Center(), g1); - normprod = Abs (g1); - - f2->CalcGradient (box.Center(), g2); - normprod *= Abs (g2); - - f3->CalcGradient (box.Center(), g3); - normprod *= Abs (g3); - - for (int i = 0; i < 3; i++) - { - mat(i,0) = g1(i); - mat(i,1) = g2(i); - mat(i,2) = g3(i); - } - - if (fabs (Det (mat)) < cpeps1 * normprod) - return 1; - else - return 0; -} - - - - - -void SpecialPointCalculation :: CrossPointNewton (const Surface * f1, - const Surface * f2, - const Surface * f3, Point<3> & p) -{ - int i; - Vec<3> g1, g2, g3; - Vec<3> rs, sol; - Mat<3> mat; - - i = 10; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - rs(2) = f3->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - f3->CalcGradient (p, g3); - - for (int j = 0; j < 3; j++) - { - mat(0, j) = g1(j); - mat(1, j) = g2(j); - mat(2, j) = g3(j); - } - mat.Solve (rs, sol); - /* - Transpose (g1, g2, g3); - SolveLinearSystem (g1, g2, g3, rs, sol); - */ - if (sol.Length() < 1e-12 && i > 1) i = 1; - - p -= sol; - } -} - - - - -/******* Tests for Point on edges **********************/ - - - - -bool SpecialPointCalculation :: -EdgeNewtonConvergence (const Surface * f1, const Surface * f2, - const Point<3> & p) -{ - int i; - Vec<3> g1, g2, sol; - Vec<2> vrs; - double alpha, beta, gamma, eta; - double sum; - Mat<2,3> mat; - Mat<3,2> inv; - int j; - - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - for (i = 0; i < 3; i++) - { - mat(0,i) = g1(i); - mat(1,i) = g2(i); - } - - alpha = 1; - - if ( fabs(g1 * g2) < (1 - 1e-8) * Abs (g1) * Abs (g2)) - { - CalcInverse (mat, inv); - sol = inv * vrs; - - // SolveLinearSystemLS (g1, g2, vrs, sol); - - gamma = f1 -> HesseNorm() + f2 -> HesseNorm(); - - /* - Vec<3> inv1, inv2; - PseudoInverse (g1, g2, inv1, inv2); - */ - - beta = 0; - for (i = 0; i < 3; i++) - for (j = 0; j < 2; j++) - beta += inv(i,j) * inv(i,j); - beta = sqrt (beta); - - // beta = inv1.Length() + inv2.Length(); - eta = Abs (sol); - alpha = beta * gamma * eta; - } - return (alpha < 0.1); -} - - - - -bool SpecialPointCalculation :: -EdgeDegenerated (const Surface * f1, - const Surface * f2, - const BoxSphere<3> & box) const -{ - // perform newton steps. normals parallel ? - // if not decideable: return 0 - - - Point<3> p = box.Center(); - int i; - Vec<3> grad, g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - i = 20; - while (i > 0) - { - if (Dist (p, box.Center()) > box.Diam()) - return 0; - - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - if ( fabs (g1 * g2) > (1 - 1e-10) * Abs (g1) * Abs (g2)) - return 1; - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - // SolveLinearSystemLS (g1, g2, vrs, sol); - - if (Abs (sol) < 1e-12 && i > 1) i = 1; - p -= sol; - } - - return 0; - /* - return 0; - - static DenseMatrix jacobi(3); - Vec<3> grad, g1, g2, g3; - double normprod; - - if (box.Diam() > relydegtest) return 0; - - f1->CalcGradient (box.Center(), g1); - normprod = g1.Length(); - - f2->CalcGradient (box.Center(), g2); - normprod *= g2.Length(); - - if (fabs (g1 * g2) < 1e-8 * normprod) - return 1; - else - return 0; - */ -} - - - - - - -void SpecialPointCalculation :: EdgeNewton (const Surface * f1, - const Surface * f2, Point<3> & p) -{ - int i; - Vec<3> grad, g1, g2, sol; - Vec<2> vrs; - Mat<2,3> mat; - - i = 10; - while (i > 0) - { - i--; - vrs(0) = f1->CalcFunctionValue (p); - vrs(1) = f2->CalcFunctionValue (p); - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - for (int j = 0; j < 3; j++) - { - mat(0,j) = g1(j); - mat(1,j) = g2(j); - } - mat.Solve (vrs, sol); - // SolveLinearSystemLS (g1, g2, vrs, sol); - - if (Abs (sol) < 1e-12 && i > 1) i = 1; - p -= sol; - } -} - - - -bool SpecialPointCalculation :: -IsEdgeExtremalPoint (const Surface * f1, const Surface * f2, - const Point<3> & p, Point<3> & pp, double rad) -{ - Vec<3> g1, g2, t, t1, t2; - int j; - - f1->CalcGradient (p, g1); - f2->CalcGradient (p, g2); - - t = Cross (g1, g2); - t.Normalize(); - - Point<3> p1 = p + rad * t; - Point<3> p2 = p - rad * t; - - EdgeNewton (f1, f2, p1); - EdgeNewton (f1, f2, p2); - - - f1->CalcGradient (p1, g1); - f2->CalcGradient (p1, g2); - t1 = Cross (g1, g2); - t1.Normalize(); - - f1->CalcGradient (p2, g1); - f2->CalcGradient (p2, g2); - t2 = Cross (g1, g2); - t2.Normalize(); - - double val = 1e-8 * rad * rad; - for (j = 0; j < 3; j++) - if ( (t1(j) * t2(j) < -val) ) - { - pp = p; - ExtremalPointNewton (f1, f2, j+1, pp); - return 1; - } - - return 0; -} - - - - - - - - - -/********** Tests of Points of extremal coordinates ****************/ - - -void SpecialPointCalculation :: ExtremalPointNewton (const Surface * f1, - const Surface * f2, - int dir, Point<3> & p) -{ - int i; - - Vec<3> g1, g2, v, curv; - Vec<3> rs, x, y1, y2, y; - Mat<3> h1, h2; - Mat<3> jacobi; - - - if (dir < 1 || dir > 3) - { - cerr << "Error: Illegal extremdir" << endl; - return; - } - - i = 50; - while (i > 0) - { - i--; - rs(0) = f1->CalcFunctionValue (p); - rs(1) = f2->CalcFunctionValue (p); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - - v = Cross (g1, g2); - - rs(2) = v(dir-1); - - jacobi(0,0) = g1(0); - jacobi(0,1) = g1(1); - jacobi(0,2) = g1(2); - - jacobi(1,0) = g2(0); - jacobi(1,1) = g2(1); - jacobi(1,2) = g2(2); - - - switch (dir) - { - case 1: - { - y1(0) = 0; - y1(1) = g2(2); - y1(2) = -g2(1); - y2(0) = 0; - y2(1) = -g1(2); - y2(2) = g1(1); - break; - } - case 2: - { - y1(0) = -g2(2); - y1(1) = 0; - y1(2) = g2(0); - y2(0) = g1(2); - y2(1) = 0; - y2(2) = -g1(0); - break; - } - case 3: - { - y1(0) = g2(1); - y1(1) = -g2(0); - y1(2) = 0; - y2(0) = -g1(1); - y2(1) = g1(0); - y2(2) = 0; - break; - } - } - - y = h1 * y1 + h2 * y2; - - jacobi(2,0) = y(0); - jacobi(2,1) = y(1); - jacobi(2,2) = y(2); - - jacobi.Solve (rs, x); - /* - CalcInverse (jacobi, inv); - inv.Mult (rs, x); - */ - // (*testout) << "err = " << x.L2Norm() << endl; - - if (Abs (x) < 1e-12 && i > 1) - { - // (*testout) << "convergent in " << (10 - i) << " steps " << endl; - - i = 1; - } - - p -= x; - } - - if (Abs (x) > 1e-10) - { - (*testout) << "Error: extremum Newton not convergent" << endl; - (*testout) << "dir = " << dir << endl; - (*testout) << "p = " << p << endl; - (*testout) << "x = " << x << endl; - } -} - - - - -bool SpecialPointCalculation :: ExtremalPointPossible (const Surface * f1, - const Surface * f2, - int dir, - const BoxSphere<3> & box) -{ - double hn1, hn2, gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double f3; - double r = box.Diam()/2; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - - gn1 = g1.Length(); - gn2 = g2.Length(); - - hn1 = f1 -> HesseNorm (); - hn2 = f2 -> HesseNorm (); - - v = Cross (g1, g2); - f3 = fabs (v(dir-1)); - - // (*testout) << "f3 = " << f3 << " r = " << r - // << "normbound = " - // << (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1)) << endl; - - return (f3 <= 3 * r * (hn1 * (gn2 + r * hn2) + hn2 * (gn1 + r * hn1))); -} - - - -bool SpecialPointCalculation :: -ExtremalPointNewtonConvergence (const Surface * f1, const Surface * f2, - int dir, - const BoxSphere<3> & box) -{ - return box.Diam() < 1e-8; -} - - -bool SpecialPointCalculation :: -ExtremalPointDegenerated (const Surface * f1, const Surface * f2, - int dir, const BoxSphere<3> & box) -{ - double gn1, gn2; - Point<3> p; - Vec<3> g1, g2, v; - double maxderiv; - double minv; - Vec<3> curv, t; - Vec<2> rs, x; - Mat<3> h1, h2; - Mat<2> a, inv; - double leftside; - - if (box.Diam() > relydegtest) return 0; - - p = box.Center(); - - f1 -> CalcGradient (p, g1); - f2 -> CalcGradient (p, g2); - gn1 = g1.Length(); - gn2 = g2.Length(); - - v = Cross (g1, g2); - if (Abs (v) < epeps1 * gn1 * gn2) return 1; // irregular edge - - f1 -> CalcHesse (p, h1); - f2 -> CalcHesse (p, h2); - - // hn1 = f1 -> HesseNorm (); - // hn2 = f2 -> HesseNorm (); - - t = v; - a(0, 0) = g1 * g1; - a(0, 1) = - a(1, 0) = g1 * g2; - a(1, 1) = g2 * g2; - - rs(0) = g1(dir-1); - rs(1) = g2(dir-1); - - a.Solve (rs, x); - - /* - CalcInverse (a, inv); - inv.Mult (rs, x); // x .. Lagrangeparameter - */ - // (*testout) << "g1 = " << g1 << " g2 = " << g2 << endl; - // (*testout) << "lam = " << x << endl; - // (*testout) << "h2 = " << h2 << endl; - - leftside = fabs (x(0) * ( t * (h1 * t)) + - x(1) * ( t * (h2 * t))); - - // (*testout) << "leftside = " << leftside << endl; - - if (leftside < epeps2 * Abs2 (v)) return 1; - - return 0; -} - - - -bool SpecialPointCalculation :: AddPoint (const Point<3> & p, int layer) -{ - for (int i = 0; i < points->Size(); i++) - if (Dist2 ( (*points)[i], p) < epspointdist2 && - (*points)[i].GetLayer() == layer) - return 0; - - points->Append (MeshPoint(p, layer)); - return 1; -} - - - - - - - -/* -void SpecialPointCalculation :: -AnalyzeSpecialPoints (const CSGeometry & ageometry, - ARRAY<Point<3> > & apoints, - ARRAY<SpecialPoint> & specpoints) -{ - int si, i, j, k, l, m, spi; - Solid * locsol; - ARRAY<int> surfind; - ARRAY<Vec<3>> normalvecs; - const Solid * sol; - Vec<3> t; - Point<3> p; - - ARRAY<int> specpoint2point; - specpoints.SetSize (0); - - (*testout) << "AnalyzeSpecialPoints" << endl; - - for (si = 1; si <= ageometry.GetNTopLevelObjects(); si++) - { - (*testout) << "main solid " << si << endl; - - sol = ageometry.GetTopLevelObject(si)->GetSolid(); - for (i = 1; i <= apoints.Size(); i++) - { - p = apoints.Get(i); - - sol -> TangentialSolid (p, locsol); - if (!locsol) continue; - - (*testout) << "Point " << apoints.Get(i) << endl; - - locsol -> GetSurfaceIndices (surfind); - for (j = surfind.Size(); j >= 1; j--) - if (fabs (ageometry.GetSurface(surfind.Get(j))-> - CalcFunctionValue (p)) > 1e-6) - surfind.DeleteElement (j); - - - - (*testout) << "Surfaces: "; - for (j = 1; j <= surfind.Size(); j++) - (*testout) << surfind.Get(j) << " "; - (*testout) << endl; - - normalvecs.SetSize(surfind.Size()); - for (j = 1; j <= surfind.Size(); j++) - ageometry.GetSurface(surfind.Get(j)) -> - GetNormalVector(apoints.Get(i), normalvecs.Elem(j)); - - for (j = 1; j <= normalvecs.Size() - 1; j ++) - for (k = j+1; k <= normalvecs.Size(); k++) - for (l = 1; l <= 2; l++) - { - t = Cross (normalvecs.Get(j), normalvecs.Get(k)); - if (t.Length2() < 1e-8) - { - cerr << "AnalyzePoint: Surfaces degenerated" << endl; - break; - } - t /= t.Length(); - if (l == 2) t *= -1; - - if (locsol -> Edge (apoints.Get(i), t)) - { - spi = 0; - for (m = 1; m <= specpoints.Size(); m++) - if (Dist2 (specpoints.Get(m).p, apoints.Get(i)) < 1e-8 - && (specpoints.Get(m).v - t).Length2() < 1e-8) - { - spi = m; - break; - } - if (!spi) - { - spi = specpoints.Append (SpecialPoint()); - specpoint2point.Append (i); - specpoints.Last().unconditional = 0; - } - specpoints.Elem(spi).p = apoints.Get(i); - specpoints.Elem(spi).v = t; - if (surfind.Size() >= 3) - specpoints.Elem(spi).unconditional = 1; - specpoints.Elem(spi).s1 = surfind.Get(j); - specpoints.Elem(spi).s2 = surfind.Get(k); - (*testout) << "spi = " << spi - << " uncond = " << specpoints.Get(spi).unconditional - << " t = " << t << endl; - } - - } - delete locsol; - } - } - - // if special point is unconditional on some solid, - // it must be unconditional everywhere: - - BitArray uncond (apoints.Size()); - uncond.Clear(); - - for (i = 1; i <= specpoints.Size(); i++) - if (specpoints.Get(i).unconditional) - uncond.Set (specpoint2point.Get(i)); - - for (i = 1; i <= specpoints.Size(); i++) - specpoints.Elem(i).unconditional = - uncond.Test (specpoint2point.Get(i)) ? 1 : 0; -} -*/ - - - -void SpecialPointCalculation :: -AnalyzeSpecialPoints (const CSGeometry & ageometry, - ARRAY<MeshPoint> & apoints, - ARRAY<SpecialPoint> & specpoints) -{ - int si, i, j, k, l, m, spi; - - Solid * locsol; - ARRAY<int> surfind; - ARRAY<int> surfind2; - - ARRAY<Vec<3> > normalvecs; - const Solid * sol; - const Surface * surf; - - Vec<3> t, nsurf; - Point<3> p; - - ARRAY<int> specpoint2point; - specpoints.SetSize (0); - - geometry = &ageometry; - - (*testout) << "AnalyzeSpecialPoints\n"; - - for (si = 0; si < ageometry.GetNTopLevelObjects(); si++) - { - (*testout) << "main solid " << si << "\n"; - - sol = ageometry.GetTopLevelObject(si)->GetSolid(); - surf = ageometry.GetTopLevelObject(si)->GetSurface(); - - for (i = 0; i < apoints.Size(); i++) - { - p = apoints[i]; - if (ageometry.GetTopLevelObject(si)->GetLayer() != - apoints[i].GetLayer()) - continue; - - // (*testout) << "Point " << apoints[i] << "\n"; - - sol -> TangentialSolid (p, locsol); - if (!locsol) continue; - - // get all surface indices, - if (surf) - { - locsol -> GetSurfaceIndices (surfind); - bool hassurf = 0; - for (m = 0; m < surfind.Size(); m++) - if (ageometry.GetSurface(surfind[m]) == surf) - hassurf = 1; - - if (!hassurf) - continue; - - surf->GetNormalVector (p, nsurf); - } - - // get independent surfaces of tangential solid - - BoxSphere<3> box(p,p); - box.Increase (1e-6); - box.CalcDiamCenter(); - ageometry.GetIndependentSurfaceIndices (locsol, box, surfind); - - - /* - locsol -> GetSurfaceIndices (surfind); - for (j = surfind.Size(); j >= 1; j--) - if (fabs (ageometry.GetSurface(surfind.Get(j))-> - CalcFunctionValue (p)) > 1e-6) - surfind.DeleteElement (j); - */ - - /* - (*testout) << "Surfaces: "; - for (j = 0; j < surfind.Size(); j++) - (*testout) << surfind[j] << " "; - (*testout) << "\n"; - */ - - - normalvecs.SetSize(surfind.Size()); - for (j = 0; j < surfind.Size(); j++) - ageometry.GetSurface(surfind[j]) -> - GetNormalVector(apoints[i], normalvecs[j]); - - for (j = 0; j < normalvecs.Size(); j++) - for (k = j+1; k < normalvecs.Size(); k++) - for (l = 1; l <= 2; l++) - { - t = Cross (normalvecs[j], normalvecs[k]); - if (Abs2 (t) < 1e-8) - { - cerr << "AnalyzePoint: Surfaces degenerated" << "\n"; - break; - } - t.Normalize(); - if (l == 2) t *= -1; - - // try tangential direction t - - // (*testout) << "check tangential " << t << "\n"; - - if (surf && fabs (nsurf * t) > 1e-6) - continue; - - if (!surf) - { - ageometry.GetIndependentSurfaceIndices - (locsol, p, t, surfind2); - - bool found1 = 0, found2 = 0; - for (int ii = 0; ii < surfind2.Size(); ii++) - { - if (surfind2[ii] == surfind[j]) - found1 = 1; - if (surfind2[ii] == surfind[k]) - found2 = 1; - } - if (!found1 || !found2) - continue; - } - - - bool isedge; - - // isedge = locsol -> Edge (apoints.Get(i), t); - - // edge must be on tangential surface - isedge = - locsol->VectorIn (p, t) && - !locsol->VectorStrictIn (p, t); - - // (*testout) << "isedge,1 = " << isedge << "\n"; - - // there must exist at least two different faces on edge - if (isedge) - { - int cnts = 0; - for (m = 0; m < surfind.Size(); m++) - { - if (fabs (normalvecs[m] * t) > 1e-6) - continue; - - Vec<3> s = Cross (normalvecs[m], t); - Vec<3> t2a = t + 0.01 *s; - Vec<3> t2b = t - 0.01 *s; - - /* - (*testout) << "nv = " << normalvecs[m] << ", s = " << s << "\n"; - (*testout) << "t2a = " << t2a << ", t2b = " << t2b << "\n"; - (*testout) << "via = " - << locsol->VectorIn (p, t2a) << "/" - << locsol->VectorStrictIn (p, t2a); - (*testout) << "vib = " - << locsol->VectorIn (p, t2b) << "/" - << locsol->VectorStrictIn (p, t2b) << "\n"; - */ - - bool isface = - (locsol->VectorIn (p, t2a) && - !locsol->VectorStrictIn (p, t2a)) - || - (locsol->VectorIn (p, t2b) && - !locsol->VectorStrictIn (p, t2b)); - - if (isface) - { - cnts++; - } - } - if (cnts < 2) isedge = 0; - } - - if (isedge) - { - spi = -1; - for (m = 0; m < specpoints.Size(); m++) - if (Dist2 (specpoints[m].p, apoints[i]) < 1e-8 - && Abs2(specpoints[m].v - t) < 1e-8) - { - spi = m; - break; - } - if (spi == -1) - { - spi = specpoints.Append (SpecialPoint()) - 1; - specpoint2point.Append (i); - specpoints.Last().unconditional = 0; - } - specpoints[spi].p = apoints[i]; - specpoints[spi].v = t; - if (surfind.Size() >= 3) - specpoints[spi].unconditional = 1; - specpoints[spi].s1 = surfind[j]; - specpoints[spi].s2 = surfind[k]; - specpoints[spi].layer = apoints[i].GetLayer(); - for (int up = 0; up < geometry->GetNUserPoints(); up++) - if (Dist (geometry->GetUserPoint(up), apoints[i]) < 1e-10) - specpoints[spi].unconditional = 1; - - /* - (*testout) << "spi = " << spi - << " uncond = " << specpoints[spi].unconditional - << " t = " << t << "\n"; - */ - } - - } - delete locsol; - } - } - - // if special point is unconditional on some solid, - // it must be unconditional everywhere: - - BitArray uncond (apoints.Size()); - uncond.Clear(); - - for (i = 0; i < specpoints.Size(); i++) - if (specpoints[i].unconditional) - uncond.Set (specpoint2point[i]); - - for (i = 0; i < specpoints.Size(); i++) - specpoints[i].unconditional = - uncond.Test (specpoint2point[i]) ? 1 : 0; -} -} diff --git a/contrib/Netgen/libsrc/csg/spline3d.cpp b/contrib/Netgen/libsrc/csg/spline3d.cpp deleted file mode 100644 index 455493ad6f470d32f1e3b71ee17982bf006de9e2..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/spline3d.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include <mystdlib.h> - -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ -splinesegment3d :: splinesegment3d (const Point<3> & ap1, const Point<3> & ap2, - const Point<3> & ap3) -{ - p1 = ap1; - p2 = ap2; - p3 = ap3; -} - - -/* - todo - Tip von Joerg Stiller: - setzt Du in - void splinesegment3d :: Evaluate - Zeilen 54 und 56 - b2 = 2 * t * (1-t); - b2 /= sqrt(2); - Das heisst, Du wichtest das zweite Bersteinpolynom mit - w2 = 1 / sqrt(2); - Das ist aber nur fuer 45-Grad-Segmente korrekt. Fuer den - allgemeinen Fall funktioniert - w2 = ( e(p3 - p1), e(p2 - p1) ); // also cos(winkel(p3-p1, p2-p1)) - bzw. schoen symmetrisch - w2 = ( e(p3 - p1), e(p2 - p1) )/2 + ( e(p1 - p3), e(p2 - p3) )/2; - Das ist natuerlich kein C++ Code sondern symbolisch, wobei - e(p3 - p1) ist der von p1 zu p3 zeigende Einheitsvektor und - (a, b) steht fuer das Skalarprodukt zweier Vektoren etc. - - Eine vergleichbare Information steht auch irgendwo im Hoscheck & Lasser. - Ich habe das Buch aber eben nicht zur Hand. -*/ - -void splinesegment3d :: Evaluate (double t, Point<3> & p) const -{ - double x, y, z, w; - double b1, b2, b3; - - b1 = (1-t)*(1-t); - b2 = 2 * t * (1-t); - b3 = t * t; - - b2 /= sqrt(double(2)); - - x = p1(0) * b1 + p2(0) * b2 + p3(0) * b3; - y = p1(1) * b1 + p2(1) * b2 + p3(1) * b3; - z = p1(2) * b1 + p2(2) * b2 + p3(2) * b3; - w = b1 + b2 + b3; - - p(0) = x / w; - p(1) = y / w; - p(2) = z / w; -} - -void splinesegment3d :: EvaluateTangent (double t, Vec<3> & tang) const -{ - double x, y, z, w, xprime, yprime, zprime, wprime; - double b1, b2, b3, b1prime, b2prime, b3prime; - - b1 = (1-t)*(1-t); - b2 = 2 * t * (1-t); - b3 = t * t; - b2 /= sqrt(double(2)); - - b1prime = 2 * t - 2; - b2prime = - 4 * t + 2; - b3prime = 2 * t; - b2prime /= sqrt(double(2)); - - - x = p1(0) * b1 + p2(0) * b2 + p3(0) * b3; - y = p1(1) * b1 + p2(1) * b2 + p3(1) * b3; - z = p1(2) * b1 + p2(2) * b2 + p3(2) * b3; - w = b1 + b2 + b3; - - xprime = p1(0) * b1prime + p2(0) * b2prime + p3(0) * b3prime; - yprime = p1(1) * b1prime + p2(1) * b2prime + p3(1) * b3prime; - zprime = p1(2) * b1prime + p2(2) * b2prime + p3(2) * b3prime; - wprime = b1prime + b2prime + b3prime; - - tang(0) = (w * xprime - x * wprime) / (w * w); - tang(1) = (w * yprime - y * wprime) / (w * w); - tang(2) = (w * zprime - z * wprime) / (w * w); -} - - -void spline3d :: AddSegment (const Point<3> & ap1, const Point<3> & ap2, - const Point<3> & ap3) -{ - segments.Append (new splinesegment3d (ap1, ap2, ap3)); -} - -void spline3d :: Evaluate (double t, Point<3> & p) const -{ - int nr; - double loct; - static int cnt = 0; - - cnt++; - if (cnt % 10000 == 0) (*mycout) << "Evaluate calls: " << cnt << endl; - - while (t < 0) t += GetNumSegments(); - while (t >= GetNumSegments()) t -= GetNumSegments(); - nr = 1 + int (t); - loct = t - nr + 1; - segments.Get(nr)->Evaluate (loct, p); -} - -void spline3d :: EvaluateTangent (double t, Vec<3> & tang) const -{ - int nr; - double loct; - - while (t < 0) t += GetNumSegments(); - while (t >= GetNumSegments()) t -= GetNumSegments(); - nr = 1 + int (t); - loct = t - nr + 1; - segments.Get(nr)->EvaluateTangent (loct, tang); -} - - -double spline3d :: ProjectToSpline (Point<3> & p) const -{ - double t, tl, tu, dt, dist, mindist, optt; - Point<3> hp; - Vec<3> tanx, px; - - dt = 0.01; - mindist = 0; - for (t = 0; t <= GetNumSegments() + dt/2; t += dt) - { - Evaluate (t, hp); - dist = Dist (hp, p); - if (t == 0 || dist < mindist) - { - optt = t; - mindist = dist; - } - } - - - tu = optt + dt; - tl = optt - dt; - while (tu - tl > 1e-2) - { - optt = 0.5 * (tu + tl); - Evaluate (optt, hp); - EvaluateTangent (optt, tanx); - if (tanx * (hp - p) > 0) - tu = optt; - else - tl = optt; - } - - optt = 0.5 * (tu + tl); - - optt = ProjectToSpline (p, optt); - return optt; -} - - -double spline3d :: ProjectToSpline (Point<3> & p, double optt) const -{ - double tl, tu, dt, val, dval, valu, vall; - Point<3> hp; - Vec<3> tanx, px; - int its = 0; - int cnt = 1000; - do - { - dt = 1e-8; - tl = optt - dt; - tu = optt + dt; - - EvaluateTangent (optt, tanx); - Evaluate (optt, hp); - px = hp - p; - val = px * tanx; - - EvaluateTangent (tl, tanx); - Evaluate (tl, hp); - px = hp - p; - vall = px * tanx; - - EvaluateTangent (tu, tanx); - Evaluate (tu, hp); - px = hp - p; - valu = px * tanx; - - dval = (valu - vall) / (2 * dt); - - if (its % 100 == 99) - (*testout) << "optt = " << optt - << " val = " << val - << " dval = " << dval << endl; - optt -= val / dval; - its++; - if (fabs(val) < 1e-8 && cnt > 5) cnt = 5; - cnt--; - } - while (cnt > 0); - - Evaluate (optt, p); - return optt; -} - - -splinetube :: splinetube (const spline3d & amiddlecurve, double ar) - : Surface(), middlecurve (amiddlecurve), r(ar) -{ - (*mycout) << "Splinetube Allocated, r = " << r << endl; - -} - -void splinetube :: DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2) -{ - double t; - double phi, z; - - p1 = ap1; - p2 = ap2; - cp = p1; - t = middlecurve.ProjectToSpline (cp); - ex = p1 - cp; - middlecurve.EvaluateTangent (t, ez); - ex.Normalize(); - ez.Normalize(); - ey = Cross (ez, ex); - - phi = r * atan2 (ey * (p2-cp), ex * (p2-cp)); - z = ez * (p2 - cp); - e2x(0) = phi; - e2x(1) = z; - e2x.Normalize(); - e2y(1) = e2x(0); - e2y(0) = -e2x(1); - - // (*testout) << "Defineplane: " << endl - // << "p1 = " << p1 << " p2 = " << p2 << endl - // << "pc = " << cp << endl - // << "ex = " << ex << " ey = " << ey << " ez = " << ez << endl - // << "phi = " << phi << " z = " << z << endl - // << "e2x = " << e2x << " e2y = " << e2y << endl; -} - -void splinetube :: ToPlane (const Point<3> & p3d, Point<2> & pplain, double h, - int & zone) const -{ - Vec<2> v; - v(0) = r * atan2 (ey * (p3d-cp), ex * (p3d-cp)); - v(1) = ez * (p3d - cp); - zone = 0; - if (v(0) > r * 2) zone = 1; - if (v(0) < r * 2) zone = 2; - - pplain(0) = (v * e2x) / h; - pplain(1) = (v * e2y) / h; -} - -void splinetube :: FromPlane (const Point<2> & pplain, Point<3> & p3d, double h) const -{ - Vec<2> v; - - v(0) = pplain(0) * h * e2x(0) + pplain(1) * h * e2y(0); - v(1) = pplain(0) * h * e2x(1) + pplain(1) * h * e2y(1); - - p3d = p1 + v(0) * ey + v(1) * ez; - - Project (p3d); -} - -void splinetube :: Project (Point<3> & p3d) const -{ - Point<3> hp; - - hp = p3d; - middlecurve.ProjectToSpline (hp); - - p3d = hp + (r / Dist(p3d, hp)) * (p3d - hp); -} - - - -double splinetube :: CalcFunctionValue (const Point<3> & point) const -{ - Point<3> hcp; - double rad; - - hcp = point; - middlecurve.ProjectToSpline (hcp); - rad = Dist (hcp, point); - return 0.5 * (rad * rad / r - r); -} - -void splinetube :: CalcGradient (const Point<3> & point, Vec<3> & grad) const -{ - Point<3> hcp; - - hcp = point; - middlecurve.ProjectToSpline (hcp); - - grad = point - hcp; - grad /= r; -} - - - - -Point<3> splinetube :: GetSurfacePoint () const -{ - Point<3> p; - Vec<3> t, n; - - middlecurve.Evaluate (0, p); - middlecurve.EvaluateTangent (0, t); - n = t.GetNormal (); - n *= r; - (*mycout) << "p = " << p << " t = " << t << " n = " << n << endl; - return p + n; -} - -void splinetube :: Print (ostream & str) const -{ - int i; - str << "SplineTube, " - << middlecurve.GetNumSegments () << " segments, r = " << r << endl; - for (i = 1; i <= middlecurve.GetNumSegments(); i++) - str << middlecurve.P1(i) << " - " - << middlecurve.P2(i) << " - " - << middlecurve.P3(i) << endl; -} - - -int splinetube :: BoxInSolid (const BoxSphere<3> & box) const - // 0 .. no, 1 .. yes, 2 .. maybe -{ - Point<3> pc = box.Center(); - middlecurve.ProjectToSpline (pc); - double d = Dist (pc, box.Center()); - - if (d < r - box.Diam()/2) return 1; - if (d > r + box.Diam()/2) return 0; - return 2; -} -} diff --git a/contrib/Netgen/libsrc/csg/spline3d.hpp b/contrib/Netgen/libsrc/csg/spline3d.hpp deleted file mode 100644 index 753788459f60b68381c2979f401b5a916a038a2f..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/spline3d.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/// -class splinesegment3d - { - /// - Point<3> p1, p2, p3; - - public: - /// - splinesegment3d (const Point<3> & ap1, const Point<3> & ap2, - const Point<3> & ap3); - /// - void Evaluate (double t, Point<3> & p) const; - /// - void EvaluateTangent (double t, Vec<3> & tang) const; - /// - const Point<3> & P1() const { return p1; } - /// - const Point<3> & P2() const { return p2; } - /// - const Point<3> & P3() const { return p3; } - }; - -/// -class spline3d - { - /// - ARRAY<splinesegment3d *> segments; - - public: - /// - spline3d () { }; - /// - void AddSegment (const Point<3> & ap1, const Point<3> & ap2, const Point<3> & ap3); - /// - int GetNumSegments () const { return segments.Size(); } - /// - double ProjectToSpline (Point<3> & p) const; - /// - double ProjectToSpline (Point<3> & p, double t) const; - /// - void Evaluate (double t, Point<3> & p) const; - /// - void EvaluateTangent (double t, Vec<3> & tang) const; - /// - const Point<3> & P1(int i) const { return segments.Get(i)->P1(); } - /// - const Point<3> & P2(int i) const { return segments.Get(i)->P2(); } - /// - const Point<3> & P3(int i) const { return segments.Get(i)->P3(); } - }; - -/// -class splinetube : public Surface - { - /// - const spline3d & middlecurve; - /// - double r; -/// Vec<3> ex, ey, ez; - Vec<2> e2x, e2y; - /// - Point<3> cp; - - public: - /// - splinetube (const spline3d & amiddlecurve, double ar); - - /// - virtual void DefineTangentialPlane (const Point<3> & ap1, const Point<3> & ap2); - /// - virtual void ToPlane (const Point<3> & p, Point<2> & pplain, double h, int & zone) const; - /// - virtual void FromPlane (const Point<2> & pplain, Point<3> & p, double h) const; - /// - virtual void Project (Point<3> & p) const; - -// virtual int RootInBox (const box3d & box) const { return 0; } - /// 0 .. no, 1 .. yes, 2 .. maybe - - virtual int BoxInSolid (const BoxSphere<3> & box) const; - /// 0 .. no, 1 .. yes, 2 .. maybe - - virtual double CalcFunctionValue (const Point<3> & point) const; - /// - virtual void CalcGradient (const Point<3> & point, Vec<3> & grad) const; - /// - virtual double HesseNorm () const { return 0.5 / r; } - /// - virtual Point<3> GetSurfacePoint () const; - /// - virtual void Print (ostream & str) const; - }; diff --git a/contrib/Netgen/libsrc/csg/surface.cpp b/contrib/Netgen/libsrc/csg/surface.cpp deleted file mode 100644 index 8b8d58127a04e47e843f629720eb64c459746116..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/surface.cpp +++ /dev/null @@ -1,392 +0,0 @@ -#include <mystdlib.h> - -#include <myadt.hpp> -#include <csg.hpp> - -#include <linalg.hpp> -#include <meshing.hpp> - - -namespace netgen -{ -Surface :: Surface () -{ - maxh = 1e10; - name = new char[7]; - strcpy (name, "noname"); - bcprop = -1; -} - -Surface :: ~Surface() -{ - delete [] name; -} - - -void Surface :: SetName (const char * aname) -{ - delete [] name; - name = new char[strlen (aname)+1]; - strcpy (name, aname); -} - - -int Surface :: PointOnSurface (const Point<3> & p, - double eps) const -{ - double val = CalcFunctionValue (p); - return fabs (val) < eps; -} - - -void Surface :: CalcHesse (const Point<3> & point, Mat<3> & hesse) const -{ - double dx = 1e-5; - Point<3> hp1, hp2; - Vec<3> g1, g2; - - for (int i = 0; i < 3; i++) - { - hp1 = point; - hp2 = point; - - hp1(i) += dx; - hp2(i) -= dx; - - CalcGradient (hp1, g1); - CalcGradient (hp2, g2); - - for (int j = 0; j < 3; j++) - hesse(i, j) = (g1(j) - g2(j)) / (2 * dx); - } -} - -/* -void Surface :: GetNormalVector (const Point<3> & p, Vec<3> & n) const -{ - CalcGradient (p, n); - n.Normalize(); -} -*/ -Vec<3> Surface :: GetNormalVector (const Point<3> & p) const -{ - Vec<3> n; - CalcGradient (p, n); - n.Normalize(); - return n; -} - -void Surface :: DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2) -{ - p1 = ap1; - p2 = ap2; - - ez = GetNormalVector (p1); - ex = p2 - p1; - ex -= (ex * ez) * ez; - ex.Normalize(); - ey = Cross (ez, ex); -} - -void Surface :: ToPlane (const Point<3> & p3d, Point<2> & pplane, - double h, int & zone) const -{ - Vec<3> p1p, n; - - n = GetNormalVector (p3d); - if (n * ez < 0) - { - zone = -1; - pplane(0) = 1e8; - pplane(1) = 1e9; - return; - } - - p1p = p3d - p1; - pplane(0) = (p1p * ex) / h; - pplane(1) = (p1p * ey) / h; - zone = 0; -} - -void Surface :: FromPlane (const Point<2> & pplane, - Point<3> & p3d, double h) const -{ - p3d = p1 - + (h * pplane(0)) * ex - + (h * pplane(1)) * ey; - - Project (p3d); -} - -void Surface :: Project (Point<3> & p) const -{ - Vec<3> n; - double val; - - for (int i = 1; i <= 10; i++) - { - val = CalcFunctionValue (p); - if (fabs (val) < 1e-12) return; - - CalcGradient (p, n); - p -= (val / Abs2 (n)) * n; - } -} - -double Surface :: MaxCurvature () const -{ - return 0.5 * HesseNorm (); -} - -double Surface :: -MaxCurvatureLoc (const Point<3> & /* c */ , double /* rad */) const -{ - return MaxCurvature (); -} - - - -double Surface :: LocH (const Point<3> & p, double x, - double c, double hmax) const - // finds h <= hmax, s.t. h * \kappa_x*h < c -{ - /* - double h, hmin, kappa; - hmin = 0; - - while (hmin < 0.9 * hmax) - { - h = 0.5 * (hmin + hmax); - kappa = 2 * MaxCurvatureLoc (p, x * h); - - if (kappa * h >= c) - hmax = h; - else - hmin = h; - } - return h; - */ - - double hret; - double kappa = MaxCurvatureLoc (p, x*hmax); - - kappa *= c * mparam.curvaturesafety; - - if (hmax * kappa < 1) - hret = hmax; - else - hret = 1 / kappa; - - if (maxh < hret) - hret = maxh; - - return hret; -} - - - - -Primitive :: Primitive () -{ - surfaceids.SetSize (1); - surfaceactive.SetSize (1); - surfaceactive[0] = 1; -} - -Primitive :: ~Primitive() -{ - ; -} - -int Primitive :: GetSurfaceId (int i) const -{ - return surfaceids[i]; -} - -void Primitive :: SetSurfaceId (int i, int id) -{ - surfaceids[i] = id; -} - - - - -void Primitive :: GetPrimitiveData (char *& classname, - ARRAY<double> & coeffs) const -{ - classname = "undef"; - coeffs.SetSize (0); -} - -void Primitive :: SetPrimitiveData (ARRAY<double> & coeffs) -{ - ; -} - -Primitive * Primitive :: CreatePrimitive (const char * classname) -{ - if (strcmp (classname, "sphere") == 0) - return Sphere::CreateDefault(); - if (strcmp (classname, "plane") == 0) - return Plane::CreateDefault(); - if (strcmp (classname, "cylinder") == 0) - return Cylinder::CreateDefault(); - if (strcmp (classname, "cone") == 0) - return Cone::CreateDefault(); - if (strcmp (classname, "brick") == 0) - return Brick::CreateDefault(); - - cout << "cannot create primitive " << classname << endl; - return NULL; -} - - -Primitive * Primitive :: Copy () const -{ - cout << "Primitive called for baseclass" << endl; - return NULL; -} - - -void Primitive :: Transform (Transformation<3> & trans) -{ - cout << "transform called for baseclass" << endl; -} - - -INSOLID_TYPE Primitive :: -VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const -{ - Point<3> hp = p + 1e-3 * v1 + 1e-5 * v2; - - INSOLID_TYPE res = PointInSolid (hp, eps); - // (*testout) << "vectorin2, type = " << typeid(*this).name() << ", res = " << res << endl; - - return res; -} - - - - - - -OneSurfacePrimitive :: OneSurfacePrimitive() -{ - ; -} - -OneSurfacePrimitive :: ~OneSurfacePrimitive() -{ - ; -} - - -INSOLID_TYPE OneSurfacePrimitive :: -PointInSolid (const Point<3> & p, - double eps) const -{ - double hv1 = (GetSurface(0).CalcFunctionValue(p)); - if (hv1 <= -eps) - return IS_INSIDE; - if (hv1 >= eps) - return IS_OUTSIDE; - return DOES_INTERSECT; -} - -INSOLID_TYPE OneSurfacePrimitive :: -VecInSolid (const Point<3> & p, const Vec<3> & v, - double eps) const -{ - Vec<3> hv; - double hv1; - GetSurface(0).CalcGradient (p, hv); - - hv1 = v * hv; - - if (hv1 <= -eps) - return IS_INSIDE; - if (hv1 >= eps) - return IS_OUTSIDE; - - return DOES_INTERSECT; -} - - -INSOLID_TYPE OneSurfacePrimitive :: -VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const -{ - Vec<3> hv; - double hv1, hv2; - - GetSurface(0).CalcGradient (p, hv); - - hv1 = v1 * hv; - if (hv1 <= -eps) - return IS_INSIDE; - if (hv1 >= eps) - return IS_OUTSIDE; - - hv2 = v2 * hv; - if (hv2 <= 0) - return IS_INSIDE; - else - return IS_OUTSIDE; -} - - - - -int OneSurfacePrimitive :: GetNSurfaces() const -{ - return 1; -} - -Surface & OneSurfacePrimitive :: GetSurface (int i) -{ - return *this; -} - -const Surface & OneSurfacePrimitive :: GetSurface (int i) const -{ - return *this; -} - - - - - - -void ProjectToEdge (const Surface * f1, const Surface * f2, Point<3> & hp) -{ - Vec<2> rs, lam; - Vec<3> a1, a2; - Mat<2> a; - - int i = 10; - while (i > 0) - { - i--; - rs(0) = f1 -> CalcFunctionValue (hp); - rs(1) = f2 -> CalcFunctionValue (hp); - f1->CalcGradient (hp, a1); - f2->CalcGradient (hp, a2); - - a(0,0) = a1 * a1; - a(0,1) = a(1,0) = a1 * a2; - a(1,1) = a2 * a2; - - a.Solve (rs, lam); - - hp -= lam(0) * a1 + lam(1) * a2; - - if (Abs2 (rs) < 1e-24 && i > 1) i = 1; - } -} -} diff --git a/contrib/Netgen/libsrc/csg/surface.hpp b/contrib/Netgen/libsrc/csg/surface.hpp deleted file mode 100644 index db0b4a74d24beb51dcafab58ce8394343d19353c..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/surface.hpp +++ /dev/null @@ -1,301 +0,0 @@ -#ifndef FILE_SURFACE -#define FILE_SURFACE - -/**************************************************************************/ -/* File: surface.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 1. Dez. 95 */ -/**************************************************************************/ - - - - -// 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; - /// - -public: - Surface (); - /** @name Tangential plane. - The tangential plane is used for surface mesh generation. - */ - - virtual ~Surface(); - -protected: - /** @name Points in the surface defining tangential plane. - Tangential plane is taken in p1, the local x-axis - is directed to p2. - */ - //@{ - /// - Point<3> p1; - /// - Point<3> p2; - //@} - /** @name Base-vectos for local coordinate system. */ - //@{ - /// in plane, directed p1->p2 - Vec<3> ex; - /// in plane - Vec<3> ey; - /// outer normal direction - Vec<3> ez; - //@} -public: - - void SetName (const char * aname); - const char * Name () const { return name; } - - //@{ - /** - Defines tangential plane in ap1. - The local x-coordinate axis point to the direction of ap2 */ - virtual void DefineTangentialPlane (const Point<3> & ap1, - const Point<3> & ap2); - - /// Transforms 3d point p3d to local coordinates pplane - virtual void ToPlane (const Point<3> & p3d, Point<2> & pplane, - double h, int & zone) const; - - /// Transforms point pplane in local coordinates to 3d point - virtual void FromPlane (const Point<2> & pplane, - Point<3> & p3d, double h) const; - //@} - - - /// Move Point p to closes point in surface - virtual void Project (Point<3> & p) const; - - - virtual 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 { }; - -#ifdef MYGRAPH - /// - virtual void Plot (const class ROT3D & /* rot */) const { }; -#endif - }; - - -typedef enum { IS_OUTSIDE = 0, IS_INSIDE = 1, DOES_INTERSECT = 2} -INSOLID_TYPE; - - - - -class Primitive -{ - -public: - - Primitive (); - - virtual ~Primitive(); - - - /* - Check, whether box intersects solid defined by surface. - - return values: - 0 .. box outside solid \\ - 1 .. box in solid \\ - 2 .. can't decide (allowed, iff box is close to solid) - */ - virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const = 0; - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, - double eps) const = 0; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const = 0; - - // 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 = 0; - virtual Surface & GetSurface (int i = 0) = 0; - virtual const Surface & GetSurface (int i = 0) const = 0; - - ARRAY<int> surfaceids; - ARRAY<int> surfaceactive; - - int GetSurfaceId (int i = 0) const; - void SetSurfaceId (int i, int id); - int SurfaceActive (int i) const { return surfaceactive[i]; } - virtual int SurfaceInverted (int i = 0) const { return 0; } - - virtual void GetPrimitiveData (char *& classname, - ARRAY<double> & coeffs) const; - virtual void SetPrimitiveData (ARRAY<double> & coeffs); - static Primitive * CreatePrimitive (const char * classname); - - - virtual void Reduce (const BoxSphere<3> & /* box */) { }; - virtual void UnReduce () { }; - - virtual Primitive * Copy () const; - virtual void Transform (Transformation<3> & trans); -}; - - - - -class OneSurfacePrimitive : public Surface, public Primitive -{ -public: - OneSurfacePrimitive(); - ~OneSurfacePrimitive(); - - virtual INSOLID_TYPE PointInSolid (const Point<3> & p, - double eps) const; - virtual INSOLID_TYPE VecInSolid (const Point<3> & p, - const Vec<3> & v, - double eps) const; - virtual INSOLID_TYPE VecInSolid2 (const Point<3> & p, - const Vec<3> & v1, - const Vec<3> & v2, - double eps) const; - - - virtual int GetNSurfaces() const; - virtual Surface & GetSurface (int i = 0); - virtual const Surface & GetSurface (int i = 0) const; -}; - - - - - - -/** - Projects point to edge. - The point hp is projected to the edge descibed by f1 and f2. - It is assumed that the edge is non-degenerated, and the - (generalized) Newton method converges. - */ -extern void ProjectToEdge (const Surface * f1, - const Surface * f2, - Point<3> & hp); - - - -#endif diff --git a/contrib/Netgen/libsrc/csg/triapprox.cpp b/contrib/Netgen/libsrc/csg/triapprox.cpp deleted file mode 100644 index 403716155b735fb4144cd4c4b9cfae67affa4e54..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/triapprox.cpp +++ /dev/null @@ -1,59 +0,0 @@ -#include <mystdlib.h> -#include <myadt.hpp> - -#include <linalg.hpp> -#include <csg.hpp> - - -namespace netgen -{ - - TriangleApproximation :: TriangleApproximation () - { - ; - } - - int TriangleApproximation :: - AddTriangle (const TATriangle & tri, bool invert) - { - trigs.Append (tri); - if (invert) - { - trigs.Last()[1] = tri[2]; - trigs.Last()[2] = tri[1]; - } - return trigs.Size()-1; - } - - - void TriangleApproximation :: RemoveUnusedPoints () - { - BitArray used(GetNP()); - ARRAY<int> map (GetNP()); - int i, j; - int cnt = 0; - - used.Clear(); - for (i = 0; i < GetNT(); i++) - for (j = 0; j < 3; j++) - used.Set (GetTriangle (i)[j]); - - for (i = 0; i < GetNP(); i++) - if (used.Test(i)) - map[i] = cnt++; - - for (i = 0; i < GetNT(); i++) - for (j = 0; j < 3; j++) - trigs[i][j] = map[trigs[i][j]]; - - for (i = 0; i < GetNP(); i++) - if (used.Test(i)) - { - points[map[i]] = points[i]; - normals[map[i]] = normals[i]; - } - - points.SetSize (cnt); - normals.SetSize (cnt); - } -} diff --git a/contrib/Netgen/libsrc/csg/triapprox.hpp b/contrib/Netgen/libsrc/csg/triapprox.hpp deleted file mode 100644 index 7b2db16b0951875704144fad2cdc1992ddaadb3f..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/csg/triapprox.hpp +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef FILE_TRIAPPROX -#define FILE_TRIAPPROX - -/**************************************************************************/ -/* File: triapprox.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 2. Mar. 98 */ -/**************************************************************************/ - -/** - Triangulated approxiamtion to true surface -*/ - - -class TATriangle -{ - int pi[3]; - int surfind; -public: - TATriangle () { ; } - - TATriangle (int si, int pi1, int pi2, int pi3) - { surfind = si; pi[0] = pi1; pi[1] = pi2; pi[2] = pi3; } - - int SurfaceIndex() const { return surfind; } - int & SurfaceIndex() { return surfind; } - - int & operator[] (int i) { return pi[i]; } - const int & operator[] (int i) const { return pi[i]; } -}; - - -class TriangleApproximation -{ - ARRAY<Point<3> > points; - ARRAY<Vec<3> > normals; - ARRAY<TATriangle> trigs; - -public: - TriangleApproximation(); - int GetNP () const { return points.Size(); } - int GetNT () const { return trigs.Size(); } - - int AddPoint (const Point<3> & p) { points.Append (p); return points.Size()-1; } - int AddNormal (const Vec<3> & n) { normals.Append (n); return normals.Size()-1; } - int AddTriangle (const TATriangle & tri, bool invert = 0); - - const Point<3> & GetPoint (int i) const { return points[i]; } - const TATriangle & GetTriangle (int i) const { return trigs[i]; } - const Vec<3> & GetNormal (int i) const { return normals[i]; } - - void RemoveUnusedPoints (); - - friend class CSGeometry; -}; - -#endif diff --git a/contrib/Netgen/libsrc/geom2d/Makefile b/contrib/Netgen/libsrc/geom2d/Makefile deleted file mode 100644 index 8371fa19e784b5353fda083881edad04e09549f5..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# -# Makefile for geometric library -# -src = spline2d.cpp geom2dmesh.cpp splinegeometry2.cpp genmesh2d.cpp -# -lib = geom2d -libpath = libsrc/geom2d -# -# -include ../makefile.inc -# - diff --git a/contrib/Netgen/libsrc/geom2d/genmesh2d.cpp b/contrib/Netgen/libsrc/geom2d/genmesh2d.cpp deleted file mode 100644 index 34f93b66eed51df1fb02323885dca83b73adadcb..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/genmesh2d.cpp +++ /dev/null @@ -1,145 +0,0 @@ -#include <mystdlib.h> -#include <csg.hpp> -#include <geometry2d.hpp> -#include "meshing.hpp" - -namespace netgen -{ - - // static ARRAY<Point<2> > points2; - // static ARRAY<int> lp1, lp2; - - - extern void Optimize2d (Mesh & mesh, MeshingParameters & mp); - - - - - void MeshFromSpline2D (SplineGeometry2d & geometry, - Mesh *& mesh, - MeshingParameters & mp) - { - int i, j, domnr; - double elto0, minx, miny, maxx, maxy; - - // mp.Print(*testout); - - PointIndex pi; - SegmentIndex si; - SurfaceElementIndex sei; - - double h = mp.maxh; - - Box<2> bbox; - geometry.GetBoundingBox (bbox); - - if (bbox.Diam() < h) - { - h = bbox.Diam(); - mp.maxh = h; - } - - mesh = new Mesh; - mesh->SetDimension (2); - PrintMessage (1, "Generate Mesh from spline geometry"); - - geometry.PartitionBoundary (h, *mesh); - - for (i = 0; i < geometry.GetNP(); i++) - if (geometry.GetPoint(i).hpref) - { - double mindist = 1e99; - PointIndex mpi; - Point<2> gp = geometry.GetPoint(i); - Point<3> gp3(gp(0), gp(1), 0); - for (PointIndex pi = PointIndex::BASE; - pi < mesh->GetNP()+PointIndex::BASE; pi++) - if (Dist2(gp3, (*mesh)[pi]) < mindist) - { - mpi = pi; - mindist = Dist2(gp3, (*mesh)[pi]); - } - (*mesh)[mpi].SetSingular(); - } - - - int maxdomnr = 0; - for (si = 0; si < mesh->GetNSeg(); si++) - { - if ( (*mesh)[si].domin > maxdomnr) maxdomnr = (*mesh)[si].domin; - if ( (*mesh)[si].domout > maxdomnr) maxdomnr = (*mesh)[si].domout; - } - - mesh->ClearFaceDescriptors(); - for (i = 1; i <= maxdomnr; i++) - mesh->AddFaceDescriptor (FaceDescriptor (i, 0, 0, i)); - - Point3d pmin(bbox.PMin()(0), bbox.PMin()(1), -bbox.Diam()); - Point3d pmax(bbox.PMax()(0), bbox.PMax()(1), bbox.Diam()); - - mesh->SetLocalH (pmin, pmax, mparam.grading); - mesh->SetGlobalH (h); - - mesh->CalcLocalH(); - - int bnp = mesh->GetNP(); // boundary points - - for (domnr = 1; domnr <= maxdomnr; domnr++) - { - PrintMessage (3, "Meshing domain ", domnr, " / ", maxdomnr); - - int oldnf = mesh->GetNSE(); - - Meshing2 meshing (Box3d (pmin, pmax)); - - for (pi = PointIndex::BASE; - pi < bnp+PointIndex::BASE; pi++) - meshing.AddPoint ( (*mesh)[pi], pi); - - - PointGeomInfo gi; - gi.trignum = 1; - for (si = 0; si < mesh->GetNSeg(); si++) - { - if ( (*mesh)[si].domin == domnr) - meshing.AddBoundaryElement ( (*mesh)[si].p1 + 1 - PointIndex::BASE, - (*mesh)[si].p2 + 1 - PointIndex::BASE, gi, gi); - if ( (*mesh)[si].domout == domnr) - meshing.AddBoundaryElement ( (*mesh)[si].p2 + 1 - PointIndex::BASE, - (*mesh)[si].p1 + 1 - PointIndex::BASE, gi, gi); - } - - - mparam.checkoverlap = 0; - meshing.GenerateMesh (*mesh, h, domnr); - - for (sei = oldnf; sei < mesh->GetNSE(); sei++) - (*mesh)[sei].SetIndex (domnr); - } - - - int hsteps = mp.optsteps2d; - - mp.optimize2d = "smcm"; - mp.optsteps2d = hsteps/2; - Optimize2d (*mesh, mp); - - mp.optimize2d = "Smcm"; - mp.optsteps2d = (hsteps+1)/2; - Optimize2d (*mesh, mp); - - mp.optsteps2d = hsteps; - - mesh->Compress(); - mesh -> SetNextMajorTimeStamp(); - - -#ifdef OPENGL - extern void Render(); - Render(); -#endif - - } - - -} diff --git a/contrib/Netgen/libsrc/geom2d/geom2dmesh.cpp b/contrib/Netgen/libsrc/geom2d/geom2dmesh.cpp deleted file mode 100644 index 1b679bd3c0dd4f6294a0fda83478ee8821374ce7..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/geom2dmesh.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include <mystdlib.h> - -#include <csg.hpp> -#include <geometry2d.hpp> -#include <meshing.hpp> - -namespace netgen -{ - - Refinement2d :: Refinement2d (const SplineGeometry2d & ageometry) - : Refinement(), geometry(ageometry) - { - ; - } - - Refinement2d :: ~Refinement2d () - { - ; - } - - - void Refinement2d :: - PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point3d & newp, PointGeomInfo & newgi) - { - newp = p1+secpoint*(p2-p1); - newgi.trignum = 1; - } - - - - void Refinement2d :: - PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point3d & newp, EdgePointGeomInfo & newgi) - { - Point<2> p2d; - - p2d = geometry.GetSplines().Get(ap1.edgenr) -> - GetPoint (((1-secpoint)*ap1.dist+secpoint*ap2.dist)); - - // (*testout) << "refine 2d line, ap1.dist, ap2.dist = " << ap1.dist << ", " << ap2.dist << endl; - // (*testout) << "p1, p2 = " << p1 << p2 << ", newp = " << p2d << endl; - - newp = Point3d (p2d(0), p2d(1), 0); - newgi.edgenr = ap1.edgenr; - newgi.dist = ((1-secpoint)*ap1.dist+secpoint*ap2.dist); - } - -} diff --git a/contrib/Netgen/libsrc/geom2d/geom2dmesh.hpp b/contrib/Netgen/libsrc/geom2d/geom2dmesh.hpp deleted file mode 100644 index 6912cd775280c69688d28b4017ba401b9686330b..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/geom2dmesh.hpp +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef FILE_GEOM2DMESH -#define FILE_GEOM2DMESH - -/**************************************************************************/ -/* File: geom2dmesh.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 22. Jan. 01 */ -/**************************************************************************/ - - -class Refinement2d : public Refinement -{ - const SplineGeometry2d & geometry; - -public: - Refinement2d (const SplineGeometry2d & ageometry); - virtual ~Refinement2d (); - - virtual void PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi, - const PointGeomInfo & gi1, - const PointGeomInfo & gi2, - Point3d & newp, PointGeomInfo & newgi); - - virtual void PointBetween (const Point3d & p1, const Point3d & p2, double secpoint, - int surfi1, int surfi2, - const EdgePointGeomInfo & ap1, - const EdgePointGeomInfo & ap2, - Point3d & newp, EdgePointGeomInfo & newgi); - -}; - - - - - - -#endif diff --git a/contrib/Netgen/libsrc/geom2d/geometry2d.hpp b/contrib/Netgen/libsrc/geom2d/geometry2d.hpp deleted file mode 100644 index 80d276e340a63aba1431ab1351d8affd20515fa8..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/geometry2d.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef FILE_GEOMETRY2D -#define FILE_GEOMETRY2D - -/* *************************************************************************/ -/* File: geometry2d.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 20. Jul. 02 */ -/* *************************************************************************/ - -#include <myadt.hpp> -#include <gprim.hpp> - -namespace netgen -{ -#include "spline2d.hpp" -#include "splinegeometry2.hpp" -#include "geom2dmesh.hpp" -} - -#endif diff --git a/contrib/Netgen/libsrc/geom2d/spline2d.cpp b/contrib/Netgen/libsrc/geom2d/spline2d.cpp deleted file mode 100644 index 8609e064d1781b219bdedd3efb541b12168bab8f..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/spline2d.cpp +++ /dev/null @@ -1,395 +0,0 @@ -/* - -2d Spline curve for Mesh generator - -*/ - -#include <mystdlib.h> -#include <csg.hpp> -#include <linalg.hpp> -#include <meshing.hpp> - -namespace netgen -{ -#include "spline2d.hpp" - - - void CalcPartition (double l, double h, double r1, double r2, - double ra, double elto0, ARRAY<double> & points); - - - - // calculates length of spline-curve - double SplineSegment :: Length () const - { - Point<2> p, pold; - - int i, n = 100; - double dt = 1.0 / n; - - pold = GetPoint (0); - - double l = 0; - for (i = 1; i <= n; i++) - { - p = GetPoint (i * dt); - l += Dist (p, pold); - pold = p; - } - return l; - } - - - - // partitionizes spline curve - void SplineSegment :: Partition (double h, double elto0, - Mesh & mesh, Point3dTree & searchtree, int segnr) const - { - int i, j; - double l, r1, r2, ra; - double lold, dt, frac; - int n = 100; - Point<2> p, pold, mark, oldmark; - ARRAY<double> curvepoints; - double edgelength, edgelengthold; - l = Length(); - - r1 = StartPI().refatpoint; - r2 = EndPI().refatpoint; - ra = reffak; - - // cout << "Partition, l = " << l << ", h = " << h << endl; - CalcPartition (l, h, r1, r2, ra, elto0, curvepoints); - // cout << "curvepoints = " << curvepoints << endl; - - dt = 1.0 / n; - - l = 0; - j = 1; - - pold = GetPoint (0); - lold = 0; - oldmark = pold; - edgelengthold = 0; - ARRAY<int> locsearch; - - for (i = 1; i <= n; i++) - { - p = GetPoint (i*dt); - l = lold + Dist (p, pold); - while (j < curvepoints.Size() && (l >= curvepoints[j] || i == n)) - { - frac = (curvepoints[j]-lold) / (l-lold); - mark = pold + frac * (p-pold); - edgelength = i*dt + (frac-1)*dt; - { - PointIndex pi1 = -1, pi2 = -1; - - Point3d mark3(mark(0), mark(1), 0); - Point3d oldmark3(oldmark(0), oldmark(1), 0); - - Vec<3> v (1e-4*h, 1e-4*h, 1e-4*h); - searchtree.GetIntersecting (oldmark3 - v, oldmark3 + v, locsearch); - if (locsearch.Size()) pi1 = locsearch[0]; - - searchtree.GetIntersecting (mark3 - v, mark3 + v, locsearch); - if (locsearch.Size()) pi2 = locsearch[0]; - /* - for (PointIndex pk = PointIndex::BASE; - pk < mesh.GetNP()+PointIndex::BASE; pk++) - { - if (Dist (mesh[pk], oldmark3) < 1e-4 * h) pi1 = pk; - if (Dist (mesh[pk], mark3) < 1e-4 * h) pi2 = pk; - } - */ - - - // cout << "pi1 = " << pi1 << endl; - // cout << "pi2 = " << pi2 << endl; - - if (pi1 == -1) - { - pi1 = mesh.AddPoint(oldmark3); - searchtree.Insert (oldmark3, pi1); - } - if (pi2 == -1) - { - pi2 = mesh.AddPoint(mark3); - searchtree.Insert (mark3, pi2); - } - - // cout << "pi1 = " << pi1 << endl; - // cout << "pi2 = " << pi2 << endl; - - Segment seg; - seg.edgenr = segnr; - seg.si = bc; // segnr; - seg.p1 = pi1; - seg.p2 = pi2; - seg.domin = leftdom; - seg.domout = rightdom; - seg.epgeominfo[0].edgenr = segnr; - seg.epgeominfo[0].dist = edgelengthold; - seg.epgeominfo[1].edgenr = segnr; - seg.epgeominfo[1].dist = edgelength; - seg.singedge_left = hpref_left; - seg.singedge_right = hpref_right; - mesh.AddSegment (seg); - } - - oldmark = mark; - edgelengthold = edgelength; - j++; - } - - pold = p; - lold = l; - } - } - - - void SplineSegment :: GetPoints (int n, ARRAY<Point<2> > & points) - { - points.SetSize (n); - if (n >= 2) - for (int i = 0; i < n; i++) - points[i] = GetPoint(double(i) / (n-1)); - } - - - - /* - Implementation of line-segment from p1 to p2 - */ - - - LineSegment :: LineSegment (const GeomPoint2d & ap1, - const GeomPoint2d & ap2) - : p1(ap1), p2(ap2) - { - ; - } - - - Point<2> LineSegment :: GetPoint (double t) const - { - return p1 + t * (p2 - p1); - } - - double LineSegment :: Length () const - { - return Dist (p1, p2); - } - - - void LineSegment :: PrintCoeff (ostream & ost) const - { - double dx = p2(0) - p1(0); - double dy = p2(1) - p1(1); - ost << "0 0 0 " << dy << " " << -dx << " " - << dx * p1(1) - dy * p1(0) << endl; - } - - - - - - SplineSegment3 :: SplineSegment3 (const GeomPoint2d & ap1, - const GeomPoint2d & ap2, - const GeomPoint2d & ap3) - : p1(ap1), p2(ap2), p3(ap3) - { - ; - } - - Point<2> SplineSegment3 :: GetPoint (double t) const - { - double x, y, w; - double b1, b2, b3; - - b1 = (1-t)*(1-t); - b2 = sqrt(2.0) * t * (1-t); - b3 = t * t; - - x = p1(0) * b1 + p2(0) * b2 + p3(0) * b3; - y = p1(1) * b1 + p2(1) * b2 + p3(1) * b3; - w = b1 + b2 + b3; - - return Point<2> (x/w, y/w); - } - - - void SplineSegment3 :: PrintCoeff (ostream & ost) const - { - double t; - int i; - Point<2> p; - DenseMatrix a(6, 6); - DenseMatrix ata(6, 6); - Vector u(6), f(6); - - // ata.SetSymmetric(1); - - t = 0; - for (i = 1; i <= 5; i++, t += 0.25) - { - p = GetPoint (t); - a.Elem(i, 1) = p(0) * p(0); - a.Elem(i, 2) = p(1) * p(1); - a.Elem(i, 3) = p(0) * p(1); - a.Elem(i, 4) = p(0); - a.Elem(i, 5) = p(1); - a.Elem(i, 6) = 1; - } - a.Elem(6, 1) = 1; - - CalcAtA (a, ata); - - u = 0; - u.Elem(6) = 1; - a.MultTrans (u, f); - ata.Solve (f, u); - - for (i = 1; i <= 6; i++) - ost << u.Get(i) << " "; - ost << endl; - } - - - - - //######################################################################## - // circlesegment - - CircleSegment :: CircleSegment (const GeomPoint2d & ap1, - const GeomPoint2d & ap2, - const GeomPoint2d & ap3) - : p1(ap1), p2(ap2), p3(ap3) - { - Vec<2> v1,v2; - - v1 = p1 - p2; - v2 = p3 - p2; - - Point<2> p1t(p1(0)+v1[1], p1(1)-v1[0]); - Point<2> p2t(p3(0)+v2[1], p3(1)-v2[0]); - Line2d g1t(p1, p1t), g2t(p3, p2t); - - pm = CrossPoint (g1t,g2t); - radius = Dist(pm,StartPI()); - w1 = Angle(Vec2d (p1 - pm)); - w3 = Angle(Vec2d (p3 - pm)); - if ( fabs(w3-w1) > M_PI ) - { - if ( w3>M_PI ) w3 -= 2*M_PI; - if ( w1>M_PI ) w1 -= 2*M_PI; - } - } - - Point<2> CircleSegment :: GetPoint (double t) const - { - if (t >= 1.0) { return p3; } - - double phi = StartAngle() + t*(EndAngle()-StartAngle()); - Vec2d tmp(cos(phi),sin(phi)); - - return pm + Radius()*tmp; - } - - void CircleSegment :: PrintCoeff (ostream & ost) const - { - double a,b,c,d,e,f; - - a = b = 1.0; - c = 0.0; - d = -2.0 * pm[0]; - e = -2.0 * pm[1]; - f = sqr(pm[0]) + sqr(pm[1]) - sqr(Radius()); - - ost << a << " " << b << " " << c << " " << d << " " << e << " " << f ; - ost << endl; - } - - - - DiscretePointsSegment :: DiscretePointsSegment (const ARRAY<Point<2> > & apts) - : pts (apts), - p1 (apts[0](0), apts[0](1), 1), - p2 (apts.Last()(0), apts.Last()(1), 1) - - { ; } - - - DiscretePointsSegment :: ~DiscretePointsSegment () - { ; } - - Point<2> DiscretePointsSegment :: GetPoint (double t) const - { - double t1 = t * (pts.Size()-1); - int segnr = int(t1); - if (segnr < 0) segnr = 0; - if (segnr >= pts.Size()) segnr = pts.Size()-1; - - double rest = t1 - segnr; - - return Point<2> ((1-rest)*pts[segnr](0) + rest*pts[segnr+1](0), - (1-rest)*pts[segnr](1) + rest*pts[segnr+1](1)); - } - - - - - - - //######################################################################## - - - - - void CalcPartition (double l, double h, double r1, double r2, - double ra, double elto0, ARRAY<double> & points) - { - int i, j, n, nel; - double sum, t, dt, fun, fperel, oldf, f; - - n = 1000; - - points.SetSize (0); - - sum = 0; - dt = l / n; - t = 0.5 * dt; - for (i = 1; i <= n; i++) - { - fun = min3 (h/ra, t/elto0 + h/r1, (l-t)/elto0 + h/r2); - sum += dt / fun; - t += dt; - } - - nel = int (sum+1); - fperel = sum / nel; - - points.Append (0); - - i = 1; - oldf = 0; - t = 0.5 * dt; - for (j = 1; j <= n && i < nel; j++) - { - fun = min3 (h/ra, t/elto0 + h/r1, (l-t)/elto0 + h/r2); - - f = oldf + dt / fun; - - while (f > i * fperel && i < nel) - { - points.Append ( (l/n) * (j-1 + (i * fperel - oldf) / (f - oldf)) ); - i++; - } - oldf = f; - t += dt; - } - points.Append (l); - } - - -} diff --git a/contrib/Netgen/libsrc/geom2d/spline2d.hpp b/contrib/Netgen/libsrc/geom2d/spline2d.hpp deleted file mode 100644 index f107a137f102cc9ef40c5646c50ebedcae3ffbb4..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/spline2d.hpp +++ /dev/null @@ -1,204 +0,0 @@ -#ifndef FILE_SPLINE2D -#define FILE_SPLINE2D - -/**************************************************************************/ -/* File: spline2d.hh */ -/* Author: Joachim Schoeberl */ -/* Date: 24. Jul. 96 */ -/**************************************************************************/ - - -/* - Spline curves for 2D mesh generation - */ - - -/// Geometry point -class GeomPoint2d : public Point<2> -{ -public: - /// refinement to point - double refatpoint; - bool hpref; - - GeomPoint2d () - { ; } - - /// - GeomPoint2d (double ax, double ay, double aref = 1) - : Point<2> (ax, ay), refatpoint(aref) { ; } -}; - - - -/// base class for 2d - segment -class SplineSegment -{ -public: - /// left domain - int leftdom; - /// right domain - int rightdom; - /// refinement at line - double reffak; - /// boundary condition number - int bc; - /// copy spline mesh from other spline (-1.. do not copy) - int copyfrom; - /// perfrom anisotropic refinement (hp-refinement) to edge - bool hpref_left; - bool hpref_right; - /// calculates length of curve - virtual double Length () const; - /// returns point at curve, 0 <= t <= 1 - virtual Point<2> GetPoint (double t) const = 0; - /// partitionizes curve - void Partition (double h, double elto0, - Mesh & mesh, Point3dTree & searchtree, int segnr) const; - /// returns initial point on curve - virtual const GeomPoint2d & StartPI () const = 0; - /// returns terminal point on curve - virtual const GeomPoint2d & EndPI () const = 0; - /** writes curve description for fepp: - for implicitly given quadratic curves, the 6 coefficients of - the polynomial - $$ a x^2 + b y^2 + c x y + d x + e y + f = 0 $$ - are written to ost */ - virtual void PrintCoeff (ostream & ost) const = 0; - - virtual void GetPoints (int n, ARRAY<Point<2> > & points); - - virtual string GetType(void) const {return "splinebase";} -}; - - -/// Straight line form p1 to p2 -class LineSegment : public SplineSegment -{ - /// - const GeomPoint2d &p1, &p2; -public: - /// - LineSegment (const GeomPoint2d & ap1, const GeomPoint2d & ap2); - /// - virtual double Length () const; - /// - virtual Point<2> GetPoint (double t) const; - /// - virtual const GeomPoint2d & StartPI () const { return p1; }; - /// - virtual const GeomPoint2d & EndPI () const { return p2; } - /// - virtual void PrintCoeff (ostream & ost) const; - - virtual string GetType(void) const {return "line";} -}; - - -/// curve given by a rational, quadratic spline (including ellipses) -class SplineSegment3 : public SplineSegment -{ - /// - const GeomPoint2d &p1, &p2, &p3; -public: - /// - SplineSegment3 (const GeomPoint2d & ap1, - const GeomPoint2d & ap2, - const GeomPoint2d & ap3); - /// - virtual Point<2> GetPoint (double t) const; - /// - virtual const GeomPoint2d & StartPI () const { return p1; }; - /// - virtual const GeomPoint2d & EndPI () const { return p3; } - /// - virtual void PrintCoeff (ostream & ost) const; - - virtual string GetType(void) const {return "spline3";} -}; - - -// Gundolf Haase 8/26/97 -/// A circle -class CircleSegment : public SplineSegment -{ - /// -private: - const GeomPoint2d &p1, &p2, &p3; - Point<2> pm; - double radius, w1,w3; -public: - /// - CircleSegment (const GeomPoint2d & ap1, - const GeomPoint2d & ap2, - const GeomPoint2d & ap3); - /// - virtual Point<2> GetPoint (double t) const; - /// - virtual const GeomPoint2d & StartPI () const { return p1; }; - /// - virtual const GeomPoint2d & EndPI () const { return p3; } - /// - virtual void PrintCoeff (ostream & ost) const; - /// - double Radius() const { return radius; } - /// - double StartAngle() const { return w1; } - /// - double EndAngle() const { return w3; } - - virtual string GetType(void) const {return "circle";} -}; - - -// Gundolf Haase 8/26/97 -/// elliptic curve with one axe parallel to line {P1,P2} -/* -class ellipsegment3 : public SplineSegment -{ - /// - GeomPoint2d *p1, *p2, *p3; -public: - /// - SplineSegment3 (GeomPoint2d * ap1, GeomPoint2d * ap2, GeomPoint2d * ap3); - /// - virtual Point<2> GetPoint (double t) const; - /// - virtual GeomPoint2d * StartPI () const { return p1; }; - /// - virtual GeomPoint2d * EndPI () const { return p3; } - /// - virtual void PrintCoeff (ostream & ost) const; -}; -*/ - - - - - - -/// -class DiscretePointsSegment : public SplineSegment -{ - ARRAY<Point<2> > pts; - GeomPoint2d p1, p2; -public: - /// - DiscretePointsSegment (const ARRAY<Point<2> > & apts); - /// - virtual ~DiscretePointsSegment (); - /// - virtual Point<2> GetPoint (double t) const; - /// - virtual const GeomPoint2d & StartPI () const { return p1; }; - /// - virtual const GeomPoint2d & EndPI () const { return p2; } - /// - virtual void PrintCoeff (ostream & /* ost */) const { ; } -}; - - - - - -#endif diff --git a/contrib/Netgen/libsrc/geom2d/splinegeometry2.cpp b/contrib/Netgen/libsrc/geom2d/splinegeometry2.cpp deleted file mode 100644 index a034d5398978900a65116c47c9cd07862dfaecf8..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/splinegeometry2.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - -2d Spline curve for Mesh generator - -*/ - -#include <mystdlib.h> -#include <csg.hpp> -#include <linalg.hpp> -#include <meshing.hpp> - - -namespace netgen - -{ - -#include "spline2d.hpp" -#include "splinegeometry2.hpp" - - - -SplineGeometry2d :: ~SplineGeometry2d() -{ - for(int i=0; i<splines.Size(); i++) - { - delete splines[i]; - } - splines.DeleteAll(); - geompoints.DeleteAll(); -} - -void SplineGeometry2d :: Load (const char * filename) -{ - ifstream infile; - int nump, numseg, leftdom, rightdom; - double x, y; - int hi1, hi2, hi3; - double hd; - char buf[50], ch; - - infile.open (filename); - - if (! infile.good() ) - throw NgException(string ("2D Input file '") + - string (filename) + - string ("' not available!")); - - infile >> buf; // file recognition - infile >> elto0; - - infile >> nump; - for (int i = 0; i < nump; i++) - { - infile >> x >> y >> hd; - - Flags flags; - - ch = 'a'; - // infile >> ch; - do { - infile.get (ch); - } while (isspace(ch) && ch != '\n'); - while (ch == '-') - { - char flag[100]; - flag[0]='-'; - infile >> (flag+1); - flags.SetCommandLineFlag (flag); - ch = 'a'; - do { - infile.get (ch); - } while (isspace(ch) && ch != '\n'); - } - - if (infile.good()) - infile.putback (ch); - - geompoints.Append (GeomPoint2d(x, y, hd)); - geompoints.Last().hpref = flags.GetDefineFlag ("hpref"); - } - - infile >> numseg; - SplineSegment * spline = 0; - for (int i = 0; i < numseg; i++) - { - infile >> leftdom >> rightdom; - - // cout << "add spline " << i << ", left = " << leftdom << endl; - - infile >> buf; - // type of spline segement - if (strcmp (buf, "2") == 0) - { // a line - infile >> hi1 >> hi2; - spline = new LineSegment(geompoints[hi1-1], - geompoints[hi2-1]); - } - else if (strcmp (buf, "3") == 0) - { // a rational spline - infile >> hi1 >> hi2 >> hi3; - spline = new SplineSegment3 (geompoints[hi1-1], - geompoints[hi2-1], - geompoints[hi3-1]); - } - else if (strcmp (buf, "4") == 0) - { // an arc - infile >> hi1 >> hi2 >> hi3; - spline = new CircleSegment (geompoints[hi1-1], - geompoints[hi2-1], - geompoints[hi3-1]); - break; - } - else if (strcmp (buf, "discretepoints") == 0) - { - int npts; - infile >> npts; - ARRAY<Point<2> > pts(npts); - for (int j = 0; j < npts; j++) - infile >> pts[j](0) >> pts[j](1); - - spline = new DiscretePointsSegment (pts); - cout << "pts = " << pts << endl; - } - - infile >> spline->reffak; - spline -> leftdom = leftdom; - spline -> rightdom = rightdom; - splines.Append (spline); - - - Flags flags; - ch = 'a'; - infile >> ch; - while (ch == '-') - { - char flag[100]; - flag[0]='-'; - infile >> (flag+1); - flags.SetCommandLineFlag (flag); - ch = 'a'; - infile >> ch; - } - - if (infile.good()) - infile.putback (ch); - - splines.Last()->bc = int (flags.GetNumFlag ("bc", i+1)); - splines.Last()->hpref_left = int (flags.GetDefineFlag ("hpref")) || - int (flags.GetDefineFlag ("hprefleft")); - splines.Last()->hpref_right = int (flags.GetDefineFlag ("hpref")) || - int (flags.GetDefineFlag ("hprefright")); - splines.Last()->copyfrom = int (flags.GetNumFlag ("copy", -1)); - } - - - infile.close(); -} - - - -void SplineGeometry2d :: -PartitionBoundary (double h, Mesh & mesh2d) -{ - Box<2> bbox; - GetBoundingBox (bbox); - double dist = Dist (bbox.PMin(), bbox.PMax()); - Point<3> pmin(bbox.PMin()(0), bbox.PMin()(1), -dist); - Point<3> pmax(bbox.PMax()(0), bbox.PMax()(1), dist); - - cout << "searchtree from " << pmin << " to " << pmax << endl; - Point3dTree searchtree (pmin, pmax); - - for (int i = 0; i < splines.Size(); i++) - if (splines[i]->copyfrom == -1) - splines[i]->Partition(h, elto0, mesh2d, searchtree, i+1); - else - CopyEdgeMesh (splines[i]->copyfrom, i+1, mesh2d, searchtree); -} - - -void SplineGeometry2d :: CopyEdgeMesh (int from, int to, Mesh & mesh, Point3dTree & searchtree) -{ - int i, j, k; - - ARRAY<int, PointIndex::BASE> mappoints (mesh.GetNP()); - ARRAY<double, PointIndex::BASE> param (mesh.GetNP()); - mappoints = -1; - param = 0; - - Point3d pmin, pmax; - mesh.GetBox (pmin, pmax); - double diam2 = Dist2(pmin, pmax); - - cout << "copy edge, from = " << from << " to " << to << endl; - - for (i = 1; i <= mesh.GetNSeg(); i++) - { - const Segment & seg = mesh.LineSegment(i); - if (seg.edgenr == from) - { - mappoints.Elem(seg.p1) = 1; - param.Elem(seg.p1) = seg.epgeominfo[0].dist; - - mappoints.Elem(seg.p2) = 1; - param.Elem(seg.p2) = seg.epgeominfo[1].dist; - } - } - - for (i = 1; i <= mappoints.Size(); i++) - { - if (mappoints.Get(i) != -1) - { - Point<2> newp = splines.Get(to)->GetPoint (param.Get(i)); - Point<3> newp3 (newp(0), newp(1), 0); - - int npi = -1; - - for (PointIndex pi = PointIndex::BASE; - pi < mesh.GetNP()+PointIndex::BASE; pi++) - if (Dist2 (mesh.Point(pi), newp3) < 1e-12 * diam2) - npi = pi; - - if (npi == -1) - { - npi = mesh.AddPoint (newp3); - searchtree.Insert (newp3, npi); - } - - mappoints.Elem(i) = npi; - - mesh.GetIdentifications().Add (i, npi, to); - } - } - - // copy segments - int oldnseg = mesh.GetNSeg(); - for (i = 1; i <= oldnseg; i++) - { - const Segment & seg = mesh.LineSegment(i); - if (seg.edgenr == from) - { - Segment nseg; - nseg.edgenr = to; - nseg.si = splines.Get(to)->bc; - nseg.p1 = mappoints.Get(seg.p1); - nseg.p2 = mappoints.Get(seg.p2); - nseg.domin = splines.Get(to)->leftdom; - nseg.domout = splines.Get(to)->rightdom; - - nseg.epgeominfo[0].edgenr = to; - nseg.epgeominfo[0].dist = param.Get(seg.p1); - nseg.epgeominfo[1].edgenr = to; - nseg.epgeominfo[1].dist = param.Get(seg.p2); - mesh.AddSegment (nseg); - } - } -} - - -void SplineGeometry2d :: -GetBoundingBox (Box<2> & box) const -{ - if (!splines.Size()) - { - box.Set (Point<2> (0,0)); - return; - } - - ARRAY<Point<2> > points; - for (int i = 0; i < splines.Size(); i++) - { - splines[i]->GetPoints (20, points); - - if (i == 0) box.Set(points[0]); - for (int j = 0; j < points.Size(); j++) - box.Add (points[j]); - } -} - -void SplineGeometry2d :: -SetGrading (const double grading) -{ elto0 = grading;} - -void SplineGeometry2d :: -AppendPoint (const double x, const double y, const double reffac, const bool hpref) -{ - geompoints.Append (GeomPoint2d(x, y, reffac)); - geompoints.Last().hpref = hpref; -} - - -void SplineGeometry2d :: -AppendSegment(SplineSegment * spline, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom) -{ - spline -> leftdom = leftdomain; - spline -> rightdom = rightdomain; - spline -> bc = (bc >= 0) ? bc : (splines.Size()+1); - spline -> reffak = reffac; - spline -> hpref_left = hprefleft; - spline -> hpref_right = hprefright; - spline -> copyfrom = copyfrom; - - splines.Append(spline); -} - -void SplineGeometry2d :: -AppendLineSegment (const int n1, const int n2, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom) -{ - SplineSegment * spline = new LineSegment(geompoints[n1],geompoints[n2]); - AppendSegment(spline,leftdomain,rightdomain,bc,reffac,hprefleft,hprefright,copyfrom); -} -void SplineGeometry2d :: -AppendSplineSegment (const int n1, const int n2, const int n3, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom) -{ - SplineSegment * spline = new SplineSegment3(geompoints[n1],geompoints[n2],geompoints[n3]); - AppendSegment(spline,leftdomain,rightdomain,bc,reffac,hprefleft,hprefright,copyfrom); -} -void SplineGeometry2d :: -AppendCircleSegment (const int n1, const int n2, const int n3, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom) -{ - SplineSegment * spline = new CircleSegment(geompoints[n1],geompoints[n2],geompoints[n3]); - AppendSegment(spline,leftdomain,rightdomain,bc,reffac,hprefleft,hprefright,copyfrom); -} -void SplineGeometry2d :: -AppendDiscretePointsSegment (const ARRAY< Point<2> > & points, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom) -{ - SplineSegment * spline = new DiscretePointsSegment(points); - AppendSegment(spline,leftdomain,rightdomain,bc,reffac,hprefleft,hprefright,copyfrom); -} - -} diff --git a/contrib/Netgen/libsrc/geom2d/splinegeometry2.hpp b/contrib/Netgen/libsrc/geom2d/splinegeometry2.hpp deleted file mode 100644 index 66c2a4d79f576c71ad21ec5ec7f518d1af7b5f49..0000000000000000000000000000000000000000 --- a/contrib/Netgen/libsrc/geom2d/splinegeometry2.hpp +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef FILE_SPLINEGEOMETRY2 -#define FILE_SPLINEGEOMETRY2 - -/**************************************************************************/ -/* File: splinegeometry2.hpp */ -/* Author: Joachim Schoeberl */ -/* Date: 24. Jul. 96 */ -/**************************************************************************/ - - - -/// -extern void LoadBoundarySplines (const char * filename, - ARRAY<GeomPoint2d> & geompoints, - ARRAY<SplineSegment*> & splines, - double & elto0); -/// -extern void PartitionBoundary (const ARRAY<SplineSegment*> & splines, - double h, double elto0, - Mesh & mesh2d); - -class SplineGeometry2d -{ - ARRAY<GeomPoint2d> geompoints; - ARRAY<SplineSegment*> splines; - double elto0; - - -private: - void AppendSegment(SplineSegment * spline, const int leftdomain, const int rightdomain, - const int bc, - const double reffac, const bool hprefleft, const bool hprefright, - const int copyfrom); - -public: - ~SplineGeometry2d(); - - void Load (const char * filename); - void PartitionBoundary (double h, Mesh & mesh2d); - - void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); - - const ARRAY<SplineSegment*> & GetSplines () const - { return splines; } - - void GetBoundingBox (Box<2> & box) const; - - int GetNP () const { return geompoints.Size(); } - const GeomPoint2d & 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 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 double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - void AppendCircleSegment (const int n1, const int n2, const int n3, - const int leftdomain, const int rightdomain, const int bc = -1, - const double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - void AppendDiscretePointsSegment (const ARRAY< Point<2> > & points, - const int leftdomain, const int rightdomain, const int bc = -1, - const double reffac = 1., - const bool hprefleft = false, const bool hprefright = false, - const int copyfrom = -1); - -}; - - -void MeshFromSpline2D (SplineGeometry2d & geometry, - Mesh *& mesh, - MeshingParameters & mp); - - -#endif