Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: BRepExtrema_ExtPF.cxx |
2 | // Created: Wed Dec 15 16:48:53 1993 | |
3 | // Author: Christophe MARION | |
7fd59977 | 4 | // modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement |
5 | // si IsDone de Extrema est vrai | |
92d1589b A |
6 | |
7 | #include <BRepExtrema_ExtPF.hxx> | |
8 | ||
7fd59977 | 9 | #include <BRep_Tool.hxx> |
10 | #include <BRepTools.hxx> | |
7fd59977 | 11 | #include <BRepClass_FaceClassifier.hxx> |
12 | #include <gp_Pnt2d.hxx> | |
7fd59977 | 13 | #include <BRepAdaptor_Surface.hxx> |
7fd59977 | 14 | |
15 | //======================================================================= | |
16 | //function : BRepExtrema_ExtPF | |
17 | //purpose : | |
18 | //======================================================================= | |
19 | ||
92d1589b A |
20 | BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace, |
21 | const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo) | |
7fd59977 | 22 | { |
92d1589b A |
23 | Initialize(TheFace,TheFlag,TheAlgo); |
24 | Perform(TheVertex,TheFace); | |
7fd59977 | 25 | } |
26 | ||
27 | //======================================================================= | |
28 | //function : Initialize | |
29 | //purpose : | |
30 | //======================================================================= | |
31 | ||
92d1589b A |
32 | void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace, |
33 | const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo) | |
7fd59977 | 34 | { |
35 | // cette surface doit etre en champ. Extrema ne fait | |
36 | // pas de copie et prend seulement un pointeur dessus. | |
92d1589b A |
37 | mySurf.Initialize(TheFace, Standard_False); |
38 | const Standard_Real Tol = BRep_Tool::Tolerance(TheFace); | |
7fd59977 | 39 | Standard_Real U1, U2, V1, V2; |
92d1589b A |
40 | BRepTools::UVBounds(TheFace, U1, U2, V1, V2); |
41 | myExtPS.SetFlag(TheFlag); | |
42 | myExtPS.SetAlgo(TheAlgo); | |
43 | myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol); | |
7fd59977 | 44 | } |
45 | ||
46 | //======================================================================= | |
47 | //function : Perform | |
48 | //purpose : | |
49 | //======================================================================= | |
50 | ||
92d1589b | 51 | void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace) |
7fd59977 | 52 | { |
53 | mySqDist.Clear(); | |
54 | myPoints.Clear(); | |
7fd59977 | 55 | |
92d1589b A |
56 | const gp_Pnt P = BRep_Tool::Pnt(TheVertex); |
57 | myExtPS.Perform(P); | |
58 | ||
59 | // Exploration of points and classification | |
60 | if (myExtPS.IsDone()) | |
61 | { | |
62 | BRepClass_FaceClassifier classifier; | |
63 | Standard_Real U1, U2; | |
64 | const Standard_Real Tol = BRep_Tool::Tolerance(TheFace); | |
65 | for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++) | |
66 | { | |
67 | myExtPS.Point(i).Parameter(U1, U2); | |
68 | const gp_Pnt2d Puv(U1, U2); | |
69 | classifier.Perform(TheFace, Puv, Tol); | |
70 | const TopAbs_State state = classifier.State(); | |
71 | if(state == TopAbs_ON || state == TopAbs_IN) | |
72 | { | |
73 | mySqDist.Append(myExtPS.SquareDistance(i)); | |
74 | myPoints.Append(myExtPS.Point(i)); | |
75 | } | |
7fd59977 | 76 | } |
77 | } | |
7fd59977 | 78 | } |