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