1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
7 * http://cg.cs.uni-bonn.de/ *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_BEZIERCURVE3D_H_
39 #define _OSG_BEZIERCURVE3D_H_
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
46 #include "OSGBaseFunctions.h"
53 #include "OSGdctptypes.h"
59 typedef std::vector
<BezierCurve3D
> bezier3dvector
;
60 typedef std::vector
<bezier3dvector
> bezier3dmatrix
;
61 typedef std::deque
<BezierCurve3D
> bezier3ddeque
;
62 typedef std::vector
<bezier3ddeque
> bezier3ddequevector
;
64 class OSG_DRAWABLE_DLLMAPPING BezierCurve3D
67 int approximate_sub(std::vector
<double> &vertices
, double delta
, double min
, double max
, unsigned char strategy
);
69 DCTPVec4dvector control_points
; //control points of the curve
71 // static std::vector<std::vector<std::vector<double> > > m_svvvdCreateMatrix;
72 Vec4d
computewdeCasteljau4D(double t
, int &error
); //compute curve at parameter value t
75 static const unsigned char SUBDIVISION
= 1;
76 static const unsigned char MIDPOINT_SUBDIVISION
= 0;
77 static const unsigned char ARBITRARY_SUBDIVISION
= 1;
79 static const unsigned char DISTANCE
= 2;
80 static const unsigned char POINT_DISTANCE
= 0;
81 static const unsigned char LINE_DISTANCE
= 2;
82 inline BezierCurve3D(void);
83 inline ~BezierCurve3D(void);
86 int setControlPointVector(const DCTPVec4dvector
& cps
); //ok, acts like its name says
89 inline DCTPVec4dvector
& getControlPointVector(void);
91 //some REAL functionality
92 Vec3d
computewdeCasteljau(double t
, int &error
); //compute curve at parameter value t
93 Vec3d
computeLinearApproximation(double t
, int &error
); //ok like its name sayz
94 int midPointSubDivision(bezier3dvector
&newbeziers
); //subdivide curve at midpoint into two new curves
95 int midPointSubDivision(BezierCurve3D
&newcurve
); //subdivide curve at midpoint into two new curves
96 int subDivision(double t
, bezier3dvector
&newbeziers
); //subdivide curvee at t into two new curves
97 int subDivision(double t
, BezierCurve3D
&newcurve
);
98 int approximate(std::vector
<double> &vertices
, double delta
, unsigned char strategy
= MIDPOINT_SUBDIVISION
| POINT_DISTANCE
); // approximate curve linearly with given maximum tolerance
99 int createCurve(DCTPVec4dvector
&points
); // generate a (rational) bezier curve through these points
100 bool reduceDegree(double tol
= DCTP_EPS
);
102 inline void optimizeDegree(void);
107 #include "OSGBezierCurve3D.inl"
109 #endif //BezierCurve3D.h