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_Curve_HeaderFile
0015 #define GeomBndLib_Curve_HeaderFile
0016 
0017 #include <GeomBndLib_BezierCurve.hxx>
0018 #include <GeomBndLib_BSplineCurve.hxx>
0019 #include <GeomBndLib_Circle.hxx>
0020 #include <GeomBndLib_Ellipse.hxx>
0021 #include <GeomBndLib_Hyperbola.hxx>
0022 #include <GeomBndLib_Line.hxx>
0023 #include <GeomBndLib_OffsetCurve.hxx>
0024 #include <GeomBndLib_OtherCurve.hxx>
0025 #include <GeomBndLib_Parabola.hxx>
0026 #include <Bnd_Box.hxx>
0027 #include <GeomAbs_CurveType.hxx>
0028 #include <Standard.hxx>
0029 #include <Standard_DefineAlloc.hxx>
0030 
0031 #include <variant>
0032 
0033 class Adaptor3d_Curve;
0034 class Geom_Curve;
0035 
0036 //! Variant-based dispatcher for 3D curve bounding box computation.
0037 //! Auto-detects the curve type and delegates to the appropriate specialized class.
0038 class GeomBndLib_Curve
0039 {
0040 public:
0041   DEFINE_STANDARD_ALLOC
0042 
0043   //! Construct from an adaptor curve.
0044   Standard_EXPORT GeomBndLib_Curve(const Adaptor3d_Curve& theCurve);
0045 
0046   //! Construct from a Geom_Curve handle.
0047   Standard_EXPORT GeomBndLib_Curve(const occ::handle<Geom_Curve>& theCurve);
0048 
0049   GeomBndLib_Curve(const GeomBndLib_Curve&)            = delete;
0050   GeomBndLib_Curve& operator=(const GeomBndLib_Curve&) = delete;
0051   GeomBndLib_Curve(GeomBndLib_Curve&&)                 = delete;
0052   GeomBndLib_Curve& operator=(GeomBndLib_Curve&&)      = 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_Box Box(double theTol) const;
0059 
0060   //! Compute bounding box for arc [theU1, theU2].
0061   [[nodiscard]] Standard_EXPORT Bnd_Box Box(double theU1, double theU2, double theTol) const;
0062 
0063   //! Compute precise bounding box for full curve.
0064   [[nodiscard]] Standard_EXPORT Bnd_Box BoxOptimal(double theTol) const;
0065 
0066   //! Compute precise bounding box for arc [theU1, theU2].
0067   [[nodiscard]] Standard_EXPORT Bnd_Box BoxOptimal(double theU1, double theU2, double theTol) const;
0068 
0069   //! Add bounding box for full curve.
0070   Standard_EXPORT void Add(double theTol, Bnd_Box& theBox) const;
0071 
0072   //! Add bounding box for arc [theU1, theU2].
0073   Standard_EXPORT void Add(double theU1, double theU2, double theTol, Bnd_Box& theBox) const;
0074 
0075   //! Add precise bounding box for full curve.
0076   Standard_EXPORT void AddOptimal(double theTol, Bnd_Box& theBox) const;
0077 
0078   //! Add precise bounding box for arc [theU1, theU2].
0079   Standard_EXPORT void AddOptimal(double theU1, double theU2, double theTol, Bnd_Box& theBox) const;
0080 
0081 private:
0082   using EvaluatorVariant = std::variant<std::monostate,
0083                                         GeomBndLib_Line,
0084                                         GeomBndLib_Circle,
0085                                         GeomBndLib_Ellipse,
0086                                         GeomBndLib_Hyperbola,
0087                                         GeomBndLib_Parabola,
0088                                         GeomBndLib_BezierCurve,
0089                                         GeomBndLib_BSplineCurve,
0090                                         GeomBndLib_OffsetCurve,
0091                                         GeomBndLib_OtherCurve>;
0092   const Adaptor3d_Curve* adaptor() const;
0093   double                 effectiveU1() const;
0094   double                 effectiveU2() const;
0095 
0096 private:
0097   const Adaptor3d_Curve*       myAdaptorRef = nullptr;
0098   occ::handle<Adaptor3d_Curve> myAdaptorOwned;
0099   EvaluatorVariant             myEvaluator;
0100   GeomAbs_CurveType            myCurveType;
0101 };
0102 
0103 #endif // GeomBndLib_Curve_HeaderFile