7b247d499dc7019b7dbb2db17a0c663c3180f596
[occt.git] / src / BRepExtrema / BRepExtrema_ExtCC.cxx
1 // File:        BRepExtrema_ExtCC.cxx
2 // Created:     Wed Dec 15 16:48:53 1993
3 // Author:      Christophe MARION
4 //              <cma@sdsun1>
5
6 #include <BRepExtrema_ExtCC.ixx>
7 #include <BRep_Tool.hxx>
8 #include <StdFail_NotDone.hxx>
9 #include <Standard_Failure.hxx>
10 #include <Extrema_POnCurv.hxx>
11 #include <BRepAdaptor_Curve.hxx>
12 #include <BRepAdaptor_HCurve.hxx>
13
14
15 //=======================================================================
16 //function : BRepExtrema_ExtCC
17 //purpose  : 
18 //=======================================================================
19
20 BRepExtrema_ExtCC::BRepExtrema_ExtCC()
21 {
22 }
23
24 //=======================================================================
25 //function : BRepExtrema_ExtCC
26 //purpose  : 
27 //=======================================================================
28
29 BRepExtrema_ExtCC::BRepExtrema_ExtCC
30   (const TopoDS_Edge& E1,
31    const TopoDS_Edge& E2)
32 {
33   Initialize(E2);
34   Perform(E1);
35 }
36
37 //=======================================================================
38 //function : Initialize
39 //purpose  : 
40 //=======================================================================
41
42 void BRepExtrema_ExtCC::Initialize(const TopoDS_Edge& E2)
43 {
44   Standard_Real V1,V2;
45   BRepAdaptor_Curve Curv(E2);
46   myHC = new BRepAdaptor_HCurve(Curv);
47   BRep_Tool::Range(E2,V1,V2);
48   myExtrem.SetCurve (2, myHC->Curve(),V1,V2);
49 }
50
51 //=======================================================================
52 //function : Perform
53 //purpose  : 
54 //=======================================================================
55
56 void BRepExtrema_ExtCC::Perform(const TopoDS_Edge& E1)
57 {
58   Standard_Real U1, U2;
59   BRepAdaptor_Curve Curv(E1);
60   Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
61   BRep_Tool::Range(E1,U1,U2);
62   myExtrem.SetCurve (1, HC->Curve(), U1, U2);
63   myExtrem.Perform();
64 }
65
66 //=======================================================================
67 //function : IsDone
68 //purpose  : 
69 //=======================================================================
70
71 Standard_Boolean BRepExtrema_ExtCC::IsDone()const
72 {
73   return myExtrem.IsDone();
74 }
75
76 //=======================================================================
77 //function : NbExt
78 //purpose  : 
79 //=======================================================================
80
81 Standard_Integer BRepExtrema_ExtCC::NbExt() const
82 {
83   return myExtrem.NbExt();
84 }
85
86 //=======================================================================
87 //function : IsMin
88 //purpose  : 
89 //=======================================================================
90
91 Standard_Boolean BRepExtrema_ExtCC::IsParallel() const
92 {
93   return myExtrem.IsParallel();
94 }
95
96 //=======================================================================
97 //function : SquareDistance
98 //purpose  : 
99 //=======================================================================
100
101 Standard_Real BRepExtrema_ExtCC::SquareDistance
102   (const Standard_Integer N) const
103 {
104   return myExtrem.SquareDistance(N);
105 }
106
107 //=======================================================================
108 //function : ParameterOnE1
109 //purpose  : 
110 //=======================================================================
111
112 Standard_Real BRepExtrema_ExtCC::ParameterOnE1
113   (const Standard_Integer N) const
114 {
115   Extrema_POnCurv POnE1, POnE2;
116   myExtrem.Points(N, POnE1, POnE2);
117   return POnE1.Parameter();
118 }
119
120 //=======================================================================
121 //function : PointOnE1
122 //purpose  : 
123 //=======================================================================
124
125 gp_Pnt BRepExtrema_ExtCC::PointOnE1
126   (const Standard_Integer N) const
127 {
128   Extrema_POnCurv POnE1, POnE2;
129   myExtrem.Points(N, POnE1, POnE2);
130   gp_Pnt P = POnE1.Value();
131   return P; 
132 }
133
134 //=======================================================================
135 //function : ParameterOnE2
136 //purpose  : 
137 //=======================================================================
138
139 Standard_Real BRepExtrema_ExtCC::ParameterOnE2
140   (const Standard_Integer N) const
141 {
142   Extrema_POnCurv POnE1, POnE2;
143   myExtrem.Points(N, POnE1, POnE2);
144   return POnE2.Parameter();
145 }
146
147 //=======================================================================
148 //function : PointOnE2
149 //purpose  : 
150 //=======================================================================
151
152 gp_Pnt BRepExtrema_ExtCC::PointOnE2
153   (const Standard_Integer N) const
154 {
155   Extrema_POnCurv POnE1, POnE2;
156   myExtrem.Points(N, POnE1, POnE2);
157   gp_Pnt P = POnE2.Value();
158   return P; 
159 }
160
161
162 //=======================================================================
163 //function : TrimmedSquareDistances
164 //purpose  : 
165 //=======================================================================
166
167 void BRepExtrema_ExtCC::TrimmedSquareDistances
168   (Standard_Real& dist11,
169    Standard_Real& dist12,
170    Standard_Real& dist21,
171    Standard_Real& dist22,
172    gp_Pnt& pnt11,
173    gp_Pnt& pnt12,
174    gp_Pnt& pnt21,
175    gp_Pnt& pnt22) const
176 {
177   myExtrem.TrimmedSquareDistances(dist11,dist12,dist21, dist22,
178                             pnt11,pnt12, pnt21, pnt22);
179 }
180