Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-28 09:20:07

0001 // Copyright (c) 2025 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef GeomBndLib_Curve2d_HeaderFile
0015 #define GeomBndLib_Curve2d_HeaderFile
0016 
0017 #include <GeomBndLib_BezierCurve2d.hxx>
0018 #include <GeomBndLib_BSplineCurve2d.hxx>
0019 #include <GeomBndLib_Circle2d.hxx>
0020 #include <GeomBndLib_Ellipse2d.hxx>
0021 #include <GeomBndLib_Hyperbola2d.hxx>
0022 #include <GeomBndLib_Line2d.hxx>
0023 #include <GeomBndLib_OffsetCurve2d.hxx>
0024 #include <GeomBndLib_OtherCurve2d.hxx>
0025 #include <GeomBndLib_Parabola2d.hxx>
0026 #include <Bnd_Box2d.hxx>
0027 #include <GeomAbs_CurveType.hxx>
0028 #include <Standard.hxx>
0029 #include <Standard_DefineAlloc.hxx>
0030 
0031 #include <variant>
0032 
0033 class Adaptor2d_Curve2d;
0034 class Geom2d_Curve;
0035 
0036 //! Variant-based dispatcher for 2D curve bounding box computation.
0037 //! Auto-detects the curve type and delegates to the appropriate specialized class.
0038 class GeomBndLib_Curve2d
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Construct from an adaptor curve.
0044   Standard_EXPORT GeomBndLib_Curve2d(const Adaptor2d_Curve2d& theCurve);
0045 
0046   //! Construct from a Geom2d_Curve handle.
0047   Standard_EXPORT GeomBndLib_Curve2d(const occ::handle<Geom2d_Curve>& theCurve);
0048 
0049   GeomBndLib_Curve2d(const GeomBndLib_Curve2d&)            = delete;
0050   GeomBndLib_Curve2d& operator=(const GeomBndLib_Curve2d&) = delete;
0051   GeomBndLib_Curve2d(GeomBndLib_Curve2d&&)                 = delete;
0052   GeomBndLib_Curve2d& operator=(GeomBndLib_Curve2d&&)      = delete;
0053 
0054   //! Return detected curve type.
0055   GeomAbs_CurveType GetType() const { return myCurveType; }
0056 
0057   //! Compute bounding box for full curve.
0058   [[nodiscard]] Standard_EXPORT Bnd_Box2d Box(double theTol) const;
0059 
0060   //! Compute bounding box for arc [theU1, theU2].
0061   [[nodiscard]] Standard_EXPORT Bnd_Box2d Box(double theU1, double theU2, double theTol) const;
0062 
0063   //! Compute precise bounding box for full curve.
0064   [[nodiscard]] Standard_EXPORT Bnd_Box2d BoxOptimal(double theTol) const;
0065 
0066   //! Compute precise bounding box for arc [theU1, theU2].
0067   [[nodiscard]] Standard_EXPORT Bnd_Box2d BoxOptimal(double theU1,
0068                                                      double theU2,
0069                                                      double theTol) const;
0070 
0071   //! Add bounding box for full curve.
0072   Standard_EXPORT void Add(double theTol, Bnd_Box2d& theBox) const;
0073 
0074   //! Add bounding box for arc [theU1, theU2].
0075   Standard_EXPORT void Add(double theU1, double theU2, double theTol, Bnd_Box2d& theBox) const;
0076 
0077   //! Add precise bounding box for full curve.
0078   Standard_EXPORT void AddOptimal(double theTol, Bnd_Box2d& theBox) const;
0079 
0080   //! Add precise bounding box for arc [theU1, theU2].
0081   Standard_EXPORT void AddOptimal(double     theU1,
0082                                   double     theU2,
0083                                   double     theTol,
0084                                   Bnd_Box2d& theBox) const;
0085 
0086 private:
0087   using EvaluatorVariant = std::variant<std::monostate,
0088                                         GeomBndLib_Line2d,
0089                                         GeomBndLib_Circle2d,
0090                                         GeomBndLib_Ellipse2d,
0091                                         GeomBndLib_Hyperbola2d,
0092                                         GeomBndLib_Parabola2d,
0093                                         GeomBndLib_BezierCurve2d,
0094                                         GeomBndLib_BSplineCurve2d,
0095                                         GeomBndLib_OffsetCurve2d,
0096                                         GeomBndLib_OtherCurve2d>;
0097   const Adaptor2d_Curve2d* adaptor() const;
0098   double                   effectiveU1() const;
0099   double                   effectiveU2() const;
0100 
0101 private:
0102   const Adaptor2d_Curve2d*       myAdaptorRef = nullptr;
0103   occ::handle<Adaptor2d_Curve2d> myAdaptorOwned;
0104   EvaluatorVariant               myEvaluator;
0105   GeomAbs_CurveType              myCurveType;
0106 };
0107 
0108 #endif // GeomBndLib_Curve2d_HeaderFile