0022689: Infinite loop in BRepExtrema_DistanceSS, in static function TRIM_INFINIT_FACE
[occt.git] / src / BRepExtrema / BRepExtrema_DistShapeShape.hxx
CommitLineData
92d1589b
A
1// File generated by CPPExt (Value)
2//
3// Copyright (C) 1991 - 2000 by
4// Matra Datavision SA. All rights reserved.
5//
6// Copyright (C) 2001 - 2004 by
7// Open CASCADE SA. All rights reserved.
8//
9// This file is part of the Open CASCADE Technology software.
10//
11// This software may be distributed and/or modified under the terms and
12// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
13// and appearing in the file LICENSE included in the packaging of this file.
14//
15// This software is distributed on an "AS IS" basis, without warranty of any
16// kind, and Open CASCADE SA hereby disclaims all such warranties,
17// including without limitation, any warranties of merchantability, fitness
18// for a particular purpose or non-infringement. Please see the License for
19// the specific terms and conditions governing rights and limitations under the
20// License.
21
22#ifndef _BRepExtrema_DistShapeShape_HeaderFile
23#define _BRepExtrema_DistShapeShape_HeaderFile
24
25#ifndef _Standard_HeaderFile
26#include <Standard.hxx>
27#endif
28#ifndef _Standard_Macro_HeaderFile
29#include <Standard_Macro.hxx>
30#endif
31
32#ifndef _Standard_Integer_HeaderFile
33#include <Standard_Integer.hxx>
34#endif
35#ifndef _Standard_Real_HeaderFile
36#include <Standard_Real.hxx>
37#endif
38#ifndef _Standard_Boolean_HeaderFile
39#include <Standard_Boolean.hxx>
40#endif
41#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
42#include <BRepExtrema_SeqOfSolution.hxx>
43#endif
44#ifndef _BRepExtrema_SolutionElem_HeaderFile
45#include <BRepExtrema_SolutionElem.hxx>
46#endif
47#ifndef _TopoDS_Shape_HeaderFile
48#include <TopoDS_Shape.hxx>
49#endif
50#ifndef _TopTools_IndexedMapOfShape_HeaderFile
51#include <TopTools_IndexedMapOfShape.hxx>
52#endif
53#ifndef _Extrema_ExtFlag_HeaderFile
54#include <Extrema_ExtFlag.hxx>
55#endif
56#ifndef _Extrema_ExtAlgo_HeaderFile
57#include <Extrema_ExtAlgo.hxx>
58#endif
59#ifndef _BRepExtrema_SupportType_HeaderFile
60#include <BRepExtrema_SupportType.hxx>
61#endif
62#ifndef _Standard_OStream_HeaderFile
63#include <Standard_OStream.hxx>
64#endif
65#ifndef _gp_Pnt_HeaderFile
66#include <gp_Pnt.hxx>
67#endif
68class TopoDS_Shape;
69class TopTools_IndexedMapOfShape;
70class Bnd_SeqOfBox;
71
72
73//! This class provides tools to compute minimum distance <br>
74//! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
75class BRepExtrema_DistShapeShape
76{
77 public:
78
79 void* operator new(size_t,void* anAddress)
80 {
81 return anAddress;
82 }
83 void* operator new(size_t size)
84 {
85 return Standard::Allocate(size);
86 }
87 void operator delete(void *anAddress)
88 {
89 if (anAddress) Standard::Free((Standard_Address&)anAddress);
90 }
91
92 //! create empty tool <br>
93 Standard_EXPORT BRepExtrema_DistShapeShape();
94 //! computation of the minimum distance (value and pair of points) using default deflection <br>
95 //! Default value is Precision::Confusion(). <br>
96 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);
97 //! create tool and load both shapes into it <br>
98 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);
99
100 Standard_EXPORT void SetDeflection(const Standard_Real theDeflection)
101 {
102 myEps = theDeflection;
103 }
104 //! load first shape into extrema <br>
105 Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
106 //! load second shape into extrema <br>
107 Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
108 //! computation of the minimum distance (value and <br>
109 //! couple of points). Parameter theDeflection is used <br>
110 //! to specify a maximum deviation of extreme distances <br>
111 //! from the minimum one. <br>
112 //! Returns IsDone status. <br>
113 Standard_EXPORT Standard_Boolean Perform();
114 //! True if the minimum distance is found. <br>
115 Standard_EXPORT Standard_Boolean IsDone() const
116 {
117 return myIsDone;
118 }
119 //! Returns the number of solutions satisfying the minimum distance. <br>
120 Standard_EXPORT Standard_Integer NbSolution() const
121 {
122 return mySolutionsShape1.Length();
123 }
124 //! Returns the value of the minimum distance. <br>
125 Standard_EXPORT Standard_Real Value() const;
126 //! True if one of the shapes is a solid and the other shape <br>
127 //! is completely or partially inside the solid. <br>
128 Standard_EXPORT Standard_Boolean InnerSolution() const
129 {
130 return myInnerSol;
131 }
132 //! Returns the Point corresponding to the <N>th solution on the first Shape <br>
133 Standard_EXPORT const gp_Pnt & PointOnShape1(const Standard_Integer N) const
134 {
135 return mySolutionsShape1.Value(N).Point();
136 }
137 //! Returns the Point corresponding to the <N>th solution on the second Shape <br>
138 Standard_EXPORT const gp_Pnt & PointOnShape2(const Standard_Integer N) const
139 {
140 return mySolutionsShape2.Value(N).Point();
141 }
142 //! gives the type of the support where the Nth solution on the first shape is situated: <br>
143 //! IsVertex => the Nth solution on the first shape is a Vertex <br>
144 //! IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
145 //! IsInFace => the Nth solution on the first shape is inside a face <br>
146 //! the corresponding support is obtained by the method SupportOnShape1 <br>
147 Standard_EXPORT BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
148 {
149 return mySolutionsShape1.Value(N).SupportKind();
150 }
151 //! gives the type of the support where the Nth solution on the second shape is situated: <br>
152 //! IsVertex => the Nth solution on the second shape is a Vertex <br>
153 //! IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
154 //! IsInFace => the Nth solution on the second shape is inside a face <br>
155 //! the corresponding support is obtained by the method SupportOnShape2 <br>
156 Standard_EXPORT BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
157 {
158 return mySolutionsShape2.Value(N).SupportKind();
159 }
160 //! gives the support where the Nth solution on the first shape is situated. <br>
161 //! This support can be a Vertex, an Edge or a Face. <br>
162 Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
163 //! gives the support where the Nth solution on the second shape is situated. <br>
164 //! This support can be a Vertex, an Edge or a Face. <br>
165 Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const;
166 //! gives the corresponding parameter t if the Nth solution <br>
167 //! is situated on an Egde of the first shape <br>
168 Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
169 //! gives the corresponding parameter t if the Nth solution <br>
170 //! is situated on an Egde of the first shape <br>
171 Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
172 //! gives the corresponding parameters (U,V) if the Nth solution <br>
173 //! is situated on an face of the first shape <br>
174 Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
175 //! gives the corresponding parameters (U,V) if the Nth solution <br>
176 //! is situated on an Face of the second shape <br>
177 Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
178 //! Prints on the stream o information on the current state of the object. <br>
179 Standard_EXPORT void Dump(Standard_OStream& o) const;
180
181 Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
182 {
183 myFlag = F;
184 }
185
186 Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
187 {
188 myAlgo = A;
189 }
190
191private:
192
193 //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
194 Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2);
195
196 Standard_Real myDistRef;
197 Standard_Real myDistValue;
198 Standard_Boolean myIsDone;
199 BRepExtrema_SeqOfSolution mySolutionsShape1;
200 BRepExtrema_SeqOfSolution mySolutionsShape2;
201 Standard_Boolean myInnerSol;
202 Standard_Real myEps;
203 TopoDS_Shape myShape1;
204 TopoDS_Shape myShape2;
205 TopTools_IndexedMapOfShape myMapV1;
206 TopTools_IndexedMapOfShape myMapV2;
207 TopTools_IndexedMapOfShape myMapE1;
208 TopTools_IndexedMapOfShape myMapE2;
209 TopTools_IndexedMapOfShape myMapF1;
210 TopTools_IndexedMapOfShape myMapF2;
211 Extrema_ExtFlag myFlag;
212 Extrema_ExtAlgo myAlgo;
213};
214
215#endif