0024428: Implementation of LGPL license
[occt.git] / src / BRepExtrema / BRepExtrema_ExtPF.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//
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 (june 96) : on utilise BRepClass_FaceClassifier seulement
18// si IsDone de Extrema est vrai
92d1589b
A
19
20#include <BRepExtrema_ExtPF.hxx>
21
7fd59977 22#include <BRep_Tool.hxx>
23#include <BRepTools.hxx>
7fd59977 24#include <BRepClass_FaceClassifier.hxx>
25#include <gp_Pnt2d.hxx>
7fd59977 26#include <BRepAdaptor_Surface.hxx>
7fd59977 27
28//=======================================================================
29//function : BRepExtrema_ExtPF
30//purpose :
31//=======================================================================
32
92d1589b
A
33BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace,
34 const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
7fd59977 35{
92d1589b
A
36 Initialize(TheFace,TheFlag,TheAlgo);
37 Perform(TheVertex,TheFace);
7fd59977 38}
39
40//=======================================================================
41//function : Initialize
42//purpose :
43//=======================================================================
44
92d1589b
A
45void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
46 const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
7fd59977 47{
48 // cette surface doit etre en champ. Extrema ne fait
49 // pas de copie et prend seulement un pointeur dessus.
92d1589b
A
50 mySurf.Initialize(TheFace, Standard_False);
51 const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
7fd59977 52 Standard_Real U1, U2, V1, V2;
92d1589b
A
53 BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
54 myExtPS.SetFlag(TheFlag);
55 myExtPS.SetAlgo(TheAlgo);
56 myExtPS.Initialize(mySurf, U1, U2, V1, V2, Tol, Tol);
7fd59977 57}
58
59//=======================================================================
60//function : Perform
61//purpose :
62//=======================================================================
63
92d1589b 64void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace)
7fd59977 65{
66 mySqDist.Clear();
67 myPoints.Clear();
7fd59977 68
92d1589b
A
69 const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
70 myExtPS.Perform(P);
71
72 // Exploration of points and classification
73 if (myExtPS.IsDone())
74 {
75 BRepClass_FaceClassifier classifier;
76 Standard_Real U1, U2;
77 const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
78 for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
79 {
80 myExtPS.Point(i).Parameter(U1, U2);
81 const gp_Pnt2d Puv(U1, U2);
82 classifier.Perform(TheFace, Puv, Tol);
83 const TopAbs_State state = classifier.State();
84 if(state == TopAbs_ON || state == TopAbs_IN)
85 {
86 mySqDist.Append(myExtPS.SquareDistance(i));
87 myPoints.Append(myExtPS.Point(i));
88 }
7fd59977 89 }
90 }
7fd59977 91}