b311480e |
1 | // Created on: 1994-03-30 |
2 | // Created by: Laurent BUCHARD |
3 | // Copyright (c) 1994-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #define MARCHEPASSIUNESEULEFACE 0 |
18 | |
19 | |
20 | #ifdef DEB |
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 | |
61 | #include <BRepClass3d_SolidClassifier.ixx> |
62 | |
63 | #include <TopoDS_Shape.hxx> |
64 | |
65 | BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier() |
66 | { |
67 | aSolidLoaded=isaholeinspace=Standard_False; |
68 | #if LBRCOMPT |
69 | STAT.NbConstrVide++; |
70 | #endif |
71 | } |
72 | |
73 | |
74 | void BRepClass3d_SolidClassifier::Load(const TopoDS_Shape& S) { |
75 | |
76 | #if LBRCOMPT |
77 | STAT.NbLoad++; |
78 | #endif |
79 | |
80 | if(aSolidLoaded) { |
81 | explorer.Destroy(); |
82 | } |
83 | explorer.InitShape(S); |
84 | aSolidLoaded = Standard_True; |
85 | |
86 | |
87 | #if MARCHEPASSIUNESEULEFACE |
88 | PerformInfinitePoint(1e-7); |
89 | if(State()==TopAbs_OUT) { |
90 | isaholeinspace=Standard_False; |
91 | } |
92 | else { |
93 | isaholeinspace=Standard_True; |
94 | } |
95 | #endif |
96 | } |
97 | |
98 | BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S) |
99 | : aSolidLoaded(Standard_True),explorer(S) |
100 | { |
101 | #if LBRCOMPT |
102 | STAT.NbConstrShape++; |
103 | #endif |
104 | #if MARCHEPASSIUNESEULEFACE |
105 | PerformInfinitePoint(1e-7); |
106 | if(State()==TopAbs_OUT) { |
107 | isaholeinspace=Standard_False; |
108 | } |
109 | else { |
110 | isaholeinspace=Standard_True; |
111 | } |
112 | #endif |
113 | } |
114 | |
115 | BRepClass3d_SolidClassifier::BRepClass3d_SolidClassifier(const TopoDS_Shape& S, |
116 | const gp_Pnt& P, |
117 | const Standard_Real Tol) |
118 | : explorer(S) { |
119 | #if LBRCOMPT |
120 | STAT.NbConstrShapePnt++; |
121 | #endif |
122 | aSolidLoaded = Standard_True; |
123 | #if MARCHEPASSIUNESEULEFACE |
124 | PerformInfinitePoint(1e-7); |
125 | if(State()==TopAbs_OUT) { |
126 | isaholeinspace=Standard_False; |
127 | } |
128 | else { |
129 | isaholeinspace=Standard_True; |
130 | } |
131 | |
132 | if(isaholeinspace==Standard_False) { |
133 | if(explorer.Box().IsOut(P)) { |
134 | ForceOut(); |
135 | } |
136 | else { |
137 | Perform(P,Tol); |
138 | } |
139 | } |
140 | else { |
141 | if(explorer.Box().IsOut(P)) { |
142 | ForceIn(); |
143 | } |
144 | else { |
145 | Perform(P,Tol); |
146 | } |
147 | } |
148 | #else |
149 | Perform(P,Tol); |
150 | #endif |
151 | } |
152 | |
153 | |
154 | void BRepClass3d_SolidClassifier::Perform(const gp_Pnt& P,const Standard_Real Tol) { |
155 | #if LBRCOMPT |
156 | STAT.NbPerform++; |
157 | #endif |
158 | #if MARCHEPASSIUNESEULEFACE |
159 | if(aSolidLoaded) { |
160 | if(isaholeinspace==Standard_False) { |
161 | if(explorer.Box().IsOut(P)) { |
162 | ForceOut(); |
163 | #if LBRCOMPT |
164 | STAT.NbPerformRejection++; |
165 | #endif |
166 | |
167 | } |
168 | else { |
169 | BRepClass3d_SClassifier::Perform(explorer,P,Tol); |
170 | } |
171 | } |
172 | else { |
173 | if(explorer.Box().IsOut(P)) { |
174 | ForceIn(); |
175 | #if LBRCOMPT |
176 | STAT.NbPerformRejection++; |
177 | #endif |
178 | |
179 | } |
180 | else { |
181 | BRepClass3d_SClassifier::Perform(explorer,P,Tol); |
182 | } |
183 | } |
184 | } |
185 | #else |
186 | BRepClass3d_SClassifier::Perform(explorer,P,Tol); |
187 | #endif |
188 | } |
189 | |
190 | void BRepClass3d_SolidClassifier::PerformInfinitePoint(const Standard_Real Tol) { |
191 | #if LBRCOMPT |
192 | STAT.NbPerformInfinitePoint++; |
193 | #endif |
194 | |
195 | if(aSolidLoaded) { |
196 | BRepClass3d_SClassifier::PerformInfinitePoint(explorer,Tol); |
197 | if(State()==TopAbs_OUT) |
198 | isaholeinspace=Standard_False; |
199 | else |
200 | isaholeinspace=Standard_True; |
201 | } |
202 | } |
203 | |
204 | |
205 | |
206 | void BRepClass3d_SolidClassifier::Destroy() { |
207 | #if LBRCOMPT |
208 | STAT.NbDestroy++; |
209 | #endif |
210 | |
211 | if(aSolidLoaded) { |
212 | explorer.Destroy(); |
213 | aSolidLoaded = Standard_False; |
214 | } |
215 | } |
216 | |
217 | |
218 | |