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