1 // Created on: 1993-12-15
2 // Created by: Christophe MARION
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
21 // modified by mps (juillet 96 ): on utilise BRepAdaptor a la place de
22 // GeomAdaptor dans Initialize et Perform.
24 #include <BRepExtrema_ExtFF.hxx>
26 #include <BRepExtrema_ExtCF.hxx>
27 #include <BRep_Tool.hxx>
28 #include <BRepTools.hxx>
29 #include <BRepClass_FaceClassifier.hxx>
30 #include <gp_Pnt2d.hxx>
31 #include <Precision.hxx>
32 #include <BRepAdaptor_HSurface.hxx>
34 //=======================================================================
35 //function : BRepExtrema_ExtFF
37 //=======================================================================
39 BRepExtrema_ExtFF::BRepExtrema_ExtFF(const TopoDS_Face& F1, const TopoDS_Face& F2)
45 //=======================================================================
46 //function : Initialize
48 //=======================================================================
50 void BRepExtrema_ExtFF::Initialize(const TopoDS_Face& F2)
52 BRepAdaptor_Surface Surf(F2);
53 myHS = new BRepAdaptor_HSurface(Surf);
54 const Standard_Real Tol = BRep_Tool::Tolerance(F2);
55 Standard_Real U1, U2, V1, V2;
56 BRepTools::UVBounds(F2, U1, U2, V1, V2);
57 myExtSS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol);
60 //=======================================================================
63 //=======================================================================
65 void BRepExtrema_ExtFF::Perform(const TopoDS_Face& F1, const TopoDS_Face& F2)
71 BRepAdaptor_Surface Surf1(F1);
72 Handle(BRepAdaptor_HSurface) HS1 = new BRepAdaptor_HSurface(Surf1);
73 const Standard_Real Tol1 = BRep_Tool::Tolerance(F1);
74 Standard_Real U1, U2, V1, V2;
75 BRepTools::UVBounds(F1, U1, U2, V1, V2);
76 myExtSS.Perform(HS1->Surface(), U1, U2, V1, V2, Tol1);
78 if (!myExtSS.IsDone())
81 if (myExtSS.IsParallel())
82 mySqDist.Append(myExtSS.SquareDistance(1));
85 // Exploration of points and classification
86 BRepClass_FaceClassifier classifier;
87 const Standard_Real Tol2 = BRep_Tool::Tolerance(F2);
88 Extrema_POnSurf P1, P2;
91 for (i = 1; i <= myExtSS.NbExt(); i++)
93 myExtSS.Points(i, P1, P2);
95 const gp_Pnt2d Puv1(U1, U2);
96 classifier.Perform(F1, Puv1, Tol1);
97 const TopAbs_State state1 = classifier.State();
98 if (state1 == TopAbs_ON || state1 == TopAbs_IN)
100 P2.Parameter(U1, U2);
101 const gp_Pnt2d Puv2(U1, U2);
102 classifier.Perform(F2, Puv2, Tol2);
103 const TopAbs_State state2 = classifier.State();
104 if (state2 == TopAbs_ON || state2 == TopAbs_IN)
106 mySqDist.Append(myExtSS.SquareDistance(i));
107 myPointsOnS1.Append(P1);
108 myPointsOnS2.Append(P2);