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_DistanceSS_HeaderFile | |
15 | #define _BRepExtrema_DistanceSS_HeaderFile | |
16 | ||
92d1589b | 17 | #include <BRepExtrema_SeqOfSolution.hxx> |
92d1589b | 18 | #include <Extrema_ExtFlag.hxx> |
92d1589b | 19 | #include <Extrema_ExtAlgo.hxx> |
92d1589b | 20 | #include <Precision.hxx> |
ebc93ae7 | 21 | #include <Standard_DefineAlloc.hxx> |
22 | ||
92d1589b A |
23 | class TopoDS_Shape; |
24 | class Bnd_Box; | |
25 | class TopoDS_Vertex; | |
26 | class TopoDS_Edge; | |
27 | class TopoDS_Face; | |
28 | ||
bcecb583 | 29 | //! This class allows to compute minimum distance between two brep shapes |
30 | //! (face edge vertex) and is used in DistShapeShape class. | |
92d1589b A |
31 | class BRepExtrema_DistanceSS |
32 | { | |
bcecb583 | 33 | public: |
92d1589b | 34 | |
1c35b92f | 35 | DEFINE_STANDARD_ALLOC |
92d1589b | 36 | |
bcecb583 | 37 | public: //! @name Constructor from two shapes |
38 | ||
39 | //! Computes the distance between two Shapes (face edge vertex). | |
40 | //! @param theS1 - First shape | |
41 | //! @param theS2 - Second shape | |
42 | //! @param theBox1 - Bounding box of first shape | |
43 | //! @param theBox2 - Bounding box of second shape | |
44 | //! @param theDstRef - Initial distance between the shapes to start with | |
45 | //! @param theDeflection - Maximum deviation of extreme distances from the minimum | |
46 | //! one (default is Precision::Confusion()). | |
47 | //! @param theExtFlag - Specifies which extrema solutions to look for | |
48 | //! (default is MINMAX, applied only to point-face extrema) | |
49 | //! @param theExtAlgo - Specifies which extrema algorithm is to be used | |
50 | //! (default is Grad algo, applied only to point-face extrema) | |
51 | BRepExtrema_DistanceSS(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, | |
52 | const Bnd_Box& theBox1, const Bnd_Box& theBox2, | |
53 | const Standard_Real theDstRef, | |
54 | const Standard_Real theDeflection = Precision::Confusion(), | |
55 | const Extrema_ExtFlag theExtFlag = Extrema_ExtFlag_MINMAX, | |
56 | const Extrema_ExtAlgo theExtAlgo = Extrema_ExtAlgo_Grad) | |
57 | : | |
58 | myDstRef(theDstRef), | |
59 | myModif(Standard_False), | |
60 | myEps(theDeflection), | |
61 | myFlag(theExtFlag), | |
62 | myAlgo(theExtAlgo) | |
92d1589b | 63 | { |
bcecb583 | 64 | Perform(theS1, theS2, theBox1, theBox2); |
92d1589b | 65 | } |
bcecb583 | 66 | |
67 | public: //! @name Results | |
68 | ||
69 | //! Returns true if the distance has been computed, false otherwise. | |
0f57ab75 | 70 | Standard_Boolean IsDone() const |
92d1589b A |
71 | { |
72 | return myModif; | |
73 | } | |
bcecb583 | 74 | |
75 | //! Returns the distance value. | |
0f57ab75 | 76 | Standard_Real DistValue() const |
92d1589b A |
77 | { |
78 | return myDstRef; | |
79 | } | |
bcecb583 | 80 | |
81 | //! Returns the list of solutions on the first shape. | |
0f57ab75 | 82 | const BRepExtrema_SeqOfSolution& Seq1Value() const |
92d1589b | 83 | { |
bcecb583 | 84 | return mySeqSolShape1; |
92d1589b | 85 | } |
bcecb583 | 86 | |
87 | //! Returns the list of solutions on the second shape. | |
0f57ab75 | 88 | const BRepExtrema_SeqOfSolution& Seq2Value() const |
92d1589b | 89 | { |
bcecb583 | 90 | return mySeqSolShape2; |
92d1589b A |
91 | } |
92 | ||
bcecb583 | 93 | private: //! @name private methods performing the search |
94 | ||
95 | //! Computes the distance between two Shapes (face edge vertex). | |
96 | //! General method to sort out the shape types and call the specific method. | |
97 | Standard_EXPORT void Perform(const TopoDS_Shape& theS1, const TopoDS_Shape& theS2, | |
98 | const Bnd_Box& theBox1, const Bnd_Box& theBox2); | |
99 | ||
100 | //! Computes the distance between two vertices. | |
101 | void Perform(const TopoDS_Vertex& S1, const TopoDS_Vertex& S2, | |
102 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
103 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
104 | ||
105 | //! Computes the minimum distance between a vertex and an edge. | |
106 | void Perform(const TopoDS_Vertex& theS1, const TopoDS_Edge& theS2, | |
107 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
108 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
109 | ||
110 | //! Computes the minimum distance between a vertex and a face. | |
111 | void Perform(const TopoDS_Vertex& theS1, const TopoDS_Face& theS2, | |
112 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
113 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
114 | ||
115 | //! Computes the minimum distance between two edges. | |
116 | void Perform(const TopoDS_Edge& theS1, const TopoDS_Edge& theS2, | |
117 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
118 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
119 | ||
120 | //! Computes the minimum distance between an edge and a face. | |
121 | void Perform(const TopoDS_Edge& theS1, const TopoDS_Face& theS2, | |
122 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
123 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
124 | ||
125 | //! Computes the minimum distance between two faces. | |
126 | void Perform(const TopoDS_Face& theS1, const TopoDS_Face& theS2, | |
127 | BRepExtrema_SeqOfSolution& theSeqSolShape1, | |
128 | BRepExtrema_SeqOfSolution& theSeqSolShape2); | |
129 | ||
130 | private: //! @name Fields | |
131 | ||
132 | BRepExtrema_SeqOfSolution mySeqSolShape1; //!< Solutions on the first shape | |
133 | BRepExtrema_SeqOfSolution mySeqSolShape2; //!< Solutions on the second shape | |
134 | Standard_Real myDstRef; //!< The minimal distance found | |
135 | Standard_Boolean myModif; //!< Flag indicating whether the solution was improved or not | |
136 | Standard_Real myEps; //!< Deflection | |
137 | Extrema_ExtFlag myFlag; //!< Extrema flag indicating what solutions to look for | |
138 | Extrema_ExtAlgo myAlgo; //!< Extrema algo to be used to look for solutions | |
92d1589b A |
139 | }; |
140 | ||
141 | #endif |