changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Nurbs / Internal / OSGBSplineCurve2D.h
blob58d1bbd9f9fef41dceda0b8491b8ae55403b0a64
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_BSPLINECURVE2D_H_
39 #define _OSG_BSPLINECURVE2D_H_
40 #ifdef __sgi
41 #pragma once
42 #endif
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
48 #include "OSGdctptypes.h"
49 #include "OSGBSplineBasisFunction.h"
50 #include "OSGBezierCurve2D.h"
52 OSG_BEGIN_NAMESPACE
54 class OSG_DRAWABLE_DLLMAPPING BSplineCurve2D
56 protected:
57 DCTPVec3dvector control_points; //control points of the curve
58 int dimension; //dimension of the B-spline (degree)
59 BSplineBasisFunction basis_function; //placeholder for the knots & facility to easily compute 'em
61 //file format constants
62 static const char ff_const_1[];
63 static const char ff_const_2[];
64 static const char ff_const_3[];
65 static const char ff_const_4[];
67 int CheckKnotPoints(const DCTPdvector& knots, int dim); //check whether knots has a right format
69 // delete a knot which is on a 'bezier' curve, i.e. [0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3] -> [0 0 0 0 1 1 1 2 2 2 3 3 3 3]
70 // must have a multiplicity of (at least) dimension + 1, and its associated control point also must have a multiplicity of (at least) 2.
71 int deleteBezierKnot(double k);
74 public:
75 inline BSplineCurve2D(void);
76 inline ~BSplineCurve2D(void);
78 //setup functions
79 // FIXME: the setup interface is very rigid, maybe it should allow knot & dimension setting alone, eg. to resize dimension, etc
80 int setKnotsAndDimension(const DCTPdvector& knots, int dim); //ok, acts like its name says
81 void setControlPointVector(const DCTPVec3dvector &cps); //set control point vector
83 //query functions
84 inline DCTPdvector& getKnotVector (void); //return knot points of basis functions
85 inline DCTPVec3dvector& getControlPointVector(void);
86 inline int getDimension (void);
88 void getParameterInterval(double &minpar, double &maxpar); //returns minimal and maximal parameter value
90 //I/O support - FIXME: read( char *fname ) outta be supported , etc
91 int read(std::istream &infile);
92 int write(std::ostream &outfile);
94 //some REAL functionality
95 Vec2d compute(double t, int &error); // compute curve at parameter value t
96 int insertKnot(double k); // insert a new knot (recalculates control points and knotvector)
98 // convert curve into Bezier form.
99 int makeBezier(bezier2dvector &beziers, DCTPdvector &pars);
102 OSG_END_NAMESPACE
104 #include "OSGBSplineCurve2D.inl"
106 #endif //BSplineCurve2D.h