Commit | Line | Data |
---|---|---|
7fd59977 | 1 | // File: BRepExtrema_ExtFF.cxx |
2 | // Created: Wed Dec 15 16:48:53 1993 | |
3 | // Author: Christophe MARION | |
7fd59977 | 4 | // modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de |
5 | // GeomAdaptor dans Initialize et Perform. | |
92d1589b A |
6 | |
7 | #include <BRepExtrema_ExtFF.hxx> | |
8 | ||
7fd59977 | 9 | #include <BRepExtrema_ExtCF.hxx> |
10 | #include <BRep_Tool.hxx> | |
11 | #include <BRepTools.hxx> | |
7fd59977 | 12 | #include <BRepClass_FaceClassifier.hxx> |
7fd59977 | 13 | #include <gp_Pnt2d.hxx> |
14 | #include <Precision.hxx> | |
15 | #include <BRepAdaptor_HSurface.hxx> | |
16 | ||
17 | //======================================================================= | |
18 | //function : BRepExtrema_ExtFF | |
19 | //purpose : | |
20 | //======================================================================= | |
21 | ||
92d1589b | 22 | BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F2) |
7fd59977 | 23 | { |
24 | Initialize(F2); | |
25 | Perform(F1,F2); | |
26 | } | |
92d1589b | 27 | |
7fd59977 | 28 | //======================================================================= |
29 | //function : Initialize | |
30 | //purpose : | |
31 | //======================================================================= | |
32 | ||
33 | void BRepExtrema_ExtFF::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 | myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol); |
7fd59977 | 41 | } |
42 | ||
43 | //======================================================================= | |
44 | //function : Perform | |
45 | //purpose : | |
46 | //======================================================================= | |
47 | ||
92d1589b | 48 | void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2) |
7fd59977 | 49 | { |
7fd59977 | 50 | mySqDist.Clear(); |
51 | myPointsOnS1.Clear(); | |
52 | myPointsOnS2.Clear(); | |
92d1589b | 53 | |
7fd59977 | 54 | BRepAdaptor_Surface Surf1(F1); |
55 | Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1); | |
92d1589b A |
56 | const Standard_Real Tol1 = BRep_Tool::Tolerance(F1); |
57 | Standard_Real U1, U2, V1, V2; | |
7fd59977 | 58 | BRepTools::UVBounds(F1, U1, U2, V1, V2); |
92d1589b A |
59 | myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1); |
60 | ||
61 | if (!myExtSS.IsDone()) | |
62 | return; | |
63 | ||
64 | if (myExtSS.IsParallel()) | |
65 | mySqDist.Append(myExtSS.SquareDistance(1)); | |
66 | else | |
67 | { | |
68 | // Exploration of points and classification | |
69 | BRepClass_FaceClassifier classifier; | |
70 | const Standard_Real Tol2 = BRep_Tool::Tolerance(F2); | |
71 | Extrema_POnSurf P1, P2; | |
72 | ||
73 | Standard_Integer i; | |
74 | for (i = 1; i <= myExtSS.NbExt(); i++) | |
75 | { | |
76 | myExtSS.Points(i, P1, P2); | |
7fd59977 | 77 | P1.Parameter(U1, U2); |
92d1589b A |
78 | const gp_Pnt2d Puv1(U1, U2); |
79 | classifier.Perform(F1, Puv1, Tol1); | |
80 | const TopAbs_State state1 = classifier.State(); | |
81 | if (state1 == TopAbs_ON || state1 == TopAbs_IN) | |
82 | { | |
83 | P2.Parameter(U1, U2); | |
84 | const gp_Pnt2d Puv2(U1, U2); | |
85 | classifier.Perform(F2, Puv2, Tol2); | |
86 | const TopAbs_State state2 = classifier.State(); | |
87 | if (state2 == TopAbs_ON || state2 == TopAbs_IN) | |
88 | { | |
89 | mySqDist.Append(myExtSS.SquareDistance(i)); | |
90 | myPointsOnS1.Append(P1); | |
91 | myPointsOnS2.Append(P2); | |
92 | } | |
7fd59977 | 93 | } |
94 | } | |
95 | } | |
96 | } |