]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Field.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/med.git] / src / MEDMEM / MEDMEM_Field.cxx
1 //  MED MEDMEM : MED files in memory
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 //
24 //  File   : MEDMEM_Field.cxx
25 //  Module : MED
26
27 using namespace std;
28 #include "MEDMEM_Field.hxx"
29
30 // ---------------------------------
31 // FIELD_ : Constructors
32 // ---------------------------------
33 FIELD_::FIELD_(): 
34   _isRead(false),
35   _name(""), _description(""), _support((SUPPORT *)NULL),
36   _numberOfComponents(0), _numberOfValues(0),_componentsTypes((int *)NULL),
37   _componentsNames((string *)NULL), 
38   _componentsDescriptions((string *)NULL),
39   _componentsUnits((UNIT*)NULL),
40   _MEDComponentsUnits((string *)NULL),
41   _iterationNumber(-1),_time(0.0),_orderNumber(-1)
42 {
43   MESSAGE("Constructeur FIELD_ sans parametre");
44 }
45
46 FIELD_::FIELD_(const SUPPORT * Support, const int NumberOfComponents):
47   _isRead(false),
48   _name(""), _description(""), _support(Support),
49   _numberOfComponents(NumberOfComponents),
50   _iterationNumber(-1),_time(0.0),_orderNumber(-1)
51 {
52   MESSAGE("FIELD_(const SUPPORT * Support, const int NumberOfComponents)");
53
54   _numberOfValues = Support->getNumberOfElements(MED_ALL_ELEMENTS);
55   _componentsTypes = new int[NumberOfComponents] ;
56   _componentsNames = new string[NumberOfComponents];
57   _componentsDescriptions = new string[NumberOfComponents];
58   _componentsUnits = new UNIT[NumberOfComponents];
59   _MEDComponentsUnits = new string[NumberOfComponents];
60   for(int i=0;i<NumberOfComponents;i++) {
61     _componentsTypes[i] = 0 ;
62   }
63 }
64
65 FIELD_::FIELD_(const FIELD_ &m)
66 {
67   _isRead = m._isRead ;
68   _name = m._name;
69   _description = m._description;
70   _support = m._support;
71   _numberOfComponents = m._numberOfComponents;
72   _numberOfValues = m._numberOfValues;
73
74   if (m._componentsTypes != NULL)
75     {
76       _componentsTypes = new int[m._numberOfComponents] ;
77       memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents);
78       /*
79       _componentsTypes = new int[m._numberOfComponents] ;
80       for(int i=0;i<m._numberOfComponents;i++) {
81         _componentsTypes[i] = m._componentsTypes[i] ;
82       }
83       */
84     }
85   else _componentsTypes = (int *) NULL;
86
87   _componentsNames = new string[m._numberOfComponents];
88   for (int i=0; i<m._numberOfComponents; i++)
89     {_componentsNames[i]=m._componentsNames[i];}
90   _componentsDescriptions = new string[m._numberOfComponents];
91   for (int i=0; i<m._numberOfComponents; i++)
92     {_componentsDescriptions[i]=m._componentsDescriptions[i];}
93   _componentsUnits = new UNIT[m._numberOfComponents];
94   for (int i=0; i<m._numberOfComponents; i++)
95     {_componentsUnits[i] = m._componentsUnits[i];}
96   // L'operateur '=' est defini dans la classe UNIT
97   _MEDComponentsUnits = new string[m._numberOfComponents];
98   for (int i=0; i<m._numberOfComponents; i++)
99     {_MEDComponentsUnits[i] = m._MEDComponentsUnits[i];}
100   _iterationNumber = m._iterationNumber;
101   _time = m._time;
102   _orderNumber = m._orderNumber;
103   _valueType = m._valueType;
104   //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor !
105
106 }
107
108 FIELD_::~FIELD_()
109 {   
110   MESSAGE("~FIELD_()");
111   if ( _componentsTypes !=NULL)
112     delete[] _componentsTypes ;
113   if ( _componentsNames !=NULL)
114     delete[] _componentsNames ;
115   if ( _componentsDescriptions !=NULL)
116     delete[] _componentsDescriptions ;
117   if ( _componentsUnits !=NULL)
118     delete[] _componentsUnits ;
119   if ( _MEDComponentsUnits !=NULL)
120     delete[] _MEDComponentsUnits ;
121
122   // delete driver
123 //   vector<GENDRIVER *>::const_iterator it ;
124 //   SCRUTE(_drivers.size());
125 //   int i=0;
126 //   for (it=_drivers.begin();it!=_drivers.end();it++) {
127 //     i++;
128 //     SCRUTE(i);
129 //     delete (*it) ;
130
131
132   MESSAGE("In this object FIELD_ there is(are) " << _drivers.size() << " driver(s)");
133
134   for (int index=0; index < _drivers.size(); index++ )
135     {
136       SCRUTE(_drivers[index]);
137       if ( _drivers[index] != NULL) delete _drivers[index];
138     }
139 }
140
141 //  void     FIELD_::setIterationNumber (int IterationNumber)           {};
142 //  void     FIELD_::setOrderNumber     (int OrderNumber)               {}; 
143 //  void     FIELD_::setFieldName       (string& fieldName)             {}; 
144          
145 void     FIELD_::rmDriver      (int index)                            {};
146 int      FIELD_::addDriver     (driverTypes driverType, 
147                                 const string & fileName,
148                                 const string & driverFieldName)       {};
149 int      FIELD_::addDriver     (GENDRIVER & driver)                   {};
150 void     FIELD_::write         (const GENDRIVER &)                    {};
151 void     FIELD_::read          (const GENDRIVER &)                    {};
152 void     FIELD_::write         (int index, const string & driverName) {};
153 void     FIELD_::read          (int index)                                  {};
154
155 //  void                     FIELD_::setValueType(med_type_champ ValueType) {};
156 //  med_type_champ FIELD_::getValueType() {};