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 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
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 | |
7fd59977 |
15 | |
42cf5bc1 |
16 | #include <BRepAdaptor_HSurface.hxx> |
7fd59977 |
17 | #include <BRepAdaptor_Surface.hxx> |
42cf5bc1 |
18 | #include <BRepClass_FaceClassifier.hxx> |
19 | #include <BRepClass_FaceExplorer.hxx> |
7fd59977 |
20 | #include <BRepTools.hxx> |
42cf5bc1 |
21 | #include <Extrema_ExtPS.hxx> |
22 | #include <gp_Pnt.hxx> |
23 | #include <gp_Pnt2d.hxx> |
24 | #include <TopAbs_State.hxx> |
25 | #include <TopoDS_Face.hxx> |
7fd59977 |
26 | |
27 | //======================================================================= |
28 | //function : BRepClass_FaceClassifier |
29 | //purpose : |
30 | //======================================================================= |
31 | BRepClass_FaceClassifier::BRepClass_FaceClassifier() |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : BRepClass_FaceClassifier |
37 | //purpose : |
38 | //======================================================================= |
39 | BRepClass_FaceClassifier::BRepClass_FaceClassifier(BRepClass_FaceExplorer& F, |
40 | const gp_Pnt2d& P, |
41 | const Standard_Real Tol) |
42 | : |
43 | BRepClass_FClassifier(F,P,Tol) |
44 | { |
45 | } |
46 | //======================================================================= |
47 | //function : BRepClass_FaceClassifier |
48 | //purpose : |
49 | //======================================================================= |
50 | BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& F, |
51 | const gp_Pnt& P, |
52 | const Standard_Real Tol) |
53 | { |
54 | Perform(F,P,Tol); |
55 | } |
56 | //======================================================================= |
57 | //function : BRepClass_FaceClassifier |
58 | //purpose : |
59 | //======================================================================= |
60 | BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& F, |
61 | const gp_Pnt2d& P, |
62 | const Standard_Real Tol) |
63 | { |
64 | Perform(F,P,Tol); |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : Perform |
69 | //purpose : |
70 | //======================================================================= |
71 | void BRepClass_FaceClassifier::Perform(const TopoDS_Face& F, |
72 | const gp_Pnt2d& P, |
73 | const Standard_Real Tol) |
74 | { |
75 | BRepClass_FaceExplorer Fex(F); |
76 | BRepClass_FClassifier::Perform(Fex,P,Tol); |
77 | } |
78 | |
79 | |
80 | |
81 | |
82 | |
83 | |
84 | //======================================================================= |
85 | //function : Perform |
86 | //purpose : |
87 | //======================================================================= |
88 | void BRepClass_FaceClassifier::Perform(const TopoDS_Face& aF, |
89 | const gp_Pnt& aP, |
90 | const Standard_Real aTol) |
91 | { |
92 | Standard_Integer aNbExt, aIndice, i; |
93 | Standard_Real aU1, aU2, aV1, aV2, aMaxDist, aD; |
94 | gp_Pnt2d aPuv; |
95 | Extrema_ExtPS aExtrema; |
96 | // |
97 | aMaxDist=RealLast(); |
98 | aIndice=0; |
99 | // |
47cd8af2 |
100 | BRepAdaptor_Surface aSurf(aF, Standard_False); |
7fd59977 |
101 | BRepTools::UVBounds(aF, aU1, aU2, aV1, aV2); |
102 | aExtrema.Initialize(aSurf, aU1, aU2, aV1, aV2, aTol, aTol); |
103 | // |
104 | //modified by NIZNHY-PKV Wed Aug 13 11:28:47 2008f |
105 | rejected=Standard_True; |
106 | //modified by NIZNHY-PKV Wed Aug 13 11:28:49 2008t |
107 | aExtrema.Perform(aP); |
108 | if(!aExtrema.IsDone()) { |
109 | return; |
110 | } |
111 | // |
112 | aNbExt=aExtrema.NbExt(); |
113 | if(!aNbExt) { |
114 | return; |
115 | } |
116 | // |
117 | for (i=1; i<=aNbExt; ++i) { |
118 | aD=aExtrema.SquareDistance(i); |
119 | if(aD < aMaxDist) { |
120 | aMaxDist=aD; |
121 | aIndice=i; |
122 | } |
123 | } |
124 | // |
125 | if(aIndice) { |
126 | aExtrema.Point(aIndice).Parameter(aU1, aU2); |
127 | aPuv.SetCoord(aU1, aU2); |
128 | Perform(aF, aPuv, aTol); |
129 | } |
130 | } |