Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / CONVERTOR / VISU_ConvertorUtils.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //  File   : VISU_Convertor_impl.cxx
24 //  Author : Alexey PETROV
25 //  Module : VISU
26
27 #include "VISU_Convertor_impl.hxx"
28
29 #include <vtkCellType.h>
30
31 using namespace std;
32
33 #define MED2VTK(MEDTYPE,VTKTYPE,VTKNBNODES) \
34  {MEDTYPE,#MEDTYPE,getNbMedNodes(MEDTYPE),VTKTYPE,#VTKTYPE,VTKNBNODES}
35 Med2vtk med2vtk[MED_NBR_GEOMETRIE_MAILLE] = {
36   MED2VTK(MED_POINT1,VTK_VERTEX,1),
37   MED2VTK(MED_SEG2,VTK_LINE,2),
38   MED2VTK(MED_SEG3,VTK_LINE,2),
39   MED2VTK(MED_TRIA3,VTK_TRIANGLE,3),
40   MED2VTK(MED_TRIA6,VTK_TRIANGLE,3),
41   MED2VTK(MED_QUAD4,VTK_QUAD,4),
42   MED2VTK(MED_QUAD8,VTK_QUAD,4),
43   MED2VTK(MED_TETRA4,VTK_TETRA,4),
44   MED2VTK(MED_TETRA10,VTK_TETRA,4),
45   MED2VTK(MED_HEXA8,VTK_HEXAHEDRON,8),
46   MED2VTK(MED_HEXA20,VTK_HEXAHEDRON,8),
47   MED2VTK(MED_PENTA6,VTK_WEDGE,6),
48   MED2VTK(MED_PENTA15,VTK_WEDGE,6),
49   MED2VTK(MED_PYRA5,VTK_PYRAMID,5),
50   MED2VTK(MED_PYRA13,VTK_PYRAMID,5)
51 };
52 #undef MED2VTK
53
54 extern "C" {
55   int getNbMedConnect(int theMedType, int theMedEntity, int theMeshDim){
56     int anElemDim = theMedType / 100, nsup = 0;
57     if(theMedEntity == VISU::CELL_ENTITY && anElemDim < theMeshDim) nsup = 1;
58     return nsup + theMedType % 100;
59   }
60
61   int getNbMedNodes(int geom){ 
62     return geom % 100;
63   } 
64
65   int getIdMedType(int medType){
66     for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
67       if(med2vtk[i].medType == medType) return i;
68     return -1;
69   }
70
71   int med2vtkCellType(int medType){
72     for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
73       if(med2vtk[i].medType == medType) return med2vtk[i].vtkType;
74     return -1;
75   }
76   
77   int vtk2medCellType(int vtkType){
78     for(int i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++)
79       if(med2vtk[i].vtkType == vtkType) return med2vtk[i].medType;
80     return -1;
81   }
82 }