0033040: Coding - get rid of unused headers [Storage to TopOpeBRepTool]
[occt.git] / src / TopOpeBRepDS / TopOpeBRepDS_Association.cxx
1 // Created on: 1998-09-03
2 // Created by: Yves FRICAUD
3 // Copyright (c) 1998-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 <TopOpeBRepDS_Association.hxx>
19 #include <TopOpeBRepDS_Interference.hxx>
20
21 IMPLEMENT_STANDARD_RTTIEXT(TopOpeBRepDS_Association,Standard_Transient)
22
23 //=======================================================================
24 //function : Contains
25 //purpose  : 
26 //=======================================================================
27 static Standard_Boolean Contains (const TopOpeBRepDS_ListOfInterference& LI,
28                                   const Handle(TopOpeBRepDS_Interference)& I)
29 {
30   for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
31     if (I->HasSameGeometry(it.Value())) return 1;
32   }
33   return 0;
34 }
35
36
37 //=======================================================================
38 //function : TopOpeBRepDS_Association
39 //purpose  : 
40 //=======================================================================
41
42 TopOpeBRepDS_Association::TopOpeBRepDS_Association()
43 {
44 }
45
46
47 //=======================================================================
48 //function : Associate
49 //purpose  : 
50 //=======================================================================
51
52 void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
53                                          const Handle(TopOpeBRepDS_Interference)& K) 
54 {
55   if (!myMap.IsBound(I)) {
56     TopOpeBRepDS_ListOfInterference empty;
57     myMap.Bind(I,empty);
58     myMap(I).Append(K);
59   }
60   else if (!Contains(myMap(I),K)) {
61     myMap(I).Append(K);
62   }
63   if (!myMap.IsBound(K)) {
64     TopOpeBRepDS_ListOfInterference empty;
65     myMap.Bind(K,empty);
66     myMap(K).Append(I);
67   }
68   else if (!Contains(myMap(K),I)) {
69     myMap(K).Append(I);
70   }
71 }
72
73
74 //=======================================================================
75 //function : Associate
76 //purpose  : 
77 //=======================================================================
78
79 void TopOpeBRepDS_Association::Associate(const Handle(TopOpeBRepDS_Interference)& I,
80                                          const TopOpeBRepDS_ListOfInterference& LI) 
81 {  
82   for (TopOpeBRepDS_ListIteratorOfListOfInterference it(LI); it.More(); it.Next()) {
83     Associate(I,it.Value());
84   }
85 }
86
87 //=======================================================================
88 //function : HasAssociation
89 //purpose  : 
90 //=======================================================================
91
92 Standard_Boolean TopOpeBRepDS_Association::HasAssociation(const Handle(TopOpeBRepDS_Interference)& I) const
93 {
94   return myMap.IsBound(I);
95 }
96
97
98 //=======================================================================
99 //function : Associated
100 //purpose  : 
101 //=======================================================================
102
103 TopOpeBRepDS_ListOfInterference& TopOpeBRepDS_Association::Associated
104 (const Handle(TopOpeBRepDS_Interference)& I)
105 {
106   if (myMap.IsBound(I)) {
107     return myMap.ChangeFind(I);
108   }
109   static TopOpeBRepDS_ListOfInterference empty;
110   return empty;
111 }
112
113
114 //=======================================================================
115 //function : AreAssociated
116 //purpose  : 
117 //=======================================================================
118
119 Standard_Boolean TopOpeBRepDS_Association::AreAssociated(const Handle(TopOpeBRepDS_Interference)& I,
120                                                          const Handle(TopOpeBRepDS_Interference)& K) const
121 {
122   return (myMap.IsBound(I) && Contains(myMap(I),K));
123 }
124
125