0024428: Implementation of LGPL license
[occt.git] / src / BRepClass / BRepClass_FaceClassifier.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
973c2be1 6// This library is free software; you can redistribute it and / or modify it
7// under the terms of the GNU Lesser General Public version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
7fd59977 14
15#include <BRepClass_FaceClassifier.ixx>
16#include <TopAbs_State.hxx>
17#include <Extrema_ExtPS.hxx>
18
19#include <BRepAdaptor_Surface.hxx>
20#include <BRepTools.hxx>
21#include <BRepAdaptor_HSurface.hxx>
22
23//=======================================================================
24//function : BRepClass_FaceClassifier
25//purpose :
26//=======================================================================
27BRepClass_FaceClassifier::BRepClass_FaceClassifier()
28{
29}
30
31//=======================================================================
32//function : BRepClass_FaceClassifier
33//purpose :
34//=======================================================================
35BRepClass_FaceClassifier::BRepClass_FaceClassifier(BRepClass_FaceExplorer& F,
36 const gp_Pnt2d& P,
37 const Standard_Real Tol)
38:
39 BRepClass_FClassifier(F,P,Tol)
40{
41}
42//=======================================================================
43//function : BRepClass_FaceClassifier
44//purpose :
45//=======================================================================
46BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& F,
47 const gp_Pnt& P,
48 const Standard_Real Tol)
49{
50 Perform(F,P,Tol);
51}
52//=======================================================================
53//function : BRepClass_FaceClassifier
54//purpose :
55//=======================================================================
56BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& F,
57 const gp_Pnt2d& P,
58 const Standard_Real Tol)
59{
60 Perform(F,P,Tol);
61}
62
63//=======================================================================
64//function : Perform
65//purpose :
66//=======================================================================
67void BRepClass_FaceClassifier::Perform(const TopoDS_Face& F,
68 const gp_Pnt2d& P,
69 const Standard_Real Tol)
70{
71 BRepClass_FaceExplorer Fex(F);
72 BRepClass_FClassifier::Perform(Fex,P,Tol);
73}
74
75
76
77
78
79
80//=======================================================================
81//function : Perform
82//purpose :
83//=======================================================================
84void BRepClass_FaceClassifier::Perform(const TopoDS_Face& aF,
85 const gp_Pnt& aP,
86 const Standard_Real aTol)
87{
88 Standard_Integer aNbExt, aIndice, i;
89 Standard_Real aU1, aU2, aV1, aV2, aMaxDist, aD;
90 gp_Pnt2d aPuv;
91 Extrema_ExtPS aExtrema;
92 //
93 aMaxDist=RealLast();
94 aIndice=0;
95 //
96 BRepAdaptor_Surface aSurf(aF);
97 BRepTools::UVBounds(aF, aU1, aU2, aV1, aV2);
98 aExtrema.Initialize(aSurf, aU1, aU2, aV1, aV2, aTol, aTol);
99 //
100 //modified by NIZNHY-PKV Wed Aug 13 11:28:47 2008f
101 rejected=Standard_True;
102 //modified by NIZNHY-PKV Wed Aug 13 11:28:49 2008t
103 aExtrema.Perform(aP);
104 if(!aExtrema.IsDone()) {
105 return;
106 }
107 //
108 aNbExt=aExtrema.NbExt();
109 if(!aNbExt) {
110 return;
111 }
112 //
113 for (i=1; i<=aNbExt; ++i) {
114 aD=aExtrema.SquareDistance(i);
115 if(aD < aMaxDist) {
116 aMaxDist=aD;
117 aIndice=i;
118 }
119 }
120 //
121 if(aIndice) {
122 aExtrema.Point(aIndice).Parameter(aU1, aU2);
123 aPuv.SetCoord(aU1, aU2);
124 Perform(aF, aPuv, aTol);
125 }
126}
127
128
129
130
131
132
133