Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-17 08:35:17

0001 // Created: 1998-06-03
0002 //
0003 // Copyright (c) 1999-2013 OPEN CASCADE SAS
0004 //
0005 // This file is part of commercial software by OPEN CASCADE SAS,
0006 // furnished in accordance with the terms and conditions of the contract
0007 // and with the inclusion of this copyright notice.
0008 // This file or any part thereof may not be provided or otherwise
0009 // made available to any third party.
0010 //
0011 // No ownership title to the software is transferred hereby.
0012 //
0013 // OPEN CASCADE SAS makes no representation or warranties with respect to the
0014 // performance of this software, and specifically disclaims any responsibility
0015 // for any damages, special or consequential, connected with its use.
0016 
0017 #ifndef _GeomConvert_SurfToAnaSurf_HeaderFile
0018 #define _GeomConvert_SurfToAnaSurf_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_DefineAlloc.hxx>
0022 #include <Standard_Handle.hxx>
0023 
0024 #include <Standard_Real.hxx>
0025 #include <Standard_Boolean.hxx>
0026 #include <GeomConvert_ConvType.hxx>
0027 #include <GeomAbs_SurfaceType.hxx>
0028 #include <TColgp_HArray1OfXYZ.hxx>
0029 class Geom_Surface;
0030 class Geom_SurfaceOfRevolution;
0031 class Geom_Circle;
0032 
0033 //! Converts a surface to the analytical form with given
0034 //! precision. Conversion is done only the surface is bspline
0035 //! of bezier and this can be approximated by some analytical
0036 //! surface with that precision.
0037 class GeomConvert_SurfToAnaSurf
0038 {
0039 public:
0040   DEFINE_STANDARD_ALLOC
0041 
0042   Standard_EXPORT GeomConvert_SurfToAnaSurf();
0043 
0044   Standard_EXPORT GeomConvert_SurfToAnaSurf(const Handle(Geom_Surface)& S);
0045 
0046   Standard_EXPORT void Init(const Handle(Geom_Surface)& S);
0047 
0048   void SetConvType(const GeomConvert_ConvType theConvType = GeomConvert_Simplest)
0049   {
0050     myConvType = theConvType;
0051   }
0052 
0053   void SetTarget(const GeomAbs_SurfaceType theSurfType = GeomAbs_Plane) { myTarget = theSurfType; }
0054 
0055   //! Returns maximal deviation of converted surface from the original
0056   //! one computed by last call to ConvertToAnalytical
0057   Standard_Real Gap() const { return myGap; }
0058 
0059   //! Tries to convert the Surface to an Analytic form
0060   //! Returns the result
0061   //! In case of failure, returns a Null Handle
0062   //!
0063   Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical(const Standard_Real InitialToler);
0064   Standard_EXPORT Handle(Geom_Surface) ConvertToAnalytical(const Standard_Real InitialToler,
0065                                                            const Standard_Real Umin,
0066                                                            const Standard_Real Umax,
0067                                                            const Standard_Real Vmin,
0068                                                            const Standard_Real Vmax);
0069 
0070   //! Returns true if surfaces is same with the given tolerance
0071   Standard_EXPORT static Standard_Boolean IsSame(const Handle(Geom_Surface)& S1,
0072                                                  const Handle(Geom_Surface)& S2,
0073                                                  const Standard_Real         tol);
0074 
0075   //! Returns true, if surface is canonical
0076   Standard_EXPORT static Standard_Boolean IsCanonical(const Handle(Geom_Surface)& S);
0077 
0078 private:
0079   //! static method for checking surface of revolution
0080   //! To avoid two-parts cone-like surface
0081   static void CheckVTrimForRevSurf(const Handle(Geom_SurfaceOfRevolution)& aRevSurf,
0082                                    Standard_Real&                          V1,
0083                                    Standard_Real&                          V2);
0084 
0085   //! static method to try create cylindrical or conical surface
0086   static Handle(Geom_Surface) TryCylinerCone(const Handle(Geom_Surface)& theSurf,
0087                                              const Standard_Boolean      theVCase,
0088                                              const Handle(Geom_Curve)&   theUmidiso,
0089                                              const Handle(Geom_Curve)&   theVmidiso,
0090                                              const Standard_Real         theU1,
0091                                              const Standard_Real         theU2,
0092                                              const Standard_Real         theV1,
0093                                              const Standard_Real         theV2,
0094                                              const Standard_Real         theToler);
0095 
0096   //! static method to try create cylinrical surface using least square method
0097   static Standard_Boolean GetCylByLS(const Handle(TColgp_HArray1OfXYZ)& thePoints,
0098                                      const Standard_Real                theTol,
0099                                      gp_Ax3&                            thePos,
0100                                      Standard_Real&                     theR,
0101                                      Standard_Real&                     theGap);
0102 
0103   //! static method to try create cylinrical surface based on its Gauss field
0104   static Handle(Geom_Surface) TryCylinderByGaussField(
0105     const Handle(Geom_Surface)& theSurf,
0106     const Standard_Real         theU1,
0107     const Standard_Real         theU2,
0108     const Standard_Real         theV1,
0109     const Standard_Real         theV2,
0110     const Standard_Real         theToler,
0111     const Standard_Integer      theNbU         = 20,
0112     const Standard_Integer      theNbV         = 20,
0113     const Standard_Boolean      theLeastSquare = Standard_False);
0114 
0115   //! static method to try create toroidal surface.
0116   //! In case <isTryUMajor> = Standard_True try to use V isoline radius as minor radaius.
0117   static Handle(Geom_Surface) TryTorusSphere(const Handle(Geom_Surface)& theSurf,
0118                                              const Handle(Geom_Circle)&  circle,
0119                                              const Handle(Geom_Circle)&  otherCircle,
0120                                              const Standard_Real         Param1,
0121                                              const Standard_Real         Param2,
0122                                              const Standard_Real         aParam1ToCrv,
0123                                              const Standard_Real         aParam2ToCrv,
0124                                              const Standard_Real         toler,
0125                                              const Standard_Boolean      isTryUMajor);
0126 
0127   static Standard_Real ComputeGap(const Handle(Geom_Surface)& theSurf,
0128                                   const Standard_Real         theU1,
0129                                   const Standard_Real         theU2,
0130                                   const Standard_Real         theV1,
0131                                   const Standard_Real         theV2,
0132                                   const Handle(Geom_Surface)& theNewSurf,
0133                                   const Standard_Real         theTol = RealLast());
0134 
0135 protected:
0136 private:
0137   Handle(Geom_Surface) mySurf;
0138   Standard_Real        myGap;
0139   GeomConvert_ConvType myConvType;
0140   GeomAbs_SurfaceType  myTarget;
0141 };
0142 
0143 #endif // _GeomConvert_SurfToAnaSurf_HeaderFile