b311480e |
1 | // Created on: 1993-06-23 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1993-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 | |
42cf5bc1 |
17 | |
18 | #include <Geom_Surface.hxx> |
7fd59977 |
19 | #include <Standard_ProgramError.hxx> |
20 | #include <TopoDS.hxx> |
42cf5bc1 |
21 | #include <TopoDS_Edge.hxx> |
22 | #include <TopoDS_Shape.hxx> |
23 | #include <TopOpeBRepDS_Curve.hxx> |
7fd59977 |
24 | #include <TopOpeBRepDS_CurveData.hxx> |
42cf5bc1 |
25 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
26 | #include <TopOpeBRepDS_DataStructure.hxx> |
27 | #include <TopOpeBRepDS_define.hxx> |
28 | #include <TopOpeBRepDS_Interference.hxx> |
29 | #include <TopOpeBRepDS_Point.hxx> |
7fd59977 |
30 | #include <TopOpeBRepDS_PointData.hxx> |
42cf5bc1 |
31 | #include <TopOpeBRepDS_PointExplorer.hxx> |
7fd59977 |
32 | #include <TopOpeBRepDS_ShapeData.hxx> |
42cf5bc1 |
33 | #include <TopOpeBRepDS_ShapeWithState.hxx> |
34 | #include <TopOpeBRepDS_Surface.hxx> |
35 | #include <TopOpeBRepDS_SurfaceData.hxx> |
36 | #include <TopOpeBRepDS_SurfaceExplorer.hxx> |
37 | #include <TopOpeBRepTool_ShapeTool.hxx> |
7fd59977 |
38 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
7fd59977 |
39 | |
7fd59977 |
40 | //======================================================================= |
41 | //function : TopOpeBRepDS_DataStructure |
42 | //purpose : |
43 | //======================================================================= |
44 | TopOpeBRepDS_DataStructure::TopOpeBRepDS_DataStructure() : |
45 | myNbSurfaces(0), |
46 | myNbCurves(0), |
47 | myNbPoints(0), |
c24d4017 |
48 | myIsfafa(Standard_False), |
49 | myI(0) |
7fd59977 |
50 | { |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : Init |
55 | //purpose : |
56 | //======================================================================= |
57 | void TopOpeBRepDS_DataStructure::Init() |
58 | { |
59 | myNbSurfaces = 0; |
60 | myNbCurves = 0; |
61 | myNbPoints = 0; |
62 | mySurfaces.Clear(); |
63 | myCurves.Clear(); |
64 | myPoints.Clear(); |
65 | myShapes.Clear(); |
66 | //Begin modified by NIZHNY-MZV Tue Apr 18 16:33:26 2000 |
67 | myMapOfShapeWithStateObj.Clear(); |
68 | myMapOfShapeWithStateTool.Clear(); |
69 | myMapOfRejectedShapesObj.Clear(); |
70 | myMapOfRejectedShapesTool.Clear(); |
71 | //End modified by NIZHNY-MZV Tue Apr 18 16:33:32 2000 |
72 | InitSectionEdges(); |
73 | } |
74 | |
75 | |
76 | //======================================================================= |
77 | //function : AddSurface |
78 | //purpose : |
79 | //======================================================================= |
80 | Standard_Integer TopOpeBRepDS_DataStructure::AddSurface(const TopOpeBRepDS_Surface& S) |
81 | { |
82 | myNbSurfaces++; |
83 | //modified by NIZNHY-PKV Tue Oct 30 09:22:04 2001 f |
84 | TopOpeBRepDS_SurfaceData aSD(S); |
85 | mySurfaces.Bind(myNbSurfaces, aSD); |
86 | //mySurfaces.Bind(myNbSurfaces,S); |
87 | //modified by NIZNHY-PKV Tue Oct 30 09:22:20 2001 t |
88 | return myNbSurfaces; |
89 | } |
90 | |
91 | |
92 | //======================================================================= |
93 | //function : RemoveSurface |
94 | //purpose : |
95 | //======================================================================= |
96 | void TopOpeBRepDS_DataStructure::RemoveSurface(const Standard_Integer I) |
97 | { |
536a3cb8 |
98 | mySurfaces.UnBind(I); |
7fd59977 |
99 | } |
100 | |
101 | //======================================================================= |
102 | //function : KeepSurface |
103 | //purpose : |
104 | //======================================================================= |
105 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepSurface(const Standard_Integer I) const |
106 | { |
107 | const TopOpeBRepDS_Surface& S = Surface(I); |
108 | Standard_Boolean b = S.Keep(); |
109 | return b; |
110 | } |
111 | |
112 | //======================================================================= |
113 | //function : KeepSurface |
114 | //purpose : |
115 | //======================================================================= |
116 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepSurface(TopOpeBRepDS_Surface& S) const |
117 | { |
118 | Standard_Boolean b = S.Keep(); |
119 | return b; |
120 | } |
121 | |
122 | //======================================================================= |
123 | //function : ChangeKeepSurface |
124 | //purpose : |
125 | //======================================================================= |
126 | void TopOpeBRepDS_DataStructure::ChangeKeepSurface(const Standard_Integer I,const Standard_Boolean FindKeep) |
127 | { |
128 | TopOpeBRepDS_Surface& S = ChangeSurface(I); |
129 | S.ChangeKeep(FindKeep); |
130 | } |
131 | |
132 | //======================================================================= |
133 | //function : ChangeKeepSurface |
134 | //purpose : |
135 | //======================================================================= |
136 | void TopOpeBRepDS_DataStructure::ChangeKeepSurface(TopOpeBRepDS_Surface& S,const Standard_Boolean FindKeep) |
137 | { |
138 | S.ChangeKeep(FindKeep); |
139 | } |
140 | |
141 | //======================================================================= |
142 | //function : AddCurve |
143 | //purpose : |
144 | //======================================================================= |
145 | Standard_Integer TopOpeBRepDS_DataStructure::AddCurve(const TopOpeBRepDS_Curve& C) |
146 | { |
147 | myNbCurves++; |
148 | |
149 | // NYI : modifier const & sur Curve dans le CDL NYI |
150 | TopOpeBRepDS_Curve* PC = (TopOpeBRepDS_Curve*)(void*)&C; |
151 | PC->ChangeDSIndex(myNbCurves); |
152 | |
153 | TopOpeBRepDS_CurveData CD(C); |
154 | myCurves.Bind(myNbCurves,CD); |
155 | |
7fd59977 |
156 | return myNbCurves; |
157 | } |
158 | |
159 | //======================================================================= |
160 | //function : RemoveCurve |
161 | //purpose : |
162 | //======================================================================= |
163 | void TopOpeBRepDS_DataStructure::RemoveCurve(const Standard_Integer I) |
164 | { |
165 | TopOpeBRepDS_Curve& C = ChangeCurve(I); |
166 | |
167 | TopoDS_Shape S1,S2; |
168 | C.GetShapes(S1,S2); |
169 | Handle(TopOpeBRepDS_Interference) I1,I2; |
170 | C.GetSCI(I1,I2); |
171 | if ( ! I1.IsNull() ) RemoveShapeInterference(S1,I1); |
172 | if ( ! I2.IsNull() ) RemoveShapeInterference(S2,I2); |
173 | C.ChangeKeep(Standard_False); |
174 | |
175 | // NYI : nullify interferences I1,I2 |
176 | } |
177 | |
178 | //======================================================================= |
179 | //function : KeepCurve |
180 | //purpose : |
181 | //======================================================================= |
182 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepCurve(const Standard_Integer I) const |
183 | { |
184 | const TopOpeBRepDS_Curve& C = Curve(I); |
185 | Standard_Boolean b = C.Keep(); |
186 | return b; |
187 | } |
188 | |
189 | //======================================================================= |
190 | //function : KeepCurve |
191 | //purpose : |
192 | //======================================================================= |
193 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepCurve(const TopOpeBRepDS_Curve& C) const |
194 | { |
195 | Standard_Boolean b = C.Keep(); |
196 | return b; |
197 | } |
198 | |
199 | //======================================================================= |
200 | //function : ChangeKeepCurve |
201 | //purpose : |
202 | //======================================================================= |
203 | void TopOpeBRepDS_DataStructure::ChangeKeepCurve(const Standard_Integer I,const Standard_Boolean FindKeep) |
204 | { |
205 | TopOpeBRepDS_Curve& C = ChangeCurve(I); |
206 | C.ChangeKeep(FindKeep); |
207 | } |
208 | |
209 | //======================================================================= |
210 | //function : ChangeKeepCurve |
211 | //purpose : |
212 | //======================================================================= |
213 | void TopOpeBRepDS_DataStructure::ChangeKeepCurve(TopOpeBRepDS_Curve& C,const Standard_Boolean FindKeep) |
214 | { |
215 | C.ChangeKeep(FindKeep); |
216 | } |
217 | |
218 | |
219 | //======================================================================= |
220 | //function : AddPoint |
221 | //purpose : |
222 | //======================================================================= |
223 | Standard_Integer TopOpeBRepDS_DataStructure::AddPoint(const TopOpeBRepDS_Point& PDS) |
224 | { |
225 | myNbPoints++; |
226 | myPoints.Bind(myNbPoints,PDS); |
227 | return myNbPoints; |
228 | } |
229 | |
230 | //======================================================================= |
231 | //function : AddPointSS |
232 | //purpose : |
233 | //======================================================================= |
234 | Standard_Integer TopOpeBRepDS_DataStructure::AddPointSS(const TopOpeBRepDS_Point& PDS, |
235 | const TopoDS_Shape& /*S1*/, |
236 | const TopoDS_Shape& /*S2*/) |
237 | { |
238 | Standard_Integer i = AddPoint(PDS); |
239 | return i; |
240 | } |
241 | |
242 | |
243 | //======================================================================= |
244 | //function : RemovePoint |
245 | //purpose : |
246 | //======================================================================= |
247 | void TopOpeBRepDS_DataStructure::RemovePoint(const Standard_Integer I) |
248 | { |
249 | TopOpeBRepDS_Point& P = ChangePoint(I); |
250 | P.ChangeKeep(Standard_False); |
251 | } |
252 | |
253 | //======================================================================= |
254 | //function : KeepPoint |
255 | //purpose : |
256 | //======================================================================= |
257 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepPoint(const Standard_Integer I) const |
258 | { |
259 | const TopOpeBRepDS_Point& P = Point(I); |
260 | Standard_Boolean b = P.Keep(); |
261 | return b; |
262 | } |
263 | |
264 | //======================================================================= |
265 | //function : KeepPoint |
266 | //purpose : |
267 | //======================================================================= |
268 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepPoint(const TopOpeBRepDS_Point& P) const |
269 | { |
270 | Standard_Boolean b = P.Keep(); |
271 | return b; |
272 | } |
273 | |
274 | //======================================================================= |
275 | //function : ChangeKeepPoint |
276 | //purpose : |
277 | //======================================================================= |
278 | void TopOpeBRepDS_DataStructure::ChangeKeepPoint(const Standard_Integer I,const Standard_Boolean FindKeep) |
279 | { |
280 | TopOpeBRepDS_Point& P = ChangePoint(I); |
281 | P.ChangeKeep(FindKeep); |
282 | } |
283 | |
284 | //======================================================================= |
285 | //function : ChangeKeepPoint |
286 | //purpose : |
287 | //======================================================================= |
288 | void TopOpeBRepDS_DataStructure::ChangeKeepPoint(TopOpeBRepDS_Point& P,const Standard_Boolean FindKeep) |
289 | { |
290 | P.ChangeKeep(FindKeep); |
291 | } |
292 | |
293 | |
294 | //======================================================================= |
295 | //function : AddShape |
296 | //purpose : |
297 | //======================================================================= |
298 | Standard_Integer TopOpeBRepDS_DataStructure::AddShape(const TopoDS_Shape& S) |
299 | { |
300 | Standard_Integer iS = myShapes.FindIndex(S); |
301 | if (iS == 0) { |
302 | TopOpeBRepDS_ShapeData SD; |
303 | iS = myShapes.Add(S,SD); |
304 | // a shape is its own reference, oriented as itself |
7fd59977 |
305 | SameDomainRef(iS,iS); |
306 | SameDomainOri(iS,TopOpeBRepDS_SAMEORIENTED); |
307 | } |
308 | return iS; |
309 | } |
310 | |
311 | //======================================================================= |
312 | //function : AddShape |
313 | //purpose : |
314 | //======================================================================= |
315 | Standard_Integer TopOpeBRepDS_DataStructure::AddShape(const TopoDS_Shape& S,const Standard_Integer Ianc) |
316 | { |
317 | Standard_Integer iS = myShapes.FindIndex(S); |
318 | if (iS == 0) { |
319 | TopOpeBRepDS_ShapeData SD; |
320 | iS = myShapes.Add(S,SD); |
321 | // a shape is its own reference, oriented as itself |
7fd59977 |
322 | SameDomainRef(iS,iS); |
323 | SameDomainOri(iS,TopOpeBRepDS_SAMEORIENTED); |
324 | AncestorRank(iS,Ianc); |
325 | } |
326 | return iS; |
327 | } |
328 | |
329 | //======================================================================= |
330 | //function : KeepShape |
331 | //purpose : |
332 | //======================================================================= |
333 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepShape(const Standard_Integer I,const Standard_Boolean FindKeep) const |
334 | { |
335 | Standard_Boolean b = Standard_False; |
336 | if (I >= 1 && I <= myShapes.Extent()) { |
337 | const TopoDS_Shape& S = myShapes.FindKey(I); |
338 | if(FindKeep) |
339 | b = KeepShape(S); |
340 | else |
341 | b = Standard_True; |
342 | } |
343 | return b; |
344 | } |
345 | |
346 | //======================================================================= |
347 | //function : KeepShape |
348 | //purpose : |
349 | //======================================================================= |
350 | Standard_Boolean TopOpeBRepDS_DataStructure::KeepShape(const TopoDS_Shape& S,const Standard_Boolean FindKeep) const |
351 | { |
352 | Standard_Boolean b = Standard_False; |
353 | if ( (!myShapes.IsEmpty()) && (!S.IsNull()) && myShapes.Contains(S)) { |
354 | const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromKey(S); |
355 | if(FindKeep) |
356 | b = SD.Keep(); |
357 | else |
358 | b = Standard_True; |
359 | } |
360 | return b; |
361 | } |
362 | |
363 | //======================================================================= |
364 | //function : ChangeKeepShape |
365 | //purpose : |
366 | //======================================================================= |
367 | void TopOpeBRepDS_DataStructure::ChangeKeepShape(const Standard_Integer I, const Standard_Boolean FindKeep) |
368 | { |
369 | if (I >= 1 && I <= myShapes.Extent()) { |
370 | const TopoDS_Shape& S = myShapes.FindKey(I); |
371 | ChangeKeepShape(S, FindKeep); |
372 | } |
373 | } |
374 | |
375 | //======================================================================= |
376 | //function : ChangeKeepShape |
377 | //purpose : |
378 | //======================================================================= |
379 | void TopOpeBRepDS_DataStructure::ChangeKeepShape(const TopoDS_Shape& S,const Standard_Boolean FindKeep) |
380 | { |
381 | if(!S.IsNull() && myShapes.Contains(S)) { |
382 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
383 | SD.ChangeKeep(FindKeep); |
384 | } |
385 | } |
386 | |
387 | //======================================================================= |
388 | //function : InitSectionEdges |
389 | //purpose : |
390 | //======================================================================= |
391 | void TopOpeBRepDS_DataStructure::InitSectionEdges() |
392 | { |
393 | mySectionEdges.Clear(); |
394 | } |
395 | |
396 | //======================================================================= |
397 | //function : AddSectionEdge |
398 | //purpose : |
399 | //======================================================================= |
400 | Standard_Integer TopOpeBRepDS_DataStructure::AddSectionEdge(const TopoDS_Edge& E) |
401 | { |
402 | Standard_Integer iE = mySectionEdges.FindIndex(E); |
403 | if (iE == 0) iE = mySectionEdges.Add(E); |
404 | return iE; |
405 | } |
406 | |
407 | //======================================================================= |
408 | //function : ChangeShapes |
409 | //purpose : |
410 | //======================================================================= |
411 | TopOpeBRepDS_MapOfShapeData& TopOpeBRepDS_DataStructure::ChangeShapes () |
412 | { |
413 | return myShapes; |
414 | } |
415 | |
416 | |
417 | //======================================================================= |
418 | //function : SurfaceInterferences |
419 | //purpose : |
420 | //======================================================================= |
421 | const TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::SurfaceInterferences(const Standard_Integer I)const |
422 | { |
423 | |
424 | if ( !mySurfaces.IsBound(I) ) { |
425 | return myEmptyListOfInterference; |
426 | } |
427 | const TopOpeBRepDS_SurfaceData& SD = mySurfaces.Find(I); |
428 | const TopOpeBRepDS_ListOfInterference& LI = SD.Interferences(); |
429 | return LI; |
430 | } |
431 | |
432 | |
433 | //======================================================================= |
434 | //function : ChangeSurfaceInterferences |
435 | //purpose : |
436 | //======================================================================= |
437 | TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ChangeSurfaceInterferences(const Standard_Integer I) |
438 | { |
439 | |
440 | if ( !mySurfaces.IsBound(I) ) { |
441 | return myEmptyListOfInterference; |
442 | } |
443 | TopOpeBRepDS_SurfaceData& SD = mySurfaces.ChangeFind(I); |
444 | TopOpeBRepDS_ListOfInterference& LI = SD.ChangeInterferences(); |
445 | return LI; |
446 | } |
447 | |
448 | //======================================================================= |
449 | //function : CurveInterferences |
450 | //purpose : |
451 | //======================================================================= |
452 | const TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::CurveInterferences(const Standard_Integer I)const |
453 | { |
454 | |
455 | if ( !myCurves.IsBound(I) ) { |
456 | return myEmptyListOfInterference; |
457 | } |
458 | const TopOpeBRepDS_CurveData& CD = myCurves.Find(I); |
459 | const TopOpeBRepDS_ListOfInterference& LI = CD.Interferences(); |
460 | return LI; |
461 | } |
462 | |
463 | |
464 | //======================================================================= |
465 | //function : ChangeCurveInterferences |
466 | //purpose : |
467 | //======================================================================= |
468 | TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ChangeCurveInterferences(const Standard_Integer I) |
469 | { |
470 | |
471 | if ( !myCurves.IsBound(I) ) { |
472 | return myEmptyListOfInterference; |
473 | } |
474 | TopOpeBRepDS_CurveData& CD = myCurves.ChangeFind(I); |
475 | TopOpeBRepDS_ListOfInterference& LI = CD.ChangeInterferences(); |
476 | return LI; |
477 | } |
478 | |
479 | |
480 | //======================================================================= |
481 | //function : PointInterferences |
482 | //purpose : |
483 | //======================================================================= |
484 | const TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::PointInterferences(const Standard_Integer I)const |
485 | { |
486 | |
487 | if ( !myPoints.IsBound(I) ) { |
488 | return myEmptyListOfInterference; |
489 | } |
490 | const TopOpeBRepDS_PointData& PD = myPoints.Find(I); |
491 | const TopOpeBRepDS_ListOfInterference& LI = PD.Interferences(); |
492 | return LI; |
493 | } |
494 | |
495 | |
496 | //======================================================================= |
497 | //function : ChangePointInterferences |
498 | //purpose : |
499 | //======================================================================= |
500 | TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ChangePointInterferences(const Standard_Integer I) |
501 | { |
502 | |
503 | if ( !myPoints.IsBound(I) ) { |
504 | return myEmptyListOfInterference; |
505 | } |
506 | TopOpeBRepDS_PointData& PD = myPoints.ChangeFind(I); |
507 | TopOpeBRepDS_ListOfInterference& LI = PD.ChangeInterferences(); |
508 | return LI; |
509 | } |
510 | |
511 | |
512 | //======================================================================= |
513 | //function : ShapeInterferences |
514 | //purpose : |
515 | //======================================================================= |
516 | const TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ShapeInterferences(const TopoDS_Shape& S,const Standard_Boolean FindKeep)const |
517 | { |
518 | if(HasShape(S, FindKeep)) |
519 | return myShapes.FindFromKey(S).myInterferences; |
520 | return myEmptyListOfInterference; |
521 | } |
522 | |
523 | |
524 | //======================================================================= |
525 | //function : ChangeShapeInterferences |
526 | //purpose : |
527 | //======================================================================= |
528 | TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ChangeShapeInterferences(const TopoDS_Shape& S) |
529 | { |
530 | if(!HasShape(S)) |
531 | return myEmptyListOfInterference; |
532 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
533 | return SD.myInterferences; |
534 | } |
535 | |
536 | //======================================================================= |
537 | //function : ShapeInterferences |
538 | //purpose : |
539 | //======================================================================= |
540 | const TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ShapeInterferences(const Standard_Integer I,const Standard_Boolean FindKeep) const |
541 | { |
542 | if(FindKeep && !KeepShape(I)) |
543 | return myEmptyListOfInterference; |
544 | return myShapes.FindFromIndex(I).myInterferences; |
545 | } |
546 | |
547 | |
548 | //======================================================================= |
549 | //function : ChangeShapeInterferences |
550 | //purpose : |
551 | //======================================================================= |
552 | TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_DataStructure::ChangeShapeInterferences(const Standard_Integer I) |
553 | { |
554 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
555 | return SD.myInterferences; |
556 | } |
557 | |
558 | |
559 | //======================================================================= |
560 | //function : ShapeSameDomain |
561 | //purpose : |
562 | //======================================================================= |
563 | const TopTools_ListOfShape& TopOpeBRepDS_DataStructure::ShapeSameDomain(const TopoDS_Shape& S)const |
564 | { |
565 | if(!S.IsNull()) |
566 | if (myShapes.Contains(S)) { |
567 | const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromKey(S); |
568 | const TopTools_ListOfShape& l = SD.mySameDomain; |
569 | return l; |
570 | } |
571 | return myEmptyListOfShape; |
572 | } |
573 | |
574 | |
575 | //======================================================================= |
576 | //function : ChangeShapeSameDomain |
577 | //purpose : |
578 | //======================================================================= |
579 | TopTools_ListOfShape& TopOpeBRepDS_DataStructure::ChangeShapeSameDomain(const TopoDS_Shape& S) |
580 | { |
581 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
582 | return SD.mySameDomain; |
583 | } |
584 | |
585 | |
586 | //======================================================================= |
587 | //function : ShapeSameDomain |
588 | //purpose : |
589 | //======================================================================= |
590 | const TopTools_ListOfShape& TopOpeBRepDS_DataStructure::ShapeSameDomain(const Standard_Integer I)const |
591 | { |
592 | if (I >= 1 && I <= myShapes.Extent()) { |
593 | const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromIndex(I); |
594 | const TopTools_ListOfShape& l = SD.mySameDomain; |
595 | return l; |
596 | } |
597 | else { |
598 | return myEmptyListOfShape; |
599 | } |
600 | } |
601 | |
602 | |
603 | //======================================================================= |
604 | //function : ChangeShapeSameDomain |
605 | //purpose : |
606 | //======================================================================= |
607 | TopTools_ListOfShape& TopOpeBRepDS_DataStructure::ChangeShapeSameDomain(const Standard_Integer I) |
608 | { |
609 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
610 | return SD.mySameDomain; |
611 | } |
612 | |
613 | |
614 | //======================================================================= |
615 | //function : AddShapeSameDomain |
616 | //purpose : |
617 | //======================================================================= |
618 | void TopOpeBRepDS_DataStructure::AddShapeSameDomain(const TopoDS_Shape& S, const TopoDS_Shape& SSD) |
619 | { |
7fd59977 |
620 | Standard_Boolean append = Standard_True; |
621 | { |
622 | TopTools_ListIteratorOfListOfShape it(ShapeSameDomain(S)); |
623 | for (; it.More(); it.Next() ) { |
624 | const TopoDS_Shape& itS = it.Value(); |
625 | if ( itS.IsSame(SSD) ) { |
626 | append = Standard_False; |
627 | break; |
628 | } |
629 | } |
630 | } |
631 | if (append) { |
632 | ChangeShapeSameDomain(S).Append(SSD); |
633 | } |
634 | } |
635 | |
636 | //======================================================================= |
637 | //function : RemoveShapeSameDomain |
638 | //purpose : |
639 | //======================================================================= |
640 | void TopOpeBRepDS_DataStructure::RemoveShapeSameDomain(const TopoDS_Shape& S, const TopoDS_Shape& SSD) |
641 | { |
7fd59977 |
642 | TopTools_ListOfShape& L = ChangeShapeSameDomain(S); |
643 | TopTools_ListIteratorOfListOfShape it(L); |
644 | while (it.More()) { |
645 | const TopoDS_Shape& itS = it.Value(); |
646 | Standard_Boolean remove = itS.IsSame(SSD); |
647 | if (remove) |
648 | L.Remove(it); |
649 | else |
650 | it.Next(); |
651 | } |
652 | } |
653 | |
654 | //======================================================================= |
655 | //function : SameDomainRef |
656 | //purpose : |
657 | //======================================================================= |
658 | Standard_Integer TopOpeBRepDS_DataStructure::SameDomainRef(const Standard_Integer I)const |
659 | { |
660 | if (I >= 1 && I <= myShapes.Extent()) { |
661 | return myShapes.FindFromIndex(I).mySameDomainRef; |
662 | } |
663 | return 0; |
664 | } |
665 | |
666 | //======================================================================= |
667 | //function : SameDomainRef |
668 | //purpose : |
669 | //======================================================================= |
670 | Standard_Integer TopOpeBRepDS_DataStructure::SameDomainRef(const TopoDS_Shape& S) const |
671 | { |
672 | if(S.IsNull()) return 0; |
673 | if (myShapes.Contains(S)) { |
674 | return myShapes.FindFromKey(S).mySameDomainRef; |
675 | } |
676 | return 0; |
677 | } |
678 | |
679 | //======================================================================= |
680 | //function : SameDomainRef |
681 | //purpose : |
682 | //======================================================================= |
683 | void TopOpeBRepDS_DataStructure::SameDomainRef(const Standard_Integer I, const Standard_Integer Ref) |
684 | { |
685 | if (I >= 1 && I <= myShapes.Extent()) { |
686 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
687 | SD.mySameDomainRef = Ref; |
688 | } |
689 | } |
690 | |
691 | //======================================================================= |
692 | //function : SameDomainRef |
693 | //purpose : |
694 | //======================================================================= |
695 | void TopOpeBRepDS_DataStructure::SameDomainRef(const TopoDS_Shape& S, const Standard_Integer Ref) |
696 | { |
697 | if(S.IsNull()) return; |
698 | if (myShapes.Contains(S)) { |
699 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
700 | SD.mySameDomainRef = Ref; |
701 | } |
702 | } |
703 | |
704 | //======================================================================= |
705 | //function : SameDomainOri |
706 | //purpose : |
707 | //======================================================================= |
708 | TopOpeBRepDS_Config TopOpeBRepDS_DataStructure::SameDomainOri(const Standard_Integer I)const |
709 | { |
710 | if (I >= 1 && I <= myShapes.Extent()) { |
711 | return myShapes.FindFromIndex(I).mySameDomainOri; |
712 | } |
713 | return TopOpeBRepDS_UNSHGEOMETRY; |
714 | } |
715 | |
716 | //======================================================================= |
717 | //function : SameDomainOri |
718 | //purpose : |
719 | //======================================================================= |
720 | TopOpeBRepDS_Config TopOpeBRepDS_DataStructure::SameDomainOri(const TopoDS_Shape& S) const |
721 | { |
722 | if(!S.IsNull()) |
723 | if (myShapes.Contains(S)) { |
724 | return myShapes.FindFromKey(S).mySameDomainOri; |
725 | } |
726 | return TopOpeBRepDS_UNSHGEOMETRY; |
727 | } |
728 | |
729 | //======================================================================= |
730 | //function : SameDomainOri |
731 | //purpose : |
732 | //======================================================================= |
733 | void TopOpeBRepDS_DataStructure::SameDomainOri(const Standard_Integer I, const TopOpeBRepDS_Config Ori) |
734 | { |
735 | if (I >= 1 && I <= myShapes.Extent()) { |
736 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
737 | SD.mySameDomainOri = Ori; |
738 | } |
739 | } |
740 | |
741 | //======================================================================= |
742 | //function : SameDomainOri |
743 | //purpose : |
744 | //======================================================================= |
745 | void TopOpeBRepDS_DataStructure::SameDomainOri(const TopoDS_Shape& S, const TopOpeBRepDS_Config Ori) |
746 | { |
747 | if(!S.IsNull()) |
748 | if (myShapes.Contains(S)) { |
749 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
750 | SD.mySameDomainOri = Ori; |
751 | } |
752 | } |
753 | |
754 | //======================================================================= |
755 | //function : SameDomainInd |
756 | //purpose : |
757 | //======================================================================= |
758 | Standard_Integer TopOpeBRepDS_DataStructure::SameDomainInd(const Standard_Integer I)const |
759 | { |
760 | if (I >= 1 && I <= myShapes.Extent()) { |
761 | return myShapes.FindFromIndex(I).mySameDomainInd; |
762 | } |
763 | return 0; |
764 | } |
765 | |
766 | //======================================================================= |
767 | //function : SameDomainInd |
768 | //purpose : |
769 | //======================================================================= |
770 | Standard_Integer TopOpeBRepDS_DataStructure::SameDomainInd(const TopoDS_Shape& S) const |
771 | { |
772 | if(!S.IsNull()) |
773 | if (myShapes.Contains(S)) { |
774 | return myShapes.FindFromKey(S).mySameDomainInd; |
775 | } |
776 | return 0; |
777 | } |
778 | |
779 | //======================================================================= |
780 | //function : SameDomainInd |
781 | //purpose : |
782 | //======================================================================= |
783 | void TopOpeBRepDS_DataStructure::SameDomainInd(const Standard_Integer I, const Standard_Integer Ind) |
784 | { |
785 | if (I >= 1 && I <= myShapes.Extent()) { |
786 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
787 | SD.mySameDomainInd = Ind; |
788 | } |
789 | } |
790 | |
791 | //======================================================================= |
792 | //function : SameDomainInd |
793 | //purpose : |
794 | //======================================================================= |
795 | void TopOpeBRepDS_DataStructure::SameDomainInd(const TopoDS_Shape& S, const Standard_Integer Ind) |
796 | { |
797 | if(S.IsNull()) return; |
798 | if (myShapes.Contains(S)) { |
799 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
800 | SD.mySameDomainInd = Ind; |
801 | } |
802 | } |
803 | |
804 | //======================================================================= |
805 | //function : AncestorRank |
806 | //purpose : |
807 | //======================================================================= |
808 | Standard_Integer TopOpeBRepDS_DataStructure::AncestorRank(const Standard_Integer I)const |
809 | { |
810 | if (I >= 1 && I <= myShapes.Extent()) { |
811 | return myShapes.FindFromIndex(I).myAncestorRank; |
812 | } |
813 | return 0; |
814 | } |
815 | |
816 | //======================================================================= |
817 | //function : AncestorRank |
818 | //purpose : |
819 | //======================================================================= |
820 | Standard_Integer TopOpeBRepDS_DataStructure::AncestorRank(const TopoDS_Shape& S) const |
821 | { |
822 | if(S.IsNull()) return 0; |
823 | if (myShapes.Contains(S)) { |
824 | return myShapes.FindFromKey(S).myAncestorRank; |
825 | } |
826 | return 0; |
827 | } |
828 | |
829 | //======================================================================= |
830 | //function : AncestorRank |
831 | //purpose : |
832 | //======================================================================= |
833 | void TopOpeBRepDS_DataStructure::AncestorRank(const Standard_Integer I, const Standard_Integer Ianc) |
834 | { |
835 | if (I >= 1 && I <= myShapes.Extent()) { |
836 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromIndex(I); |
837 | SD.myAncestorRank = Ianc; |
838 | } |
839 | } |
840 | |
841 | //======================================================================= |
842 | //function : AncestorRank |
843 | //purpose : |
844 | //======================================================================= |
845 | void TopOpeBRepDS_DataStructure::AncestorRank(const TopoDS_Shape& S, const Standard_Integer Ianc) |
846 | { |
847 | if(S.IsNull()) return; |
848 | if (myShapes.Contains(S)) { |
849 | TopOpeBRepDS_ShapeData& SD = myShapes.ChangeFromKey(S); |
850 | SD.myAncestorRank = Ianc; |
851 | } |
852 | } |
853 | |
854 | //======================================================================= |
855 | //function : AddShapeInterference |
856 | //purpose : |
857 | //======================================================================= |
858 | void TopOpeBRepDS_DataStructure::AddShapeInterference(const TopoDS_Shape& S, const Handle(TopOpeBRepDS_Interference)& I) |
859 | { |
860 | ChangeShapeInterferences(S).Append(I); |
861 | } |
862 | |
863 | |
864 | //======================================================================= |
865 | //function : RemoveShapeInterference |
866 | //purpose : |
867 | //======================================================================= |
868 | void TopOpeBRepDS_DataStructure::RemoveShapeInterference(const TopoDS_Shape& S, const Handle(TopOpeBRepDS_Interference)& I) |
869 | { |
870 | TopOpeBRepDS_ListOfInterference& L = ChangeShapeInterferences(S); |
871 | TopOpeBRepDS_ListIteratorOfListOfInterference it(L); |
872 | Standard_Boolean b = FindInterference(it,I); |
873 | if (b) { |
874 | L.Remove(it); |
875 | } |
876 | } |
877 | |
878 | //======================================================================= |
879 | //function : FillShapesSameDomain |
880 | //purpose : |
881 | //======================================================================= |
882 | void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, |
883 | const TopoDS_Shape& S2, |
884 | const Standard_Boolean refFirst) |
885 | { |
886 | TopAbs_Orientation o1 = S1.Orientation(); |
887 | TopAbs_Orientation o2 = S2.Orientation(); |
888 | |
889 | Standard_Integer iS1 = AddShape(S1,1); |
890 | TopOpeBRepDS_ShapeData& SD1 = myShapes.ChangeFromIndex(iS1); |
891 | Standard_Boolean isdef1 = SD1.myOrientationDef; |
892 | Standard_Boolean todef1 = ( !isdef1 ); |
893 | if ( isdef1 && SD1.mySameDomainOri == TopOpeBRepDS_UNSHGEOMETRY ) todef1 = Standard_True; |
894 | if ( todef1 ) { |
895 | SD1.myOrientation = o1; |
896 | SD1.myOrientationDef = Standard_True; |
897 | } |
898 | |
899 | Standard_Integer iS2 = AddShape(S2,2); |
900 | TopOpeBRepDS_ShapeData& SD2 = myShapes.ChangeFromIndex(iS2); |
901 | Standard_Boolean isdef2 = SD2.myOrientationDef; |
902 | Standard_Boolean todef2 = ( !isdef2 ); |
903 | if ( isdef2 && SD2.mySameDomainOri == TopOpeBRepDS_UNSHGEOMETRY ) todef2 = Standard_True; |
904 | if ( todef2 ) { |
905 | SD2.myOrientation = o2; |
906 | SD2.myOrientationDef = Standard_True; |
907 | } |
908 | |
909 | Standard_Integer n1 = ShapeSameDomain(S1).Extent(); |
910 | Standard_Integer n2 = ShapeSameDomain(S2).Extent(); |
911 | |
912 | AddShapeSameDomain(S1,S2); |
913 | AddShapeSameDomain(S2,S1); |
914 | |
915 | Standard_Integer n11 = ShapeSameDomain(S1).Extent(); |
916 | Standard_Integer n22 = ShapeSameDomain(S2).Extent(); |
917 | |
918 | Standard_Boolean cond = ( n11 == n1 ) && (n22 == n2); |
919 | cond = cond && (!todef1) && (!todef2); |
920 | if ( cond ) { |
921 | // nothing changed in SameDomain data of S1 and S2 : return |
922 | return; |
923 | } |
924 | |
925 | Standard_Integer r1 = SameDomainRef(S1); |
926 | Standard_Integer r2 = SameDomainRef(S2); |
927 | Standard_Integer r = 0; |
928 | // r1 == i1 r2 == i2 : shapes have no SameDomain ref : take S1 as reference |
929 | // r1 == i1 r2 != i2 : S2 has a SameDomain reference : give it to S1 |
930 | // r1 != i1 r2 == i2 : S1 has a SameDomain reference : give it to S2 |
931 | // r1 != i1 r2 != i2 : S1,S2 have SameDomain reference : check equality |
932 | if ( r1 == iS1 && r2 == iS2 ) r = (refFirst? iS1 : iS2); |
933 | else if ( r1 == iS1 && r2 != iS2 ) r = r2; |
934 | else if ( r1 != iS1 && r2 == iS2 ) r = r1; |
935 | else if ( r1 != iS1 && r2 != iS2 ) { |
936 | if (r1 != r2) { |
9775fa61 |
937 | // throw Standard_ProgramError("FacesFiller::Insert SD 1"); |
7fd59977 |
938 | } |
939 | r = (refFirst? r1 : r2); |
940 | } |
941 | |
942 | if (r == 0) { |
9775fa61 |
943 | throw Standard_ProgramError("FacesFiller::Insert SD 2"); |
7fd59977 |
944 | } |
945 | |
946 | TopoDS_Shape Sr = Shape(r); |
947 | const TopOpeBRepDS_ShapeData& SD = myShapes.FindFromKey(Sr); |
948 | TopAbs_Orientation oSr = SD.myOrientation; |
949 | Sr.Orientation(oSr); |
950 | |
951 | if ( r != r1 || todef1) { // S1 gets a new reference r |
952 | TopOpeBRepDS_Config o = TopOpeBRepDS_SAMEORIENTED; |
953 | if ( r != iS1 || todef1) { |
954 | Standard_Boolean sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(S1,Sr); |
955 | if (!sso) o = TopOpeBRepDS_DIFFORIENTED; |
956 | } |
957 | SameDomainRef(iS1,r); |
958 | SameDomainOri(iS1,o); |
959 | } |
960 | |
961 | if ( r != r2 || todef2) { // S2 gets a new reference r |
962 | TopOpeBRepDS_Config o = TopOpeBRepDS_SAMEORIENTED; |
963 | if ( r != iS2 || todef2) { |
964 | Standard_Boolean sso = TopOpeBRepTool_ShapeTool::ShapesSameOriented(S2,Sr); |
965 | if (!sso) o = TopOpeBRepDS_DIFFORIENTED; |
966 | } |
967 | SameDomainRef(iS2,r); |
968 | SameDomainOri(iS2,o); |
969 | } |
970 | |
971 | // index |
972 | SameDomainInd(S1,1); |
973 | SameDomainInd(S2,2); |
974 | } |
975 | |
976 | //======================================================================= |
977 | //function : FillShapesSameDomain |
978 | //purpose : |
979 | //======================================================================= |
980 | void TopOpeBRepDS_DataStructure::FillShapesSameDomain(const TopoDS_Shape& S1, |
981 | const TopoDS_Shape& S2, |
982 | const TopOpeBRepDS_Config c1, |
983 | const TopOpeBRepDS_Config c2, |
984 | const Standard_Boolean refFirst) |
985 | { |
986 | Standard_Integer iS1 = AddShape(S1,1); |
987 | TopOpeBRepDS_ShapeData& SD1 = myShapes.ChangeFromIndex(iS1); |
988 | Standard_Boolean isdef1 = SD1.myOrientationDef; |
989 | Standard_Boolean todef1 = Standard_True; |
990 | if (c1 == TopOpeBRepDS_UNSHGEOMETRY && isdef1) todef1 = Standard_False; |
991 | |
992 | Standard_Integer iS2 = AddShape(S2,2); |
993 | TopOpeBRepDS_ShapeData& SD2 = myShapes.ChangeFromIndex(iS2); |
994 | Standard_Boolean isdef2 = SD2.myOrientationDef; |
995 | Standard_Boolean todef2 = Standard_True; |
996 | if (c2 == TopOpeBRepDS_UNSHGEOMETRY && isdef2) todef2 = Standard_False; |
997 | |
998 | if (todef1 || todef2 ) { |
999 | FillShapesSameDomain(S1,S2,refFirst); |
1000 | } |
1001 | |
1002 | if (todef1 && c1 == TopOpeBRepDS_UNSHGEOMETRY) |
1003 | SameDomainOri(S1,TopOpeBRepDS_UNSHGEOMETRY); |
1004 | if (todef2 && c2 == TopOpeBRepDS_UNSHGEOMETRY) |
1005 | SameDomainOri(S2,TopOpeBRepDS_UNSHGEOMETRY); |
1006 | } |
1007 | |
1008 | //======================================================================= |
1009 | //function : UnfillShapesSameDomain |
1010 | //purpose : |
1011 | //======================================================================= |
1012 | void TopOpeBRepDS_DataStructure::UnfillShapesSameDomain(const TopoDS_Shape& S1,const TopoDS_Shape& S2) |
1013 | { |
7fd59977 |
1014 | RemoveShapeSameDomain(S1,S2); |
1015 | RemoveShapeSameDomain(S2,S1); |
7fd59977 |
1016 | } |
1017 | |
1018 | //======================================================================= |
1019 | //function : NbSurfaces |
1020 | //purpose : |
1021 | //======================================================================= |
1022 | Standard_Integer TopOpeBRepDS_DataStructure::NbSurfaces()const |
1023 | { |
1024 | Standard_Integer n = myNbSurfaces; |
1025 | return n; |
1026 | } |
1027 | |
1028 | |
1029 | //======================================================================= |
1030 | //function : NbCurves |
1031 | //purpose : |
1032 | //======================================================================= |
1033 | Standard_Integer TopOpeBRepDS_DataStructure::NbCurves()const |
1034 | { |
1035 | Standard_Integer n = myNbCurves; |
1036 | return n; |
1037 | } |
1038 | |
1039 | |
1040 | //======================================================================= |
1041 | //function : ChangeNbCurves |
1042 | //purpose : |
1043 | //======================================================================= |
1044 | void TopOpeBRepDS_DataStructure::ChangeNbCurves(const Standard_Integer n) |
1045 | { |
1046 | myNbCurves = n; |
1047 | } |
1048 | |
1049 | |
1050 | //======================================================================= |
1051 | //function : NbPoints |
1052 | //purpose : |
1053 | //======================================================================= |
1054 | Standard_Integer TopOpeBRepDS_DataStructure::NbPoints()const |
1055 | { |
1056 | Standard_Integer n = myNbPoints; |
1057 | return n; |
1058 | } |
1059 | |
1060 | |
1061 | //======================================================================= |
1062 | //function : NbShapes |
1063 | //purpose : |
1064 | //======================================================================= |
1065 | Standard_Integer TopOpeBRepDS_DataStructure::NbShapes()const |
1066 | { |
1067 | Standard_Integer n = myShapes.Extent(); |
1068 | return n; |
1069 | } |
1070 | |
1071 | |
1072 | //======================================================================= |
1073 | //function : NbSectionEdges |
1074 | //purpose : |
1075 | //======================================================================= |
1076 | Standard_Integer TopOpeBRepDS_DataStructure::NbSectionEdges()const |
1077 | { |
1078 | Standard_Integer n = mySectionEdges.Extent(); |
1079 | return n; |
1080 | } |
1081 | |
1082 | |
1083 | //======================================================================= |
1084 | //function : Surface |
1085 | //purpose : |
1086 | //======================================================================= |
1087 | const TopOpeBRepDS_Surface& TopOpeBRepDS_DataStructure::Surface(const Standard_Integer I) const |
1088 | { |
1089 | if ( mySurfaces.IsBound(I) ) |
1090 | return mySurfaces(I).mySurface; |
1091 | else |
1092 | return myEmptySurface; |
1093 | } |
1094 | |
1095 | |
1096 | //======================================================================= |
1097 | //function : ChangeSurface |
1098 | //purpose : |
1099 | //======================================================================= |
1100 | TopOpeBRepDS_Surface& TopOpeBRepDS_DataStructure::ChangeSurface(const Standard_Integer I) |
1101 | { |
1102 | if ( mySurfaces.IsBound(I) ) |
1103 | return mySurfaces(I).mySurface; |
1104 | else |
1105 | return myEmptySurface; |
1106 | } |
1107 | |
1108 | |
1109 | //======================================================================= |
1110 | //function : Curve |
1111 | //purpose : |
1112 | //======================================================================= |
1113 | const TopOpeBRepDS_Curve& TopOpeBRepDS_DataStructure::Curve(const Standard_Integer I)const |
1114 | { |
1115 | if ( myCurves.IsBound(I) ) { |
1116 | const TopOpeBRepDS_CurveData& CD = myCurves(I); |
1117 | const TopOpeBRepDS_Curve& C = CD.myCurve; |
1118 | return C; |
1119 | } |
1120 | else |
1121 | return myEmptyCurve; |
1122 | } |
1123 | |
1124 | //======================================================================= |
1125 | //function : ChangeCurve |
1126 | //purpose : |
1127 | //======================================================================= |
1128 | TopOpeBRepDS_Curve& TopOpeBRepDS_DataStructure::ChangeCurve(const Standard_Integer I) |
1129 | { |
1130 | if ( myCurves.IsBound(I) ) { |
1131 | TopOpeBRepDS_CurveData& CD = myCurves.ChangeFind(I); |
1132 | TopOpeBRepDS_Curve& C = CD.myCurve; |
1133 | return C; |
1134 | } |
1135 | return myEmptyCurve; |
1136 | } |
1137 | |
1138 | //======================================================================= |
1139 | //function : Point |
1140 | //purpose : |
1141 | //======================================================================= |
1142 | const TopOpeBRepDS_Point& TopOpeBRepDS_DataStructure::Point(const Standard_Integer I)const |
1143 | { |
1144 | if ( I < 1 || I > myNbPoints ) { |
9775fa61 |
1145 | throw Standard_ProgramError("TopOpeBRepDS_DataStructure::Point"); |
7fd59977 |
1146 | } |
1147 | |
1148 | if ( myPoints.IsBound(I) ) |
1149 | return myPoints(I).myPoint; |
1150 | else |
1151 | return myEmptyPoint; |
1152 | } |
1153 | |
1154 | //======================================================================= |
1155 | //function : ChangePoint |
1156 | //purpose : |
1157 | //======================================================================= |
1158 | TopOpeBRepDS_Point& TopOpeBRepDS_DataStructure::ChangePoint(const Standard_Integer I) |
1159 | { |
1160 | if ( I < 1 || I > myNbPoints ) { |
9775fa61 |
1161 | throw Standard_ProgramError("TopOpeBRepDS_DataStructure::Point"); |
7fd59977 |
1162 | } |
1163 | |
1164 | if ( myPoints.IsBound(I) ) |
1165 | return myPoints(I).myPoint; |
1166 | else |
1167 | return myEmptyPoint; |
1168 | } |
1169 | |
1170 | |
1171 | //======================================================================= |
1172 | //function : Shape |
1173 | //purpose : |
1174 | //======================================================================= |
1175 | const TopoDS_Shape& TopOpeBRepDS_DataStructure::Shape(const Standard_Integer I,const Standard_Boolean FindKeep) const |
1176 | { |
1177 | if(KeepShape(I, FindKeep)) { |
1178 | const TopoDS_Shape& S = myShapes.FindKey(I); |
1179 | return S; |
1180 | } |
1181 | return myEmptyShape; |
1182 | } |
1183 | |
1184 | //======================================================================= |
1185 | //function : Shape |
1186 | //purpose : |
1187 | //======================================================================= |
1188 | Standard_Integer TopOpeBRepDS_DataStructure::Shape(const TopoDS_Shape& S,const Standard_Boolean FindKeep)const |
1189 | { |
1190 | Standard_Integer i = 0; |
1191 | Standard_Boolean hs = HasShape(S, FindKeep); |
1192 | if (hs) { |
1193 | i = myShapes.FindIndex(S); |
1194 | } |
1195 | return i; |
1196 | } |
1197 | |
1198 | |
1199 | //======================================================================= |
1200 | //function : SectionEdge |
1201 | //purpose : |
1202 | //======================================================================= |
1203 | const TopoDS_Edge& TopOpeBRepDS_DataStructure::SectionEdge(const Standard_Integer I,const Standard_Boolean FindKeep) const |
1204 | { |
1205 | const TopoDS_Shape& S = mySectionEdges.FindKey(I); |
1206 | if(HasShape(S, FindKeep)) |
1207 | return TopoDS::Edge(S); |
1208 | return TopoDS::Edge(myEmptyShape); |
1209 | } |
1210 | |
1211 | //======================================================================= |
1212 | //function : SectionEdge |
1213 | //purpose : |
1214 | //======================================================================= |
1215 | Standard_Integer TopOpeBRepDS_DataStructure::SectionEdge(const TopoDS_Edge& S,const Standard_Boolean FindKeep) const |
1216 | { |
1217 | Standard_Integer i = 0; |
1218 | if(KeepShape(S, FindKeep)) |
1219 | i = mySectionEdges.FindIndex(S); |
1220 | return i; |
1221 | } |
1222 | |
1223 | |
1224 | //======================================================================= |
1225 | //function : IsSectionEdge |
1226 | //purpose : |
1227 | //======================================================================= |
1228 | Standard_Boolean TopOpeBRepDS_DataStructure::IsSectionEdge(const TopoDS_Edge& S,const Standard_Boolean FindKeep) const |
1229 | { |
1230 | Standard_Boolean b = KeepShape(S, FindKeep); |
1231 | if(b) { |
1232 | b = mySectionEdges.Contains(S); |
1233 | } |
1234 | return b; |
1235 | } |
1236 | |
1237 | |
1238 | //======================================================================= |
1239 | //function : HasGeometry |
1240 | //purpose : |
1241 | //======================================================================= |
1242 | Standard_Boolean TopOpeBRepDS_DataStructure::HasGeometry(const TopoDS_Shape& S)const |
1243 | { |
1244 | Standard_Boolean has = HasShape(S); |
1245 | if ( has ) { |
1246 | has = ! ShapeInterferences(S).IsEmpty(); |
1247 | } |
1248 | return has; |
1249 | } |
1250 | |
1251 | |
1252 | //======================================================================= |
1253 | //function : HasShape |
1254 | //purpose : |
1255 | //======================================================================= |
1256 | Standard_Boolean TopOpeBRepDS_DataStructure::HasShape(const TopoDS_Shape& S,const Standard_Boolean FindKeep)const |
1257 | { |
1258 | Standard_Boolean res = KeepShape(S, FindKeep); |
1259 | return res; |
1260 | } |
1261 | |
1262 | //======================================================================= |
1263 | //function : SetNewSurface |
1264 | //purpose : |
1265 | //======================================================================= |
1266 | void TopOpeBRepDS_DataStructure::SetNewSurface(const TopoDS_Shape& F, const Handle(Geom_Surface)& S) |
1267 | { |
1268 | myNewSurface.Bind(F,S); |
1269 | } |
1270 | |
1271 | //======================================================================= |
1272 | //function : HasNewSurface |
1273 | //purpose : |
1274 | //======================================================================= |
1275 | Standard_Boolean TopOpeBRepDS_DataStructure::HasNewSurface(const TopoDS_Shape& F) const |
1276 | { |
1277 | Standard_Boolean b = myNewSurface.IsBound(F); |
1278 | return b; |
1279 | } |
1280 | |
1281 | //======================================================================= |
1282 | //function : NewSurface |
1283 | //purpose : |
1284 | //======================================================================= |
1285 | const Handle(Geom_Surface)& TopOpeBRepDS_DataStructure::NewSurface(const TopoDS_Shape& F) const |
1286 | { |
1287 | if (HasNewSurface(F)) return myNewSurface.Find(F); |
1288 | return myEmptyGSurface; |
1289 | } |
1290 | |
1291 | //======================================================================= |
1292 | //function : FindInterference |
1293 | //purpose : |
1294 | //======================================================================= |
1295 | Standard_Boolean TopOpeBRepDS_DataStructure::FindInterference(TopOpeBRepDS_ListIteratorOfListOfInterference& IT,const Handle(TopOpeBRepDS_Interference)& I) const |
1296 | { |
1297 | for( ; IT.More(); IT.Next()) if (IT.Value() == I ) return Standard_True; |
1298 | return Standard_False; |
1299 | } |
1300 | |
1301 | |
1302 | //======================================================================= |
1303 | //function : Isfafa |
1304 | //purpose : |
1305 | //======================================================================= |
1306 | void TopOpeBRepDS_DataStructure::Isfafa(const Standard_Boolean isfafa) |
1307 | { |
1308 | myIsfafa = isfafa; |
1309 | } |
1310 | |
1311 | //======================================================================= |
1312 | //function : Isfafa |
1313 | //purpose : |
1314 | //======================================================================= |
1315 | Standard_Boolean TopOpeBRepDS_DataStructure::Isfafa() const |
1316 | { |
1317 | return myIsfafa; |
1318 | } |
1319 | |
1320 | // |
1321 | //======================================================================= |
1322 | //function :ChangeMapOfShapeWithStateObj |
1323 | //purpose : |
1324 | //======================================================================= |
1325 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& TopOpeBRepDS_DataStructure::ChangeMapOfShapeWithStateObj() |
1326 | { |
1327 | return myMapOfShapeWithStateObj; |
1328 | } |
1329 | |
1330 | //======================================================================= |
1331 | //function :ChangeMapOfShapeWithStateTool |
1332 | //purpose : |
1333 | //======================================================================= |
1334 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& TopOpeBRepDS_DataStructure::ChangeMapOfShapeWithStateTool() |
1335 | { |
1336 | return myMapOfShapeWithStateTool; |
1337 | } |
1338 | |
1339 | //======================================================================= |
1340 | //function :ChangeMapOfShapeWithState |
1341 | //purpose : |
1342 | //======================================================================= |
1343 | TopOpeBRepDS_IndexedDataMapOfShapeWithState& TopOpeBRepDS_DataStructure::ChangeMapOfShapeWithState |
1344 | (const TopoDS_Shape& aShape, Standard_Boolean& aFlag) |
1345 | { |
1346 | static TopOpeBRepDS_IndexedDataMapOfShapeWithState dummy; |
1347 | aFlag=Standard_True; |
1348 | |
1349 | if (myMapOfShapeWithStateObj.Contains(aShape)) |
1350 | return myMapOfShapeWithStateObj; |
1351 | |
1352 | if (myMapOfShapeWithStateTool.Contains(aShape)) |
1353 | return myMapOfShapeWithStateTool; |
1354 | |
1355 | aFlag=Standard_False; |
1356 | return dummy; |
1357 | } |
1358 | |
1359 | |
1360 | //======================================================================= |
1361 | //function :GetShapeWithState |
1362 | //purpose : |
1363 | //======================================================================= |
1364 | const TopOpeBRepDS_ShapeWithState& TopOpeBRepDS_DataStructure::GetShapeWithState(const TopoDS_Shape& aShape) const |
1365 | { |
1366 | static TopOpeBRepDS_ShapeWithState dummy; |
1367 | if(myMapOfShapeWithStateObj.Contains(aShape)) |
1368 | return myMapOfShapeWithStateObj.FindFromKey(aShape); |
1369 | else if(myMapOfShapeWithStateTool.Contains(aShape)) |
1370 | return myMapOfShapeWithStateTool.FindFromKey(aShape); |
1371 | |
1372 | return dummy; |
1373 | } |
1374 | |
1375 | //======================================================================= |
1376 | //function :ChangeMapOfRejectedShapesObj |
1377 | //purpose : |
1378 | //======================================================================= |
1379 | TopTools_IndexedMapOfShape& TopOpeBRepDS_DataStructure::ChangeMapOfRejectedShapesObj() |
1380 | { |
1381 | return myMapOfRejectedShapesObj; |
1382 | } |
1383 | |
1384 | //======================================================================= |
1385 | //function :ChangeMapOfRejectedShapesTool |
1386 | //purpose : |
1387 | //======================================================================= |
1388 | TopTools_IndexedMapOfShape& TopOpeBRepDS_DataStructure::ChangeMapOfRejectedShapesTool() |
1389 | { |
1390 | return myMapOfRejectedShapesTool; |
1391 | } |
1392 | |
1393 | |