Salome HOME
fix: replace unordered_set/map with set/map
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingFieldFloat.cxx
1 // Copyright (C) 2007-2024  CEA, EDF
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 : Anthony GEAY (EDF R&D)
20
21 #include "MEDCouplingFieldFloat.hxx"
22 #include "MEDCouplingFieldT.txx"
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MEDCouplingFieldInt.hxx"
25 #include "MEDCouplingFieldInt64.hxx"
26 #include "MEDCouplingFieldTemplate.hxx"
27 #include "MEDCouplingMesh.hxx"
28 #include "MEDCouplingMemArray.txx"
29
30 using namespace MEDCoupling;
31
32 template class MEDCoupling::MEDCouplingFieldT<float>;
33
34 MEDCouplingFieldFloat *MEDCouplingFieldFloat::New(TypeOfField type, TypeOfTimeDiscretization td)
35 {
36   return new MEDCouplingFieldFloat(type,td);
37 }
38
39 MEDCouplingFieldFloat *MEDCouplingFieldFloat::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
40 {
41   return new MEDCouplingFieldFloat(ft,td);
42 }
43
44 MEDCouplingFieldFloat::MEDCouplingFieldFloat(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<float>(type,MEDCouplingTimeDiscretizationFloat::New(td))
45 {
46 }
47
48 MEDCouplingFieldFloat::MEDCouplingFieldFloat(const MEDCouplingFieldFloat& other, bool deepCpy):MEDCouplingFieldT<float>(other,deepCpy)
49 {
50 }
51
52 MEDCouplingFieldFloat::MEDCouplingFieldFloat(NatureOfField n, MEDCouplingTimeDiscretizationFloat *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT<float>(type,n,td)
53 {
54 }
55
56 /*!
57  * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
58  */
59 MEDCouplingFieldFloat::MEDCouplingFieldFloat(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT<float>(ft,MEDCouplingTimeDiscretizationFloat::New(td),false)
60 {
61 }
62
63 MEDCouplingFieldFloat *MEDCouplingFieldFloat::deepCopy() const
64 {
65   return cloneWithMesh(true);
66 }
67
68 MEDCouplingFieldFloat *MEDCouplingFieldFloat::clone(bool recDeepCpy) const
69 {
70   return new MEDCouplingFieldFloat(*this,recDeepCpy);
71 }
72
73 template<class U>
74 typename Traits<U>::FieldType *ConvertToUField(const MEDCouplingFieldFloat *self)
75 {
76   MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*self));
77   int t1,t2;
78   double t0(self->getTime(t1,t2));
79   MCAuto<typename Traits<U>::FieldType> ret(Traits<U>::FieldType::New(*tmp,self->getTimeDiscretization()));
80   ret->setTime(t0,t1,t2);
81   if(self->getArray())
82     {
83       MCAuto<typename Traits<U>::ArrayType> arr(self->getArray()->convertToOtherTypeOfArr<U>());
84       ret->setArray(arr);
85     }
86   return ret.retn();
87 }
88
89 MEDCouplingFieldDouble * MEDCouplingFieldFloat::convertToDblField() const
90 {
91   return ConvertToUField<double>(this);
92 }
93
94 MEDCouplingFieldInt32 * MEDCouplingFieldFloat::convertToIntField() const
95 {
96   return ConvertToUField<int>(this);
97 }
98
99 MEDCouplingFieldInt64 * MEDCouplingFieldFloat::convertToInt64Field() const
100 {
101   return ConvertToUField<Int64>(this);
102 }