0023948: Wrong intersection between a surface of revolution and a plane.
[occt.git] / src / BRepExtrema / BRepExtrema_DistanceSS.hxx
1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
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.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef _BRepExtrema_DistanceSS_HeaderFile
15 #define _BRepExtrema_DistanceSS_HeaderFile
16
17 #include <BRepExtrema_SeqOfSolution.hxx>
18 #include <Extrema_ExtFlag.hxx>
19 #include <Extrema_ExtAlgo.hxx>
20 #include <Precision.hxx>
21 #include <Standard_DefineAlloc.hxx>
22
23 class TopoDS_Shape;
24 class Bnd_Box;
25 class TopoDS_Vertex;
26 class TopoDS_Edge;
27 class TopoDS_Face;
28
29
30 //!  This class allows to compute minimum distance between two shapes <br>
31 //! (face edge vertex) and is used in DistShapeShape class. <br>
32 class BRepExtrema_DistanceSS
33 {
34  public:
35
36   DEFINE_STANDARD_ALLOC
37
38   //! computes the distance between two Shapes ( face edge vertex). <br>
39   Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
40                                          const Bnd_Box& B1, const Bnd_Box& B2,
41                                          const Standard_Real DstRef,
42                                          const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
43                                          const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
44   : myDstRef(DstRef), myModif(Standard_False), myEps(Precision::Confusion()), myFlag(F), myAlgo(A)
45   {
46     Perform(S1, S2, B1, B2);
47   }
48   //! computes the distance between two Shapes ( face edge vertex). <br>
49   //! Parameter theDeflection is used to specify a maximum deviation <br>
50   //! of extreme distances from the minimum one. <br>
51   //! Default value is Precision::Confusion(). <br>
52   Standard_EXPORT BRepExtrema_DistanceSS(const TopoDS_Shape& S1, const TopoDS_Shape& S2,
53                                          const Bnd_Box& B1, const Bnd_Box& B2,
54                                          const Standard_Real DstRef, const Standard_Real aDeflection,
55                                          const Extrema_ExtFlag F = Extrema_ExtFlag_MINMAX,
56                                          const Extrema_ExtAlgo A = Extrema_ExtAlgo_Grad)
57   : myDstRef(DstRef), myModif(Standard_False), myEps(aDeflection), myFlag(F), myAlgo(A)
58   {
59     Perform(S1, S2, B1, B2);
60   }
61   //! True if the distance has been computed <br>
62   Standard_EXPORT Standard_Boolean IsDone() const
63   {
64     return myModif;
65   }
66   //! returns the distance value <br>
67   Standard_EXPORT Standard_Real DistValue() const
68   {
69     return myDstRef;
70   }
71   //! returns the list of solutions on the first shape <br>
72   Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq1Value() const
73   {
74     return SeqSolShape1;
75   }
76   //! returns the list of solutions on the second shape <br>
77   Standard_EXPORT const BRepExtrema_SeqOfSolution& Seq2Value() const
78   {
79     return SeqSolShape2;
80   }
81   //! sets the flag controlling minimum and maximum search
82   Standard_EXPORT void SetFlag(const Extrema_ExtFlag F)
83   {
84     myFlag = F;
85   }
86   //! sets the flag controlling ...
87   Standard_EXPORT void SetAlgo(const Extrema_ExtAlgo A)
88   {
89     myAlgo = A;
90   }
91
92  private:
93
94   //! computes the distance between two Shapes ( face edge vertex) <br>
95   Standard_EXPORT void Perform(const TopoDS_Shape& S1,const TopoDS_Shape& S2,const Bnd_Box& B1,const Bnd_Box& B2);
96
97   //! computes the distance between two vertices <br>
98   void Perform(const TopoDS_Vertex& S1,const TopoDS_Vertex& S2);
99   //! computes the minimum distance between a vertex and an edge <br>
100   void Perform(const TopoDS_Vertex& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
101   //! computes the minimum distance between a vertex and a face <br>
102   void Perform(const TopoDS_Vertex& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
103
104   //! computes the minimum distance between an edge and a vertex <br>
105   void Perform(const TopoDS_Edge& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2);
106   /*{
107     Perform(S2, S1, B2, B1);
108   }*/
109   //! computes the minimum distance between two edges <br>
110   void Perform(const TopoDS_Edge& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
111   //! computes the minimum distance an edge and a face <br>
112   void Perform(const TopoDS_Edge& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
113
114   //! computes the minimum distance betwwen a face and a vertex <br>
115   void Perform(const TopoDS_Face& S1,const TopoDS_Vertex& S2,const Bnd_Box& B1,const Bnd_Box& B2);
116   /*{
117     Perform(S2, S1, B2, B1);
118   }*/
119   //! computes the minimum distance between a face and an edge <br>
120   void Perform(const TopoDS_Face& S1,const TopoDS_Edge& S2,const Bnd_Box& B1,const Bnd_Box& B2);
121   /*{
122     Perform(S2, S1, B2, B1);
123   }*/
124   //! computes the minimum distance between two faces <br>
125   void Perform(const TopoDS_Face& S1,const TopoDS_Face& S2,const Bnd_Box& B1,const Bnd_Box& B2);
126
127   BRepExtrema_SeqOfSolution SeqSolShape1;
128   BRepExtrema_SeqOfSolution SeqSolShape2;
129   Standard_Real myDstRef;
130   Standard_Boolean myModif;
131   Standard_Real myEps;
132   Extrema_ExtFlag myFlag;
133   Extrema_ExtAlgo myAlgo;
134 };
135
136 #endif