Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / INTERPOLATION / MEDMEM_WrapperConnectivity.hxx
1 //  Copyright (C) 2007-2008  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 #ifndef MEDMEM_WRAPPER_CONNECTIVITY_HXX
23 #define MEDMEM_WRAPPER_CONNECTIVITY_HXX
24
25 #include "MEDMEM_Connectivity.hxx"
26
27 #include <vector>
28
29 //////////////////////////////////////////////////////////////////
30 ///                                                            ///
31 ///                DECLARATIONS ET CODE                        ///
32 ///                                                            ///
33 //////////////////////////////////////////////////////////////////
34
35 /*********************************************************/
36 /*                                                       */
37 /*               Wrapper_Med_Connectivity                */
38 /*                                                       */
39 /*********************************************************/
40
41 // obligé de faire de la recopie car MED n'utilise pas la numérotation standart C
42
43 class Wrapper_Med_Connectivity
44 {
45 protected :
46         int * mailles;
47         int nbr_mailles;
48         vector<int> types;
49         vector< int* > premier_pointeur;
50         
51 public :        
52         ~Wrapper_Med_Connectivity() {if (mailles) delete [] mailles;}
53         Wrapper_Med_Connectivity():mailles(NULL) {}
54         Wrapper_Med_Connectivity(MEDMEM::CONNECTIVITY * maillesmed)
55                 {
56                 const int * tab_sommets_mailles=maillesmed->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
57                 const int * med_index=maillesmed->getValueIndex(MED_EN::MED_FULL_INTERLACE);
58                 nbr_mailles=maillesmed->getNumberOf(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS);
59                 int size=med_index[nbr_mailles]-med_index[0];
60                 types.resize(nbr_mailles);
61                 premier_pointeur.resize(nbr_mailles);
62                 mailles=new int[size];
63                 int i;
64                 for (i=0;i<size;i++) 
65                         {
66                         mailles[i]=tab_sommets_mailles[i]-1;
67                         }
68                 for (i=0;i<nbr_mailles;i++)
69                         {
70                         types[i]=maillesmed->getElementType(MED_EN::MED_CELL,i+1); // A VERIFIER : le +1
71                         premier_pointeur[i]=&mailles[med_index[i]-1]; // A VERIFIER : la formule
72                         }
73                 }
74         // Méthodes de la politique
75         inline int SIZE() {return nbr_mailles;}
76         inline int DONNE_TYPE_MAILLE(int i) {return types[i];}
77         inline int * DONNE_PREMIER_POINTEUR(int i) {return premier_pointeur[i];}
78 };
79
80
81 #endif