0024624: Lost word in license statement in source files
[occt.git] / src / BRepExtrema / BRepExtrema_ExtCF.cxx
CommitLineData
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//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 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.
7fd59977 16
92d1589b
A
17#include <BRepExtrema_ExtCF.hxx>
18
7fd59977 19#include <BRep_Tool.hxx>
20#include <BRepTools.hxx>
21#include <Geom_Curve.hxx>
7fd59977 22#include <BRepClass_FaceClassifier.hxx>
7fd59977 23#include <gp_Pnt2d.hxx>
24#include <BRepAdaptor_Surface.hxx>
25#include <BRepAdaptor_HSurface.hxx>
26#include <BRepAdaptor_Curve.hxx>
27#include <BRepAdaptor_HCurve.hxx>
28
29//=======================================================================
30//function : BRepExtrema_ExtCF
31//purpose :
32//=======================================================================
33
92d1589b 34BRepExtrema_ExtCF::BRepExtrema_ExtCF(const TopoDS_Edge& E, const TopoDS_Face& F)
7fd59977 35{
36 Initialize(F);
37 Perform(E, F);
38}
39
40//=======================================================================
41//function : Initialize
42//purpose :
43//=======================================================================
44
45void BRepExtrema_ExtCF::Initialize(const TopoDS_Face& F2)
46{
47 BRepAdaptor_Surface Surf(F2);
48 myHS = new BRepAdaptor_HSurface(Surf);
92d1589b 49 const Standard_Real Tol = BRep_Tool::Tolerance(F2);
7fd59977 50 Standard_Real U1, U2, V1, V2;
51 BRepTools::UVBounds(F2, U1, U2, V1, V2);
92d1589b 52 myExtCS.Initialize(myHS->Surface(), U1, U2, V1, V2, Tol, Tol);
7fd59977 53}
54
55//=======================================================================
56//function : Perform
57//purpose :
58//=======================================================================
59
92d1589b 60void BRepExtrema_ExtCF::Perform(const TopoDS_Edge& E, const TopoDS_Face& F2)
7fd59977 61{
62 mySqDist.Clear();
63 myPointsOnS.Clear();
64 myPointsOnC.Clear();
92d1589b 65
7fd59977 66 Standard_Real U1, U2;
67 BRep_Tool::Range(E, U1, U2);
68
69 BRepAdaptor_Curve Curv(E);
70 Handle(BRepAdaptor_HCurve) HC = new BRepAdaptor_HCurve(Curv);
92d1589b 71 myExtCS.Perform(HC->Curve(), U1, U2);
7fd59977 72
92d1589b 73 if(!myExtCS.IsDone())
7fd59977 74 return;
75
92d1589b
A
76 if (myExtCS.IsParallel())
77 mySqDist.Append(myExtCS.SquareDistance(1));
78 else
79 {
80 // Exploration of points and classification
81 BRepClass_FaceClassifier classifier;
82 const Standard_Real Tol = BRep_Tool::Tolerance(F2);
83 Extrema_POnCurv P1;
84 Extrema_POnSurf P2;
85
86 for (Standard_Integer i = 1; i <= myExtCS.NbExt(); i++)
87 {
88 myExtCS.Points(i, P1, P2);
7fd59977 89 P2.Parameter(U1, U2);
92d1589b 90 const gp_Pnt2d Puv(U1, U2);
7fd59977 91 classifier.Perform(F2, Puv, Tol);
92d1589b
A
92 const TopAbs_State state = classifier.State();
93 if (state == TopAbs_ON || state == TopAbs_IN)
94 {
95 mySqDist.Append(myExtCS.SquareDistance(i));
96 myPointsOnC.Append(P1);
97 myPointsOnS.Append(P2);
7fd59977 98 }
99 }
100 }
101}