Salome HOME
Update copyrights
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingFieldInt.cxx
1 // Copyright (C) 2007-2019  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 #include "MEDCouplingFieldT.txx"
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MEDCouplingFieldTemplate.hxx"
25 #include "MEDCouplingMesh.hxx"
26
27 using namespace MEDCoupling;
28
29 template class MEDCoupling::MEDCouplingFieldT<int>;
30
31 MEDCouplingFieldInt *MEDCouplingFieldInt::New(TypeOfField type, TypeOfTimeDiscretization td)
32 {
33   return new MEDCouplingFieldInt(type,td);
34 }
35
36 MEDCouplingFieldInt *MEDCouplingFieldInt::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
37 {
38   return new MEDCouplingFieldInt(ft,td);
39 }
40
41 MEDCouplingFieldInt::MEDCouplingFieldInt(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<int>(type,MEDCouplingTimeDiscretizationInt::New(td))
42 {
43 }
44
45 MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldInt& other, bool deepCpy):MEDCouplingFieldT<int>(other,deepCpy)
46 {
47 }
48
49 MEDCouplingFieldInt::MEDCouplingFieldInt(NatureOfField n, MEDCouplingTimeDiscretizationInt *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT<int>(type,n,td)
50 {
51 }
52
53 /*!
54  * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
55  */
56 MEDCouplingFieldInt::MEDCouplingFieldInt(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT<int>(ft,MEDCouplingTimeDiscretizationInt::New(td),false)
57 {
58 }
59
60 MEDCouplingFieldInt *MEDCouplingFieldInt::deepCopy() const
61 {
62   return cloneWithMesh(true);
63 }
64
65 MEDCouplingFieldInt *MEDCouplingFieldInt::clone(bool recDeepCpy) const
66 {
67   return new MEDCouplingFieldInt(*this,recDeepCpy);
68 }
69
70 MEDCouplingFieldDouble *MEDCouplingFieldInt::convertToDblField() const
71 {
72   MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
73   int t1,t2;
74   double t0(getTime(t1,t2));
75   MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization()));
76   ret->setTime(t0,t1,t2);
77   if(getArray())
78     {
79       MCAuto<DataArrayDouble> arr(getArray()->convertToDblArr());
80       ret->setArray(arr);
81     }
82   return ret.retn();
83 }