Salome HOME
DGTUMesh with no cells can be now converted into umesh
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingFieldInt.cxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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 // Author : Yann Pora (EDF R&D)
20
21 #include "MEDCouplingFieldInt.hxx"
22
23 using namespace MEDCoupling;
24
25 MEDCouplingFieldInt *MEDCouplingFieldInt::New(TypeOfField type, TypeOfTimeDiscretization td)
26 {
27   return new MEDCouplingFieldInt(type,td);
28 }
29
30 void MEDCouplingFieldInt::checkConsistencyLight() const
31 {
32   MEDCouplingField::checkConsistencyLight();
33   if(_array.isNull())
34     throw INTERP_KERNEL::Exception("MEDCouplingFieldInt::checkConsistencyLight : array is null !");
35   _type->checkCoherencyBetween(_mesh,getArray());
36 }
37
38 std::string MEDCouplingFieldInt::simpleRepr() const
39 {
40   return std::string();
41 }
42
43 void MEDCouplingFieldInt::reprQuickOverview(std::ostream& stream) const
44 {
45 }
46
47 void MEDCouplingFieldInt::setTimeUnit(const std::string& unit)
48 {
49   _time_discr->setTimeUnit(unit);
50 }
51
52 std::string MEDCouplingFieldInt::getTimeUnit() const
53 {
54   return _time_discr->getTimeUnit();
55 }
56
57 void MEDCouplingFieldInt::setTime(double val, int iteration, int order) 
58
59   _time_discr->setTime(val,iteration,order); 
60 }
61
62 double MEDCouplingFieldInt::getTime(int& iteration, int& order) const
63 {
64   return _time_discr->getTime(iteration,order);
65 }
66
67 void MEDCouplingFieldInt::setArray(DataArrayInt *array)
68 {
69   MCAuto<DataArrayInt> array2(array);
70   if(array2.isNotNull())
71     array2->incrRef();
72   _array=array2;
73   //_time_discr->setArray(array,this);
74 }
75
76 const DataArrayInt *MEDCouplingFieldInt::getArray() const
77 {
78   return _array;
79 }
80
81 DataArrayInt *MEDCouplingFieldInt::getArray()
82 {
83   return _array;
84 }
85
86 MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingField(type),_time_discr(MEDCouplingTimeDiscretization::New(td))
87 {
88 }
89
90 MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCopy):MEDCouplingField(other,deepCopy),_time_discr(other._time_discr->performCopyOrIncrRef(deepCopy))
91 {
92   if(other._array.isNull())
93     return ;
94   if(deepCopy)
95     {
96       _array=other._array->deepCopy();
97     }
98   else
99     {
100       _array=other._array;
101     }
102 }
103
104 MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type):MEDCouplingField(type,n),_time_discr(td)
105 {
106 }
107
108 MEDCouplingFieldInt::~MEDCouplingFieldInt()
109 {
110   delete _time_discr;
111 }