1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _BRepExtrema_DistShapeShape_HeaderFile
15 #define _BRepExtrema_DistShapeShape_HeaderFile
17 #include <Bnd_SeqOfBox.hxx>
18 #include <BRepExtrema_SeqOfSolution.hxx>
19 #include <BRepExtrema_SolutionElem.hxx>
20 #include <BRepExtrema_SupportType.hxx>
21 #include <Extrema_ExtAlgo.hxx>
22 #include <Extrema_ExtFlag.hxx>
24 #include <TopoDS_Shape.hxx>
25 #include <TopTools_IndexedMapOfShape.hxx>
26 #include <Standard_OStream.hxx>
27 #include <Standard_DefineAlloc.hxx>
30 class TopTools_IndexedMapOfShape;
33 //! This class provides tools to compute minimum distance <br>
34 //! between two Shapes (Compound,CompSolid, Solid, Shell, Face, Wire, Edge, Vertex). <br>
35 class BRepExtrema_DistShapeShape
41 //! create empty tool <br>
42 Standard_EXPORT BRepExtrema_DistShapeShape();
43 //! computation of the minimum distance (value and pair of points) using default deflection <br>
44 //! Default value is Precision::Confusion(). <br>
45 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);
46 //! create tool and load both shapes into it <br>
47 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);
49 Standard_EXPORT void SetDeflection(const Standard_Real theDeflection)
51 myEps = theDeflection;
53 //! load first shape into extrema <br>
54 Standard_EXPORT void LoadS1(const TopoDS_Shape& Shape1);
55 //! load second shape into extrema <br>
56 Standard_EXPORT void LoadS2(const TopoDS_Shape& Shape1);
57 //! computation of the minimum distance (value and <br>
58 //! couple of points). Parameter theDeflection is used <br>
59 //! to specify a maximum deviation of extreme distances <br>
60 //! from the minimum one. <br>
61 //! Returns IsDone status. <br>
62 Standard_EXPORT Standard_Boolean Perform();
63 //! True if the minimum distance is found. <br>
64 Standard_EXPORT Standard_Boolean IsDone() const
68 //! Returns the number of solutions satisfying the minimum distance. <br>
69 Standard_EXPORT Standard_Integer NbSolution() const
71 return mySolutionsShape1.Length();
73 //! Returns the value of the minimum distance. <br>
74 Standard_EXPORT Standard_Real Value() const;
75 //! True if one of the shapes is a solid and the other shape <br>
76 //! is completely or partially inside the solid. <br>
77 Standard_EXPORT Standard_Boolean InnerSolution() const
81 //! Returns the Point corresponding to the <N>th solution on the first Shape <br>
82 Standard_EXPORT const gp_Pnt & PointOnShape1(const Standard_Integer N) const
84 return mySolutionsShape1.Value(N).Point();
86 //! Returns the Point corresponding to the <N>th solution on the second Shape <br>
87 Standard_EXPORT const gp_Pnt & PointOnShape2(const Standard_Integer N) const
89 return mySolutionsShape2.Value(N).Point();
91 //! gives the type of the support where the Nth solution on the first shape is situated: <br>
92 //! IsVertex => the Nth solution on the first shape is a Vertex <br>
93 //! IsOnEdge => the Nth soluion on the first shape is on a Edge <br>
94 //! IsInFace => the Nth solution on the first shape is inside a face <br>
95 //! the corresponding support is obtained by the method SupportOnShape1 <br>
96 Standard_EXPORT BRepExtrema_SupportType SupportTypeShape1(const Standard_Integer N) const
98 return mySolutionsShape1.Value(N).SupportKind();
100 //! gives the type of the support where the Nth solution on the second shape is situated: <br>
101 //! IsVertex => the Nth solution on the second shape is a Vertex <br>
102 //! IsOnEdge => the Nth soluion on the secondt shape is on a Edge <br>
103 //! IsInFace => the Nth solution on the second shape is inside a face <br>
104 //! the corresponding support is obtained by the method SupportOnShape2 <br>
105 Standard_EXPORT BRepExtrema_SupportType SupportTypeShape2(const Standard_Integer N) const
107 return mySolutionsShape2.Value(N).SupportKind();
109 //! gives the support where the Nth solution on the first shape is situated. <br>
110 //! This support can be a Vertex, an Edge or a Face. <br>
111 Standard_EXPORT TopoDS_Shape SupportOnShape1(const Standard_Integer N) const;
112 //! gives the support where the Nth solution on the second shape is situated. <br>
113 //! This support can be a Vertex, an Edge or a Face. <br>
114 Standard_EXPORT TopoDS_Shape SupportOnShape2(const Standard_Integer N) 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 ParOnEdgeS1(const Standard_Integer N,Standard_Real& t) const;
118 //! gives the corresponding parameter t if the Nth solution <br>
119 //! is situated on an Egde of the first shape <br>
120 Standard_EXPORT void ParOnEdgeS2(const Standard_Integer N,Standard_Real& t) const;
121 //! gives the corresponding parameters (U,V) if the Nth solution <br>
122 //! is situated on an face of the first shape <br>
123 Standard_EXPORT void ParOnFaceS1(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
124 //! gives the corresponding parameters (U,V) if the Nth solution <br>
125 //! is situated on an Face of the second shape <br>
126 Standard_EXPORT void ParOnFaceS2(const Standard_Integer N,Standard_Real& u,Standard_Real& v) const;
127 //! Prints on the stream o information on the current state of the object. <br>
128 Standard_EXPORT void Dump(Standard_OStream& o) const;
130 Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
135 Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
142 //! computes the minimum distance between two maps of shapes (Face,Edge,Vertex) <br>
143 Standard_EXPORT void DistanceMapMap(const TopTools_IndexedMapOfShape& Map1,const TopTools_IndexedMapOfShape& Map2,const Bnd_SeqOfBox& LBox1,const Bnd_SeqOfBox& LBox2);
145 Standard_Real myDistRef;
146 Standard_Boolean myIsDone;
147 BRepExtrema_SeqOfSolution mySolutionsShape1;
148 BRepExtrema_SeqOfSolution mySolutionsShape2;
149 Standard_Boolean myInnerSol;
151 TopoDS_Shape myShape1;
152 TopoDS_Shape myShape2;
153 TopTools_IndexedMapOfShape myMapV1;
154 TopTools_IndexedMapOfShape myMapV2;
155 TopTools_IndexedMapOfShape myMapE1;
156 TopTools_IndexedMapOfShape myMapE2;
157 TopTools_IndexedMapOfShape myMapF1;
158 TopTools_IndexedMapOfShape myMapF2;
159 Standard_Boolean myIsInitS1;
160 Standard_Boolean myIsInitS2;
161 Extrema_ExtFlag myFlag;
162 Extrema_ExtAlgo myAlgo;