1 // Created on: 1993-12-15
2 // Created by: Christophe MARION
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 // modified by MPS (june 96) : on utilise BRepClass_FaceClassifier seulement
18 // si IsDone de Extrema est vrai
20 #include <BRepExtrema_ExtPF.hxx>
22 #include <BRep_Tool.hxx>
23 #include <BRepTools.hxx>
24 #include <BRepClass_FaceClassifier.hxx>
25 #include <gp_Pnt2d.hxx>
26 #include <BRepAdaptor_Surface.hxx>
27 #include <Precision.hxx>
29 //=======================================================================
30 //function : BRepExtrema_ExtPF
32 //=======================================================================
34 BRepExtrema_ExtPF::BRepExtrema_ExtPF(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace,
35 const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
37 Initialize(TheFace,TheFlag,TheAlgo);
38 Perform(TheVertex,TheFace);
41 //=======================================================================
42 //function : Initialize
44 //=======================================================================
46 void BRepExtrema_ExtPF::Initialize(const TopoDS_Face& TheFace,
47 const Extrema_ExtFlag TheFlag, const Extrema_ExtAlgo TheAlgo)
49 // cette surface doit etre en champ. Extrema ne fait
50 // pas de copie et prend seulement un pointeur dessus.
51 mySurf.Initialize(TheFace, Standard_False);
53 if (mySurf.GetType() == GeomAbs_OtherSurface)
54 return; // protect against non-geometric type (e.g. triangulation)
56 Standard_Real Tol = Min(BRep_Tool::Tolerance(TheFace), Precision::Confusion());
57 Standard_Real aTolU, aTolV;
58 aTolU = Max(mySurf.UResolution(Tol), Precision::PConfusion());
59 aTolV = Max(mySurf.VResolution(Tol), Precision::PConfusion());
60 Standard_Real U1, U2, V1, V2;
61 BRepTools::UVBounds(TheFace, U1, U2, V1, V2);
62 myExtPS.SetFlag(TheFlag);
63 myExtPS.SetAlgo(TheAlgo);
64 myExtPS.Initialize(mySurf, U1, U2, V1, V2, aTolU, aTolV);
67 //=======================================================================
70 //=======================================================================
72 void BRepExtrema_ExtPF::Perform(const TopoDS_Vertex& TheVertex, const TopoDS_Face& TheFace)
77 const gp_Pnt P = BRep_Tool::Pnt(TheVertex);
78 if (mySurf.GetType() == GeomAbs_OtherSurface)
79 return; // protect against non-geometric type (e.g. triangulation)
83 // Exploration of points and classification
86 BRepClass_FaceClassifier classifier;
88 const Standard_Real Tol = BRep_Tool::Tolerance(TheFace);
89 for (Standard_Integer i = 1; i <= myExtPS.NbExt(); i++)
91 myExtPS.Point(i).Parameter(U1, U2);
92 const gp_Pnt2d Puv(U1, U2);
93 classifier.Perform(TheFace, Puv, Tol);
94 const TopAbs_State state = classifier.State();
95 if(state == TopAbs_ON || state == TopAbs_IN)
97 mySqDist.Append(myExtPS.SquareDistance(i));
98 myPoints.Append(myExtPS.Point(i));