0032781: Coding - get rid of unused headers [BRepCheck to ChFiKPart]
[occt.git] / src / BRepClass3d / BRepClass3d_SolidClassifier.cxx
1 // Created on: 1994-03-30
2 // Created by: Laurent BUCHARD
3 // Copyright (c) 1994-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #define MARCHEPASSIUNESEULEFACE 0
18
19
20 #ifdef OCCT_DEBUG
21 #define LBRCOMPT 0
22 #else 
23 #define LBRCOMPT 0
24 #endif
25
26 #if LBRCOMPT
27 #include <stdio.h>
28
29 class StatistiquesBRepClass3d { 
30 public:
31   long unsigned NbConstrVide;
32   long unsigned NbLoad;
33   long unsigned NbConstrShape;
34   long unsigned NbConstrShapePnt;
35   long unsigned NbPerform;
36   long unsigned NbPerformRejection;
37   long unsigned NbPerformInfinitePoint;
38   long unsigned NbDestroy;
39 public:
40   StatistiquesBRepClass3d() { 
41     NbConstrVide=NbLoad=NbConstrShape=NbConstrShapePnt=NbPerform=NbPerformInfinitePoint=NbDestroy=0;
42   }
43   ~StatistiquesBRepClass3d() { 
44     printf("\n--- Statistiques BRepClass3d:\n");
45
46     printf("\nConstructeurVide    : %10lu",NbConstrVide);
47     printf("\nConstructeur(Shape) : %10lu",NbConstrShape);
48     printf("\nLoad(Shape)         : %10lu",NbLoad);
49     printf("\nPerform(pnt3d)      : %10lu",NbPerform);
50     printf("\nPerform(pnt3d) REJ  : %10lu",NbPerformRejection);
51     printf("\nPerformInfinitePoint: %10lu",NbPerformInfinitePoint);
52     printf("\nDestroy             : %10lu",NbDestroy             );
53   }
54 };
55
56 static StatistiquesBRepClass3d STAT;
57 #endif
58
59
60 #include <BRepClass3d_SolidClassifier.hxx>
61 #include <gp_Pnt.hxx>
62 #include <TopoDS_Shape.hxx>
63
64 BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier()
65 {
66   aSolidLoaded=isaholeinspace=Standard_False;
67 #if LBRCOMPT
68   STAT.NbConstrVide++;
69 #endif
70 }
71
72
73 void BRepClass3d_SolidClassifier::Load(const TopoDS_Shape& S) {
74
75 #if LBRCOMPT
76   STAT.NbLoad++;
77 #endif
78
79   if(aSolidLoaded) { 
80     explorer.Destroy();
81   }
82   explorer.InitShape(S);
83   aSolidLoaded = Standard_True;
84
85
86 #if MARCHEPASSIUNESEULEFACE
87   PerformInfinitePoint(1e-7);
88   if(State()==TopAbs_OUT) { 
89     isaholeinspace=Standard_False;
90   }
91   else { 
92     isaholeinspace=Standard_True;
93   }
94 #endif  
95 }
96
97 BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S)
98 : aSolidLoaded(Standard_True),
99   explorer(S),
100   isaholeinspace(Standard_False)
101
102 #if LBRCOMPT
103   STAT.NbConstrShape++;
104 #endif
105 #if MARCHEPASSIUNESEULEFACE
106   PerformInfinitePoint(1e-7);
107   if(State()==TopAbs_OUT) { 
108     isaholeinspace=Standard_False;
109   }
110   else { 
111     isaholeinspace=Standard_True;
112   }
113 #endif  
114 }
115
116 BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S,
117                                                          const gp_Pnt&       P,
118                                                          const Standard_Real Tol) 
119 : explorer(S) { 
120 #if LBRCOMPT
121   STAT.NbConstrShapePnt++;
122 #endif
123   aSolidLoaded = Standard_True;
124 #if MARCHEPASSIUNESEULEFACE  
125   PerformInfinitePoint(1e-7);
126   if(State()==TopAbs_OUT) { 
127     isaholeinspace=Standard_False;
128   }
129   else { 
130     isaholeinspace=Standard_True;
131   }
132   
133   if(isaholeinspace==Standard_False) { 
134     if(explorer.Box().IsOut(P)) { 
135       ForceOut(); 
136     }
137     else {
138       Perform(P,Tol); 
139     }
140   }
141   else { 
142     if(explorer.Box().IsOut(P)) { 
143       ForceIn(); 
144     }
145     else {
146       Perform(P,Tol); 
147     }
148   }
149 #else 
150   Perform(P,Tol); 
151 #endif
152 }
153
154
155 void BRepClass3d_SolidClassifier::Perform(const gp_Pnt& P,const Standard_Real Tol) { 
156 #if LBRCOMPT
157   STAT.NbPerform++;
158 #endif
159 #if MARCHEPASSIUNESEULEFACE 
160   if(aSolidLoaded) { 
161     if(isaholeinspace==Standard_False) { 
162       if(explorer.Box().IsOut(P)) { 
163         ForceOut(); 
164 #if LBRCOMPT
165         STAT.NbPerformRejection++;
166 #endif
167         
168       }
169       else {
170         BRepClass3d_SClassifier::Perform(explorer,P,Tol);
171       }
172     }
173     else { 
174       if(explorer.Box().IsOut(P)) { 
175         ForceIn(); 
176 #if LBRCOMPT
177         STAT.NbPerformRejection++;
178 #endif
179         
180       }
181       else {
182         BRepClass3d_SClassifier::Perform(explorer,P,Tol);
183       }
184     }
185   }
186 #else 
187   BRepClass3d_SClassifier::Perform(explorer,P,Tol);
188 #endif
189 }
190
191 void BRepClass3d_SolidClassifier::PerformInfinitePoint(const Standard_Real Tol) { 
192 #if LBRCOMPT
193   STAT.NbPerformInfinitePoint++;
194 #endif
195
196   if(aSolidLoaded) { 
197     BRepClass3d_SClassifier::PerformInfinitePoint(explorer,Tol);
198     if(State()==TopAbs_OUT) 
199       isaholeinspace=Standard_False;
200     else 
201       isaholeinspace=Standard_True;
202   }
203 }
204
205
206
207 void BRepClass3d_SolidClassifier::Destroy() { 
208 #if LBRCOMPT
209   STAT.NbDestroy++;
210 #endif
211
212   if(aSolidLoaded) { 
213     explorer.Destroy();
214     aSolidLoaded = Standard_False;
215   }
216 }
217
218
219