42cf5bc1 |
1 | // Created on: 1997-09-11 |
2 | // Created by: Roman BORISOV |
3 | // Copyright (c) 1997-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 _GeomConvert_ApproxCurve_HeaderFile |
18 | #define _GeomConvert_ApproxCurve_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_DefineAlloc.hxx> |
22 | #include <Standard_Handle.hxx> |
23 | |
24 | #include <Standard_Boolean.hxx> |
25 | #include <Standard_Real.hxx> |
26 | #include <GeomAbs_Shape.hxx> |
27 | #include <Standard_Integer.hxx> |
28 | #include <Standard_OStream.hxx> |
29 | class Geom_BSplineCurve; |
30 | class Standard_OutOfRange; |
31 | class Standard_ConstructionError; |
32 | class Geom_Curve; |
33 | class Adaptor3d_HCurve; |
34 | |
35 | |
36 | //! A framework to convert a 3D curve to a 3D BSpline. |
37 | //! This is done by approximation to a BSpline curve within a given tolerance. |
38 | class GeomConvert_ApproxCurve |
39 | { |
40 | public: |
41 | |
42 | DEFINE_STANDARD_ALLOC |
43 | |
44 | |
45 | //! Constructs a curve approximation framework defined by - |
46 | //! - the conic Curve, |
47 | //! - the tolerance value Tol3d, |
48 | //! - the degree of continuity Order, |
49 | //! - the maximum number of segments |
50 | //! MaxSegments allowed in the resulting BSpline curve, and |
51 | //! - the highest degree MaxDeg which the |
52 | //! polynomial defining the BSpline curve may have. |
53 | Standard_EXPORT GeomConvert_ApproxCurve(const Handle(Geom_Curve)& Curve, const Standard_Real Tol3d, const GeomAbs_Shape Order, const Standard_Integer MaxSegments, const Standard_Integer MaxDegree); |
54 | |
55 | //! Constructs a curve approximation framework defined by - |
56 | //! - the Curve, |
57 | //! - the tolerance value Tol3d, |
58 | //! - the degree of continuity Order, |
59 | //! - the maximum number of segments |
60 | //! MaxSegments allowed in the resulting BSpline curve, and |
61 | //! - the highest degree MaxDeg which the |
62 | //! polynomial defining the BSpline curve may have. |
63 | Standard_EXPORT GeomConvert_ApproxCurve(const Handle(Adaptor3d_HCurve)& Curve, const Standard_Real Tol3d, const GeomAbs_Shape Order, const Standard_Integer MaxSegments, const Standard_Integer MaxDegree); |
64 | |
65 | //! Returns the BSpline curve resulting from the approximation algorithm. |
66 | Standard_EXPORT Handle(Geom_BSplineCurve) Curve() const; |
67 | |
68 | //! returns Standard_True if the approximation has |
69 | //! been done within requiered tolerance |
70 | Standard_EXPORT Standard_Boolean IsDone() const; |
71 | |
72 | //! Returns Standard_True if the approximation did come out |
73 | //! with a result that is not NECESSARELY within the required tolerance |
74 | Standard_EXPORT Standard_Boolean HasResult() const; |
75 | |
76 | //! Returns the greatest distance between a point on the |
77 | //! source conic and the BSpline curve resulting from the |
78 | //! approximation. (>0 when an approximation |
79 | //! has been done, 0 if no approximation) |
80 | Standard_EXPORT Standard_Real MaxError() const; |
81 | |
82 | //! Print on the stream o information about the object |
83 | Standard_EXPORT void Dump (Standard_OStream& o) const; |
84 | |
85 | |
86 | |
87 | |
88 | protected: |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | private: |
95 | |
96 | |
97 | //! Converts a curve to B-spline |
98 | Standard_EXPORT void Approximate (const Handle(Adaptor3d_HCurve)& theCurve, const Standard_Real theTol3d, const GeomAbs_Shape theOrder, const Standard_Integer theMaxSegments, const Standard_Integer theMaxDegree); |
99 | |
100 | |
101 | Standard_Boolean myIsDone; |
102 | Standard_Boolean myHasResult; |
103 | Handle(Geom_BSplineCurve) myBSplCurve; |
104 | Standard_Real myMaxError; |
105 | |
106 | |
107 | }; |
108 | |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | |
115 | #endif // _GeomConvert_ApproxCurve_HeaderFile |