Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/geom.git] / src / NMTDS / NMTDS_InterfPool.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either 
7 // version 2.1 of the License.
8 // 
9 // This library is distributed in the hope that it will be useful 
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 // Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public  
15 // License along with this library; if not, write to the Free Software 
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 // File:        NMTDS_.InterfPoolcxx
21 // Created:     Wed Feb 21 10:35:35 2007
22 // Author:      Peter KURNEV
23 //              <pkv@irinox>
24
25
26 #include <NMTDS_InterfPool.ixx>
27 #include <NMTDS_PassKeyBoolean.hxx>
28 #include <NMTDS_ListOfPassKeyBoolean.hxx>
29 #include <NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx>
30 #include <NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx>
31
32 static
33   Standard_Integer TypeToInteger(const NMTDS_InterfType aType);
34
35 //=======================================================================
36 //function : 
37 //purpose  : 
38 //=======================================================================
39   NMTDS_InterfPool::NMTDS_InterfPool()
40 {
41   myMaxInd=6;
42 }
43 //=======================================================================
44 //function : ~
45 //purpose  : 
46 //=======================================================================
47   NMTDS_InterfPool::~NMTDS_InterfPool()
48 {
49 }
50 //=======================================================================
51 //function : Add
52 //purpose  : 
53 //=======================================================================
54   Standard_Boolean NMTDS_InterfPool::Add (const NMTDS_PassKeyBoolean& aPKB,
55                                           const NMTDS_InterfType aType)
56 {
57   Standard_Boolean bRet;
58   Standard_Integer iType;
59   //
60   bRet=Standard_False;
61   //
62   iType=TypeToInteger(aType);
63   if (iType>-1 && iType<myMaxInd) {
64     bRet=myTable[iType].Add(aPKB);
65   }
66   return bRet;
67 }
68 //=======================================================================
69 //function : Add
70 //purpose  : 
71 //=======================================================================
72   Standard_Boolean NMTDS_InterfPool::Add (const Standard_Integer aInd1,
73                                           const Standard_Integer aInd2,
74                                           const NMTDS_InterfType aType)
75 {
76   NMTDS_PassKeyBoolean aPKB;
77   //
78   aPKB.SetIds(aInd1, aInd2);
79   return Add(aPKB, aType);
80 }
81 //=======================================================================
82 //function : Add
83 //purpose  : 
84 //=======================================================================
85   Standard_Boolean NMTDS_InterfPool::Add (const Standard_Integer aInd1,
86                                           const Standard_Integer aInd2,
87                                           const Standard_Boolean bFlag,
88                                           const NMTDS_InterfType aType)
89 {
90   NMTDS_PassKeyBoolean aPKB;
91   //
92   aPKB.SetIds(aInd1, aInd2);
93   aPKB.SetFlag(bFlag);
94   return Add(aPKB, aType);
95 }
96 //=======================================================================
97 //function : Contains 
98 //purpose  : 
99 //=======================================================================
100   Standard_Boolean NMTDS_InterfPool::Contains(const NMTDS_PassKeyBoolean& aPKB)const
101 {
102   Standard_Boolean bRet;
103   Standard_Integer i;
104   //
105   for (i=0; i<myMaxInd; ++i) {
106     bRet=myTable[i].Contains(aPKB);
107     if (bRet) {
108       break;
109     }
110   }
111   return bRet;
112 }
113 //=======================================================================
114 //function : Contains 
115 //purpose  : 
116 //=======================================================================
117   Standard_Boolean NMTDS_InterfPool::Contains(const Standard_Integer aInd1,
118                                               const Standard_Integer aInd2)const
119 {
120   NMTDS_PassKeyBoolean aPKB;
121   //
122   aPKB.SetIds(aInd1, aInd2);
123   return Contains(aPKB);
124 }
125 //=======================================================================
126 //function :  Get
127 //purpose  : 
128 //=======================================================================
129   const NMTDS_ListOfPassKeyBoolean& NMTDS_InterfPool::Get()const
130 {
131   Standard_Integer i;
132   NMTDS_ListOfPassKeyBoolean* pL;
133   //
134   pL=(NMTDS_ListOfPassKeyBoolean*)&myList;
135   pL->Clear();
136   //
137   for (i=0; i<myMaxInd; ++i) {
138     NMTDS_MapIteratorOfMapOfPassKeyBoolean aIt;
139     //
140     aIt.Initialize(myTable[i]);
141     for(; aIt.More(); aIt.Next()) {
142       const NMTDS_PassKeyBoolean& aPKB=aIt.Key();
143       pL->Append(aPKB);
144     }
145   }
146   return myList;
147 }
148 //=======================================================================
149 //function :  Get
150 //purpose  : 
151 //=======================================================================
152   const NMTDS_ListOfPassKeyBoolean& NMTDS_InterfPool::Get(const Standard_Integer aInd)const
153 {
154   Standard_Integer i, n1, n2;
155   NMTDS_ListOfPassKeyBoolean* pL;
156   //
157   pL=(NMTDS_ListOfPassKeyBoolean*)&myList;
158   pL->Clear();
159   //
160   for (i=0; i<myMaxInd; ++i) {
161     NMTDS_MapIteratorOfMapOfPassKeyBoolean aIt;
162     //
163     aIt.Initialize(myTable[i]);
164     for(; aIt.More(); aIt.Next()) {
165       const NMTDS_PassKeyBoolean& aPKB=aIt.Key();
166       aPKB.Ids(n1, n2);
167       if(n1==aInd || n2==aInd) {
168         pL->Append(aPKB);
169       }
170     }
171   }
172   return myList;
173 }
174 //=======================================================================
175 //function :  Get
176 //purpose  : 
177 //=======================================================================
178   const NMTDS_ListOfPassKeyBoolean& NMTDS_InterfPool::Get(const NMTDS_InterfType aType)const
179 {
180   Standard_Integer iType;
181   NMTDS_ListOfPassKeyBoolean* pL;
182   //
183   pL=(NMTDS_ListOfPassKeyBoolean*)&myList;
184   pL->Clear();
185   //
186   iType=TypeToInteger(aType);
187   if (iType>-1 && iType<myMaxInd) {
188     NMTDS_MapIteratorOfMapOfPassKeyBoolean aIt;
189     //
190     aIt.Initialize(myTable[iType]);
191     for(; aIt.More(); aIt.Next()) {
192       const NMTDS_PassKeyBoolean& aPKB=aIt.Key();
193       pL->Append(aPKB);
194     }
195   }
196   return myList;
197 }
198 //=======================================================================
199 //function :  Get
200 //purpose  : 
201 //=======================================================================
202   const NMTDS_ListOfPassKeyBoolean& NMTDS_InterfPool::Get(const Standard_Integer aInd,
203                                                           const NMTDS_InterfType aType)const
204 {
205   Standard_Integer n1, n2;
206   NMTDS_ListOfPassKeyBoolean *pL, aLPKB;
207   NMTDS_ListIteratorOfListOfPassKeyBoolean aIt;
208   //
209   aLPKB=Get(aType);
210   //
211   pL=(NMTDS_ListOfPassKeyBoolean*)&myList;
212   pL->Clear();
213   //
214   aIt.Initialize (aLPKB);
215   for (; aIt.More(); aIt.Next()) {
216     const NMTDS_PassKeyBoolean& aPKB=aIt.Value();
217     aPKB.Ids(n1, n2);
218     if(n1==aInd || n2==aInd) {
219       pL->Append(aPKB);
220     }
221   }
222   return myList;
223 }
224 ////////////////////
225 //===========================================================================
226 //function : SSInterferences
227 //purpose  : 
228 //===========================================================================
229   BOPTools_CArray1OfSSInterference&  NMTDS_InterfPool::SSInterferences()
230 {
231   return mySSInterferences;
232 }
233 //===========================================================================
234 //function : ESInterferences
235 //purpose  : 
236 //===========================================================================
237   BOPTools_CArray1OfESInterference&  NMTDS_InterfPool::ESInterferences()
238 {
239   return myESInterferences;
240 }
241 //===========================================================================
242 //function : VSInterferences
243 //purpose  : 
244 //===========================================================================
245   BOPTools_CArray1OfVSInterference&  NMTDS_InterfPool::VSInterferences()
246 {
247   return myVSInterferences;
248 }
249 //===========================================================================
250 //function : EEInterferences
251 //purpose  : 
252 //===========================================================================
253   BOPTools_CArray1OfEEInterference&  NMTDS_InterfPool::EEInterferences()
254 {
255   return myEEInterferences;
256 }
257 //===========================================================================
258 //function : VEInterferences
259 //purpose  : 
260 //===========================================================================
261   BOPTools_CArray1OfVEInterference&  NMTDS_InterfPool::VEInterferences()
262 {
263   return myVEInterferences;
264 }
265 //===========================================================================
266 //function : VVInterferences
267 //purpose  : 
268 //===========================================================================
269   BOPTools_CArray1OfVVInterference&  NMTDS_InterfPool::VVInterferences()
270 {
271   return myVVInterferences;
272 }
273 ////////////////////
274 //=======================================================================
275 //function : TypeToInteger
276 //purpose  : 
277 //=======================================================================
278 Standard_Integer TypeToInteger(const NMTDS_InterfType aType)
279 {
280   return (Standard_Integer)aType;
281 }