Salome HOME
Merge from V6_main 01/04/2013
[modules/med.git] / src / MEDWrapper / Base / MED_Structures.cxx
1 // Copyright (C) 2007-2013  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
23 //  File   : MED_Structure.cxx
24 //  Author : Eugeny NIKOLAEV
25 //  Module : MED
26 //
27 #include "MED_Structures.hxx"
28 #include "MED_Utilities.hxx"
29
30 #include <cstring>
31
32 using namespace MED;
33
34 namespace MED
35 {
36   TInt
37   GetNbNodes(EGeometrieElement typmai)
38   {
39     return typmai%100;
40   }
41
42   std::string 
43   GetString(TInt theId, 
44             TInt theStep, 
45             const TString& theString)
46   {
47     const char* aPos = &theString[theId*theStep];
48     TInt aSize = std::min(TInt(strlen(aPos)),theStep);
49     return std::string(aPos,aSize);
50   }
51
52   void 
53   SetString(TInt theId, 
54             TInt theStep, 
55             TString& theString, 
56             const std::string& theValue)
57   {
58     TInt aSize = std::min(TInt(theValue.size()+1),theStep);
59     char* aPos = &theString[theId*theStep];
60     strncpy(aPos,theValue.c_str(),aSize);
61   }
62
63   void 
64   SetString(TInt theId, 
65             TInt theStep, 
66             TString& theString, 
67             const TString& theValue)
68   {
69     TInt aSize = std::min(TInt(theValue.size()+1),theStep);
70     char* aPos = &theString[theId*theStep];
71     const char* aValue = &theValue[0];
72     strncpy(aPos,aValue,aSize);
73   }
74
75   TInt
76   GetDimGaussCoord(EGeometrieElement theGeom)
77   {
78     return theGeom/100;
79   }
80
81   TInt
82   GetNbRefCoord(EGeometrieElement theGeom)
83   {
84     return (theGeom%100);
85   }
86
87   //---------------------------------------------------------------
88   PFloatTimeStampValue
89   CastToFloatTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
90   {
91     return theTimeStampValue;
92   }
93
94   PIntTimeStampValue
95   CastToIntTimeStampValue(const PTimeStampValueBase& theTimeStampValue)
96   {
97     return theTimeStampValue;
98   }
99 }
100
101 //---------------------------------------------------------------
102 TInt
103 TFamilyInfo
104 ::GetAttrId(TInt theId) const 
105 {
106   return myAttrId[theId];
107 }
108
109 TInt
110 TFamilyInfo
111 ::GetAttrVal(TInt theId) const 
112 {
113   return myAttrVal[theId];
114 }
115
116 void
117 TFamilyInfo
118 ::SetAttrId(TInt theId,TInt theVal) 
119 {
120   myAttrId[theId] = theVal;
121 }
122
123 void
124 TFamilyInfo
125 ::SetAttrVal(TInt theId,TInt theVal) 
126 {
127   myAttrVal[theId] = theVal;
128 }
129
130 //---------------------------------------------------------------
131 TInt
132 TElemInfo
133 ::GetFamNum(TInt theId) const 
134 {
135   return (*myFamNum)[theId];
136 }
137
138 void
139 TElemInfo
140 ::SetFamNum(TInt theId, TInt theVal) 
141 {
142   (*myFamNum)[theId] = theVal;
143   myIsFamNum = eVRAI;
144 }
145
146 TInt
147 TElemInfo
148 ::GetElemNum(TInt theId) const 
149 {
150   return (*myElemNum)[theId];
151 }
152
153 void
154 TElemInfo
155 ::SetElemNum(TInt theId, TInt theVal) 
156 {
157   (*myElemNum)[theId] = theVal;
158 }
159
160 //---------------------------------------------------------------
161 TCCoordSlice 
162 TNodeInfo
163 ::GetCoordSlice(TInt theId) const
164 {
165   TInt aDim = myMeshInfo->GetSpaceDim();
166   if(GetModeSwitch() == eFULL_INTERLACE)
167     return TCCoordSlice(*myCoord, std::slice(theId*aDim, aDim, 1));
168   else
169     return TCCoordSlice(*myCoord, std::slice(theId, aDim, aDim));
170 }
171
172 TCoordSlice 
173 TNodeInfo
174 ::GetCoordSlice(TInt theId)
175 {
176   TInt aDim = myMeshInfo->GetSpaceDim();
177   if(GetModeSwitch() == eFULL_INTERLACE)
178     return TCoordSlice(*myCoord, std::slice(theId*aDim,aDim,1));
179   else
180     return TCoordSlice(*myCoord, std::slice(theId,aDim,aDim));
181 }
182
183 //---------------------------------------------------------------
184 TCConnSlice 
185 TCellInfo
186 ::GetConnSlice(TInt theElemId) const
187 {
188   if(GetModeSwitch() == eFULL_INTERLACE)
189     return TCConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
190   else
191     return TCConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
192 }
193
194 TConnSlice 
195 TCellInfo
196 ::GetConnSlice(TInt theElemId)
197 {
198   if(GetModeSwitch() == eFULL_INTERLACE)
199     return TConnSlice(*myConn, std::slice(GetConnDim()*theElemId, GetNbNodes(myGeom), 1));
200   else
201     return TConnSlice(*myConn, std::slice(theElemId, GetNbNodes(myGeom), GetConnDim()));
202 }
203
204
205 //---------------------------------------------------------------
206 TInt
207 TPolygoneInfo
208 ::GetNbConn(TInt theElemId) const 
209 {
210   return (*myIndex)[theElemId + 1] - (*myIndex)[theElemId];
211 }
212
213 TCConnSlice 
214 TPolygoneInfo
215 ::GetConnSlice(TInt theElemId) const
216 {
217   return TCConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
218 }
219
220 TConnSlice 
221 TPolygoneInfo
222 ::GetConnSlice(TInt theElemId)
223 {
224   return TConnSlice(*myConn, std::slice((*myIndex)[theElemId] - 1, GetNbConn(theElemId), 1));
225 }
226
227
228 //---------------------------------------------------------------
229 TInt 
230 TPolyedreInfo
231 ::GetNbFaces(TInt theElemId) const 
232 {
233   return (*myIndex)[theElemId+1] - (*myIndex)[theElemId];
234 }
235
236 TInt 
237 TPolyedreInfo
238 ::GetNbNodes(TInt theElemId) const 
239 {
240   TInt aNbNodes = 0;
241   TInt aNbFaces = GetNbFaces(theElemId);
242   TInt aStartFaceId = (*myIndex)[theElemId] - 1;
243   for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
244     TInt aCurrentId = (*myFaces)[aStartFaceId];
245     TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
246     aNbNodes += aDiff;
247   }
248   return aNbNodes;
249 }
250
251 TCConnSliceArr 
252 TPolyedreInfo
253 ::GetConnSliceArr(TInt theElemId) const
254 {
255   TInt aNbFaces = GetNbFaces(theElemId);
256   TCConnSliceArr aConnSliceArr(aNbFaces);
257   TInt aStartFaceId = (*myIndex)[theElemId] - 1;
258   for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
259     TInt aCurrentId = (*myFaces)[aStartFaceId];
260     TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
261     aConnSliceArr[aFaceId] =
262       TCConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
263   }
264   return aConnSliceArr;
265 }
266
267 TConnSliceArr 
268 TPolyedreInfo
269 ::GetConnSliceArr(TInt theElemId)
270 {
271   TInt aNbFaces = GetNbFaces(theElemId);
272   TConnSliceArr aConnSliceArr(aNbFaces);
273   TInt aStartFaceId = (*myIndex)[theElemId] - 1;
274   for(TInt aFaceId = 0; aFaceId < aNbFaces; aFaceId++, aStartFaceId++){
275     TInt aCurrentId = (*myFaces)[aStartFaceId];
276     TInt aDiff = (*myFaces)[aStartFaceId + 1] - aCurrentId;
277     aConnSliceArr[aFaceId] =
278       TConnSlice(*myConn, std::slice(aCurrentId - 1, aDiff, 1));
279   }
280   return aConnSliceArr;
281 }
282
283
284 //---------------------------------------------------------------
285 TMeshValueBase
286 ::TMeshValueBase():
287   myNbElem(0),
288   myNbComp(0),
289   myNbGauss(0),
290   myStep(0)
291 {}
292
293 void
294 TMeshValueBase
295 ::Allocate(TInt theNbElem,
296            TInt theNbGauss,
297            TInt theNbComp,
298            EModeSwitch theMode)
299 {
300   myModeSwitch = theMode;
301   
302   myNbElem = theNbElem;
303   myNbGauss = theNbGauss;
304   myNbComp = theNbComp;
305   
306   myStep = theNbComp*theNbGauss;
307 }
308
309 size_t
310 TMeshValueBase
311 ::GetSize() const
312 {
313   return myNbElem * myStep;
314 }
315     
316 size_t
317 TMeshValueBase
318 ::GetNbVal() const
319 {
320   return myNbElem * myNbGauss;
321 }
322
323 size_t
324 TMeshValueBase
325 ::GetNbGauss() const
326 {
327   return myNbGauss;
328 }
329
330 size_t
331 TMeshValueBase
332 ::GetStep() const
333 {
334   return myStep;
335 }
336
337
338 //---------------------------------------------------------------
339 TInt
340 TProfileInfo
341 ::GetElemNum(TInt theId) const 
342 {
343   return (*myElemNum)[theId];
344 }
345
346 void
347 TProfileInfo
348 ::SetElemNum(TInt theId,TInt theVal) 
349 {
350   (*myElemNum)[theId] = theVal;
351 }
352
353 //---------------------------------------------------------------
354 bool
355 TGaussInfo::TLess
356 ::operator()(const TKey& theLeft, const TKey& theRight) const
357 {
358   EGeometrieElement aLGeom = boost::get<0>(theLeft);
359   EGeometrieElement aRGeom = boost::get<0>(theRight);
360   if(aLGeom != aRGeom)
361     return aLGeom < aRGeom;
362
363   const std::string& aLStr = boost::get<1>(theLeft);
364   const std::string& aRStr = boost::get<1>(theRight);
365   return aLStr < aRStr;
366 }
367
368 bool
369 TGaussInfo::TLess
370 ::operator()(const TGaussInfo& theLeft, const TGaussInfo& theRight) const
371 {
372   if(!&theLeft)
373     return true;
374
375   if(!&theRight)
376     return false;
377
378   if(theLeft.myGeom != theRight.myGeom)
379     return theLeft.myGeom < theRight.myGeom;
380
381   if(theLeft.myRefCoord != theRight.myRefCoord)
382     return theLeft.myRefCoord < theRight.myRefCoord;
383
384   return theLeft.myGaussCoord < theRight.myGaussCoord;
385 }
386
387 TCCoordSlice 
388 TGaussInfo
389 ::GetRefCoordSlice(TInt theId) const
390 {
391   if(GetModeSwitch() == eFULL_INTERLACE)
392     return TCCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
393   else
394     return TCCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
395 }
396
397 TCoordSlice 
398 TGaussInfo
399 ::GetRefCoordSlice(TInt theId)
400 {
401   if(GetModeSwitch() == eFULL_INTERLACE)
402     return TCoordSlice(myRefCoord,std::slice(theId*GetDim(),GetDim(),1));
403   else
404     return TCoordSlice(myRefCoord,std::slice(theId,GetDim(),GetDim()));
405 }
406
407 TCCoordSlice 
408 TGaussInfo
409 ::GetGaussCoordSlice(TInt theId) const
410 {
411   if(GetModeSwitch() == eFULL_INTERLACE)
412     return TCCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetDim(),1));
413   else
414     return TCCoordSlice(myGaussCoord,std::slice(theId,GetDim(),GetDim()));
415 }
416
417 TCoordSlice 
418 TGaussInfo
419 ::GetGaussCoordSlice(TInt theId)
420 {
421   if(GetModeSwitch() == eFULL_INTERLACE)
422     return TCoordSlice(myGaussCoord,std::slice(theId*GetDim(),GetNbGauss(),1));
423   else
424     return TCoordSlice(myGaussCoord,std::slice(theId,GetNbGauss(),GetDim()));
425 }
426
427
428 //---------------------------------------------------------------
429 TInt
430 TTimeStampInfo
431 ::GetNbGauss(EGeometrieElement theGeom) const
432 {
433   TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
434   if(anIter == myGeom2NbGauss.end())
435     return 1;//EXCEPTION(runtime_error,"TTimeStampInfo::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
436
437   return anIter->second;
438 }
439
440
441 //---------------------------------------------------------------
442 // TGrilleInfo structure methods
443 //---------------------------------------------------------------
444 const EGrilleType&
445 TGrilleInfo
446 ::GetGrilleType() const
447 {
448   return myGrilleType;
449 }
450
451 EGrilleType
452 TGrilleInfo
453 ::GetGrilleType()
454 {
455   return myGrilleType;
456 }
457
458 void
459 TGrilleInfo
460 ::SetGrilleType(EGrilleType theGrilleType)
461 {
462   myGrilleType = theGrilleType;
463 }
464
465 const
466 TIndexes&
467 TGrilleInfo
468 ::GetMapOfIndexes() const
469 {
470   return myIndixes;
471 }
472
473 TIndexes&
474 TGrilleInfo
475 ::GetMapOfIndexes()
476 {
477   return myIndixes;
478 }
479
480 const
481 TFloatVector&
482 TGrilleInfo
483 ::GetIndexes(TInt theAxisNumber) const
484 {
485   TIndexes::const_iterator aIter=myIndixes.find(theAxisNumber);
486   if(aIter==myIndixes.end())
487     EXCEPTION(std::runtime_error, "const TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber); fails");
488   return aIter->second;
489 }
490
491 TFloatVector&
492 TGrilleInfo
493 ::GetIndexes(TInt theAxisNumber)
494 {
495   TIndexes::iterator aIter=myIndixes.find(theAxisNumber);
496   if(aIter==myIndixes.end())
497     EXCEPTION(std::runtime_error, "TGrilleInfo::GetIndexes - myIndixes.find(theAxisNumber="<<theAxisNumber<<"); fails");
498   return aIter->second;
499 }
500
501 TInt
502 TGrilleInfo
503 ::GetNbIndexes(TInt theAxisNumber)
504 {
505   const TFloatVector& aVector=GetIndexes(theAxisNumber);
506   return aVector.size();
507 }
508
509 TInt
510 TGrilleInfo
511 ::GetNbNodes()
512 {
513   TInt nbNodes=0;
514   TInt aDim = myMeshInfo->GetDim();
515   for(int i=0;i<aDim;i++)
516     if(nbNodes == 0)
517       nbNodes = this->GetGrilleStructure()[i];
518     else
519       nbNodes = nbNodes*this->GetGrilleStructure()[i];
520  
521   return nbNodes;
522 }
523
524 TInt
525 TGrilleInfo
526 ::GetNbCells()
527 {
528   TInt nbCells=0;
529   TInt aDim = myMeshInfo->GetDim();
530   for(int i=0;i<aDim;i++)
531     if(nbCells == 0)
532       nbCells = this->GetGrilleStructure()[i]-1;
533     else
534       nbCells = nbCells*(this->GetGrilleStructure()[i]-1);
535   return nbCells;
536 }
537
538 TInt
539 TGrilleInfo
540 ::GetNbSubCells()
541 {
542   TInt nb=0;
543   TInt aDim = myMeshInfo->GetDim();
544   switch (aDim) {
545   case 3:
546     nb =
547       (myGrilleStructure[0]  ) * (myGrilleStructure[1]-1) * (myGrilleStructure[2]-1) +
548       (myGrilleStructure[0]-1) * (myGrilleStructure[1]  ) * (myGrilleStructure[2]-1) +
549       (myGrilleStructure[0]-1) * (myGrilleStructure[1]-1) * (myGrilleStructure[2]  );
550     break;
551   case 2:
552     nb =
553       (myGrilleStructure[0]  ) * (myGrilleStructure[1]-1) +
554       (myGrilleStructure[0]-1) * (myGrilleStructure[1]  );
555     break;
556   }
557   return nb;
558 }
559
560 EGeometrieElement
561 TGrilleInfo
562 ::GetGeom()
563 {
564   TInt aDim = myMeshInfo->GetDim();
565   switch(aDim){
566   case 1:
567     return eSEG2;
568   case 2:
569     return eQUAD4;
570   case 3:
571     return eHEXA8;
572   default:
573     return eNONE;
574   }
575 }
576
577 EGeometrieElement
578 TGrilleInfo
579 ::GetSubGeom()
580 {
581   TInt aDim = myMeshInfo->GetDim();
582   switch(aDim){
583   case 2:
584     return eSEG2;
585   case 3:
586     return eQUAD4;
587   }
588   return eNONE;
589 }
590
591 EEntiteMaillage
592 TGrilleInfo
593 ::GetEntity()
594 {
595   return eMAILLE;
596 }
597
598 EEntiteMaillage
599 TGrilleInfo
600 ::GetSubEntity()
601 {
602   TInt aDim = myMeshInfo->GetDim();
603   switch(aDim){
604   case 2:
605     return eARETE;
606   case 3:
607     return eFACE;
608   }
609   return EEntiteMaillage(-1);
610 }
611
612 const
613 TIntVector&
614 TGrilleInfo
615 ::GetGrilleStructure() const
616 {
617   return myGrilleStructure;
618 }
619
620 TIntVector
621 TGrilleInfo
622 ::GetGrilleStructure()
623 {
624   return myGrilleStructure;
625 }
626
627 void
628 TGrilleInfo
629 ::SetGrilleStructure(TInt theAxis,TInt theNb)
630 {
631   if(theAxis >= 0 && theAxis <=2 && theNb >= 0)
632   myGrilleStructure[theAxis]=theNb;
633 }
634
635 const
636 TNodeCoord&
637 TGrilleInfo
638 ::GetNodeCoord() const
639 {
640   return myCoord;
641 }
642
643 TNodeCoord&
644 TGrilleInfo
645 ::GetNodeCoord()
646 {
647   return myCoord;
648 }
649
650 TNodeCoord
651 TGrilleInfo
652 ::GetCoord(TInt theId)
653 {
654   TNodeCoord aCoord;
655   TInt aDim       = myMeshInfo->GetDim();
656   TInt aNbNodes   = this->GetNbNodes();
657   aCoord.resize(aDim);
658   
659   if(theId >= aNbNodes)
660     EXCEPTION(std::runtime_error, "TGrilleInfo::GetCoord - theId out of range");
661
662   if(myGrilleType == eGRILLE_STANDARD){
663     switch(aDim){
664     case 3:
665       aCoord[2] = myCoord[aDim*theId+2];
666     case 2:
667       aCoord[1] = myCoord[aDim*theId+1];
668     case 1:{
669       aCoord[0] = myCoord[aDim*theId];
670       break;
671     }
672     }
673   } else {
674
675     TFloatVector aVecX  = this->GetIndexes(0);
676     TInt nbIndxX        = this->GetNbIndexes(0);
677     
678     switch(aDim){
679     case 1:{
680       aCoord[0] = aVecX[theId];
681       break;
682     }
683     case 2:{
684       TFloatVector aVecY = this->GetIndexes(1);
685       TInt i,j,k;
686       i = j = k = 0;
687       i = theId % nbIndxX;
688       j = theId / nbIndxX;
689       if(myGrilleType == eGRILLE_CARTESIENNE){
690         aCoord[0] = aVecX[i];
691         aCoord[1] = aVecY[j];
692       } else { // eGRILLE_POLAIRE (cylindrical)
693         aCoord[0] = aVecX[i] * cos(aVecY[j]);
694         aCoord[1] = aVecX[i] * sin(aVecY[j]);
695       }
696       break;
697     }
698     case 3:{
699       TFloatVector aVecY = this->GetIndexes(1);
700       TInt nbIndxY       = this->GetNbIndexes(1);
701       TFloatVector aVecZ = this->GetIndexes(2);
702       TInt i,j,k;
703       i = j = k = 0;
704       
705       i = theId % nbIndxX;
706       j = (theId / nbIndxX) % nbIndxY;
707       k = theId / (nbIndxX*nbIndxY);
708
709       if(myGrilleType == eGRILLE_CARTESIENNE){
710         aCoord[0] = aVecX[i];
711         aCoord[1] = aVecY[j];
712         aCoord[2] = aVecZ[k];
713       } else { // eGRILLE_POLAIRE (cylindrical)
714         aCoord[0] = aVecX[i] * cos(aVecY[j]);
715         aCoord[1] = aVecX[i] * sin(aVecY[j]);
716         aCoord[2] = aVecZ[k];
717       }
718       
719       break;
720     }
721     }
722   }
723
724   return aCoord;
725 }
726
727 TIntVector
728 TGrilleInfo
729 ::GetConn(TInt theId, const bool isSub)
730 {
731   TIntVector anIndexes;
732   TInt aDim = myMeshInfo->GetDim();
733
734   TInt idx;
735   TInt iMin, jMin, kMin, iMax, jMax, kMax;
736   TInt loc[3];
737
738   loc[0] = loc[1] = loc[2] = 0;
739   iMin = iMax = jMin = jMax = kMin = kMax = 0;
740
741   switch(aDim) {
742   case 3:
743     {
744       TInt nbX = this->GetGrilleStructure()[0];
745       TInt nbY = this->GetGrilleStructure()[1];
746       TInt nbZ = this->GetGrilleStructure()[2];
747       TInt d01 = nbX*nbY, dX = 1, dY = 1, dZ = 1;
748       if ( isSub )
749       {
750         if ( theId < nbX * (nbY-1) * (nbZ-1))
751         { // face is normal to X axis
752           dX = 0;
753         }
754         else if ( theId < nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1))
755         {  // face is normal to Y axis
756           theId -= nbX * (nbY-1) * (nbZ-1);
757           dY = 0;
758         }
759         else
760         {
761           theId -= nbX * (nbY-1) * (nbZ-1) + (nbX-1) * nbY * (nbZ-1);
762           dZ = 0;
763         }
764       }
765       //else
766       {
767         iMin = theId % (nbX - dX);
768         jMin = (theId / (nbX - dX)) % (nbY - dY);
769         kMin = theId / ((nbX - dX) * (nbY - dY));
770         iMax = iMin+dX;
771         jMax = jMin+dY;
772         kMax = kMin+dZ;
773       }
774       for (loc[2]=kMin; loc[2]<=kMax; loc[2]++)
775         for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
776           for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
777           {
778             idx = loc[0] + loc[1]*nbX + loc[2]*d01;
779             anIndexes.push_back(idx);
780           }
781       break;
782     }
783   case 2:
784     {
785       TInt nbX = this->GetGrilleStructure()[0];
786       TInt nbY = this->GetGrilleStructure()[1];
787       TInt dX = 1, dY = 1;
788       if ( isSub )
789       {
790         if ( theId < nbX * (nbY-1))
791         { // edge is normal to X axis
792           dX = 0;
793         }
794         else
795         {
796           theId -= nbX * (nbY-1);
797           dY = 0;
798         }
799       }
800       iMin = theId % (nbX-dX);
801       jMin = theId / (nbX-dX);
802       iMax = iMin+dX;
803       jMax = jMin+dY;
804       for (loc[1]=jMin; loc[1]<=jMax; loc[1]++)
805         for (loc[0]=iMin; loc[0]<=iMax; loc[0]++)
806         {
807           idx = loc[0] + loc[1]*nbX;
808           anIndexes.push_back(idx);
809         }
810       break;
811     }
812   case 1:
813     {
814       iMin = theId;
815       for (loc[0]=iMin; loc[0]<=iMin+1; loc[0]++)
816       {
817         idx = loc[0];
818         anIndexes.push_back(idx);
819       }
820       break;
821     }
822   }
823
824   return anIndexes;
825 }
826
827 TInt
828 TGrilleInfo
829 ::GetFamNumNode(TInt theId) const 
830 {
831   return myFamNumNode[theId];
832 }
833
834 void
835 TGrilleInfo
836 ::SetFamNumNode(TInt theId,TInt theVal) 
837 {
838   myFamNumNode[theId] = theVal;
839 }
840
841 TInt
842 TGrilleInfo
843 ::GetFamNum(TInt theId) const 
844 {
845   return myFamNum[theId];
846 }
847
848 void
849 TGrilleInfo
850 ::SetFamNum(TInt theId,TInt theVal) 
851 {
852   myFamNum[theId] = theVal;
853 }
854
855 TInt
856 TGrilleInfo
857 ::GetFamSubNum(TInt theId) const 
858 {
859   return myFamSubNum[theId];
860 }
861
862 void
863 TGrilleInfo
864 ::SetFamSubNum(TInt theId,TInt theVal) 
865 {
866   myFamSubNum[theId] = theVal;
867 }