changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGBezierCurve3D.h
blobe681aeb4c93ae614b7a634431394279908237699
1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
3 * *
4 * *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
6 * *
7 * http://cg.cs.uni-bonn.de/ *
8 * *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_BEZIERCURVE3D_H_
39 #define _OSG_BEZIERCURVE3D_H_
40 #ifdef __sgi
41 #pragma once
42 #endif
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
46 #include "OSGBaseFunctions.h"
48 //#include <iostream>
49 #include <fstream>
50 #include <iomanip>
51 #include <vector>
52 #include <deque>
53 #include "OSGdctptypes.h"
55 OSG_BEGIN_NAMESPACE
57 class BezierCurve3D;
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
66 protected:
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
74 public:
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);
85 //setup functions
86 int setControlPointVector(const DCTPVec4dvector& cps); //ok, acts like its name says
88 //query functions
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);
105 OSG_END_NAMESPACE
107 #include "OSGBezierCurve3D.inl"
109 #endif //BezierCurve3D.h