Salome HOME
adding a new test for makeMesh method.
[modules/med.git] / src / MEDCoupling / MemArray.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "MemArray.txx"
20
21 using namespace ParaMEDMEM;
22
23 void DataArray::setName(const char *name)
24 {
25   _name=name;
26 }
27
28 DataArrayDouble *DataArrayDouble::New()
29 {
30   return new DataArrayDouble;
31 }
32
33 void DataArrayDouble::alloc(int nbOfTuple, int nbOfCompo)
34 {
35   _nb_of_tuples=nbOfTuple;
36   _info_on_compo.resize(nbOfCompo);
37   _mem.alloc(nbOfCompo*_nb_of_tuples);
38   declareAsNew();
39 }
40
41 void DataArrayDouble::reAlloc(int nbOfTuples)
42 {
43   _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
44   _nb_of_tuples=nbOfTuples;
45   declareAsNew();
46 }
47
48 void DataArrayDouble::useArray(double *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
49 {
50   _nb_of_tuples=nbOfTuple;
51   _info_on_compo.resize(nbOfCompo);
52   _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
53   declareAsNew();
54 }
55
56 DataArrayInt *DataArrayInt::New()
57 {
58   return new DataArrayInt;
59 }
60
61 void DataArrayInt::alloc(int nbOfTuple, int nbOfCompo)
62 {
63   _nb_of_tuples=nbOfTuple;
64   _info_on_compo.resize(nbOfCompo);
65   _mem.alloc(nbOfCompo*_nb_of_tuples);
66   declareAsNew();
67 }
68
69 void DataArrayInt::useArray(int *array, bool ownership,  DeallocType type, int nbOfTuple, int nbOfCompo)
70 {
71   _nb_of_tuples=nbOfTuple;
72   _info_on_compo.resize(nbOfCompo);
73   _mem.useArray(array,ownership,type,nbOfTuple*nbOfCompo);
74   declareAsNew();
75 }
76
77 void DataArrayInt::reAlloc(int nbOfTuples)
78 {
79   _mem.reAlloc(_info_on_compo.size()*nbOfTuples);
80   _nb_of_tuples=nbOfTuples;
81   declareAsNew();
82 }