Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1993-12-15 |
2 | // Created by: Christophe MARION | |
3 | // Copyright (c) 1993-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
973c2be1 | 8 | // This library is free software; you can redistribute it and / or modify it |
9 | // under the terms of the GNU Lesser General Public version 2.1 as published | |
10 | // by the Free Software Foundation, with special exception defined in the file | |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
b311480e | 16 | |
7fd59977 | 17 | // modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de |
18 | // GeomAdaptor dans Initialize et Perform. | |
92d1589b A |
19 | |
20 | #include <BRepExtrema_ExtFF.hxx> | |
21 | ||
7fd59977 | 22 | #include <BRepExtrema_ExtCF.hxx> |
23 | #include <BRep_Tool.hxx> | |
24 | #include <BRepTools.hxx> | |
7fd59977 | 25 | #include <BRepClass_FaceClassifier.hxx> |
7fd59977 | 26 | #include <gp_Pnt2d.hxx> |
27 | #include <Precision.hxx> | |
28 | #include <BRepAdaptor_HSurface.hxx> | |
29 | ||
30 | //======================================================================= | |
31 | //function : BRepExtrema_ExtFF | |
32 | //purpose : | |
33 | //======================================================================= | |
34 | ||
92d1589b | 35 | BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F2) |
7fd59977 | 36 | { |
37 | Initialize(F2); | |
38 | Perform(F1,F2); | |
39 | } | |
92d1589b | 40 | |
7fd59977 | 41 | //======================================================================= |
42 | //function : Initialize | |
43 | //purpose : | |
44 | //======================================================================= | |
45 | ||
46 | void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2) | |
47 | { | |
48 | BRepAdaptor_Surface Surf(F2); | |
49 | myHS = new BRepAdaptor_HSurface(Surf); | |
92d1589b | 50 | const Standard_Real Tol = BRep_Tool::Tolerance(F2); |
7fd59977 | 51 | Standard_Real U1, U2, V1, V2; |
52 | BRepTools::UVBounds(F2, U1, U2, V1, V2); | |
92d1589b | 53 | myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol); |
7fd59977 | 54 | } |
55 | ||
56 | //======================================================================= | |
57 | //function : Perform | |
58 | //purpose : | |
59 | //======================================================================= | |
60 | ||
92d1589b | 61 | void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2) |
7fd59977 | 62 | { |
7fd59977 | 63 | mySqDist.Clear(); |
64 | myPointsOnS1.Clear(); | |
65 | myPointsOnS2.Clear(); | |
92d1589b | 66 | |
7fd59977 | 67 | BRepAdaptor_Surface Surf1(F1); |
68 | Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1); | |
92d1589b A |
69 | const Standard_Real Tol1 = BRep_Tool::Tolerance(F1); |
70 | Standard_Real U1, U2, V1, V2; | |
7fd59977 | 71 | BRepTools::UVBounds(F1, U1, U2, V1, V2); |
92d1589b A |
72 | myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1); |
73 | ||
74 | if (!myExtSS.IsDone()) | |
75 | return; | |
76 | ||
77 | if (myExtSS.IsParallel()) | |
78 | mySqDist.Append(myExtSS.SquareDistance(1)); | |
79 | else | |
80 | { | |
81 | // Exploration of points and classification | |
82 | BRepClass_FaceClassifier classifier; | |
83 | const Standard_Real Tol2 = BRep_Tool::Tolerance(F2); | |
84 | Extrema_POnSurf P1, P2; | |
85 | ||
86 | Standard_Integer i; | |
87 | for (i = 1; i <= myExtSS.NbExt(); i++) | |
88 | { | |
89 | myExtSS.Points(i, P1, P2); | |
7fd59977 | 90 | P1.Parameter(U1, U2); |
92d1589b A |
91 | const gp_Pnt2d Puv1(U1, U2); |
92 | classifier.Perform(F1, Puv1, Tol1); | |
93 | const TopAbs_State state1 = classifier.State(); | |
94 | if (state1 == TopAbs_ON || state1 == TopAbs_IN) | |
95 | { | |
96 | P2.Parameter(U1, U2); | |
97 | const gp_Pnt2d Puv2(U1, U2); | |
98 | classifier.Perform(F2, Puv2, Tol2); | |
99 | const TopAbs_State state2 = classifier.State(); | |
100 | if (state2 == TopAbs_ON || state2 == TopAbs_IN) | |
101 | { | |
102 | mySqDist.Append(myExtSS.SquareDistance(i)); | |
103 | myPointsOnS1.Append(P1); | |
104 | myPointsOnS2.Append(P2); | |
105 | } | |
7fd59977 | 106 | } |
107 | } | |
108 | } | |
109 | } |