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