0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_HDataStructure.cxx
CommitLineData
b311480e 1// Created on: 1993-06-17
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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
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 <TopOpeBRepDS_HDataStructure.ixx>
18
19#include <TopOpeBRepDS_EdgeInterferenceTool.hxx>
20#include <BRep_Tool.hxx>
21#include <TopoDS.hxx>
22#include <TopoDS_Edge.hxx>
23#include <TopExp_Explorer.hxx>
24#include <TopTools_ListOfShape.hxx>
25#include <TopOpeBRepDS_SurfaceCurveInterference.hxx>
26#include <TopOpeBRepDS_Transition.hxx>
27#include <TopAbs_ShapeEnum.hxx>
28#include <TopOpeBRepDS.hxx>
29#include <TopOpeBRepDS_Interference.hxx>
30#include <TopOpeBRepDS_ListOfInterference.hxx>
31#include <TopOpeBRepDS_ListIteratorOfListOfInterference.hxx>
32#include <TopOpeBRepDS_Check.hxx>
33#include <TopOpeBRepTool_ShapeExplorer.hxx>
34#include <TopOpeBRepDS_Filter.hxx>
35#include <TopOpeBRepDS_Reducer.hxx>
36#include <TopOpeBRepDS_Dumper.hxx>
37#include <Standard_ProgramError.hxx>
38#include <TopOpeBRepDS_define.hxx>
39
40#ifdef DEB
1d0a9d4d 41extern Standard_Boolean TopOpeBRepDS_GettraceISTO();
42extern Standard_Boolean TopOpeBRepDS_GettraceEDSF();
43extern Standard_Boolean TopOpeBRepDS_GettraceDSF();
44extern Standard_Boolean TopOpeBRepDS_GettraceDSFD();
45extern Standard_Boolean TopOpeBRepDS_GettraceDEGEN();
46extern Standard_Boolean TopOpeBRepDS_GettracePCI();
47extern Standard_Boolean TopOpeBRepDS_GettracePI();
48extern Standard_Boolean TopOpeBRepDS_GettracePEI();
49extern Standard_Boolean TopOpeBRepDS_GettracePI();
50extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
7fd59977 51
52static Standard_Boolean traceSTORE()
53{
54 Standard_Boolean trc = Standard_False;
55 trc = trc || TopOpeBRepDS_GettraceEDSF();
56 trc = trc || TopOpeBRepDS_GettraceDSF();
57 trc = trc || TopOpeBRepDS_GettraceDEGEN();
58 trc = trc || TopOpeBRepDS_GettraceISTO();
59 return trc;
60}
61#endif
62
63static void FUN_HDS_data(const Handle(TopOpeBRepDS_Interference)& I,
64 TopOpeBRepDS_Kind& GT1,Standard_Integer& G1,
65 TopOpeBRepDS_Kind& ST1,Standard_Integer& S1)
66{
67 if (I.IsNull()) return;
68 GT1 = I->GeometryType(); G1 = I->Geometry();
69 ST1 = I->SupportType(); S1 = I->Support();
70}
71
72
73Standard_EXPORT Standard_Boolean FUN_HDS_FACESINTERFER
74(const TopoDS_Shape& F1, const TopoDS_Shape& F2,
75 const Handle(TopOpeBRepDS_HDataStructure)& HDS)
76{
77 Standard_Boolean yainterf = Standard_False;
78 const TopOpeBRepDS_DataStructure& DS = HDS->DS();
79 Standard_Boolean ya = DS.HasShape(F1);
80 if ( !ya ) return Standard_False;
81
82// DS.Shape(F1);
83 Standard_Integer iF2 = DS.Shape(F2);
84
85 const TopOpeBRepDS_ListOfInterference& L1 = DS.ShapeInterferences(F1);
86 TopOpeBRepDS_ListIteratorOfListOfInterference itL1(L1);
87 for (;itL1.More(); itL1.Next()) {
88 const Handle(TopOpeBRepDS_Interference)& I = itL1.Value();
d20d815b 89 TopOpeBRepDS_Kind GT = TopOpeBRepDS_UNKNOWN, ST = TopOpeBRepDS_UNKNOWN; Standard_Integer G,S = 0;
7fd59977 90 FUN_HDS_data(I,GT,G,ST,S);
91 // interference face1/edge/face2
92 Standard_Boolean fef = Standard_True;
93 fef = fef && (GT==TopOpeBRepDS_EDGE);
94 fef = fef && (ST==TopOpeBRepDS_FACE);
95 fef = fef && (S==iF2);
96 if (fef) {
97 yainterf = Standard_True;
98 break;
99 }
100 }
101 return yainterf;
102}
103
104
105//=======================================================================
106//function : TopOpeBRepDS_HDataStructure
107//purpose :
108//=======================================================================
109TopOpeBRepDS_HDataStructure::TopOpeBRepDS_HDataStructure()
110{
111}
112
113//=======================================================================
114//function : AddAncestors
115//purpose :
116//=======================================================================
117void TopOpeBRepDS_HDataStructure::AddAncestors
118(const TopoDS_Shape& S)
119{
120 AddAncestors(S,TopAbs_WIRE,TopAbs_EDGE);
121 AddAncestors(S,TopAbs_FACE,TopAbs_WIRE);
122 AddAncestors(S,TopAbs_SHELL,TopAbs_FACE);
123 AddAncestors(S,TopAbs_SOLID,TopAbs_SHELL);
124}
125
126//=======================================================================
127//function : AddAncestors
128//purpose :
129//=======================================================================
130void TopOpeBRepDS_HDataStructure::AddAncestors
131(const TopoDS_Shape& S,
132 const TopAbs_ShapeEnum T1,const TopAbs_ShapeEnum T2)
133{
134 TopOpeBRepDS_DataStructure& BDS = ChangeDS();
135 Standard_Integer rankS = myDS.AncestorRank(S);
136 // find the shapes of type T1 containing HasShape() of type T2
137 for (TopOpeBRepTool_ShapeExplorer eT1(S,T1); eT1.More(); eT1.Next()) {
138 const TopoDS_Shape& ST1 = eT1.Current();
139 for (TopOpeBRepTool_ShapeExplorer eT2(ST1,T2); eT2.More(); eT2.Next()) {
140 const TopoDS_Shape& ST2 = eT2.Current();
141 if (BDS.HasShape(ST2)) {
142 BDS.AddShape(ST1,rankS);
143 break;
144 }
145 }
146 }
147}
148
149//=======================================================================
150//function : ChkIntg
151//purpose : Check Integrity
152//=======================================================================
153void TopOpeBRepDS_HDataStructure::ChkIntg()
154{
155 // Check the integrity of the DS
156 Handle(TopOpeBRepDS_Check) chk = new TopOpeBRepDS_Check(this);
157 chk->ChkIntg();
158// chk->PrintIntg(cout);
159}
160
161//=======================================================================
162//function : DS
163//purpose :
164//=======================================================================
165const TopOpeBRepDS_DataStructure& TopOpeBRepDS_HDataStructure::DS()const
166{
167 return myDS;
168}
169
170//=======================================================================
171//function : ChangeDS
172//purpose :
173//=======================================================================
174TopOpeBRepDS_DataStructure& TopOpeBRepDS_HDataStructure::ChangeDS()
175{
176 return myDS;
177}
178
179//=======================================================================
180//function : NbSurfaces
181//purpose :
182//=======================================================================
183Standard_Integer TopOpeBRepDS_HDataStructure::NbSurfaces()const
184{
185 return myDS.NbSurfaces();
186}
187
188//=======================================================================
189//function : NbCurves
190//purpose :
191//=======================================================================
192Standard_Integer TopOpeBRepDS_HDataStructure::NbCurves()const
193{
194 return myDS.NbCurves();
195}
196
197//=======================================================================
198//function : NbPoints
199//purpose :
200//=======================================================================
201Standard_Integer TopOpeBRepDS_HDataStructure::NbPoints()const
202{
203 return myDS.NbPoints();
204}
205
206//=======================================================================
207//function : Surface
208//purpose :
209//=======================================================================
210const TopOpeBRepDS_Surface& TopOpeBRepDS_HDataStructure::Surface
211(const Standard_Integer I)const
212{
213 return myDS.Surface(I);
214}
215
216//=======================================================================
217//function : SurfaceCurves
218//purpose :
219//=======================================================================
220TopOpeBRepDS_CurveIterator TopOpeBRepDS_HDataStructure::SurfaceCurves
221(const Standard_Integer I)const
222{
223 const TopOpeBRepDS_ListOfInterference& L = myDS.SurfaceInterferences(I);
224 return TopOpeBRepDS_CurveIterator(L);
225}
226
227//=======================================================================
228//function : Curve
229//purpose :
230//=======================================================================
231const TopOpeBRepDS_Curve& TopOpeBRepDS_HDataStructure::Curve
232(const Standard_Integer I)const
233{
234 return myDS.Curve(I);
235}
236
237//=======================================================================
238//function : ChangeCurve
239//purpose :
240//=======================================================================
241TopOpeBRepDS_Curve& TopOpeBRepDS_HDataStructure::ChangeCurve
242(const Standard_Integer I)
243{
244 return myDS.ChangeCurve(I);
245}
246
247//=======================================================================
248//function : CurvePoints
249//purpose :
250//=======================================================================
251TopOpeBRepDS_PointIterator TopOpeBRepDS_HDataStructure::CurvePoints
252(const Standard_Integer I)const
253{
254 const TopOpeBRepDS_ListOfInterference& L = myDS.CurveInterferences(I);
255 return TopOpeBRepDS_PointIterator(L);
256}
257
258//=======================================================================
259//function : Point
260//purpose :
261//=======================================================================
262const TopOpeBRepDS_Point& TopOpeBRepDS_HDataStructure::Point
263(const Standard_Integer I)const
264{
265 return myDS.Point(I);
266}
267
268//=======================================================================
269//function : HasGeometry
270//purpose :
271//=======================================================================
272Standard_Boolean TopOpeBRepDS_HDataStructure::HasGeometry
273(const TopoDS_Shape& S)const
274{
275 Standard_Boolean b = myDS.HasGeometry(S);
276 return b;
277}
278
279//=======================================================================
280//function : HasShape
281//purpose :
282//=======================================================================
283Standard_Boolean TopOpeBRepDS_HDataStructure::HasShape
284(const TopoDS_Shape& S,const Standard_Boolean FindKeep) const
285{
286 Standard_Boolean b = myDS.HasShape(S, FindKeep);
287 return b;
288}
289
290//=======================================================================
291//function : HasSameDomain
292//purpose :
293//=======================================================================
294Standard_Boolean TopOpeBRepDS_HDataStructure::HasSameDomain
295(const TopoDS_Shape& S,const Standard_Boolean FindKeep)const
296{
297 if ( ! HasShape(S, FindKeep) ) return Standard_False;
298 const TopTools_ListOfShape& l = myDS.ShapeSameDomain(S);
299 Standard_Boolean res = ! l.IsEmpty();
300 return res;
301}
302
303//=======================================================================
304//function : SameDomain
305//purpose :
306//=======================================================================
307TopTools_ListIteratorOfListOfShape TopOpeBRepDS_HDataStructure::SameDomain
308(const TopoDS_Shape& S)const
309{
310 const TopTools_ListOfShape& L = myDS.ShapeSameDomain(S);
311 return TopTools_ListIteratorOfListOfShape(L);
312}
313
314//=======================================================================
315//function : SameDomainOrientation
316//purpose :
317//=======================================================================
318TopOpeBRepDS_Config TopOpeBRepDS_HDataStructure::SameDomainOrientation
319(const TopoDS_Shape& S)const
320{
321 if ( ! HasShape(S) ) return TopOpeBRepDS_UNSHGEOMETRY;
322 return myDS.SameDomainOri(S);
323}
324
325//=======================================================================
326//function : SameDomainReference
327//purpose :
328//=======================================================================
329Standard_Integer TopOpeBRepDS_HDataStructure::SameDomainReference
330(const TopoDS_Shape& S)const
331{
332 if ( ! HasShape(S) ) return 0;
333 return myDS.SameDomainRef(S);
334}
335
336//=======================================================================
337//function : NbShapes
338//purpose :
339//=======================================================================
340Standard_Integer TopOpeBRepDS_HDataStructure::NbShapes()const
341{
342 return myDS.NbShapes();
343}
344
345//=======================================================================
346//function : Shape
347//purpose :
348//=======================================================================
349const TopoDS_Shape& TopOpeBRepDS_HDataStructure::Shape
350(const Standard_Integer I,const Standard_Boolean FindKeep) const
351{
352 return myDS.Shape(I, FindKeep);
353}
354
355//=======================================================================
356//function : Shape
357//purpose :
358//=======================================================================
359Standard_Integer TopOpeBRepDS_HDataStructure::Shape
360(const TopoDS_Shape& S,const Standard_Boolean FindKeep)const
361{
362 return myDS.Shape(S, FindKeep);
363}
364
365//=======================================================================
366//function : SolidSurfaces
367//purpose :
368//=======================================================================
369TopOpeBRepDS_SurfaceIterator TopOpeBRepDS_HDataStructure::SolidSurfaces
370(const TopoDS_Shape& S) const
371{
372 const TopOpeBRepDS_ListOfInterference& L = myDS.ShapeInterferences(S);
373 return TopOpeBRepDS_SurfaceIterator(L);
374}
375
376//=======================================================================
377//function : SolidSurfaces
378//purpose :
379//=======================================================================
380TopOpeBRepDS_SurfaceIterator TopOpeBRepDS_HDataStructure::SolidSurfaces
381(const Standard_Integer I)const
382{
383 const TopOpeBRepDS_ListOfInterference& L = myDS.ShapeInterferences(I);
384 return TopOpeBRepDS_SurfaceIterator(L);
385}
386
387//=======================================================================
388//function : FaceCurves
389//purpose :
390//=======================================================================
391TopOpeBRepDS_CurveIterator TopOpeBRepDS_HDataStructure::FaceCurves
392(const TopoDS_Shape& F)const
393{
394 const TopOpeBRepDS_ListOfInterference& L = myDS.ShapeInterferences(F);
395 return TopOpeBRepDS_CurveIterator(L);
396}
397
398//=======================================================================
399//function : FaceCurves
400//purpose :
401//=======================================================================
402TopOpeBRepDS_CurveIterator TopOpeBRepDS_HDataStructure::FaceCurves
403(const Standard_Integer I)const
404{
405 const TopOpeBRepDS_ListOfInterference& L = myDS.ShapeInterferences(I);
406 return TopOpeBRepDS_CurveIterator(L);
407}
408
409//=======================================================================
410//function : EdgePoints
411//purpose :
412//=======================================================================
413TopOpeBRepDS_PointIterator TopOpeBRepDS_HDataStructure::EdgePoints
414(const TopoDS_Shape& E)const
415{
416 const TopOpeBRepDS_ListOfInterference& L = myDS.ShapeInterferences(E);
417 return TopOpeBRepDS_PointIterator(L);
418}
419
420//=======================================================================
421//function : MakeCurve
422//purpose :
423//=======================================================================
424Standard_Integer TopOpeBRepDS_HDataStructure::MakeCurve
425(const TopOpeBRepDS_Curve& curC,TopOpeBRepDS_Curve& newC)
426{
427 // SCI1, SCI2 = new surface/curve interf. build from
428 // the surface/curve interf. of the curve curC
429 const Handle(TopOpeBRepDS_Interference)& I1 = curC.GetSCI1();
430 const Handle(TopOpeBRepDS_Interference)& I2 = curC.GetSCI2();
431 Handle(TopOpeBRepDS_SurfaceCurveInterference) SCI1,SCI2;
432 if ( ! I1.IsNull() ) SCI1 = new TopOpeBRepDS_SurfaceCurveInterference(I1);
433 if ( ! I2.IsNull() ) SCI2 = new TopOpeBRepDS_SurfaceCurveInterference(I2);
434
435 const TopoDS_Shape& S1 = curC.Shape1();
436 const TopoDS_Shape& S2 = curC.Shape2();
437
438 // add the new SCIs in the lists of SCIs connected to the shapes
439 if ( ! SCI1.IsNull() ) myDS.AddShapeInterference(S1,SCI1);
440 if ( ! SCI2.IsNull() ) myDS.AddShapeInterference(S2,SCI2);
441
442 // the shapes of the new curve are the shapes of curve curC
443 newC.SetShapes(S1,S2);
444
445 // set surface/curve interferences of the new curve
446 newC.SetSCI(SCI1,SCI2);
447
448 // newC is a daughter of curC
449 newC.ChangeMother(curC.DSIndex());
450
451 // add the new curve in the DS
452 Standard_Integer inewC = myDS.AddCurve(newC);
453
454 // the geometry of the new surface/curve interf. is new curve inewC
455 if ( ! SCI1.IsNull() ) SCI1->Geometry(inewC);
456 if ( ! SCI2.IsNull() ) SCI2->Geometry(inewC);
457
458 return inewC;
459}
460
461//=======================================================================
462//function : RemoveCurve
463//purpose :
464//=======================================================================
465void TopOpeBRepDS_HDataStructure::RemoveCurve(const Standard_Integer icurC)
466{
467 myDS.RemoveCurve(icurC);
468}
469
470//=======================================================================
471//function : NbGeometry
472//purpose :
473//=======================================================================
474Standard_Integer TopOpeBRepDS_HDataStructure::NbGeometry
475 (const TopOpeBRepDS_Kind K) const
476{
477 if ( ! TopOpeBRepDS::IsGeometry(K)) return 0;
478
479 Standard_Integer n = 0;
480 switch(K) {
481 case TopOpeBRepDS_POINT : n = NbPoints(); break;
482 case TopOpeBRepDS_CURVE : n = NbCurves(); break;
483 case TopOpeBRepDS_SURFACE : n = NbSurfaces(); break;
484 default : n = 0; break;
485 }
486 return n;
487}
488
489//=======================================================================
490//function : NbTopology
491//purpose :
492//=======================================================================
493Standard_Integer TopOpeBRepDS_HDataStructure::NbTopology() const
494{
495 Standard_Integer n = myDS.NbShapes();
496 return n;
497}
498
499//=======================================================================
500//function : NbTopology
501//purpose :
502//=======================================================================
503Standard_Integer TopOpeBRepDS_HDataStructure::NbTopology
504(const TopOpeBRepDS_Kind K) const
505{
506 if ( ! TopOpeBRepDS::IsTopology(K) ) return 0;
507 Standard_Integer res = 0;
508 const Standard_Boolean FindKeep = Standard_False;
509
510 TopAbs_ShapeEnum S = TopOpeBRepDS::KindToShape(K);
511 for (Standard_Integer i = 1; i <= NbTopology(); i++ )
512 if(myDS.KeepShape(i, FindKeep))
513 if (myDS.Shape(i, FindKeep).ShapeType() == S) res++;
514 return res;
515}
516
517//=======================================================================
518//function : EdgesSameParameter
519//purpose :
520//=======================================================================
521
522Standard_Boolean TopOpeBRepDS_HDataStructure::EdgesSameParameter() const
523{
524 Standard_Integer i,n = myDS.NbShapes();
525 for (i = 1 ; i <= n; i++) {
526 const TopoDS_Shape& s = myDS.Shape(i);
527 if ( s.ShapeType() == TopAbs_EDGE ) {
528 const TopoDS_Edge& e = TopoDS::Edge(s);
529 if ( ! BRep_Tool::SameParameter(e) ) {
530 return Standard_False;
531 }
532 }
533 }
534 return Standard_True;
535}
536
537#include <TColStd_HArray1OfBoolean.hxx>
538#include <TColStd_Array1OfBoolean.hxx>
539
540Standard_EXPORT void FUN_TopOpeBRepDS_SortOnParameter
541(const TopOpeBRepDS_ListOfInterference& List,
542 TopOpeBRepDS_ListOfInterference& SList)
543{
544 // NYI : sort a list of Items, giving a sorting FUNCTION is impossible
545 // NYI : --> foobar method complexity n2.
546
547 Standard_Integer iIntf=0,nIntf = List.Extent();
548 if (nIntf == 0) return;
549
550 Handle(TColStd_HArray1OfBoolean) HT;
551 HT = new TColStd_HArray1OfBoolean(1,nIntf,Standard_False);
552 TColStd_Array1OfBoolean& T = HT->ChangeArray1();
553
554 Handle(TopOpeBRepDS_Interference) Intf;
555
556 for (Standard_Integer i = 1; i <= nIntf; i++) {
557 Standard_Real parmin = RealLast();
558 TopOpeBRepDS_PointIterator it(List);
559 for (Standard_Integer itest = 1; it.More(); it.Next(),itest++) {
560 if ( ! T(itest) ) {
561 Standard_Real par = it.Parameter();
562 if (par < parmin) {
563 parmin = par;
564 Intf = it.Value();
565 iIntf = itest;
566 }
567 }
568 }
569 SList.Append(Intf);
570 T(iIntf) = Standard_True;
571 }
572}
573
574//=======================================================================
575//function : SortOnParameter
576//purpose :
577//=======================================================================
578void TopOpeBRepDS_HDataStructure::SortOnParameter
579(const TopOpeBRepDS_ListOfInterference& List,
580 TopOpeBRepDS_ListOfInterference& SList) const
581{
582 // NYI : sort a list of Items, giving a sorting FUNCTION is impossible
583 // NYI : --> foobar method complexity n2.
584
585 ::FUN_TopOpeBRepDS_SortOnParameter(List,SList);
586
587 // tete = interf FORWARD :
588 // modifier TopOpeBRepBuild_ParametrizedVertexSet ::SortParametrizedVertex()
589 Standard_Boolean found = Standard_False;
590 TopOpeBRepDS_ListIteratorOfListOfInterference it(SList);
591 TopOpeBRepDS_ListOfInterference L1,L2;
592
593 for (; it.More(); it.Next() ) {
594 Handle(TopOpeBRepDS_Interference) I = it.Value();
595 if ( ! found) {
596 TopAbs_Orientation o = I->Transition().Orientation(TopAbs_IN);
597 if (o == TopAbs_FORWARD) {
598 found = Standard_True;
599 L1.Append(I);
600 }
601 else L2.Append(I);
602 }
603 else L1.Append(I);
604 }
605
606 SList.Clear();
607 SList.Append(L1);
608 SList.Append(L2);
609}
610
611//=======================================================================
612//function : SortOnParameter
613//purpose :
614//=======================================================================
615void TopOpeBRepDS_HDataStructure::SortOnParameter
616(TopOpeBRepDS_ListOfInterference& List) const
617{
618 TopOpeBRepDS_PointIterator it(List);
619 if (it.More()) {
620 TopOpeBRepDS_ListOfInterference SList;
621 SortOnParameter(List,SList);
622 List.Assign(SList);
623 }
624}
625
626//=======================================================================
627//function : MinMaxOnParameter
628//purpose :
629//=======================================================================
630void TopOpeBRepDS_HDataStructure::MinMaxOnParameter
631(const TopOpeBRepDS_ListOfInterference& List,
632 Standard_Real& parmin,Standard_Real& parmax) const
633{
634 if ( ! List.IsEmpty() ) {
635 Standard_Real parline;
636 parmin = RealLast(); parmax = RealFirst();
637 TopOpeBRepDS_PointIterator it(List);
638 for ( ; it.More(); it.Next()) {
639 parline = it.Parameter();
640 parmin = Min(parmin,parline);
641 parmax = Max(parmax,parline);
642 }
643 }
644}
645
646//-----------------------------------------------------------------------
647// Search, among a list of interferences accessed by the iterator <IT>,
648// a geometry whose 3D point is identical yo the 3D point of a DS point <PDS>.
649// return True if such an interference has been found, False else.
650// if True, iterator <IT> points (by the Value() method) on the first
651// interference accessing an identical 3D point.
652//-----------------------------------------------------------------------
653//=======================================================================
654//function : ScanInterfList
655//purpose :
656//=======================================================================
657Standard_Boolean TopOpeBRepDS_HDataStructure::ScanInterfList
658(TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
659 const TopOpeBRepDS_Point& PDS) const
660{
661 for ( ; IT.More(); IT.Next() ) {
662 TopOpeBRepDS_Kind GT = IT.Value()->GeometryType();
663 Standard_Integer G = IT.Value()->Geometry();
664 if ( GT == TopOpeBRepDS_POINT ) {
665 const TopOpeBRepDS_Point& OOPDS = myDS.Point(G);
666 Standard_Boolean iseq = PDS.IsEqual(OOPDS);
667 if (iseq) return iseq;
668 }
669 else if ( GT == TopOpeBRepDS_VERTEX ) {
670 TopOpeBRepDS_Point OOPDS(myDS.Shape(G));
671 Standard_Boolean iseq = PDS.IsEqual(OOPDS);
672 if (iseq) return iseq;
673 }
674 }
675 return Standard_False;
676}
677
678//=======================================================================
679//function : GetGeometry
680//purpose :
681//=======================================================================
682
683Standard_Boolean TopOpeBRepDS_HDataStructure::GetGeometry
684(TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
685 const TopOpeBRepDS_Point& PDS,
686 Standard_Integer& G,
687 TopOpeBRepDS_Kind& K) const
688{
689 Standard_Boolean found = ScanInterfList(IT,PDS);
690 if (found) {
691 G = IT.Value()->Geometry();
692 K = IT.Value()->GeometryType();
693 }
694 return found;
695}
696
697#ifdef DEB
1d0a9d4d 698extern Standard_Boolean TopOpeBRepDS_GettraceSTRANGE();
699extern Standard_Boolean TopOpeBRepDS_GettraceSPSX(const Standard_Integer);
7fd59977 700static Standard_Boolean TRC(const Standard_Integer SIX) {
701 Standard_Boolean b1 = TopOpeBRepDS_GettraceSTRANGE();
702 Standard_Boolean b2 = TopOpeBRepDS_GettraceSPSX(SIX);
703 return (b1 || b2);
704}
705void debstore(const Standard_Integer /*i*/) {}
706#endif
707
708//=======================================================================
709//function : StoreInterference
710//purpose : Append an interference I to a list of interference LI
711// Append I to the interf. list connected to I Geometry()
712//=======================================================================
713void TopOpeBRepDS_HDataStructure::StoreInterference
714(const Handle(TopOpeBRepDS_Interference)& I,TopOpeBRepDS_ListOfInterference& LI,
715#ifdef DEB
716 const TCollection_AsciiString& str)
717#else
718 const TCollection_AsciiString& )
719#endif
720{
721#ifdef DEB
722 const TopOpeBRepDS_Transition& T = I->Transition();
723
724 TopAbs_ShapeEnum sb = T.ShapeBefore();
725 Standard_Integer ib = T.IndexBefore();
726 Standard_Boolean bok = Standard_True;
727 if (ib != 0) {
728 TopAbs_ShapeEnum sbds = myDS.Shape(ib).ShapeType();
729 bok = (sbds == sb);
730 }
731
732 TopAbs_ShapeEnum sa = T.ShapeAfter();
733 Standard_Integer ia = T.IndexAfter();
734 Standard_Boolean aok = Standard_True;
735 if (ia != 0) {
736 TopAbs_ShapeEnum sads = myDS.Shape(ia).ShapeType();
737 aok = (sads == sa);
738 }
739
740 TopOpeBRepDS_Kind ks = I->SupportType();
741 TopAbs_ShapeEnum ss = TopOpeBRepDS::KindToShape(ks);
742 Standard_Integer is = I->Support();
743 Standard_Boolean sok = Standard_True;
744 if ((is != 0) && (ks >= TopOpeBRepDS_EDGE)) {
745 TopAbs_ShapeEnum ssds = myDS.Shape(is).ShapeType();
746 sok = (ssds == ss);
747 }
748
749 if (!aok) {
750 if (TRC(ia)) cout<<"HDSstore ia,ib is "<<ia<<","<<ib<<" "<<is<<endl;
751 debstore(ia);
752 }
753 if (!bok ) {
754 if (TRC(ib)) cout<<"HDSstore ia,ib is "<<ia<<","<<ib<<" "<<is<<endl;
755 debstore(ib);
756 }
757 if (!sok ) {
758 if (TRC(is)) cout<<"HDSstore ia,ib is "<<ia<<","<<ib<<" "<<is<<endl;
759 debstore(is);
760 }
761#endif
762
763 // append I to list LI
764 LI.Append(I);
765
96a95605 766#ifdef DEB
7fd59977 767 Standard_Boolean appendtoG = Standard_False;
96a95605 768#endif
7fd59977 769 Standard_Integer G = I->Geometry();
770
771 // append I to list of interference connected to G = I->Geometry()
772 switch (I->GeometryType()) {
773
774 case TopOpeBRepDS_SOLID : case TopOpeBRepDS_FACE :
775 case TopOpeBRepDS_EDGE : case TopOpeBRepDS_VERTEX :
776// appendtoG = Standard_True;
777// myDS.ChangeShapeInterferences(G).Append(I);
778 break;
779
780 case TopOpeBRepDS_SURFACE :
96a95605 781#ifdef DEB
7fd59977 782 appendtoG = Standard_True;
96a95605 783#endif
7fd59977 784 myDS.ChangeSurfaceInterferences(G).Append(I);
785 break;
786
787 case TopOpeBRepDS_CURVE :
96a95605 788#ifdef DEB
7fd59977 789 appendtoG = Standard_True;
96a95605 790#endif
7fd59977 791 myDS.ChangeCurveInterferences(G).Append(I);
792 break;
793
794 case TopOpeBRepDS_POINT :
795// appendtoG = Standard_True;
796// myDS.ChangePointInterferences(G).Append(I);
797 break;
798 default:
799 break;
800 }
801
802#ifdef DEB
803 Standard_Boolean trc = ::traceSTORE();
804 if (trc) {
805 cout<<str<<"append "; I->Dump(cout);
806 if (appendtoG) cout<<" and to G"<<G<<" list";
807 cout<<endl;
808 }
809#endif
810}
811
812//=======================================================================
813//function : StoreInterference
814//purpose :
815//=======================================================================
816void TopOpeBRepDS_HDataStructure::StoreInterference
817(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& S,
818#ifdef DEB
819 const TCollection_AsciiString& str)
820#else
821 const TCollection_AsciiString& )
822#endif
823{
824 Standard_Boolean h = myDS.HasShape(S);
825 if ( !h ) {
826 Standard_ProgramError::Raise("StoreInterference on shape out of DS");
827 return;
828 }
829
830#ifdef DEB
831 Standard_Boolean trc = ::traceSTORE();
832 TopOpeBRepDS_Kind ks = TopOpeBRepDS::ShapeToKind(S.ShapeType());
833 Standard_Integer is = myDS.Shape(S);
834 if (trc) TopOpeBRepDS::Print(ks,is,cout,str," : ");
835#endif
836
837 StoreInterference(I,myDS.ChangeShapeInterferences(S));
838}
839
840//=======================================================================
841//function : StoreInterference
842//purpose :
843//=======================================================================
844
845void TopOpeBRepDS_HDataStructure::StoreInterference
846(const Handle(TopOpeBRepDS_Interference)& I,
847 const Standard_Integer IS,
848#ifdef DEB
849 const TCollection_AsciiString& str)
850#else
851 const TCollection_AsciiString& )
852#endif
853{
854 Standard_Integer n = myDS.NbShapes();
855 if ( IS < 1 || IS > n ) {
856 Standard_ProgramError::Raise("StoreInterference on index out of DS");
857 return;
858 }
859
860#ifdef DEB
861 Standard_Boolean trc = ::traceSTORE();
862 const TopoDS_Shape& S = Shape(IS);
863 TopOpeBRepDS_Kind ks = TopOpeBRepDS::ShapeToKind(S.ShapeType());
864 if (trc) TopOpeBRepDS::Print(ks,IS,cout,str," : ");
865#endif
866
867 StoreInterference(I,myDS.ChangeShapeInterferences(IS));
868}
869
870//=======================================================================
871//function : StoreInterference
872//purpose :
873//=======================================================================
874void TopOpeBRepDS_HDataStructure::StoreInterferences
875(const TopOpeBRepDS_ListOfInterference& LI,const Standard_Integer IS
876// ,const TCollection_AsciiString& str)
877 ,const TCollection_AsciiString& )
878{
879 TopOpeBRepDS_ListOfInterference& lids = myDS.ChangeShapeInterferences(IS);
880 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
881 for (; it.More(); it.Next()){
882 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
883 StoreInterference(I,lids);
884 }
885}
886
887//=======================================================================
888//function : StoreInterferences
889//purpose :
890//=======================================================================
891void TopOpeBRepDS_HDataStructure::StoreInterferences
892(const TopOpeBRepDS_ListOfInterference& LI,const TopoDS_Shape& S
893// ,const TCollection_AsciiString& str)
894 ,const TCollection_AsciiString& )
895{
896 TopOpeBRepDS_ListOfInterference& lids = myDS.ChangeShapeInterferences(S);
897 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
898 for (; it.More(); it.Next()){
899 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
900 StoreInterference(I,lids);
901 }
902}
903
904//=======================================================================
905//function : ClearStoreInterferences
906//purpose :
907//=======================================================================
908void TopOpeBRepDS_HDataStructure::ClearStoreInterferences
909(const TopOpeBRepDS_ListOfInterference& LI,const Standard_Integer IS
910// ,const TCollection_AsciiString& str)
911 ,const TCollection_AsciiString& )
912{
913 TopOpeBRepDS_ListOfInterference& lids = myDS.ChangeShapeInterferences(IS);
914 lids.Clear();
915 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
916 for (; it.More(); it.Next()){
917 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
918 StoreInterference(I,lids);
919 }
920}
921
922//=======================================================================
923//function : ClearStoreInterferences
924//purpose :
925//=======================================================================
926void TopOpeBRepDS_HDataStructure::ClearStoreInterferences
927(const TopOpeBRepDS_ListOfInterference& LI,const TopoDS_Shape& S
928// ,const TCollection_AsciiString& str)
929 ,const TCollection_AsciiString& )
930{
931 TopOpeBRepDS_ListOfInterference& lids = myDS.ChangeShapeInterferences(S);
932 lids.Clear();
933 TopOpeBRepDS_ListIteratorOfListOfInterference it(LI);
934 for (; it.More(); it.Next()){
935 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
936 StoreInterference(I,lids);
937 }
938}