Salome HOME
0021672: [CEA 565] Dump Study from script
[modules/geom.git] / src / NMTDS / NMTDS_InterfPool.cxx
1 // Copyright (C) 2007-2012  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_InterfPool.cxx
21 // Author:      Peter KURNEV
22
23 #include <NMTDS_InterfPool.hxx>
24
25 #include <NMTDS_PairBoolean.hxx>
26 #include <NMTDS_ListOfPairBoolean.hxx>
27 #include <NMTDS_MapIteratorOfMapOfPairBoolean.hxx>
28 #include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>
29
30 #include <Basics_OCCTVersion.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_PairBoolean& 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_PairBoolean 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_PairBoolean 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_PairBoolean& 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_PairBoolean aPKB;
121   //
122   aPKB.SetIds(aInd1, aInd2);
123   return Contains(aPKB);
124 }
125 //=======================================================================
126 //function :  Get
127 //purpose  : 
128 //=======================================================================
129 const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get()const
130 {
131   Standard_Integer i;
132   NMTDS_ListOfPairBoolean* pL;
133   //
134   pL=(NMTDS_ListOfPairBoolean*)&myList;
135   pL->Clear();
136   //
137   for (i=0; i<myMaxInd; ++i) {
138     NMTDS_MapIteratorOfMapOfPairBoolean aIt;
139     //
140     aIt.Initialize(myTable[i]);
141     for(; aIt.More(); aIt.Next()) {
142       const NMTDS_PairBoolean& aPKB=aIt.Key();
143       pL->Append(aPKB);
144     }
145   }
146   return myList;
147 }
148 //=======================================================================
149 //function :  Get
150 //purpose  : 
151 //=======================================================================
152 const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get
153   (const Standard_Integer aInd)const
154 {
155   Standard_Integer i, n1, n2;
156   NMTDS_ListOfPairBoolean* pL;
157   //
158   pL=(NMTDS_ListOfPairBoolean*)&myList;
159   pL->Clear();
160   //
161   for (i=0; i<myMaxInd; ++i) {
162     NMTDS_MapIteratorOfMapOfPairBoolean aIt;
163     //
164     aIt.Initialize(myTable[i]);
165     for(; aIt.More(); aIt.Next()) {
166       const NMTDS_PairBoolean& 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_ListOfPairBoolean& NMTDS_InterfPool::Get
180   (const NMTDS_InterfType aType)const
181 {
182   Standard_Integer iType;
183   NMTDS_ListOfPairBoolean* pL;
184   //
185   pL=(NMTDS_ListOfPairBoolean*)&myList;
186   pL->Clear();
187   //
188   iType=TypeToInteger(aType);
189   if (iType>-1 && iType<myMaxInd) {
190     NMTDS_MapIteratorOfMapOfPairBoolean aIt;
191     //
192     aIt.Initialize(myTable[iType]);
193     for(; aIt.More(); aIt.Next()) {
194       const NMTDS_PairBoolean& aPKB=aIt.Key();
195       pL->Append(aPKB);
196     }
197   }
198   return myList;
199 }
200 //=======================================================================
201 //function :  Get
202 //purpose  : 
203 //=======================================================================
204 const NMTDS_ListOfPairBoolean& NMTDS_InterfPool::Get
205   (const Standard_Integer aInd,
206    const NMTDS_InterfType aType)const
207 {
208   Standard_Integer n1, n2;
209   NMTDS_ListOfPairBoolean *pL, aLPKB;
210   NMTDS_ListIteratorOfListOfPairBoolean aIt;
211   //
212   aLPKB=Get(aType);
213   //
214   pL=(NMTDS_ListOfPairBoolean*)&myList;
215   pL->Clear();
216   //
217   aIt.Initialize (aLPKB);
218   for (; aIt.More(); aIt.Next()) {
219     const NMTDS_PairBoolean& aPKB=aIt.Value();
220     aPKB.Ids(n1, n2);
221     if(n1==aInd || n2==aInd) {
222       pL->Append(aPKB);
223     }
224   }
225   return myList;
226 }
227 ////////////////////
228 //===========================================================================
229 //function : SSInterferences
230 //purpose  : 
231 //===========================================================================
232 BOPTools_CArray1OfSSInterference&  NMTDS_InterfPool::SSInterferences()
233 {
234   return mySSInterferences;
235 }
236 //===========================================================================
237 //function : ESInterferences
238 //purpose  : 
239 //===========================================================================
240 BOPTools_CArray1OfESInterference&  NMTDS_InterfPool::ESInterferences()
241 {
242   return myESInterferences;
243 }
244 //===========================================================================
245 //function : VSInterferences
246 //purpose  : 
247 //===========================================================================
248 BOPTools_CArray1OfVSInterference&  NMTDS_InterfPool::VSInterferences()
249 {
250   return myVSInterferences;
251 }
252 //===========================================================================
253 //function : EEInterferences
254 //purpose  : 
255 //===========================================================================
256 BOPTools_CArray1OfEEInterference&  NMTDS_InterfPool::EEInterferences()
257 {
258   return myEEInterferences;
259 }
260 //===========================================================================
261 //function : VEInterferences
262 //purpose  : 
263 //===========================================================================
264 BOPTools_CArray1OfVEInterference&  NMTDS_InterfPool::VEInterferences()
265 {
266   return myVEInterferences;
267 }
268 //===========================================================================
269 //function : VVInterferences
270 //purpose  : 
271 //===========================================================================
272 BOPTools_CArray1OfVVInterference&  NMTDS_InterfPool::VVInterferences()
273 {
274   return myVVInterferences;
275 }
276
277 //modified by NIZNHY-PKV Mon Dec 12 09:07:54 2011f
278 //=======================================================================
279 //function : Purge
280 //purpose  : 
281 //=======================================================================
282 void NMTDS_InterfPool::Purge()
283 {
284 #if OCC_VERSION_LARGE > 0x06050200
285   myVVInterferences.Purge();
286   myVEInterferences.Purge();
287   myEEInterferences.Purge();
288   myVSInterferences.Purge();
289   myESInterferences.Purge();
290   mySSInterferences.Purge();
291 #endif
292 }
293 //modified by NIZNHY-PKV Mon Dec 12 09:07:58 2011t
294
295 //=======================================================================
296 //function : TypeToInteger
297 //purpose  : 
298 //=======================================================================
299 Standard_Integer TypeToInteger(const NMTDS_InterfType aType)
300 {
301   return (Standard_Integer)aType;
302 }