Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-04 08:44:06

0001 // Copyright (c) 2022 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 _ShapeAnalysis_CanonicalRecognition_HeaderFile
0015 #define _ShapeAnalysis_CanonicalRecognition_HeaderFile
0016 
0017 #include <Standard.hxx>
0018 #include <Standard_DefineAlloc.hxx>
0019 #include <Standard_Handle.hxx>
0020 
0021 #include <Standard_Boolean.hxx>
0022 #include <Standard_Integer.hxx>
0023 #include <TopAbs_ShapeEnum.hxx>
0024 #include <TopoDS_Shape.hxx>
0025 #include <TopoDS_Shell.hxx>
0026 #include <TopoDS_Face.hxx>
0027 #include <TopoDS_Wire.hxx>
0028 #include <TopoDS_Edge.hxx>
0029 #include <GeomAbs_SurfaceType.hxx>
0030 #include <GeomAbs_CurveType.hxx>
0031 #include <GeomConvert_ConvType.hxx>
0032 #include <TColStd_Array1OfReal.hxx>
0033 
0034 class gp_Pln;
0035 class gp_Cone;
0036 class gp_Cylinder;
0037 class gp_Sphere;
0038 class gp_Lin;
0039 class gp_Circ;
0040 class gp_Elips;
0041 class Geom_Curve;
0042 class Geom_Surface;
0043 
0044 //! This class provides operators for analysis surfaces and curves of shapes
0045 //! in order to find out more simple geometry entities, which could replace
0046 //! existing complex (for example, BSpline) geometry objects with given tolerance.
0047 class ShapeAnalysis_CanonicalRecognition
0048 {
0049 public:
0050   DEFINE_STANDARD_ALLOC
0051 
0052   //! Empty constructor
0053   Standard_EXPORT ShapeAnalysis_CanonicalRecognition();
0054 
0055   //! constructor with shape initialisation
0056   Standard_EXPORT ShapeAnalysis_CanonicalRecognition(const TopoDS_Shape& theShape);
0057 
0058   //! Sets shape
0059   Standard_EXPORT void SetShape(const TopoDS_Shape& theShape);
0060 
0061   //! Returns input shape
0062   const TopoDS_Shape& GetShape() const { return myShape; }
0063 
0064   //! Returns deviation between input geometry entity and analytical entity
0065   Standard_Real GetGap() const { return myGap; }
0066 
0067   //! Returns status of operation.
0068   //! Current meaning of possible values of status:
0069   //! -1 - algorithm is not initalazed by shape
0070   //!  0 - no errors
0071   //!  1 - error during any operation (usually - because of wrong input data)
0072   //! Any operation (calling any methods like IsPlane(...), ...) can be performed
0073   //! when current staue is equal 0.
0074   //! If after any operation status != 0, it is necessary to set it 0 by method ClearStatus()
0075   //! before calling other operation.
0076   Standard_Integer GetStatus() const { return myStatus; }
0077 
0078   //! Returns status to be equal 0.
0079   void ClearStatus() { myStatus = 0; }
0080 
0081   //! Returns true if the underlined surface can be represent by plane with tolerance theTol
0082   //! and sets in thePln the result plane.
0083   Standard_EXPORT Standard_Boolean IsPlane(const Standard_Real theTol, gp_Pln& thePln);
0084 
0085   //! Returns true if the underlined surface can be represent by cylindrical one with tolerance
0086   //! theTol and sets in theCyl the result cylinrical surface.
0087   Standard_EXPORT Standard_Boolean IsCylinder(const Standard_Real theTol, gp_Cylinder& theCyl);
0088 
0089   //! Returns true if the underlined surface can be represent by conical one with tolerance theTol
0090   //! and sets in theCone the result conical surface.
0091   Standard_EXPORT Standard_Boolean IsCone(const Standard_Real theTol, gp_Cone& theCone);
0092 
0093   //! Returns true if the underlined surface can be represent by spherical one with tolerance theTol
0094   //! and sets in theSphere the result spherical surface.
0095   Standard_EXPORT Standard_Boolean IsSphere(const Standard_Real theTol, gp_Sphere& theSphere);
0096 
0097   //! Returns true if the underlined curve can be represent by line with tolerance theTol
0098   //! and sets in theLin the result line.
0099   Standard_EXPORT Standard_Boolean IsLine(const Standard_Real theTol, gp_Lin& theLin);
0100 
0101   //! Returns true if the underlined curve can be represent by circle with tolerance theTol
0102   //! and sets in theCirc the result circle.
0103   Standard_EXPORT Standard_Boolean IsCircle(const Standard_Real theTol, gp_Circ& theCirc);
0104 
0105   //! Returns true if the underlined curve can be represent by ellipse with tolerance theTol
0106   //! and sets in theCirc the result ellipse.
0107   Standard_EXPORT Standard_Boolean IsEllipse(const Standard_Real theTol, gp_Elips& theElips);
0108 
0109 private:
0110   Standard_Boolean IsElementarySurf(const GeomAbs_SurfaceType theTarget,
0111                                     const Standard_Real       theTol,
0112                                     gp_Ax3&                   thePos,
0113                                     TColStd_Array1OfReal&     theParams);
0114 
0115   Standard_Boolean IsConic(const GeomAbs_CurveType theTarget,
0116                            const Standard_Real     theTol,
0117                            gp_Ax2&                 thePos,
0118                            TColStd_Array1OfReal&   theParams);
0119 
0120   static Handle(Geom_Surface) GetSurface(const TopoDS_Face&         theFace,
0121                                          const Standard_Real        theTol,
0122                                          const GeomConvert_ConvType theType,
0123                                          const GeomAbs_SurfaceType  theTarget,
0124                                          Standard_Real&             theGap,
0125                                          Standard_Integer&          theStatus);
0126 
0127   static Handle(Geom_Surface) GetSurface(const TopoDS_Shell&        theShell,
0128                                          const Standard_Real        theTol,
0129                                          const GeomConvert_ConvType theType,
0130                                          const GeomAbs_SurfaceType  theTarget,
0131                                          Standard_Real&             theGap,
0132                                          Standard_Integer&          theStatus);
0133 
0134   static Handle(Geom_Surface) GetSurface(const TopoDS_Edge&         theEdge,
0135                                          const Standard_Real        theTol,
0136                                          const GeomConvert_ConvType theType,
0137                                          const GeomAbs_SurfaceType  theTarget,
0138                                          gp_Ax3&                    thePos,
0139                                          TColStd_Array1OfReal&      theParams,
0140                                          Standard_Real&             theGap,
0141                                          Standard_Integer&          theStatus);
0142 
0143   static Handle(Geom_Surface) GetSurface(const TopoDS_Wire&         theWire,
0144                                          const Standard_Real        theTol,
0145                                          const GeomConvert_ConvType theType,
0146                                          const GeomAbs_SurfaceType  theTarget,
0147                                          gp_Ax3&                    thePos,
0148                                          TColStd_Array1OfReal&      theParams,
0149                                          Standard_Real&             theGap,
0150                                          Standard_Integer&          theStatus);
0151 
0152   static Handle(Geom_Curve) GetCurve(const TopoDS_Edge&         theEdge,
0153                                      const Standard_Real        theTol,
0154                                      const GeomConvert_ConvType theType,
0155                                      const GeomAbs_CurveType    theTarget,
0156                                      Standard_Real&             theGap,
0157                                      Standard_Integer&          theStatus);
0158 
0159   static Standard_Boolean GetSurfaceByLS(const TopoDS_Wire&        theWire,
0160                                          const Standard_Real       theTol,
0161                                          const GeomAbs_SurfaceType theTarget,
0162                                          gp_Ax3&                   thePos,
0163                                          TColStd_Array1OfReal&     theParams,
0164                                          Standard_Real&            theGap,
0165                                          Standard_Integer&         theStatus);
0166 
0167   void Init(const TopoDS_Shape& theShape);
0168 
0169 private:
0170   TopoDS_Shape     myShape;
0171   TopAbs_ShapeEnum mySType;
0172   Standard_Real    myGap;
0173   Standard_Integer myStatus;
0174 };
0175 
0176 #endif // _ShapeAnalysis_CanonicalRecognition_HeaderFile