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