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