1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
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
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.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <BRepClass_FaceClassifier.hxx>
16
17 #include <BRepAdaptor_Surface.hxx>
18 #include <BRepClass_FaceExplorer.hxx>
19 #include <BRepTools.hxx>
20 #include <Extrema_ExtPS.hxx>
21 #include <gp_Pnt.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <TopAbs_State.hxx>
24 #include <TopoDS_Face.hxx>
25
26 //=======================================================================
27 //function : BRepClass_FaceClassifier
28 //purpose :
29 //=======================================================================
BRepClass_FaceClassifier()30 BRepClass_FaceClassifier::BRepClass_FaceClassifier()
31 {
32 }
33
34 //=======================================================================
35 //function : BRepClass_FaceClassifier
36 //purpose :
37 //=======================================================================
BRepClass_FaceClassifier(BRepClass_FaceExplorer & F,const gp_Pnt2d & P,const Standard_Real Tol)38 BRepClass_FaceClassifier::BRepClass_FaceClassifier(BRepClass_FaceExplorer& F,
39 const gp_Pnt2d& P,
40 const Standard_Real Tol)
41 :
42 BRepClass_FClassifier(F,P,Tol)
43 {
44 }
45 //=======================================================================
46 //function : BRepClass_FaceClassifier
47 //purpose :
48 //=======================================================================
BRepClass_FaceClassifier(const TopoDS_Face & theF,const gp_Pnt & theP,const Standard_Real theTol,const Standard_Boolean theUseBndBox,const Standard_Real theGapCheckTol)49 BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& theF,
50 const gp_Pnt& theP,
51 const Standard_Real theTol,
52 const Standard_Boolean theUseBndBox,
53 const Standard_Real theGapCheckTol)
54 {
55 Perform(theF, theP, theTol, theUseBndBox, theGapCheckTol);
56 }
57 //=======================================================================
58 //function : BRepClass_FaceClassifier
59 //purpose :
60 //=======================================================================
BRepClass_FaceClassifier(const TopoDS_Face & theF,const gp_Pnt2d & theP,const Standard_Real theTol,const Standard_Boolean theUseBndBox,const Standard_Real theGapCheckTol)61 BRepClass_FaceClassifier::BRepClass_FaceClassifier(const TopoDS_Face& theF,
62 const gp_Pnt2d& theP,
63 const Standard_Real theTol,
64 const Standard_Boolean theUseBndBox,
65 const Standard_Real theGapCheckTol)
66 {
67 Perform(theF, theP, theTol, theUseBndBox, theGapCheckTol);
68 }
69
70 //=======================================================================
71 //function : Perform
72 //purpose :
73 //=======================================================================
Perform(const TopoDS_Face & theF,const gp_Pnt2d & theP,const Standard_Real theTol,const Standard_Boolean theUseBndBox,const Standard_Real theGapCheckTol)74 void BRepClass_FaceClassifier::Perform(const TopoDS_Face& theF,
75 const gp_Pnt2d& theP,
76 const Standard_Real theTol,
77 const Standard_Boolean theUseBndBox,
78 const Standard_Real theGapCheckTol)
79 {
80 BRepClass_FaceExplorer aFex(theF);
81 aFex.SetMaxTolerance(theGapCheckTol);
82 aFex.SetUseBndBox(theUseBndBox);
83 BRepClass_FClassifier::Perform(aFex, theP, theTol);
84 }
85
86
87
88
89
90
91 //=======================================================================
92 //function : Perform
93 //purpose :
94 //=======================================================================
Perform(const TopoDS_Face & theF,const gp_Pnt & theP,const Standard_Real theTol,const Standard_Boolean theUseBndBox,const Standard_Real theGapCheckTol)95 void BRepClass_FaceClassifier::Perform(const TopoDS_Face& theF,
96 const gp_Pnt& theP,
97 const Standard_Real theTol,
98 const Standard_Boolean theUseBndBox,
99 const Standard_Real theGapCheckTol)
100 {
101 Standard_Integer aNbExt, aIndice, i;
102 Standard_Real aU1, aU2, aV1, aV2, aMaxDist, aD;
103 gp_Pnt2d aPuv;
104 Extrema_ExtPS aExtrema;
105 //
106 aMaxDist=RealLast();
107 aIndice=0;
108 //
109 BRepAdaptor_Surface aSurf(theF, Standard_False);
110 BRepTools::UVBounds(theF, aU1, aU2, aV1, aV2);
111 aExtrema.Initialize(aSurf, aU1, aU2, aV1, aV2, theTol, theTol);
112 //
113 //modified by NIZNHY-PKV Wed Aug 13 11:28:47 2008f
114 rejected=Standard_True;
115 //modified by NIZNHY-PKV Wed Aug 13 11:28:49 2008t
116 aExtrema.Perform(theP);
117 if(!aExtrema.IsDone()) {
118 return;
119 }
120 //
121 aNbExt=aExtrema.NbExt();
122 if(!aNbExt) {
123 return;
124 }
125 //
126 for (i=1; i<=aNbExt; ++i) {
127 aD=aExtrema.SquareDistance(i);
128 if(aD < aMaxDist) {
129 aMaxDist=aD;
130 aIndice=i;
131 }
132 }
133 //
134 if(aIndice) {
135 aExtrema.Point(aIndice).Parameter(aU1, aU2);
136 aPuv.SetCoord(aU1, aU2);
137 Perform(theF, aPuv, theTol, theUseBndBox, theGapCheckTol);
138 }
139 }
140