Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-21 09:16:59

0001 // Created on: 1997-09-11
0002 // Created by: Roman BORISOV
0003 // Copyright (c) 1997-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Geom2dConvert_ApproxCurve_HeaderFile
0018 #define _Geom2dConvert_ApproxCurve_HeaderFile
0019 
0020 #include <Adaptor2d_Curve2d.hxx>
0021 #include <GeomAbs_Shape.hxx>
0022 #include <Standard_OStream.hxx>
0023 
0024 class Geom2d_BSplineCurve;
0025 class Geom2d_Curve;
0026 
0027 //! A framework to convert a 2D curve to a BSpline.
0028 //! This is done by approximation within a given tolerance.
0029 class Geom2dConvert_ApproxCurve
0030 {
0031 public:
0032   DEFINE_STANDARD_ALLOC
0033 
0034   //! Constructs an approximation framework defined by
0035   //! -   the 2D conic Curve
0036   //! -   the tolerance value Tol2d
0037   //! -   the degree of continuity Order
0038   //! -   the maximum number of segments allowed MaxSegments
0039   //! -   the highest degree MaxDegree which the
0040   //! polynomial defining the BSpline is allowed to have.
0041   Standard_EXPORT Geom2dConvert_ApproxCurve(const occ::handle<Geom2d_Curve>& Curve,
0042                                             const double                     Tol2d,
0043                                             const GeomAbs_Shape              Order,
0044                                             const int                        MaxSegments,
0045                                             const int                        MaxDegree);
0046 
0047   //! Constructs an approximation framework defined by
0048   //! -   the 2D conic Curve
0049   //! -   the tolerance value Tol2d
0050   //! -   the degree of continuity Order
0051   //! -   the maximum number of segments allowed MaxSegments
0052   //! -   the highest degree MaxDegree which the
0053   //! polynomial defining the BSpline is allowed to have.
0054   Standard_EXPORT Geom2dConvert_ApproxCurve(const occ::handle<Adaptor2d_Curve2d>& Curve,
0055                                             const double                          Tol2d,
0056                                             const GeomAbs_Shape                   Order,
0057                                             const int                             MaxSegments,
0058                                             const int                             MaxDegree);
0059 
0060   //! Returns the 2D BSpline curve resulting from the
0061   //! approximation algorithm.
0062   Standard_EXPORT occ::handle<Geom2d_BSplineCurve> Curve() const;
0063 
0064   //! returns true if the approximation has
0065   //! been done with within required tolerance
0066   Standard_EXPORT bool IsDone() const;
0067 
0068   //! returns true if the approximation did come out
0069   //! with a result that is not NECESSARELY within the required tolerance
0070   Standard_EXPORT bool HasResult() const;
0071 
0072   //! Returns the greatest distance between a point on the
0073   //! source conic and the BSpline curve resulting from the
0074   //! approximation. (>0 when an approximation
0075   //! has been done, 0 if no approximation)
0076   Standard_EXPORT double MaxError() const;
0077 
0078   //! Print on the stream o information about the object
0079   Standard_EXPORT void Dump(Standard_OStream& o) const;
0080 
0081 private:
0082   //! Converts a curve to B-spline
0083   Standard_EXPORT void Approximate(const occ::handle<Adaptor2d_Curve2d>& theCurve,
0084                                    const double                          theTol3d,
0085                                    const GeomAbs_Shape                   theOrder,
0086                                    const int                             theMaxSegments,
0087                                    const int                             theMaxDegree);
0088 
0089   bool                             myIsDone;
0090   bool                             myHasResult;
0091   occ::handle<Geom2d_BSplineCurve> myBSplCurve;
0092   double                           myMaxError;
0093 };
0094 
0095 #endif // _Geom2dConvert_ApproxCurve_HeaderFile