2f4250ffbf3a11573bbc03c696d14bf50fb556f3
[occt.git] / src / BRepExtrema / BRepExtrema_ExtPC.cxx
1 // File:        BRepExtrema_ExtPC.cxx
2 // Created:     Wed Dec 15 16:48:53 1993
3 // Author:      Christophe MARION
4 //              <cma@sdsun1>
5
6 #include <BRepExtrema_ExtPC.ixx>
7 #include <BRep_Tool.hxx>
8 #include <StdFail_NotDone.hxx>
9 #include <Standard_Failure.hxx>
10 #include <BRepAdaptor_Curve.hxx>
11 #include <BRepAdaptor_HCurve.hxx>
12
13
14 //=======================================================================
15 //function : BRepExtrema_ExtPC
16 //purpose  : 
17 //=======================================================================
18
19 BRepExtrema_ExtPC::BRepExtrema_ExtPC()
20 {
21 }
22
23 //=======================================================================
24 //function : BRepExtrema_ExtPC
25 //purpose  : 
26 //=======================================================================
27
28 BRepExtrema_ExtPC::BRepExtrema_ExtPC
29   (const TopoDS_Vertex& V,
30    const TopoDS_Edge& E)
31 {
32   Initialize(E);
33   Perform(V);
34 }
35
36 //=======================================================================
37 //function : Initialize
38 //purpose  : 
39 //=======================================================================
40
41 void BRepExtrema_ExtPC::Initialize(const TopoDS_Edge& E)
42 {
43   Standard_Real U1,U2;
44   BRepAdaptor_Curve Curv(E);
45   myHC = new BRepAdaptor_HCurve(Curv);
46   BRep_Tool::Range(E,U1,U2);
47   myExtrem.Initialize(myHC->Curve(),U1,U2);
48 }
49
50 //=======================================================================
51 //function : Perform
52 //purpose  : 
53 //=======================================================================
54
55 void BRepExtrema_ExtPC::Perform(const TopoDS_Vertex& V)
56 {
57   gp_Pnt P = BRep_Tool::Pnt(V);
58   myExtrem.Perform(P);
59 }
60
61 //=======================================================================
62 //function : IsDone
63 //purpose  : 
64 //=======================================================================
65
66 Standard_Boolean BRepExtrema_ExtPC::IsDone()const
67 {
68   return myExtrem.IsDone();
69 }
70
71 //=======================================================================
72 //function : NbExt
73 //purpose  : 
74 //=======================================================================
75
76 Standard_Integer BRepExtrema_ExtPC::NbExt() const
77 {
78   if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
79   return myExtrem.NbExt();
80 }
81
82 //=======================================================================
83 //function : IsMin
84 //purpose  : 
85 //=======================================================================
86
87 Standard_Boolean BRepExtrema_ExtPC::IsMin
88   (const Standard_Integer N) const
89 {
90   if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
91   if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
92   return myExtrem.IsMin(N);
93 }
94
95 //=======================================================================
96 //function : Value
97 //purpose  : 
98 //=======================================================================
99
100 Standard_Real BRepExtrema_ExtPC::SquareDistance
101   (const Standard_Integer N) const
102 {
103   if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
104   if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
105   return myExtrem.SquareDistance(N);
106 }
107
108 //=======================================================================
109 //function : Parameter
110 //purpose  : 
111 //=======================================================================
112
113 Standard_Real BRepExtrema_ExtPC::Parameter
114   (const Standard_Integer N) const
115 {
116   if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
117   if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
118   return myExtrem.Point(N).Parameter();
119 }
120
121 //=======================================================================
122 //function : Point
123 //purpose  : 
124 //=======================================================================
125
126 gp_Pnt BRepExtrema_ExtPC::Point
127   (const Standard_Integer N) const
128 {
129   if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
130   if ((N < 1) || (N > myExtrem.NbExt())) Standard_OutOfRange::Raise();
131   return (myExtrem.Point(N).Value()); 
132 }
133
134 //=======================================================================
135 //function : TrimmedDistances
136 //purpose  : 
137 //=======================================================================
138
139 void BRepExtrema_ExtPC::TrimmedSquareDistances
140   (Standard_Real& dist1,
141    Standard_Real& dist2,
142    gp_Pnt& pnt1,
143    gp_Pnt& pnt2) const
144 {
145   myExtrem.TrimmedSquareDistances(dist1,dist2,pnt1,pnt2);
146 }
147