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