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