Commit | Line | Data |
---|---|---|
973c2be1 | 1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
92d1589b | 2 | // |
973c2be1 | 3 | // This file is part of Open CASCADE Technology software library. |
92d1589b | 4 | // |
d5f74e42 | 5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
9 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 10 | // |
973c2be1 | 11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. | |
92d1589b A |
13 | |
14 | #ifndef _BRepExtrema_DistShapeShape_HeaderFile | |
15 | #define _BRepExtrema_DistShapeShape_HeaderFile | |
16 | ||
0f05f211 | 17 | #include <Bnd_Array1OfBox.hxx> |
92d1589b | 18 | #include <BRepExtrema_SeqOfSolution.hxx> |
92d1589b | 19 | #include <BRepExtrema_SolutionElem.hxx> |
92d1589b | 20 | #include <BRepExtrema_SupportType.hxx> |
762b6cec | 21 | #include <Extrema_ExtAlgo.hxx> |
22 | #include <Extrema_ExtFlag.hxx> | |
92d1589b | 23 | #include <gp_Pnt.hxx> |
82bee162 | 24 | #include <Message_ProgressRange.hxx> |
762b6cec | 25 | #include <TopoDS_Shape.hxx> |
26 | #include <TopTools_IndexedMapOfShape.hxx> | |
ebc93ae7 | 27 | #include <Standard_OStream.hxx> |
28 | #include <Standard_DefineAlloc.hxx> | |
b7c077b9 | 29 | #include <TopTools_IndexedMapOfShape.hxx> |
92d1589b | 30 | |
0f05f211 | 31 | //! This class provides tools to compute minimum distance |
32 | //! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). | |
92d1589b A |
33 | class BRepExtrema_DistShapeShape |
34 | { | |
35 | public: | |
36 | ||
1c35b92f | 37 | DEFINE_STANDARD_ALLOC |
92d1589b | 38 | |
0f05f211 | 39 | //! create empty tool |
92d1589b | 40 | Standard_EXPORT BRepExtrema_DistShapeShape(); |
0f05f211 | 41 | |
42 | //! create tool and computation of the minimum distance (value and pair of points) | |
43 | //! using default deflection in single thread mode. <br> | |
44 | //! Default deflection value is Precision::Confusion(). <br> | |
45 | //! @param Shape1 - the first shape for distance computation | |
46 | //! @param Shape2 - the second shape for distance computation | |
47 | //! @param F and @param A are not used in computation and are obsolete. | |
48 | //! @param theRange - the progress indicator of algorithm | |
82bee162 | 49 | Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1, |
50 | const TopoDS_Shape& Shape2, | |
51 | const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, | |
52 | const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad, | |
53 | const Message_ProgressRange& theRange = Message_ProgressRange()); | |
0f05f211 | 54 | //! create tool and computation of the minimum distance |
55 | //! (value and pair of points) in single thread mode. <br> | |
56 | //! Default deflection value is Precision::Confusion(). <br> | |
57 | //! @param Shape1 - the first shape for distance computation | |
58 | //! @param Shape2 - the second shape for distance computation | |
59 | //! @param theDeflection - the presition of distance computation | |
60 | //! @param F and @param A are not used in computation and are obsolete. | |
61 | //! @param theRange - the progress indicator of algorithm | |
82bee162 | 62 | Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1, |
63 | const TopoDS_Shape& Shape2, | |
64 | const Standard_Real theDeflection, | |
65 | const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX, | |
66 | const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad, | |
67 | const Message_ProgressRange& theRange = Message_ProgressRange()); | |
92d1589b | 68 | |
0f05f211 | 69 | //! Sets deflection to computation of the minimum distance <br> |
be5c3602 | 70 | void SetDeflection(const Standard_Real theDeflection) |
92d1589b A |
71 | { |
72 | myEps = theDeflection; | |
73 | } | |
0f05f211 | 74 | |
92d1589b A |
75 | //! load first shape into extrema <br> |
76 | Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1); | |
0f05f211 | 77 | |
92d1589b A |
78 | //! load second shape into extrema <br> |
79 | Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1); | |
0f05f211 | 80 | |
92d1589b A |
81 | //! computation of the minimum distance (value and <br> |
82 | //! couple of points). Parameter theDeflection is used <br> | |
83 | //! to specify a maximum deviation of extreme distances <br> | |
84 | //! from the minimum one. <br> | |
85 | //! Returns IsDone status. <br> | |
0f05f211 | 86 | //! theRange - the progress indicator of algorithm |
82bee162 | 87 | Standard_EXPORT Standard_Boolean Perform(const Message_ProgressRange& theRange = Message_ProgressRange()); |
0f05f211 | 88 | |
92d1589b | 89 | //! True if the minimum distance is found. <br> |
be5c3602 | 90 | Standard_Boolean IsDone() const |
92d1589b A |
91 | { |
92 | return myIsDone; | |
93 | } | |
0f05f211 | 94 | |
92d1589b | 95 | //! Returns the number of solutions satisfying the minimum distance. <br> |
be5c3602 | 96 | Standard_Integer NbSolution() const |
92d1589b A |
97 | { |
98 | return mySolutionsShape1.Length(); | |
99 | } | |
0f05f211 | 100 | |
92d1589b A |
101 | //! Returns the value of the minimum distance. <br> |
102 | Standard_EXPORT Standard_Real Value() const; | |
0f05f211 | 103 | |
92d1589b A |
104 | //! True if one of the shapes is a solid and the other shape <br> |
105 | //! is completely or partially inside the solid. <br> | |
be5c3602 | 106 | Standard_Boolean InnerSolution() const |
92d1589b A |
107 | { |
108 | return myInnerSol; | |
109 | } | |
0f05f211 | 110 | |
92d1589b | 111 | //! Returns the Point corresponding to the <N>th solution on the first Shape <br> |
be5c3602 | 112 | const gp_Pnt & PointOnShape1(const Standard_Integer N) const |
92d1589b A |
113 | { |
114 | return mySolutionsShape1.Value(N).Point(); | |
115 | } | |
0f05f211 | 116 | |
92d1589b | 117 | //! Returns the Point corresponding to the <N>th solution on the second Shape <br> |
be5c3602 | 118 | const gp_Pnt & PointOnShape2(const Standard_Integer N) const |
92d1589b A |
119 | { |
120 | return mySolutionsShape2.Value(N).Point(); | |
121 | } | |
0f05f211 | 122 | |
92d1589b A |
123 | //! gives the type of the support where the Nth solution on the first shape is situated: <br> |
124 | //! IsVertex => the Nth solution on the first shape is a Vertex <br> | |
125 | //! IsOnEdge => the Nth soluion on the first shape is on a Edge <br> | |
126 | //! IsInFace => the Nth solution on the first shape is inside a face <br> | |
127 | //! the corresponding support is obtained by the method SupportOnShape1 <br> | |
be5c3602 | 128 | BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const |
92d1589b A |
129 | { |
130 | return mySolutionsShape1.Value(N).SupportKind(); | |
131 | } | |
0f05f211 | 132 | |
92d1589b A |
133 | //! gives the type of the support where the Nth solution on the second shape is situated: <br> |
134 | //! IsVertex => the Nth solution on the second shape is a Vertex <br> | |
135 | //! IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br> | |
136 | //! IsInFace => the Nth solution on the second shape is inside a face <br> | |
137 | //! the corresponding support is obtained by the method SupportOnShape2 <br> | |
be5c3602 | 138 | BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const |
92d1589b A |
139 | { |
140 | return mySolutionsShape2.Value(N).SupportKind(); | |
141 | } | |
0f05f211 | 142 | |
92d1589b A |
143 | //! gives the support where the Nth solution on the first shape is situated. <br> |
144 | //! This support can be a Vertex, an Edge or a Face. <br> | |
145 | Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const; | |
0f05f211 | 146 | |
92d1589b A |
147 | //! gives the support where the Nth solution on the second shape is situated. <br> |
148 | //! This support can be a Vertex, an Edge or a Face. <br> | |
149 | Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const; | |
0f05f211 | 150 | |
92d1589b | 151 | //! gives the corresponding parameter t if the Nth solution <br> |
316ea293 | 152 | //! is situated on an Edge of the first shape <br> |
92d1589b | 153 | Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const; |
0f05f211 | 154 | |
92d1589b | 155 | //! gives the corresponding parameter t if the Nth solution <br> |
316ea293 | 156 | //! is situated on an Edge of the first shape <br> |
92d1589b | 157 | Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const; |
0f05f211 | 158 | |
92d1589b A |
159 | //! gives the corresponding parameters (U,V) if the Nth solution <br> |
160 | //! is situated on an face of the first shape <br> | |
161 | Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const; | |
0f05f211 | 162 | |
92d1589b A |
163 | //! gives the corresponding parameters (U,V) if the Nth solution <br> |
164 | //! is situated on an Face of the second shape <br> | |
165 | Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const; | |
0f05f211 | 166 | |
92d1589b A |
167 | //! Prints on the stream o information on the current state of the object. <br> |
168 | Standard_EXPORT void Dump(Standard_OStream& o) const; | |
169 | ||
0f05f211 | 170 | //! Sets unused parameter |
171 | //! Obsolete | |
be5c3602 | 172 | void SetFlag(const Extrema_ExtFlag F) |
92d1589b A |
173 | { |
174 | myFlag = F; | |
175 | } | |
176 | ||
0f05f211 | 177 | //! Sets unused parameter |
178 | //! Obsolete | |
be5c3602 | 179 | void SetAlgo(const Extrema_ExtAlgo A) |
92d1589b A |
180 | { |
181 | myAlgo = A; | |
182 | } | |
183 | ||
0f05f211 | 184 | //! If isMultiThread == Standard_True then computation will be performed in parallel. |
185 | void SetMultiThread(Standard_Boolean theIsMultiThread) | |
186 | { | |
187 | myIsMultiThread = theIsMultiThread; | |
188 | } | |
189 | ||
190 | //! Returns Standard_True then computation will be performed in parallel | |
191 | //! Default value is Standard_False | |
192 | Standard_Boolean IsMultiThread() const | |
193 | { | |
194 | return myIsMultiThread; | |
195 | } | |
196 | ||
92d1589b A |
197 | private: |
198 | ||
199 | //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br> | |
82bee162 | 200 | Standard_Boolean DistanceMapMap(const TopTools_IndexedMapOfShape& Map1, |
201 | const TopTools_IndexedMapOfShape& Map2, | |
0f05f211 | 202 | const Bnd_Array1OfBox& LBox1, |
203 | const Bnd_Array1OfBox& LBox2, | |
82bee162 | 204 | const Message_ProgressRange& theRange); |
205 | ||
92c1f972 | 206 | //! computes the minimum distance between two maps of vertices <br> |
207 | Standard_Boolean DistanceVertVert(const TopTools_IndexedMapOfShape& theMap1, | |
208 | const TopTools_IndexedMapOfShape& theMap2, | |
209 | const Message_ProgressRange& theRange); | |
210 | ||
82bee162 | 211 | Standard_Boolean SolidTreatment(const TopoDS_Shape& theShape, |
212 | const TopTools_IndexedMapOfShape& theMap, | |
213 | const Message_ProgressRange& theRange); | |
214 | ||
215 | private: | |
92d1589b A |
216 | |
217 | Standard_Real myDistRef; | |
92d1589b A |
218 | Standard_Boolean myIsDone; |
219 | BRepExtrema_SeqOfSolution mySolutionsShape1; | |
220 | BRepExtrema_SeqOfSolution mySolutionsShape2; | |
221 | Standard_Boolean myInnerSol; | |
222 | Standard_Real myEps; | |
223 | TopoDS_Shape myShape1; | |
224 | TopoDS_Shape myShape2; | |
225 | TopTools_IndexedMapOfShape myMapV1; | |
226 | TopTools_IndexedMapOfShape myMapV2; | |
227 | TopTools_IndexedMapOfShape myMapE1; | |
228 | TopTools_IndexedMapOfShape myMapE2; | |
229 | TopTools_IndexedMapOfShape myMapF1; | |
230 | TopTools_IndexedMapOfShape myMapF2; | |
762b6cec | 231 | Standard_Boolean myIsInitS1; |
232 | Standard_Boolean myIsInitS2; | |
92d1589b A |
233 | Extrema_ExtFlag myFlag; |
234 | Extrema_ExtAlgo myAlgo; | |
0f05f211 | 235 | Bnd_Array1OfBox myBV1; |
236 | Bnd_Array1OfBox myBV2; | |
237 | Bnd_Array1OfBox myBE1; | |
238 | Bnd_Array1OfBox myBE2; | |
239 | Bnd_Array1OfBox myBF1; | |
240 | Bnd_Array1OfBox myBF2; | |
241 | Standard_Boolean myIsMultiThread; | |
92d1589b A |
242 | }; |
243 | ||
244 | #endif |