1 // File: BRepExtrema_ExtPF.cxx
2 // Created: Wed Dec 15 16:48:53 1993
3 // Author: Christophe MARION
5 // modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement
6 // si IsDone de Extrema est vrai
7 #include <BRepExtrema_ExtPF.ixx>
8 #include <BRep_Tool.hxx>
9 #include <BRepTools.hxx>
10 #include <StdFail_NotDone.hxx>
11 #include <Standard_Failure.hxx>
12 #include <BRepClass_FaceClassifier.hxx>
13 #include <gp_Pnt2d.hxx>
14 #include <BRepAdaptor_Curve.hxx>
15 #include <BRepAdaptor_HCurve.hxx>
16 #include <BRepAdaptor_Surface.hxx>
17 #include <BRepAdaptor_HSurface.hxx>
19 //=======================================================================
20 //function : BRepExtrema_ExtPF
22 //=======================================================================
24 BRepExtrema_ExtPF::BRepExtrema_ExtPF()
28 //=======================================================================
29 //function : BRepExtrema_ExtPF
31 //=======================================================================
33 BRepExtrema_ExtPF::BRepExtrema_ExtPF
34 (const TopoDS_Vertex& V,
41 //=======================================================================
42 //function : Initialize
44 //=======================================================================
46 void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& F)
48 // cette surface doit etre en champ. Extrema ne fait
49 // pas de copie et prend seulement un pointeur dessus.
50 mySurf.Initialize(F, Standard_False);
51 Standard_Real Tol = BRep_Tool::Tolerance(F);
52 Standard_Real U1, U2, V1, V2;
53 BRepTools::UVBounds(F, U1, U2, V1, V2);
54 myExtrem.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
57 //=======================================================================
60 //=======================================================================
62 void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& V,
67 gp_Pnt P = BRep_Tool::Pnt(V);
70 // exploration des points et classification:
71 if (myExtrem.IsDone()) {
72 BRepClass_FaceClassifier classifier;
76 Standard_Real Tol = BRep_Tool::Tolerance(E);
78 for (Standard_Integer i = 1; i <= myExtrem.NbExt(); i++) {
79 myExtrem.Point(i).Parameter(U1, U2);
81 classifier.Perform(E, Puv, Tol);
82 state = classifier.State();
83 if(state == TopAbs_ON || state == TopAbs_IN) {
85 mySqDist.Append(myExtrem.SquareDistance(i));
86 myPoints.Append(myExtrem.Point(i));
91 //=======================================================================
94 //=======================================================================
96 Standard_Boolean BRepExtrema_ExtPF::IsDone()const
98 return myExtrem.IsDone();
101 //=======================================================================
104 //=======================================================================
106 Standard_Integer BRepExtrema_ExtPF::NbExt() const
108 if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
113 //=======================================================================
116 //=======================================================================
118 Standard_Real BRepExtrema_ExtPF::SquareDistance
119 (const Standard_Integer N) const
121 if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
122 if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
123 return mySqDist.Value(N);
126 //=======================================================================
127 //function : Parameters
129 //=======================================================================
132 void BRepExtrema_ExtPF::Parameter(const Standard_Integer N,
134 Standard_Real& V) const
136 if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
137 if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
138 myPoints.Value(N).Parameter(U, V);
141 //=======================================================================
144 //=======================================================================
146 gp_Pnt BRepExtrema_ExtPF::Point
147 (const Standard_Integer N) const
149 if(!myExtrem.IsDone()) StdFail_NotDone::Raise();
150 if ((N < 1) || (N > mynbext)) Standard_OutOfRange::Raise();
151 gp_Pnt P = myPoints.Value(N).Value();