diff --git a/libsrc/csg/algprim.cpp b/libsrc/csg/algprim.cpp index f101638a..1dde9179 100644 --- a/libsrc/csg/algprim.cpp +++ b/libsrc/csg/algprim.cpp @@ -79,8 +79,12 @@ namespace netgen p = ap; n = an; - n.Normalize(); + CalcData(); + } + void Plane :: CalcData() + { + 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)); @@ -100,9 +104,7 @@ namespace netgen 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)); + CalcData(); } @@ -129,11 +131,7 @@ namespace netgen 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)); + CalcData(); } Primitive * Plane :: CreateDefault () @@ -158,27 +156,21 @@ namespace netgen } else { - //(*testout) << "pos1" << endl; if (fabs (s2.CalcFunctionValue(p)) > eps) return 0; Vec<3> hv1, hv2; hv1 = n.GetNormal (); hv2 = Cross (n, hv1); Point<3> hp = p + hv1; - //(*testout) << "pos2" << endl; - //(*testout) << "eps " << eps << " s2.CalcFunctionValue(hp) " << s2.CalcFunctionValue(hp) << endl; if (fabs (s2.CalcFunctionValue(hp)) > eps) return 0; - //(*testout) << "pos3" << endl; hp = p + hv2; if (fabs (s2.CalcFunctionValue(hp)) > eps) return 0; } - //(*testout) << "pos4" << endl; Vec<3> n1, n2; n1 = GetNormalVector (p); n2 = s2.GetNormalVector (p); inv = (n1 * n2 < 0); - //(*testout) << "inv " << inv << endl; return 1; } @@ -205,14 +197,6 @@ namespace netgen 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; } @@ -1124,9 +1108,46 @@ namespace netgen } CalcData(); - // Print (cout); } + EllipticCylinder :: EllipticCylinder (Array & coeffs) + { + SetPrimitiveData(coeffs); + } + + + + void EllipticCylinder :: GetPrimitiveData (const char *& classname, Array & coeffs) const + { + classname = "ellipticcylinder"; + coeffs.SetSize (9); + coeffs[0] = a(0); + coeffs[1] = a(1); + coeffs[2] = a(2); + coeffs[3] = vl(0); + coeffs[4] = vl(1); + coeffs[5] = vl(2); + coeffs[6] = vs(0); + coeffs[7] = vs(1); + coeffs[8] = vs(2); + } + + void EllipticCylinder :: SetPrimitiveData (Array & coeffs) + { + a(0) = coeffs[0]; + a(1) = coeffs[1]; + a(2) = coeffs[2]; + vl(0) = coeffs[3]; + vl(1) = coeffs[4]; + vl(2) = coeffs[5]; + vs(0) = coeffs[6]; + vs(1) = coeffs[7]; + vs(2) = coeffs[8]; + + CalcData(); + } + + void EllipticCylinder :: CalcData () { diff --git a/libsrc/csg/algprim.hpp b/libsrc/csg/algprim.hpp index 9a6e66fa..e178a881 100644 --- a/libsrc/csg/algprim.hpp +++ b/libsrc/csg/algprim.hpp @@ -109,7 +109,8 @@ namespace netgen virtual void GetTriangleApproximation (TriangleApproximation & tas, const Box<3> & boundingbox, double facets) const; - + protected: + void CalcData(); }; // typedef Plane Plane; @@ -238,12 +239,13 @@ namespace netgen /// EllipticCylinder (const Point<3> & aa, const Vec<3> & avl, const Vec<3> & avs); + EllipticCylinder (Array & coeffs); + + + // static Primitive * CreateDefault (); + virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; + virtual void SetPrimitiveData (Array & coeffs); - /* - static Primitive * CreateDefault (); - virtual void GetPrimitiveData (const char *& classname, Array & coeffs) const; - virtual void SetPrimitiveData (Array & coeffs); - */ /// virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const; /// diff --git a/libsrc/csg/csgeom.cpp b/libsrc/csg/csgeom.cpp index 4602d4a0..13ca939b 100644 --- a/libsrc/csg/csgeom.cpp +++ b/libsrc/csg/csgeom.cpp @@ -434,6 +434,16 @@ namespace netgen delete_them.Append(cylinder); } + else if(classname == "ellipticcylinder") + { + EllipticCylinder * cylinder = new EllipticCylinder(coeffs); + AddSurface(cylinder); + delete_them.Append(cylinder); + } + + + + else if(classname == "cone") { Cone * cone = new Cone(dummypoint,dummypoint,dummydouble,dummydouble);