Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: BRepExtrema_ExtCF.cxx |
2 | // Created: Wed Dec 15 16:48:53 1993 | |
3 | // Author: Christophe MARION | |
7fd59977 | 4 | |
92d1589b A |
5 | #include <BRepExtrema_ExtCF.hxx> |
6 | ||
7fd59977 | 7 | #include <BRep_Tool.hxx> |
8 | #include <BRepTools.hxx> | |
9 | #include <Geom_Curve.hxx> | |
7fd59977 | 10 | #include <BRepClass_FaceClassifier.hxx> |
7fd59977 | 11 | #include <gp_Pnt2d.hxx> |
12 | #include <BRepAdaptor_Surface.hxx> | |
13 | #include <BRepAdaptor_HSurface.hxx> | |
14 | #include <BRepAdaptor_Curve.hxx> | |
15 | #include <BRepAdaptor_HCurve.hxx> | |
16 | ||
17 | //======================================================================= | |
18 | //function : BRepExtrema_ExtCF | |
19 | //purpose : | |
20 | //======================================================================= | |
21 | ||
92d1589b | 22 | BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F) |
7fd59977 | 23 | { |
24 | Initialize(F); | |
25 | Perform(E, F); | |
26 | } | |
27 | ||
28 | //======================================================================= | |
29 | //function : Initialize | |
30 | //purpose : | |
31 | //======================================================================= | |
32 | ||
33 | void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2) | |
34 | { | |
35 | BRepAdaptor_Surface Surf(F2); | |
36 | myHS = new BRepAdaptor_HSurface(Surf); | |
92d1589b | 37 | const Standard_Real Tol = BRep_Tool::Tolerance(F2); |
7fd59977 | 38 | Standard_Real U1, U2, V1, V2; |
39 | BRepTools::UVBounds(F2, U1, U2, V1, V2); | |
92d1589b | 40 | myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol); |
7fd59977 | 41 | } |
42 | ||
43 | //======================================================================= | |
44 | //function : Perform | |
45 | //purpose : | |
46 | //======================================================================= | |
47 | ||
92d1589b | 48 | void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2) |
7fd59977 | 49 | { |
50 | mySqDist.Clear(); | |
51 | myPointsOnS.Clear(); | |
52 | myPointsOnC.Clear(); | |
92d1589b | 53 | |
7fd59977 | 54 | Standard_Real U1, U2; |
55 | BRep_Tool::Range(E, U1, U2); | |
56 | ||
57 | BRepAdaptor_Curve Curv(E); | |
58 | Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv); | |
92d1589b | 59 | myExtCS.Perform(HC->Curve(), U1, U2); |
7fd59977 | 60 | |
92d1589b | 61 | if(!myExtCS.IsDone()) |
7fd59977 | 62 | return; |
63 | ||
92d1589b A |
64 | if (myExtCS.IsParallel()) |
65 | mySqDist.Append(myExtCS.SquareDistance(1)); | |
66 | else | |
67 | { | |
68 | // Exploration of points and classification | |
69 | BRepClass_FaceClassifier classifier; | |
70 | const Standard_Real Tol = BRep_Tool::Tolerance(F2); | |
71 | Extrema_POnCurv P1; | |
72 | Extrema_POnSurf P2; | |
73 | ||
74 | for (Standard_Integer i = 1; i <= myExtCS.NbExt(); i++) | |
75 | { | |
76 | myExtCS.Points(i, P1, P2); | |
7fd59977 | 77 | P2.Parameter(U1, U2); |
92d1589b | 78 | const gp_Pnt2d Puv(U1, U2); |
7fd59977 | 79 | classifier.Perform(F2, Puv, Tol); |
92d1589b A |
80 | const TopAbs_State state = classifier.State(); |
81 | if (state == TopAbs_ON || state == TopAbs_IN) | |
82 | { | |
83 | mySqDist.Append(myExtCS.SquareDistance(i)); | |
84 | myPointsOnC.Append(P1); | |
85 | myPointsOnS.Append(P2); | |
7fd59977 | 86 | } |
87 | } | |
88 | } | |
89 | } |