summaryrefslogtreecommitdiff
path: root/inc/BRepExtrema_DistShapeShape.hxx
blob: 119f81a9d0c6045c1f6ee56d08dda9cfdcf8b632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// File generated by CPPExt (Value)
//
//                     Copyright (C) 1991 - 2000 by  
//                      Matra Datavision SA.  All rights reserved.
//  
//                     Copyright (C) 2001 - 2004 by
//                     Open CASCADE SA.  All rights reserved.
// 
// This file is part of the Open CASCADE Technology software.
//
// This software may be distributed and/or modified under the terms and
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
// and appearing in the file LICENSE included in the packaging of this file.
//  
// This software is distributed on an "AS IS" basis, without warranty of any
// kind, and Open CASCADE SA hereby disclaims all such warranties,
// including without limitation, any warranties of merchantability, fitness
// for a particular purpose or non-infringement. Please see the License for
// the specific terms and conditions governing rights and limitations under the
// License.

#ifndef _BRepExtrema_DistShapeShape_HeaderFile
#define _BRepExtrema_DistShapeShape_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif
#ifndef _BRepExtrema_SeqOfSolution_HeaderFile
#include <BRepExtrema_SeqOfSolution.hxx>
#endif
#ifndef _BRepExtrema_SolutionElem_HeaderFile
#include <BRepExtrema_SolutionElem.hxx>
#endif
#ifndef _TopoDS_Shape_HeaderFile
#include <TopoDS_Shape.hxx>
#endif
#ifndef _TopTools_IndexedMapOfShape_HeaderFile
#include <TopTools_IndexedMapOfShape.hxx>
#endif
#ifndef _Extrema_ExtFlag_HeaderFile
#include <Extrema_ExtFlag.hxx>
#endif
#ifndef _Extrema_ExtAlgo_HeaderFile
#include <Extrema_ExtAlgo.hxx>
#endif
#ifndef _BRepExtrema_SupportType_HeaderFile
#include <BRepExtrema_SupportType.hxx>
#endif
#ifndef _Standard_OStream_HeaderFile
#include <Standard_OStream.hxx>
#endif
#ifndef _gp_Pnt_HeaderFile
#include <gp_Pnt.hxx>
#endif
class TopoDS_Shape;
class TopTools_IndexedMapOfShape;
class Bnd_SeqOfBox;


//! This class  provides tools to compute minimum distance <br>
//! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
class BRepExtrema_DistShapeShape
{
 public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! create empty tool <br>
  Standard_EXPORT BRepExtrema_DistShapeShape();
  //! computation of the minimum distance (value and pair of points) using default deflection <br>
  //! Default value is Precision::Confusion(). <br>
  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);
  //! create tool and load both shapes into it <br>
  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);
  
  Standard_EXPORT void SetDeflection(const Standard_Real theDeflection)
  {
    myEps = theDeflection;
  }
  //! load first shape into extrema <br>
  Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
  //! load second shape into extrema <br>
  Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
  //! computation of  the minimum  distance  (value  and <br>
  //!          couple  of points). Parameter theDeflection is used <br>
  //!          to specify a maximum deviation of extreme distances <br>
  //!          from the minimum one. <br>
  //!          Returns IsDone status. <br>
  Standard_EXPORT Standard_Boolean Perform();
  //! True if the minimum distance is found. <br>
  Standard_EXPORT Standard_Boolean IsDone() const
  { 
    return myIsDone;
  }
  //! Returns the number of solutions satisfying the minimum distance. <br>
  Standard_EXPORT Standard_Integer NbSolution() const
  { 
    return mySolutionsShape1.Length();
  }
  //! Returns the value of the minimum distance. <br>
  Standard_EXPORT Standard_Real Value() const;
  //! True if one of the shapes is a solid and the other shape <br>
  //! is completely or partially inside the solid. <br>
  Standard_EXPORT Standard_Boolean InnerSolution() const
  { 
    return myInnerSol;
  }
  //! Returns the Point corresponding to the <N>th solution on the first Shape <br>
  Standard_EXPORT const gp_Pnt & PointOnShape1(const Standard_Integer N) const
  { 
    return mySolutionsShape1.Value(N).Point();
  }
  //! Returns the Point corresponding to the <N>th solution on the second Shape <br>
  Standard_EXPORT const gp_Pnt & PointOnShape2(const Standard_Integer N) const
  { 
    return mySolutionsShape2.Value(N).Point();
  }
  //! gives the type of the support where the Nth solution on the first shape is situated: <br>
  //!   IsVertex => the Nth solution on the first shape is a Vertex <br>
  //!   IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
  //!   IsInFace => the Nth solution on the first shape is inside a face <br>
  //! the corresponding support is obtained by the method SupportOnShape1 <br>
  Standard_EXPORT BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
  { 
    return mySolutionsShape1.Value(N).SupportKind();
  }
  //! gives the type of the support where the Nth solution on the second shape is situated: <br>
  //!   IsVertex => the Nth solution on the second shape is a Vertex <br>
  //!   IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
  //!   IsInFace => the Nth solution on the second shape is inside a face <br>
  //! the corresponding support is obtained by the method SupportOnShape2 <br>
  Standard_EXPORT BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
  { 
    return mySolutionsShape2.Value(N).SupportKind();
  }
  //! gives the support where the Nth solution on the first shape is situated. <br>
  //! This support can be a Vertex, an Edge or a Face. <br>
  Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
  //! gives the support where the Nth solution on the second shape is situated. <br>
  //! This support can be a Vertex, an Edge or a Face. <br>
  Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) const;
  //! gives the corresponding parameter t if the Nth solution <br>
  //! is situated on an Egde of the first shape <br>
  Standard_EXPORT void ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
  //! gives the corresponding parameter t if the Nth solution <br>
  //! is situated on an Egde of the first shape <br>
  Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
  //! gives the corresponding parameters (U,V) if the Nth solution <br>
  //! is situated on an face of the first shape <br>
  Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
  //! gives the corresponding parameters (U,V) if the Nth solution <br>
  //! is situated on an Face of the second shape <br>
  Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
  //! Prints on the stream o information on the current state of the object. <br>
  Standard_EXPORT void Dump(Standard_OStream& o) const;

  Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
  {
    myFlag = F;
  }

  Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
  {
    myAlgo = A;
  }

private:

  //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
  Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2);

  Standard_Real myDistRef;
  Standard_Real myDistValue;
  Standard_Boolean myIsDone;
  BRepExtrema_SeqOfSolution mySolutionsShape1;
  BRepExtrema_SeqOfSolution mySolutionsShape2;
  Standard_Boolean myInnerSol;
  Standard_Real myEps;
  TopoDS_Shape myShape1;
  TopoDS_Shape myShape2;
  TopTools_IndexedMapOfShape myMapV1;
  TopTools_IndexedMapOfShape myMapV2;
  TopTools_IndexedMapOfShape myMapE1;
  TopTools_IndexedMapOfShape myMapE2;
  TopTools_IndexedMapOfShape myMapF1;
  TopTools_IndexedMapOfShape myMapF2;
  Extrema_ExtFlag myFlag;
  Extrema_ExtAlgo myAlgo;
};

#endif