0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / BRepExtrema / BRepExtrema_ShapeProximity.hxx
1 // Created on: 2014-10-20
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _BRepExtrema_ShapeProximity_HeaderFile
17 #define _BRepExtrema_ShapeProximity_HeaderFile
18
19 #include <BVH_Geometry.hxx>
20 #include <NCollection_DataMap.hxx>
21 #include <TColStd_PackedMapOfInteger.hxx>
22
23 #include <BRepExtrema_TriangleSet.hxx>
24 #include <BRepExtrema_OverlapTool.hxx>
25
26 //! Tool class for shape proximity detection.
27 //! For two given shapes and given tolerance (offset from the mesh) the algorithm allows
28 //! to determine whether or not they are overlapped. The algorithm input consists of any
29 //! shapes which can be decomposed into individual faces (used as basic shape elements).
30 //! High performance is achieved through the use of existing triangulation of faces. So
31 //! poly triangulation (with the desired deflection) should already be built. Note that
32 //! solution is approximate (and corresponds to the deflection used for triangulation).
33 //!
34 //! The algorithm can be run in two modes. If tolerance is set to zero, the algorithm
35 //! will detect only intersecting faces (containing triangles with common points). If
36 //! tolerance is set to positive value, the algorithm will also detect faces located
37 //! on distance less than the given tolerance from each other.
38 class BRepExtrema_ShapeProximity
39 {
40 public:
41
42   //! Creates empty proximity tool.
43   Standard_EXPORT BRepExtrema_ShapeProximity (const Standard_Real theTolerance = 0.0);
44
45   //! Creates proximity tool for the given two shapes.
46   Standard_EXPORT BRepExtrema_ShapeProximity (const TopoDS_Shape& theShape1,
47                                               const TopoDS_Shape& theShape2,
48                                               const Standard_Real theTolerance = 0.0);
49
50 public:
51
52   //! Returns tolerance value for overlap test (distance between shapes).
53   Standard_Real Tolerance() const
54   {
55     return myTolerance;
56   }
57
58   //! Sets tolerance value for overlap test (distance between shapes).
59   void SetTolerance (const Standard_Real theTolerance)
60   {
61     myTolerance = theTolerance;
62   }
63
64   //! Loads 1st shape into proximity tool.
65   Standard_EXPORT Standard_Boolean LoadShape1 (const TopoDS_Shape& theShape1);
66
67   //! Loads 2nd shape into proximity tool.
68   Standard_EXPORT Standard_Boolean LoadShape2 (const TopoDS_Shape& theShape2);
69
70   //! Performs search of overlapped faces.
71   Standard_EXPORT void Perform();
72
73   //! True if the search is completed.
74   Standard_Boolean IsDone() const
75   { 
76     return myOverlapTool.IsDone();
77   }
78
79   //! Returns set of IDs of overlapped faces of 1st shape (started from 0).
80   const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes1() const
81   {
82     return myOverlapTool.OverlapSubShapes1();
83   }
84
85   //! Returns set of IDs of overlapped faces of 2nd shape (started from 0).
86   const BRepExtrema_MapOfIntegerPackedMapOfInteger& OverlapSubShapes2() const
87   {
88     return myOverlapTool.OverlapSubShapes2();
89   }
90
91   //! Returns sub-shape from 1st shape with the given index (started from 0).
92   const TopoDS_Face& GetSubShape1 (const Standard_Integer theID) const
93   {
94     return myFaceList1.Value (theID);
95   }
96
97   //! Returns sub-shape from 1st shape with the given index (started from 0).
98   const TopoDS_Face& GetSubShape2 (const Standard_Integer theID) const
99   {
100     return myFaceList2.Value (theID);
101   }
102
103   //! Returns set of all the face triangles of the 1st shape.
104   const Handle(BRepExtrema_TriangleSet)& ElementSet1() const
105   {
106     return myElementSet1;
107   }
108
109   //! Returns set of all the face triangles of the 2nd shape.
110   const Handle(BRepExtrema_TriangleSet)& ElementSet2() const
111   {
112     return myElementSet2;
113   }
114
115 private:
116
117   //! Maximum overlapping distance.
118   Standard_Real myTolerance;
119
120   //! Is the 1st shape initialized?
121   Standard_Boolean myIsInitS1;
122   //! Is the 2nd shape initialized?
123   Standard_Boolean myIsInitS2;
124
125   //! List of faces of the 1st shape.
126   BRepExtrema_ShapeList myFaceList1;
127   //! List of faces of the 2nd shape.
128   BRepExtrema_ShapeList myFaceList2;
129
130   //! Set of all the face triangles of the 1st shape.
131   Handle(BRepExtrema_TriangleSet) myElementSet1;
132   //! Set of all the face triangles of the 2nd shape.
133   Handle(BRepExtrema_TriangleSet) myElementSet2;
134
135   //! Overlap tool used for intersection/overlap test.
136   BRepExtrema_OverlapTool myOverlapTool;
137
138 };
139
140 #endif // _BRepExtrema_ShapeProximity_HeaderFile