Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:10

0001 // Created on: 2014-10-20
0002 // Created by: Denis BOGOLEPOV
0003 // Copyright (c) 2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _BRepExtrema_ShapeProximity_HeaderFile
0017 #define _BRepExtrema_ShapeProximity_HeaderFile
0018 
0019 #include <NCollection_DataMap.hxx>
0020 #include <Precision.hxx>
0021 #include <TColStd_PackedMapOfInteger.hxx>
0022 
0023 #include <BRepExtrema_ProximityValueTool.hxx>
0024 #include <BRepExtrema_TriangleSet.hxx>
0025 #include <BRepExtrema_OverlapTool.hxx>
0026 
0027 //! @brief Tool class for shape proximity detection.
0028 //!
0029 //! First approach:
0030 //! For two given shapes and given tolerance (offset from the mesh) the algorithm allows
0031 //! to determine whether or not they are overlapped. The algorithm input consists of any
0032 //! shapes which can be decomposed into individual faces (used as basic shape elements).
0033 //!
0034 //! The algorithm can be run in two modes. If tolerance is set to zero, the algorithm
0035 //! will detect only intersecting faces (containing triangles with common points). If
0036 //! tolerance is set to positive value, the algorithm will also detect faces located
0037 //! on distance less than the given tolerance from each other.
0038 //!
0039 //! Second approach:
0040 //! Compute the proximity value between two shapes (handles only edge/edge or face/face cases)
0041 //! if the tolerance is not defined (Precision::Infinite()).
0042 //! In this case the proximity value is a minimal thickness of a layer containing both shapes.
0043 //!
0044 //! For the both approaches the high performance is achieved through the use of existing
0045 //! triangulation of faces. So, poly triangulation (with the desired deflection) should already
0046 //! be built. Note that solution is approximate (and corresponds to the deflection used for
0047 //! triangulation).
0048 class BRepExtrema_ShapeProximity
0049 {
0050 
0051 public:
0052 
0053   //! Creates empty proximity tool.
0054   Standard_EXPORT BRepExtrema_ShapeProximity (const Standard_Real theTolerance = Precision::Infinite());
0055 
0056   //! Creates proximity tool for the given two shapes.
0057   Standard_EXPORT BRepExtrema_ShapeProximity (const TopoDS_Shape& theShape1,
0058                                               const TopoDS_Shape& theShape2,
0059                                               const Standard_Real theTolerance = Precision::Infinite());
0060 
0061 public:
0062 
0063   //! Returns tolerance value for overlap test (distance between shapes).
0064   Standard_Real Tolerance() const
0065   {
0066     return myTolerance;
0067   }
0068 
0069   //! Sets tolerance value for overlap test (distance between shapes).
0070   void SetTolerance (const Standard_Real theTolerance)
0071   {
0072     myTolerance = theTolerance;
0073   }
0074 
0075   //! Returns proximity value calculated for the whole input shapes.
0076   Standard_Real Proximity() const
0077   {
0078     return Tolerance();
0079   }
0080 
0081   //! Loads 1st shape into proximity tool.
0082   Standard_EXPORT Standard_Boolean LoadShape1 (const TopoDS_Shape& theShape1);
0083 
0084   //! Loads 2nd shape into proximity tool.
0085   Standard_EXPORT Standard_Boolean LoadShape2 (const TopoDS_Shape& theShape2);
0086 
0087   //! Set number of sample points on the 1st shape used to compute the proximity value.
0088   //! In case of 0, all triangulation nodes will be used.
0089   void SetNbSamples1(const Standard_Integer theNbSamples) { myNbSamples1 = theNbSamples; }
0090 
0091   //! Set number of sample points on the 2nd shape used to compute the proximity value.
0092   //! In case of 0, all triangulation nodes will be used.
0093   void SetNbSamples2(const Standard_Integer theNbSamples) { myNbSamples2 = theNbSamples; }
0094 
0095   //! Performs search of overlapped faces.
0096   Standard_EXPORT void Perform();
0097 
0098   //! True if the search is completed.
0099   Standard_Boolean IsDone() const
0100   { 
0101     return myOverlapTool.IsDone() || myProxValTool.IsDone();
0102   }
0103 
0104   //! Returns set of IDs of overlapped faces of 1st shape (started from 0).
0105   const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes1() const
0106   {
0107     return myOverlapTool.OverlapSubShapes1();
0108   }
0109 
0110   //! Returns set of IDs of overlapped faces of 2nd shape (started from 0).
0111   const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes2() const
0112   {
0113     return myOverlapTool.OverlapSubShapes2();
0114   }
0115 
0116   //! Returns sub-shape from 1st shape with the given index (started from 0).
0117   const TopoDS_Shape& GetSubShape1 (const Standard_Integer theID) const
0118   {
0119     return myShapeList1.Value (theID);
0120   }
0121 
0122   //! Returns sub-shape from 1st shape with the given index (started from 0).
0123   const TopoDS_Shape& GetSubShape2 (const Standard_Integer theID) const
0124   {
0125     return myShapeList2.Value (theID);
0126   }
0127 
0128   //! Returns set of all the face triangles of the 1st shape.
0129   const Handle(BRepExtrema_TriangleSet)& ElementSet1() const
0130   {
0131     return myElementSet1;
0132   }
0133 
0134   //! Returns set of all the face triangles of the 2nd shape.
0135   const Handle(BRepExtrema_TriangleSet)& ElementSet2() const
0136   {
0137     return myElementSet2;
0138   }
0139 
0140   //! Returns the point on the 1st shape, which could be used as a reference point
0141   //! for the value of the proximity.
0142   const gp_Pnt& ProximityPoint1() const
0143   {
0144     return myProxPoint1;
0145   }
0146 
0147   //! Returns the point on the 2nd shape, which could be used as a reference point
0148   //! for the value of the proximity.
0149   const gp_Pnt& ProximityPoint2() const
0150   {
0151     return myProxPoint2;
0152   }
0153 
0154   //! Returns the status of point on the 1st shape, which could be used as a reference point
0155   //! for the value of the proximity.
0156   const ProxPnt_Status& ProxPntStatus1() const
0157   {
0158     return myProxPntStatus1;
0159   }
0160 
0161   //! Returns the status of point on the 2nd shape, which could be used as a reference point
0162   //! for the value of the proximity.
0163   const ProxPnt_Status& ProxPntStatus2() const
0164   {
0165     return myProxPntStatus2;
0166   }
0167 
0168 private:
0169 
0170   //! Maximum overlapping distance.
0171   Standard_Real myTolerance;
0172 
0173   //! Is the 1st shape initialized?
0174   Standard_Boolean myIsInitS1;
0175   //! Is the 2nd shape initialized?
0176   Standard_Boolean myIsInitS2;
0177 
0178   //! List of subshapes of the 1st shape.
0179   BRepExtrema_ShapeList myShapeList1;
0180   //! List of subshapes of the 2nd shape.
0181   BRepExtrema_ShapeList myShapeList2;
0182 
0183   //! Set of all the face triangles of the 1st shape.
0184   Handle(BRepExtrema_TriangleSet) myElementSet1;
0185   //! Set of all the face triangles of the 2nd shape.
0186   Handle(BRepExtrema_TriangleSet) myElementSet2;
0187 
0188   //! Number of sample points on the 1st shape used to compute the proximity value
0189   //! (if zero (default), all triangulation nodes will be used).
0190   Standard_Integer myNbSamples1;
0191   //! Number of sample points on the 2nd shape used to compute the proximity value
0192   //! (if zero (default), all triangulation nodes will be used).
0193   Standard_Integer myNbSamples2;
0194 
0195   //! Reference point of the proximity value on the 1st shape.
0196   gp_Pnt myProxPoint1;
0197   //! Reference point of the proximity value on the 2st shape.
0198   gp_Pnt myProxPoint2;
0199 
0200   //! Status of reference points of the proximity value.
0201   ProxPnt_Status myProxPntStatus1, myProxPntStatus2;
0202 
0203   //! Overlap tool used for intersection/overlap test.
0204   BRepExtrema_OverlapTool myOverlapTool;
0205 
0206   //! Shape-shape proximity tool used for computation of
0207   //! the minimal diameter of a tube containing both edges or
0208   //! the minimal thickness of a shell containing both faces.
0209   BRepExtrema_ProximityValueTool myProxValTool;
0210 
0211 };
0212 
0213 #endif // _BRepExtrema_ShapeProximity_HeaderFile