Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:54

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