b311480e |
1 | // Created on: 1997-04-10 |
2 | // Created by: Prestataire Mary FABIEN |
3 | // Copyright (c) 1997-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 | #include <TCollection_AsciiString.hxx> |
18 | #include <TopOpeBRepDS_Check.ixx> |
19 | #include <TopOpeBRepDS_Kind.hxx> |
20 | #include <TopOpeBRepDS_CheckStatus.hxx> |
21 | #include <TopOpeBRepDS_PointExplorer.hxx> |
22 | #include <TopOpeBRepDS.hxx> |
23 | #include <TopOpeBRepDS_Interference.hxx> |
24 | #include <TopOpeBRepDS_EdgeVertexInterference.hxx> |
25 | #include <TopOpeBRepDS_CurvePointInterference.hxx> |
26 | #include <TopOpeBRepDS_ListOfInterference.hxx> |
27 | #include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx> |
28 | #include <TopOpeBRepDS_InterferenceTool.hxx> |
29 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
30 | #include <TopTools_ListOfShape.hxx> |
31 | #include <TopOpeBRepTool_ShapeTool.hxx> |
32 | #include <TColStd_IndexedMapOfInteger.hxx> |
33 | #include <BRep_Tool.hxx> |
34 | #include <TopoDS.hxx> |
35 | #include <TopoDS_Shape.hxx> |
36 | #include <TopoDS_Vertex.hxx> |
37 | #include <gp_Pnt.hxx> |
38 | #include <string.h> |
39 | #include <TopOpeBRepDS_DataMapOfCheckStatus.hxx> |
40 | #include <TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus.hxx> |
41 | |
42 | //======================================================================= |
43 | //function : Create |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | TopOpeBRepDS_Check::TopOpeBRepDS_Check(const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
7fd59977 |
48 | { |
49 | myHDS = HDS; |
50 | myMapSurfaceStatus.Clear(); |
51 | myMapCurveStatus.Clear(); |
52 | myMapPointStatus.Clear(); |
53 | myMapShapeStatus.Clear(); |
54 | } |
55 | |
56 | //======================================================================= |
57 | //function : Create |
58 | //purpose : |
59 | //======================================================================= |
60 | |
61 | TopOpeBRepDS_Check::TopOpeBRepDS_Check() |
7fd59977 |
62 | { |
63 | myMapSurfaceStatus.Clear(); |
64 | myMapCurveStatus.Clear(); |
65 | myMapPointStatus.Clear(); |
66 | myMapShapeStatus.Clear(); |
67 | } |
68 | |
69 | //======================================================================= |
70 | //function : ChkIntg |
71 | //purpose : Check Integrity |
72 | //======================================================================= |
73 | Standard_Boolean CheckEdgeParameter(const Handle(TopOpeBRepDS_HDataStructure)& myHDS); |
74 | Standard_Boolean TopOpeBRepDS_Check::ChkIntg() |
75 | { |
76 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); |
77 | Standard_Boolean bI=Standard_False; |
78 | // Check the integrity of the DS |
79 | Standard_Integer i,nshape = DS.NbShapes(); |
80 | for (i = 1; i <= nshape; i++) { |
81 | // Integrity of Interferences : Check support and geometry |
82 | const TopOpeBRepDS_ListOfInterference& LI = DS.ShapeInterferences(i); |
83 | bI = ChkIntgInterf(LI); |
84 | } |
85 | Standard_Integer nsurface = DS.NbSurfaces(); |
86 | for (i = 1; i <= nsurface; i++) { |
87 | // Integrity of Interferences : Check support and geometry |
88 | const TopOpeBRepDS_ListOfInterference& LI = DS.SurfaceInterferences(i); |
89 | bI = bI && ChkIntgInterf(LI); |
90 | } |
91 | |
92 | Standard_Integer ncurve = DS.NbCurves(); |
93 | for (i = 1; i <= ncurve; i++) { |
94 | // Integrity of Interferences : Check support and geometry |
95 | const TopOpeBRepDS_ListOfInterference& LI = DS.CurveInterferences(i); |
96 | bI = bI && ChkIntgInterf(LI); |
97 | } |
98 | |
99 | Standard_Integer npoint = DS.NbPoints(); |
100 | for (i = 1; i <= npoint; i++) { |
101 | // Integrity of Interferences : Check support and geometry |
102 | const TopOpeBRepDS_ListOfInterference& LI = DS.PointInterferences(i); |
103 | bI = bI && ChkIntgInterf(LI); |
104 | } |
105 | |
0797d9d3 |
106 | #ifdef OCCT_DEBUG |
7fd59977 |
107 | PrintIntg(cout); |
108 | #endif |
109 | // CheckEdgeParameter(); |
110 | CheckEdgeParameter(myHDS); |
111 | |
112 | return bI; |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : ChkIntgInterf |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | Standard_Boolean TopOpeBRepDS_Check::ChkIntgInterf |
121 | (const TopOpeBRepDS_ListOfInterference& LI) |
122 | { |
123 | TopOpeBRepDS_ListIteratorOfListOfInterference it1; |
124 | it1.Initialize(LI); |
125 | Standard_Boolean IsOK = Standard_True; |
126 | while (it1.More() ) { |
127 | Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); |
128 | IsOK = IsOK && CheckDS(I1->Support(), I1->SupportType()); |
129 | IsOK = IsOK && CheckDS(I1->Geometry(), I1->GeometryType()); |
130 | it1.Next(); |
131 | } |
132 | return IsOK; |
133 | } |
134 | |
135 | //======================================================================= |
136 | //function : CheckDS |
137 | //purpose : |
138 | //======================================================================= |
139 | |
140 | Standard_Boolean TopOpeBRepDS_Check::CheckDS(const Standard_Integer I, |
141 | const TopOpeBRepDS_Kind K) |
142 | { |
143 | // geometry |
144 | switch(K) { |
145 | case TopOpeBRepDS_SURFACE : |
146 | { |
147 | if(myHDS->NbSurfaces() < I) { |
0797d9d3 |
148 | #ifdef OCCT_DEBUG |
7fd59977 |
149 | cout<<"Surpassed index of TopOpeBRepDS_SURFACE. actual index : "<<I; |
150 | cout<<". Index max : "<<myHDS->NbSurfaces(); |
151 | #endif |
152 | if(myMapSurfaceStatus.IsBound(I)) |
153 | myMapSurfaceStatus.UnBind(I); |
154 | myMapSurfaceStatus.Bind(I, TopOpeBRepDS_NOK); |
155 | return Standard_False; |
156 | } |
157 | if(!myMapSurfaceStatus.IsBound(I)) |
158 | myMapSurfaceStatus.Bind(I,TopOpeBRepDS_OK); |
159 | return Standard_True; |
160 | } |
161 | case TopOpeBRepDS_CURVE : |
162 | { |
163 | if(myHDS->NbCurves() < I) { |
0797d9d3 |
164 | #ifdef OCCT_DEBUG |
7fd59977 |
165 | cout<<"Surpassed index of TopOpeBRepDS_CURVE. actual index : "<<I; |
166 | cout<<". Index max : "<<myHDS->NbCurves(); |
167 | #endif |
168 | if(myMapCurveStatus.IsBound(I)) |
169 | myMapCurveStatus.UnBind(I); |
170 | myMapCurveStatus.Bind(I, TopOpeBRepDS_NOK); |
171 | return Standard_False; |
172 | } |
173 | |
174 | if(!myMapCurveStatus.IsBound(I)) |
175 | myMapCurveStatus.Bind(I,TopOpeBRepDS_OK); |
176 | return Standard_True; |
177 | } |
178 | case TopOpeBRepDS_POINT : |
179 | { |
180 | if(myHDS->NbPoints() < I) { |
0797d9d3 |
181 | #ifdef OCCT_DEBUG |
7fd59977 |
182 | cout<<"Surpassed index of TopOpeBRepDS_POINT : actual index : "<<I; |
183 | cout<<". Index max : "<<myHDS->NbPoints()<<endl; |
184 | #endif |
185 | if(myMapPointStatus.IsBound(I)) |
186 | myMapPointStatus.UnBind(I); |
187 | myMapPointStatus.Bind(I, TopOpeBRepDS_NOK); |
188 | return Standard_False; |
189 | } |
190 | if(!myMapPointStatus.IsBound(I)) |
191 | myMapPointStatus.Bind(I,TopOpeBRepDS_OK); |
192 | return Standard_True; |
193 | } |
194 | default: |
195 | break ; |
196 | } |
197 | |
198 | |
199 | // topology |
200 | if(myHDS->NbShapes() < I) { |
0797d9d3 |
201 | #ifdef OCCT_DEBUG |
7fd59977 |
202 | cout<<"Surpassed index of TopOpeBRepDS_Shape_. actual index : "<<I; |
203 | cout<<". Index max : "<<myHDS->NbShapes(); |
204 | #endif |
205 | if(myMapShapeStatus.IsBound(I)) |
206 | myMapShapeStatus.UnBind(I); |
207 | myMapShapeStatus.Bind(I,TopOpeBRepDS_NOK); |
208 | return Standard_False; |
209 | } |
210 | const TopoDS_Shape& S =myHDS->Shape(I); |
1d47d8d0 |
211 | |
7fd59977 |
212 | TopAbs_ShapeEnum se=TopAbs_COMPOUND; |
1d47d8d0 |
213 | |
7fd59977 |
214 | switch (K) { |
215 | case TopOpeBRepDS_SOLID : se = TopAbs_SOLID; break; |
216 | case TopOpeBRepDS_SHELL : se = TopAbs_SHELL; break; |
217 | case TopOpeBRepDS_FACE : se = TopAbs_FACE; break; |
218 | case TopOpeBRepDS_WIRE : se = TopAbs_WIRE; break; |
219 | case TopOpeBRepDS_EDGE : se = TopAbs_EDGE; break; |
220 | case TopOpeBRepDS_VERTEX : se = TopAbs_VERTEX;break; |
221 | default: |
222 | break ; |
223 | } |
224 | if(S.ShapeType() != se) { |
0797d9d3 |
225 | #ifdef OCCT_DEBUG |
7fd59977 |
226 | cout<<"Error : Shape "<<I<<" is a "; |
227 | TopOpeBRepDS::Print(TopOpeBRepDS::ShapeToKind(S.ShapeType()), cout); |
228 | cout<<" and not a "; |
229 | TopOpeBRepDS::Print(K, cout); |
230 | cout<<endl; |
231 | #endif |
232 | if(myMapShapeStatus.IsBound(I)) |
233 | myMapShapeStatus.UnBind(I); |
234 | myMapShapeStatus.Bind(I,TopOpeBRepDS_NOK); |
235 | return Standard_False; |
236 | } |
237 | if(!myMapShapeStatus.IsBound(I)) |
238 | myMapShapeStatus.Bind(I,TopOpeBRepDS_OK); |
239 | return Standard_True;; |
240 | } |
241 | |
242 | //======================================================================= |
243 | //function : ChkIntgSamDom |
244 | //purpose : |
245 | //======================================================================= |
246 | |
247 | Standard_Boolean TopOpeBRepDS_Check::ChkIntgSamDom() |
248 | { |
249 | Standard_Boolean b = Standard_True, bb = Standard_False; |
250 | TopOpeBRepDS_DataStructure& BDS = myHDS->ChangeDS(); |
251 | Standard_Integer NbSh = myHDS->NbShapes(), i, Curr, Loc; |
252 | for(i = 1;i <= NbSh; i++) { |
253 | // Verifie que les Shapes de mySameDomaine existe bien dans la DS |
254 | const TopoDS_Shape& Sind = myHDS->Shape(i); |
255 | const TopTools_ListOfShape& losi = BDS.ShapeSameDomain(Sind); |
256 | if(!CheckShapes(losi)) { |
0797d9d3 |
257 | #ifdef OCCT_DEBUG |
7fd59977 |
258 | cout<<"Shape of ShapeSameDomain (n*n "<<i; |
259 | cout<<") is not defined in the DS"<<endl; |
260 | #endif |
261 | b = Standard_False; |
262 | } |
263 | |
264 | // Verification de SameDomaineRef |
265 | Curr = BDS.SameDomainRef(i); |
266 | Loc = BDS.SameDomainRef(Curr); |
267 | if(Curr && (Curr != Loc)) { |
0797d9d3 |
268 | #ifdef OCCT_DEBUG |
7fd59977 |
269 | cout<<"SameDomaineRef of Shape "<<i<<" = "<<Curr; |
270 | cout<<". SameDomaineRef of Shape "<<Curr<<" = "<<Loc<<endl; |
271 | #endif |
272 | b = Standard_False; |
273 | } |
274 | |
275 | if(Curr) { |
276 | // Verification du type des differents Shapes SameDomain |
277 | const TopoDS_Shape& Sref = myHDS->Shape(Curr); |
278 | if(Sind.ShapeType() != Sref.ShapeType()) { |
0797d9d3 |
279 | #ifdef OCCT_DEBUG |
7fd59977 |
280 | cout<<"Shapes n*n "<<i<<" and "<<Curr<<" are SameDomain."<<endl; |
281 | cout<<"Type of Shape n*n "<<i<<" = "; |
282 | PrintShape(Sind.ShapeType(),cout); |
283 | cout<<endl<<"Type of Shape n*n "<<Curr<<" = "; |
284 | PrintShape(Sref.ShapeType(),cout); cout<<endl; |
285 | #endif |
286 | b = Standard_False; |
287 | } |
288 | |
289 | // Verifier que ShapeSameDomain(Sref) contient bien Sind |
290 | // sauf si Sind == Sref |
291 | if(i != Curr) { |
292 | const TopTools_ListOfShape& losr = BDS.ShapeSameDomain(Sref); |
293 | TopTools_ListIteratorOfListOfShape liolos; |
294 | liolos.Initialize(losr); |
295 | while (liolos.More() ) { |
296 | const TopoDS_Shape& Sh = liolos.Value(); |
297 | Loc = myHDS->Shape(Sh); |
298 | if(Loc == i) { |
299 | bb = Standard_True; |
300 | break; |
301 | } |
302 | liolos.Next(); |
303 | } |
304 | if(!bb) { |
0797d9d3 |
305 | #ifdef OCCT_DEBUG |
7fd59977 |
306 | cout<<"Shapes n*n "<<i<<" and "<<Curr<<" are SameDomain. "; |
307 | cout<<"The reference of "<<i<<", is "<<Curr<<"."<<endl; |
308 | cout<<"However, Shape n*n "<<i; |
309 | cout<<" is not in the list of Shape SameDomain of "<<Curr<<endl; |
310 | #endif |
311 | b = Standard_False; |
312 | } |
313 | } |
314 | } |
315 | } |
316 | return b; |
317 | } |
318 | |
319 | //======================================================================= |
320 | //function : CheckShapes |
321 | //purpose : |
322 | //======================================================================= |
323 | |
324 | Standard_Boolean TopOpeBRepDS_Check::CheckShapes |
325 | (const TopTools_ListOfShape& LS ) const |
326 | { |
327 | Standard_Integer index; |
328 | TopTools_ListIteratorOfListOfShape it(LS); |
329 | while (it.More()) { |
330 | const TopoDS_Shape& itS = it.Value(); |
331 | index = myHDS->Shape(itS); |
332 | if (!index) return Standard_False; |
333 | it.Next(); |
334 | } |
335 | return Standard_True; |
336 | } |
337 | |
338 | //======================================================================= |
339 | //function : OneVertexOnPnt |
340 | //purpose : |
341 | //======================================================================= |
342 | |
343 | Standard_Boolean TopOpeBRepDS_Check::OneVertexOnPnt(){ |
344 | Standard_Boolean b = Standard_True; |
345 | // Standard_Integer i, j, k; |
346 | Standard_Integer i, j; |
347 | Standard_Integer Curr1, Curr2, sdr1, sdr2; |
348 | Standard_Integer NbVe = 0, NbPo = myHDS->NbPoints(); |
349 | // Standard_Real tol, tol1, tol2, Dist; |
350 | Standard_Real tol1, tol2, Dist; |
351 | TColStd_IndexedMapOfInteger vert; |
352 | vert.Clear(); |
353 | for(i = 1;i <= myHDS->NbShapes();i++) { |
354 | const TopoDS_Shape& S = myHDS->Shape(i); |
355 | if((S.ShapeType() == TopAbs_VERTEX) && |
356 | myHDS->HasShape(S)) |
357 | vert.Add(i); |
358 | } |
359 | NbVe = vert.Extent(); |
360 | for(i = 1;i <= NbVe; i++) { |
361 | Curr1 = vert.FindKey(i); |
362 | const TopoDS_Shape& S1 = myHDS->Shape(Curr1); |
363 | sdr1 = myHDS->SameDomainReference(S1); |
364 | for(j = i+1;j <= NbVe; j++) { |
365 | Curr2 = vert.FindKey(j); |
366 | const TopoDS_Shape& S2 = myHDS->Shape(Curr2); |
367 | sdr2 = myHDS->SameDomainReference(S2); |
368 | tol1 = TopOpeBRepTool_ShapeTool::Tolerance(S1); |
369 | tol2 = TopOpeBRepTool_ShapeTool::Tolerance(S2); |
370 | const gp_Pnt& P1 = TopOpeBRepTool_ShapeTool::Pnt(S1); |
371 | const gp_Pnt& P2 = TopOpeBRepTool_ShapeTool::Pnt(S2); |
372 | Dist = P1.Distance(P2); |
373 | if(Dist <= tol1 + tol2) { |
374 | if(sdr1 != sdr2) { |
0797d9d3 |
375 | #ifdef OCCT_DEBUG |
7fd59977 |
376 | cout<<"Pb Vertex n+n"<<Curr1<<" and n*n"<<Curr2; |
377 | cout<<" : same place, not SameDomain"<<endl; |
378 | cout<<" Tol of Vertex n*n"<<Curr1<<" = "<<tol1<<endl; |
379 | cout<<" Tol of Vertex n*n"<<Curr2<<" = "<<tol2<<endl; |
380 | cout<<" Distance between two Vertexes = "<<Dist<<endl<<endl; |
381 | #endif |
382 | b = Standard_False; |
383 | } |
384 | } |
385 | else if(sdr1 == sdr2) { |
0797d9d3 |
386 | #ifdef OCCT_DEBUG |
7fd59977 |
387 | cout<<"Pb Vertex "<<Curr1<<" and "<<Curr2; |
388 | cout<<" : SameDomain, not same place"<<endl; |
389 | cout<<" Tol of Vertex n*n"<<Curr1<<" = "<<tol1<<endl; |
390 | cout<<" Tol of Vertex n*n"<<Curr2<<" = "<<tol2<<endl; |
391 | cout<<" Distance between two Vertexes = "<<Dist<<endl<<endl; |
392 | #endif |
393 | b = Standard_False; |
394 | } |
395 | } |
396 | TopOpeBRepDS_PointExplorer PE(myHDS->DS()); |
397 | for(;PE.More(); PE.Next()) { |
398 | const TopOpeBRepDS_Point& dsPnt = PE.Point(); |
399 | const gp_Pnt& Pnt1 = dsPnt.Point(); |
400 | tol1 = dsPnt.Tolerance(); |
401 | tol2 = TopOpeBRepTool_ShapeTool::Tolerance(S1); |
402 | const gp_Pnt& Pnt2 = TopOpeBRepTool_ShapeTool::Pnt(S1); |
403 | Dist = Pnt1.Distance(Pnt2); |
404 | if(Dist <= tol1 + tol2) { |
0797d9d3 |
405 | #ifdef OCCT_DEBUG |
7fd59977 |
406 | cout<<"Attention : Vertex "<<Curr1<<" and Point "<<PE.Index(); |
407 | cout<<" are confused"<<endl; |
408 | cout<<" Tol of Vertex n*n"<<Curr1<<" = "<<tol1<<endl; |
409 | cout<<" Tol of Point n*n"<<PE.Index()<<" = "<<tol2<<endl; |
410 | cout<<" Distance between the two = "<<Dist<<endl<<endl; |
411 | #endif |
412 | b = Standard_False; |
413 | } |
414 | } |
415 | } |
416 | for(i = 1;i <= NbPo; i++) { |
417 | TopOpeBRepDS_PointExplorer PE(myHDS->DS()); |
418 | if(PE.IsPoint(i)) { |
419 | const TopOpeBRepDS_Point& dsPnt1 = myHDS->Point(i); |
420 | for(j = i+1;j < NbPo;j++) { |
421 | const TopOpeBRepDS_Point& dsPnt2 = myHDS->Point(j); |
422 | if(dsPnt1.IsEqual(dsPnt2)) { |
0797d9d3 |
423 | #ifdef OCCT_DEBUG |
7fd59977 |
424 | cout<<"Attention : points "<<i<<" and "<<j<<" are confused"<<endl; |
425 | cout<<" Tol of Point n*n"<<i<<" = "<<dsPnt1.Tolerance()<<endl; |
426 | cout<<" Tol of Point n*n"<<j<<" = "<<dsPnt1.Tolerance()<<endl; |
427 | Dist = dsPnt1.Point().Distance(dsPnt2.Point()); |
428 | cout<<" Distance between the two = "<<Dist<<endl<<endl; |
429 | #endif |
430 | } |
431 | } |
432 | } |
433 | } |
434 | |
435 | return b; |
436 | } |
437 | |
438 | //======================================================================= |
439 | //function : CheckEdgeParameter |
440 | //purpose : |
441 | //======================================================================= |
442 | |
443 | ///Standard_Boolean TopOpeBRepDS_Check::CheckEdgeParameter() const |
444 | Standard_Boolean CheckEdgeParameter(const Handle(TopOpeBRepDS_HDataStructure)& myHDS) |
445 | { |
446 | TopOpeBRepDS_ListIteratorOfListOfInterference it1; |
447 | const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); |
448 | Standard_Integer i,nshape = DS.NbShapes(); |
449 | Standard_Boolean IsOK = Standard_True; |
450 | for (i = 1; i <= nshape; i++) { |
451 | // Integrity of Interferences : Check parameter of EdgeInterferences |
452 | const TopOpeBRepDS_ListOfInterference& LI = DS.ShapeInterferences(i); |
453 | it1.Initialize(LI); |
454 | while (it1.More() ) { |
455 | Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); |
456 | Handle(TopOpeBRepDS_EdgeVertexInterference) EVI = |
457 | Handle(TopOpeBRepDS_EdgeVertexInterference)::DownCast(I1); |
458 | if(!EVI.IsNull()) { |
0797d9d3 |
459 | //#ifdef OCCT_DEBUG |
7fd59977 |
460 | // Standard_Integer Param = EVI->Parameter(); |
461 | //#else |
462 | Standard_Integer Param = (Standard_Integer ) EVI->Parameter(); |
463 | //#endif |
464 | if(Param > 1.e50) { |
465 | I1->Dump(cout,"!!**!!** WARNING : sur l'interference : \n", |
466 | "parameter > 1.e50"); |
467 | IsOK = Standard_False; |
468 | } |
469 | } |
470 | it1.Next(); |
471 | } |
472 | } |
473 | |
474 | Standard_Integer ncurve = DS.NbCurves(); |
475 | for (i = 1; i <= ncurve; i++) { |
476 | // Integrity of Interferences : Check parameter of CurvesInterferences |
477 | const TopOpeBRepDS_ListOfInterference& LI = DS.CurveInterferences(i); |
478 | it1.Initialize(LI); |
479 | while (it1.More() ) { |
480 | const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); |
481 | const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = |
482 | Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1); |
483 | if(!CPI.IsNull()) { |
484 | Standard_Integer Param = |
0797d9d3 |
485 | //#ifdef OCCT_DEBUG |
7fd59977 |
486 | // TopOpeBRepDS_InterferenceTool::Parameter(CPI); |
487 | //#else |
488 | (Standard_Integer ) TopOpeBRepDS_InterferenceTool::Parameter(CPI); |
489 | //#endif |
490 | if(Param > 1.e50) { |
491 | I1->Dump(cout,"!!**!!** WARNING : sur l'interference : \n", |
492 | "parameter > 1.e50"); |
493 | IsOK = Standard_False; |
494 | } |
495 | } |
496 | it1.Next(); |
497 | } |
498 | |
499 | } |
500 | return IsOK; |
501 | } |
502 | |
503 | //======================================================================= |
504 | //function : PrintIntg |
505 | //purpose : |
506 | //======================================================================= |
507 | Standard_OStream& TopOpeBRepDS_Check::PrintIntg(Standard_OStream& OS) |
508 | { |
509 | OS<<endl<<endl<<"************************************************"<<endl; |
510 | OS<<"state of the DS : (only the tested elements)"<<endl<<endl; |
511 | |
512 | //Display of the geometry |
513 | PrintMap(myMapSurfaceStatus, "Surface", OS); |
514 | PrintMap(myMapCurveStatus, "Curve", OS); |
515 | PrintMap(myMapPointStatus, "Point", OS); |
516 | |
517 | //display of the topology |
518 | TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(myMapShapeStatus); |
519 | TopOpeBRepDS_DataMapOfCheckStatus MapVertex, MapEdge, MapWire, MapFace, MapSolid; |
520 | Standard_Integer i; |
521 | // different Map keep their index of myMapShapeStatus |
522 | for(DMI.Reset();DMI.More();DMI.Next()) { |
523 | i = DMI.Key(); |
524 | const TopoDS_Shape& S =myHDS->Shape(i); |
525 | switch(S.ShapeType()) { |
526 | case TopAbs_VERTEX: MapVertex.Bind(i, DMI.Value()); break; |
527 | case TopAbs_EDGE: MapEdge.Bind(i, DMI.Value()); break; |
528 | case TopAbs_WIRE: MapWire.Bind(i, DMI.Value()); break; |
529 | case TopAbs_FACE: MapFace.Bind(i, DMI.Value()); break; |
530 | case TopAbs_SOLID: MapSolid.Bind(i, DMI.Value()); break; |
531 | default: |
532 | break ; |
533 | } |
534 | } |
535 | |
536 | PrintMap(MapVertex, "Vertex", OS); |
537 | PrintMap(MapEdge, "Edge", OS); |
538 | PrintMap(MapWire, "Wire", OS); |
539 | PrintMap(MapFace, "Face", OS); |
540 | PrintMap(MapSolid, "Solid", OS); |
541 | |
542 | OS<<endl<<endl; |
543 | return OS; |
544 | } |
545 | |
546 | //======================================================================= |
547 | //function : PrintMap |
548 | //purpose : |
549 | //======================================================================= |
550 | |
551 | Standard_OStream& TopOpeBRepDS_Check::PrintMap(TopOpeBRepDS_DataMapOfCheckStatus& MapStat, |
552 | const Standard_CString eltstr, |
553 | Standard_OStream& OS) |
554 | { |
555 | TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(MapStat); |
556 | DMI.Initialize(MapStat); |
557 | if(DMI.More()) { |
558 | Standard_Boolean b = Standard_True; |
559 | OS<<" "<<eltstr<<"\t"<<"(/"<<MapStat.Extent()<<")\tnumber "; |
560 | |
561 | PrintElts(MapStat, TopOpeBRepDS_OK, b, OS); |
562 | if(!b) OS<<" = OK"<<endl; |
563 | PrintElts(MapStat, TopOpeBRepDS_NOK, b, OS); |
564 | if(!b) OS<<" = NOK"<<endl; |
565 | } |
566 | return OS; |
567 | } |
568 | |
569 | //======================================================================= |
570 | //function : PrintElts |
571 | //purpose : Print the elements in the state stat of MapStat |
572 | //======================================================================= |
573 | Standard_OStream& TopOpeBRepDS_Check::PrintElts(TopOpeBRepDS_DataMapOfCheckStatus& MapStat, |
574 | const TopOpeBRepDS_CheckStatus Stat, |
575 | Standard_Boolean& b, |
576 | Standard_OStream& OS) |
577 | { |
578 | TopOpeBRepDS_DataMapIteratorOfDataMapOfCheckStatus DMI(MapStat); |
579 | Standard_Boolean bb = !b; |
580 | b = Standard_True; |
581 | Standard_Integer i; |
582 | TopOpeBRepDS_CheckStatus s; |
583 | for(DMI.Reset();DMI.More();DMI.Next()) { |
584 | s = DMI.Value(); |
585 | i = DMI.Key(); |
586 | if(s == Stat) { |
587 | if(b) b=!b; |
588 | if(bb){OS<<"\t\tnumber ";bb=!bb;} |
589 | OS<<i<<" "; |
590 | } |
591 | } |
592 | return OS; |
593 | } |
594 | |
595 | //======================================================================= |
596 | //function : Print |
597 | //purpose : |
598 | //======================================================================= |
599 | Standard_OStream& TopOpeBRepDS_Check::Print |
600 | (const TopOpeBRepDS_CheckStatus stat, |
601 | Standard_OStream& OS) |
602 | { |
603 | switch(stat) { |
604 | case TopOpeBRepDS_OK: OS<<"OK";break; |
605 | case TopOpeBRepDS_NOK: OS<<"NOK";break; |
606 | default : break; |
607 | } |
608 | return OS; |
609 | } |
610 | |
611 | //======================================================================= |
612 | //function : PrintShape |
613 | //purpose : |
614 | //======================================================================= |
615 | Standard_OStream& TopOpeBRepDS_Check::PrintShape |
616 | (const TopAbs_ShapeEnum SE, |
617 | Standard_OStream& OS) |
618 | { |
619 | switch(SE) { |
620 | case TopAbs_SOLID : OS<<"Solid "; break; |
621 | case TopAbs_SHELL : OS<<"Shell "; break; |
622 | case TopAbs_FACE : OS<<"Face "; break; |
623 | case TopAbs_WIRE : OS<<"Wire "; break; |
624 | case TopAbs_EDGE : OS<<"Edge "; break; |
625 | case TopAbs_VERTEX : OS<<"Vertex"; break; |
626 | default: |
627 | break ; |
628 | } |
629 | return OS; |
630 | } |
631 | |
632 | //======================================================================= |
633 | //function : PrintShape |
634 | //purpose : |
635 | //======================================================================= |
636 | Standard_OStream& TopOpeBRepDS_Check::PrintShape |
637 | (const Standard_Integer index, |
638 | Standard_OStream& OS) |
639 | { |
640 | if(myHDS->NbShapes() < index) { |
641 | OS<<"**PB**IN**TopOpeBRepDS_Check::PrintShape** "; |
642 | return OS; |
643 | } |
644 | if(!myMapShapeStatus.IsBound(index)) { |
645 | OS<<"NO CHECK HAS PROCESSING"<<endl; |
646 | return OS; |
647 | } |
648 | OS<<" "; |
0797d9d3 |
649 | #ifdef OCCT_DEBUG |
7fd59977 |
650 | const TopoDS_Shape& S = |
651 | #endif |
652 | myHDS->Shape(index); |
653 | |
0797d9d3 |
654 | #ifdef OCCT_DEBUG |
7fd59977 |
655 | PrintShape(S.ShapeType(),cout); |
656 | OS<<" "<<index<<" = "; |
657 | Print(myMapShapeStatus.Find(index), cout); |
658 | #endif |
659 | return OS; |
660 | } |
661 | |
662 | //======================================================================= |
663 | //function : HDS |
664 | //purpose : |
665 | //======================================================================= |
666 | |
667 | const Handle(TopOpeBRepDS_HDataStructure)& TopOpeBRepDS_Check::HDS()const |
668 | { |
669 | return myHDS; |
670 | } |
671 | |
672 | |
673 | //======================================================================= |
674 | //function : ChangeHDS |
675 | //purpose : |
676 | //======================================================================= |
677 | |
678 | Handle(TopOpeBRepDS_HDataStructure)& TopOpeBRepDS_Check::ChangeHDS() |
679 | { |
680 | return myHDS; |
681 | } |