netgen/libsrc/csg/revolution.hpp

154 lines
3.6 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef _REVOLUTION_HPP
#define _REVOLUTION_HPP
2009-09-07 17:50:13 +06:00
namespace netgen
2009-01-13 04:40:13 +05:00
{
2009-09-07 17:50:13 +06:00
class Revolution;
class RevolutionFace : public Surface
{
private:
bool isfirst, islast;
const SplineSeg<2> * spline;
bool deletable;
Point<3> p0;
Vec<3> v_axis;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
int id;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
mutable Vector spline_coefficient;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
Array < Vec<2>* > checklines_vec;
Array < Point<2>* > checklines_start;
Array < Vec<2>* > checklines_normal;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
private:
void Init (void);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
public:
void CalcProj(const Point<3> & point3d, Point<2> & point2d) const;
void CalcProj(const Point<3> & point3d, Point<2> & point2d,
const Vec<3> & vector3d, Vec<2> & vector2d) const;
void CalcProj0(const Vec<3> & point3d_minus_p0, Point<2> & point2d) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
public:
RevolutionFace(const SplineSeg<2> & spline_in,
const Point<3> & p,
const Vec<3> & vec,
bool first = false,
bool last = false,
const int id_in = 0);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
RevolutionFace(const Array<double> & raw_data);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
~RevolutionFace();
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual int IsIdentic (const Surface & s2, int & inv, double eps) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
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;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual double MaxCurvature () const;
//virtual double MaxCurvatureLoc (const Point<3> & /* c */ ,
// double /* rad */) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual void Project (Point<3> & p) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual Point<3> GetSurfacePoint () const;
virtual void Print (ostream & str) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual void GetTriangleApproximation (TriangleApproximation & tas,
const Box<3> & boundingbox,
double facets) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
bool BoxIntersectsFace (const Box<3> & box) const;
/*
bool BoxIntersectsFace (const BoxSphere<2> & box, bool & uncertain) const;
bool BoxIntersectsFace (const BoxSphere<3> & box, bool & uncertain) const;
*/
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
const SplineSeg<2> & GetSpline(void) const {return *spline;}
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
INSOLID_TYPE PointInFace (const Point<3> & p, const double eps) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
void GetRawData(Array<double> & data) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
};
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
/*
2009-01-13 04:40:13 +05:00
Primitive of revolution
2009-09-07 17:50:13 +06:00
*/
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
class Revolution : public Primitive
{
private:
Point<3> p0,p1;
Vec<3> v_axis;
const SplineGeometry<2> & splinecurve;
const int nsplines;
// 1 ... torus-like
// 2 ... sphere-like
int type;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
Array<RevolutionFace*> faces;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
mutable int intersecting_face;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
public:
Revolution(const Point<3> & p0_in,
const Point<3> & p1_in,
const SplineGeometry<2> & spline_in);
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
~Revolution();
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
/*
Check, whether box intersects solid defined by surface.
return values:
0 .. box outside solid \\
1 .. box in solid \\
2 .. can't decide (allowed, iff box is close to solid)
*/
virtual INSOLID_TYPE BoxInSolid (const BoxSphere<3> & box) const;
virtual INSOLID_TYPE PointInSolid (const Point<3> & p,
double eps) const;
virtual INSOLID_TYPE VecInSolid (const Point<3> & p,
const Vec<3> & v,
2009-01-13 04:40:13 +05:00
double eps) const;
2009-09-07 17:50:13 +06:00
// 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;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual int GetNSurfaces() const;
virtual Surface & GetSurface (int i = 0);
virtual const Surface & GetSurface (int i = 0) const;
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
virtual void Reduce (const BoxSphere<3> & box);
virtual void UnReduce ();
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
};
2009-01-13 04:40:13 +05:00
2009-09-07 17:50:13 +06:00
}
2009-01-13 04:40:13 +05:00
#endif