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