Back to home page

EIC code displayed by LXR

 
 

    


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

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_Surface_HeaderFile
0015 #define GeomBndLib_Surface_HeaderFile
0016 
0017 #include <GeomBndLib_BezierSurface.hxx>
0018 #include <GeomBndLib_BSplineSurface.hxx>
0019 #include <GeomBndLib_Cone.hxx>
0020 #include <GeomBndLib_Cylinder.hxx>
0021 #include <GeomBndLib_OffsetSurface.hxx>
0022 #include <GeomBndLib_OtherSurface.hxx>
0023 #include <GeomBndLib_Plane.hxx>
0024 #include <GeomBndLib_Sphere.hxx>
0025 #include <GeomBndLib_SurfaceOfExtrusion.hxx>
0026 #include <GeomBndLib_SurfaceOfRevolution.hxx>
0027 #include <GeomBndLib_Torus.hxx>
0028 #include <Bnd_Box.hxx>
0029 #include <GeomAbs_SurfaceType.hxx>
0030 #include <gp_Trsf.hxx>
0031 #include <Standard.hxx>
0032 #include <Standard_DefineAlloc.hxx>
0033 
0034 #include <optional>
0035 #include <variant>
0036 
0037 class Adaptor3d_Surface;
0038 class Geom_Surface;
0039 
0040 //! Variant-based dispatcher for 3D surface bounding box computation.
0041 //! Auto-detects the surface type and delegates to the appropriate specialized class.
0042 class GeomBndLib_Surface
0043 {
0044 public:
0045   DEFINE_STANDARD_ALLOC
0046 
0047   //! Construct from an adaptor surface.
0048   Standard_EXPORT GeomBndLib_Surface(const Adaptor3d_Surface& theSurf);
0049 
0050   //! Construct from a Geom_Surface handle.
0051   Standard_EXPORT GeomBndLib_Surface(const occ::handle<Geom_Surface>& theSurf);
0052 
0053   GeomBndLib_Surface(const GeomBndLib_Surface&)            = delete;
0054   GeomBndLib_Surface& operator=(const GeomBndLib_Surface&) = delete;
0055   GeomBndLib_Surface(GeomBndLib_Surface&&)                 = delete;
0056   GeomBndLib_Surface& operator=(GeomBndLib_Surface&&)      = delete;
0057 
0058   //! Return detected surface type.
0059   GeomAbs_SurfaceType GetType() const { return mySurfType; }
0060 
0061   //! Compute bounding box for full surface.
0062   [[nodiscard]] Standard_EXPORT Bnd_Box Box(double theTol) const;
0063 
0064   //! Compute bounding box for surface patch [theUMin, theUMax] x [theVMin, theVMax].
0065   [[nodiscard]] Standard_EXPORT Bnd_Box
0066     Box(double theUMin, double theUMax, double theVMin, double theVMax, double theTol) const;
0067 
0068   //! Compute precise bounding box for full surface.
0069   [[nodiscard]] Standard_EXPORT Bnd_Box BoxOptimal(double theTol) const;
0070 
0071   //! Compute precise bounding box for surface patch [theUMin, theUMax] x [theVMin, theVMax].
0072   [[nodiscard]] Standard_EXPORT Bnd_Box
0073     BoxOptimal(double theUMin, double theUMax, double theVMin, double theVMax, double theTol) const;
0074 
0075   //! Add bounding box for full surface.
0076   Standard_EXPORT void Add(double theTol, Bnd_Box& theBox) const;
0077 
0078   //! Add bounding box for surface patch [theUMin, theUMax] x [theVMin, theVMax].
0079   Standard_EXPORT void Add(double   theUMin,
0080                            double   theUMax,
0081                            double   theVMin,
0082                            double   theVMax,
0083                            double   theTol,
0084                            Bnd_Box& theBox) const;
0085 
0086   //! Add precise bounding box for full surface.
0087   Standard_EXPORT void AddOptimal(double theTol, Bnd_Box& theBox) const;
0088 
0089   //! Add precise bounding box for surface patch [theUMin, theUMax] x [theVMin, theVMax].
0090   Standard_EXPORT void AddOptimal(double   theUMin,
0091                                   double   theUMax,
0092                                   double   theVMin,
0093                                   double   theVMax,
0094                                   double   theTol,
0095                                   Bnd_Box& theBox) const;
0096 
0097 private:
0098   using EvaluatorVariant = std::variant<std::monostate,
0099                                         GeomBndLib_Plane,
0100                                         GeomBndLib_Cylinder,
0101                                         GeomBndLib_Cone,
0102                                         GeomBndLib_Sphere,
0103                                         GeomBndLib_Torus,
0104                                         GeomBndLib_BezierSurface,
0105                                         GeomBndLib_BSplineSurface,
0106                                         GeomBndLib_SurfaceOfRevolution,
0107                                         GeomBndLib_SurfaceOfExtrusion,
0108                                         GeomBndLib_OffsetSurface,
0109                                         GeomBndLib_OtherSurface>;
0110   bool initFromSurface(const occ::handle<Geom_Surface>& theSurf);
0111   bool initFromSurfaceType(GeomAbs_SurfaceType theType, const occ::handle<Geom_Surface>& theSurf);
0112   void initOtherSurface(const Adaptor3d_Surface& theSurf);
0113   void initOtherSurface(const occ::handle<Geom_Surface>& theSurf);
0114   const Adaptor3d_Surface* adaptor() const;
0115   double                   effectiveU1() const;
0116   double                   effectiveU2() const;
0117   double                   effectiveV1() const;
0118   double                   effectiveV2() const;
0119 
0120 private:
0121   const Adaptor3d_Surface*       myAdaptorRef = nullptr;
0122   occ::handle<Adaptor3d_Surface> myAdaptorOwned;
0123   EvaluatorVariant               myEvaluator;
0124   GeomAbs_SurfaceType            mySurfType;
0125 };
0126 
0127 #endif // GeomBndLib_Surface_HeaderFile