| 1 | // Created on: 1993-03-24 |
| 2 | // Created by: DUB |
| 3 | // Copyright (c) 1993-1999 Matra Datavision |
| 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
| 5 | // |
| 6 | // This file is part of Open CASCADE Technology software library. |
| 7 | // |
| 8 | // This library is free software; you can redistribute it and/or modify it under |
| 9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
| 10 | // by the Free Software Foundation, with special exception defined in the file |
| 11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
| 12 | // distribution for complete text of the license and disclaimer of any warranty. |
| 13 | // |
| 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
| 15 | // commercial license or contractual agreement. |
| 16 | |
| 17 | #ifndef _Geom2dConvert_BSplineCurveToBezierCurve_HeaderFile |
| 18 | #define _Geom2dConvert_BSplineCurveToBezierCurve_HeaderFile |
| 19 | |
| 20 | #include <Standard.hxx> |
| 21 | #include <Standard_DefineAlloc.hxx> |
| 22 | #include <Standard_Handle.hxx> |
| 23 | |
| 24 | #include <Standard_Real.hxx> |
| 25 | #include <Standard_Integer.hxx> |
| 26 | #include <TColGeom2d_Array1OfBezierCurve.hxx> |
| 27 | #include <TColStd_Array1OfReal.hxx> |
| 28 | class Geom2d_BSplineCurve; |
| 29 | class Standard_DimensionError; |
| 30 | class Standard_DomainError; |
| 31 | class Standard_OutOfRange; |
| 32 | class Geom2d_BezierCurve; |
| 33 | |
| 34 | |
| 35 | //! An algorithm to convert a BSpline curve into a series |
| 36 | //! of adjacent Bezier curves. |
| 37 | //! A BSplineCurveToBezierCurve object provides a framework for: |
| 38 | //! - defining the BSpline curve to be converted |
| 39 | //! - implementing the construction algorithm, and |
| 40 | //! - consulting the results. |
| 41 | //! References : |
| 42 | //! Generating the Bezier points of B-spline curves and surfaces |
| 43 | //! (Wolfgang Bohm) CAD volume 13 number 6 november 1981 |
| 44 | class Geom2dConvert_BSplineCurveToBezierCurve |
| 45 | { |
| 46 | public: |
| 47 | |
| 48 | DEFINE_STANDARD_ALLOC |
| 49 | |
| 50 | |
| 51 | //! Computes all the data needed to convert |
| 52 | //! - the BSpline curve BasisCurve, into a series of adjacent Bezier arcs. |
| 53 | //! The result consists of a series of BasisCurve arcs |
| 54 | //! limited by points corresponding to knot values of the curve. |
| 55 | //! Use the available interrogation functions to ascertain |
| 56 | //! the number of computed Bezier arcs, and then to |
| 57 | //! construct each individual Bezier curve (or all Bezier curves). |
| 58 | //! Note: ParametricTolerance is not used. |
| 59 | Standard_EXPORT Geom2dConvert_BSplineCurveToBezierCurve(const Handle(Geom2d_BSplineCurve)& BasisCurve); |
| 60 | |
| 61 | //! Computes all the data needed to convert |
| 62 | //! the portion of the BSpline curve BasisCurve |
| 63 | //! limited by the two parameter values U1 and U2 |
| 64 | //! for Example if there is a Knot Uk and |
| 65 | //! Uk < U < Uk + ParametricTolerance/2 the last curve |
| 66 | //! corresponds to the span [Uk-1, Uk] and not to [Uk, Uk+1] |
| 67 | //! The result consists of a series of BasisCurve arcs |
| 68 | //! limited by points corresponding to knot values of the curve. |
| 69 | //! Use the available interrogation functions to ascertain |
| 70 | //! the number of computed Bezier arcs, and then to |
| 71 | //! construct each individual Bezier curve (or all Bezier curves). |
| 72 | //! Note: ParametricTolerance is not used. |
| 73 | //! Raises DomainError if U1 or U2 are out of the parametric bounds of the basis |
| 74 | //! curve [FirstParameter, LastParameter]. The Tolerance criterion |
| 75 | //! is ParametricTolerance. |
| 76 | //! Raised if Abs (U2 - U1) <= ParametricTolerance. |
| 77 | Standard_EXPORT Geom2dConvert_BSplineCurveToBezierCurve(const Handle(Geom2d_BSplineCurve)& BasisCurve, const Standard_Real U1, const Standard_Real U2, const Standard_Real ParametricTolerance); |
| 78 | |
| 79 | //! Constructs and returns the Bezier curve of index |
| 80 | //! Index to the table of adjacent Bezier arcs |
| 81 | //! computed by this algorithm. |
| 82 | //! This Bezier curve has the same orientation as the |
| 83 | //! BSpline curve analyzed in this framework. |
| 84 | //! Exceptions |
| 85 | //! Standard_OutOfRange if Index is less than 1 or |
| 86 | //! greater than the number of adjacent Bezier arcs |
| 87 | //! computed by this algorithm. |
| 88 | Standard_EXPORT Handle(Geom2d_BezierCurve) Arc (const Standard_Integer Index); |
| 89 | |
| 90 | //! Constructs all the Bezier curves whose data is |
| 91 | //! computed by this algorithm and loads these curves |
| 92 | //! into the Curves table. |
| 93 | //! The Bezier curves have the same orientation as the |
| 94 | //! BSpline curve analyzed in this framework. |
| 95 | //! Exceptions |
| 96 | //! Standard_DimensionError if the Curves array was |
| 97 | //! not created with the following bounds: |
| 98 | //! - 1 , and |
| 99 | //! - the number of adjacent Bezier arcs computed by |
| 100 | //! this algorithm (as given by the function NbArcs). |
| 101 | Standard_EXPORT void Arcs (TColGeom2d_Array1OfBezierCurve& Curves); |
| 102 | |
| 103 | //! This methode returns the bspline's knots associated to |
| 104 | //! the converted arcs |
| 105 | //! Raises DimensionError if the length of Curves is not equal to |
| 106 | //! NbArcs + 1 |
| 107 | Standard_EXPORT void Knots (TColStd_Array1OfReal& TKnots) const; |
| 108 | |
| 109 | |
| 110 | //! Returns the number of BezierCurve arcs. |
| 111 | //! If at the creation time you have decomposed the basis curve |
| 112 | //! between the parametric values UFirst, ULast the number of |
| 113 | //! BezierCurve arcs depends on the number of knots included inside |
| 114 | //! the interval [UFirst, ULast]. |
| 115 | //! If you have decomposed the whole basis B-spline curve the number |
| 116 | //! of BezierCurve arcs NbArcs is equal to the number of knots less |
| 117 | //! one. |
| 118 | Standard_EXPORT Standard_Integer NbArcs() const; |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | protected: |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | private: |
| 130 | |
| 131 | |
| 132 | |
| 133 | Handle(Geom2d_BSplineCurve) myCurve; |
| 134 | |
| 135 | |
| 136 | }; |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | #endif // _Geom2dConvert_BSplineCurveToBezierCurve_HeaderFile |