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 | ||
762b6cec | 17 | #include <Bnd_SeqOfBox.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> |
762b6cec | 24 | #include <TopoDS_Shape.hxx> |
25 | #include <TopTools_IndexedMapOfShape.hxx> | |
ebc93ae7 | 26 | #include <Standard_OStream.hxx> |
27 | #include <Standard_DefineAlloc.hxx> | |
b7c077b9 | 28 | #include <TopTools_IndexedMapOfShape.hxx> |
92d1589b A |
29 | |
30 | //! This class provides tools to compute minimum distance <br> | |
31 | //! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br> | |
32 | class BRepExtrema_DistShapeShape | |
33 | { | |
34 | public: | |
35 | ||
1c35b92f | 36 | DEFINE_STANDARD_ALLOC |
92d1589b A |
37 | |
38 | //! create empty tool <br> | |
39 | Standard_EXPORT BRepExtrema_DistShapeShape(); | |
40 | //! computation of the minimum distance (value and pair of points) using default deflection <br> | |
41 | //! Default value is Precision::Confusion(). <br> | |
42 | Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad); | |
43 | //! create tool and load both shapes into it <br> | |
44 | Standard_EXPORT BRepExtrema_DistShapeShape(const TopoDS_Shape& Shape1,const TopoDS_Shape& Shape2,const Standard_Real theDeflection,const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad); | |
45 | ||
be5c3602 | 46 | void SetDeflection(const Standard_Real theDeflection) |
92d1589b A |
47 | { |
48 | myEps = theDeflection; | |
49 | } | |
50 | //! load first shape into extrema <br> | |
51 | Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1); | |
52 | //! load second shape into extrema <br> | |
53 | Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1); | |
54 | //! computation of the minimum distance (value and <br> | |
55 | //! couple of points). Parameter theDeflection is used <br> | |
56 | //! to specify a maximum deviation of extreme distances <br> | |
57 | //! from the minimum one. <br> | |
58 | //! Returns IsDone status. <br> | |
59 | Standard_EXPORT Standard_Boolean Perform(); | |
60 | //! True if the minimum distance is found. <br> | |
be5c3602 | 61 | Standard_Boolean IsDone() const |
92d1589b A |
62 | { |
63 | return myIsDone; | |
64 | } | |
65 | //! Returns the number of solutions satisfying the minimum distance. <br> | |
be5c3602 | 66 | Standard_Integer NbSolution() const |
92d1589b A |
67 | { |
68 | return mySolutionsShape1.Length(); | |
69 | } | |
70 | //! Returns the value of the minimum distance. <br> | |
71 | Standard_EXPORT Standard_Real Value() const; | |
72 | //! True if one of the shapes is a solid and the other shape <br> | |
73 | //! is completely or partially inside the solid. <br> | |
be5c3602 | 74 | Standard_Boolean InnerSolution() const |
92d1589b A |
75 | { |
76 | return myInnerSol; | |
77 | } | |
78 | //! Returns the Point corresponding to the <N>th solution on the first Shape <br> | |
be5c3602 | 79 | const gp_Pnt & PointOnShape1(const Standard_Integer N) const |
92d1589b A |
80 | { |
81 | return mySolutionsShape1.Value(N).Point(); | |
82 | } | |
83 | //! Returns the Point corresponding to the <N>th solution on the second Shape <br> | |
be5c3602 | 84 | const gp_Pnt & PointOnShape2(const Standard_Integer N) const |
92d1589b A |
85 | { |
86 | return mySolutionsShape2.Value(N).Point(); | |
87 | } | |
88 | //! gives the type of the support where the Nth solution on the first shape is situated: <br> | |
89 | //! IsVertex => the Nth solution on the first shape is a Vertex <br> | |
90 | //! IsOnEdge => the Nth soluion on the first shape is on a Edge <br> | |
91 | //! IsInFace => the Nth solution on the first shape is inside a face <br> | |
92 | //! the corresponding support is obtained by the method SupportOnShape1 <br> | |
be5c3602 | 93 | BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const |
92d1589b A |
94 | { |
95 | return mySolutionsShape1.Value(N).SupportKind(); | |
96 | } | |
97 | //! gives the type of the support where the Nth solution on the second shape is situated: <br> | |
98 | //! IsVertex => the Nth solution on the second shape is a Vertex <br> | |
99 | //! IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br> | |
100 | //! IsInFace => the Nth solution on the second shape is inside a face <br> | |
101 | //! the corresponding support is obtained by the method SupportOnShape2 <br> | |
be5c3602 | 102 | BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const |
92d1589b A |
103 | { |
104 | return mySolutionsShape2.Value(N).SupportKind(); | |
105 | } | |
106 | //! gives the support where the Nth solution on the first shape is situated. <br> | |
107 | //! This support can be a Vertex, an Edge or a Face. <br> | |
108 | Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const; | |
109 | //! gives the support where the Nth solution on the second shape is situated. <br> | |
110 | //! This support can be a Vertex, an Edge or a Face. <br> | |
111 | Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const; | |
112 | //! gives the corresponding parameter t if the Nth solution <br> | |
113 | //! is situated on an Egde of the first shape <br> | |
114 | Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const; | |
115 | //! gives the corresponding parameter t if the Nth solution <br> | |
116 | //! is situated on an Egde of the first shape <br> | |
117 | Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const; | |
118 | //! gives the corresponding parameters (U,V) if the Nth solution <br> | |
119 | //! is situated on an face of the first shape <br> | |
120 | Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const; | |
121 | //! gives the corresponding parameters (U,V) if the Nth solution <br> | |
122 | //! is situated on an Face of the second shape <br> | |
123 | Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const; | |
124 | //! Prints on the stream o information on the current state of the object. <br> | |
125 | Standard_EXPORT void Dump(Standard_OStream& o) const; | |
126 | ||
be5c3602 | 127 | void SetFlag(const Extrema_ExtFlag F) |
92d1589b A |
128 | { |
129 | myFlag = F; | |
130 | } | |
131 | ||
be5c3602 | 132 | void SetAlgo(const Extrema_ExtAlgo A) |
92d1589b A |
133 | { |
134 | myAlgo = A; | |
135 | } | |
136 | ||
137 | private: | |
138 | ||
139 | //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br> | |
140 | Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2); | |
141 | ||
142 | Standard_Real myDistRef; | |
92d1589b A |
143 | Standard_Boolean myIsDone; |
144 | BRepExtrema_SeqOfSolution mySolutionsShape1; | |
145 | BRepExtrema_SeqOfSolution mySolutionsShape2; | |
146 | Standard_Boolean myInnerSol; | |
147 | Standard_Real myEps; | |
148 | TopoDS_Shape myShape1; | |
149 | TopoDS_Shape myShape2; | |
150 | TopTools_IndexedMapOfShape myMapV1; | |
151 | TopTools_IndexedMapOfShape myMapV2; | |
152 | TopTools_IndexedMapOfShape myMapE1; | |
153 | TopTools_IndexedMapOfShape myMapE2; | |
154 | TopTools_IndexedMapOfShape myMapF1; | |
155 | TopTools_IndexedMapOfShape myMapF2; | |
762b6cec | 156 | Standard_Boolean myIsInitS1; |
157 | Standard_Boolean myIsInitS2; | |
92d1589b A |
158 | Extrema_ExtFlag myFlag; |
159 | Extrema_ExtAlgo myAlgo; | |
762b6cec | 160 | Bnd_SeqOfBox myBV1; |
161 | Bnd_SeqOfBox myBV2; | |
162 | Bnd_SeqOfBox myBE1; | |
163 | Bnd_SeqOfBox myBE2; | |
164 | Bnd_SeqOfBox myBF1; | |
165 | Bnd_SeqOfBox myBF2; | |
92d1589b A |
166 | }; |
167 | ||
168 | #endif |