SET(medcoupling_SOURCES
MEDCouplingField.cxx
+ MEDCouplingFieldFloat.cxx
MEDCouplingFieldDouble.cxx
MEDCouplingFieldInt.cxx
MEDCouplingUMesh.cxx
--- /dev/null
+// Copyright (C) 2007-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#include "MEDCouplingFieldFloat.hxx"
+#include "MEDCouplingFieldT.txx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDCouplingFieldTemplate.hxx"
+#include "MEDCouplingMesh.hxx"
+
+using namespace MEDCoupling;
+
+template class MEDCoupling::MEDCouplingFieldT<float>;
+
+MEDCouplingFieldFloat *MEDCouplingFieldFloat::New(TypeOfField type, TypeOfTimeDiscretization td)
+{
+ return new MEDCouplingFieldFloat(type,td);
+}
+
+MEDCouplingFieldFloat *MEDCouplingFieldFloat::New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td)
+{
+ return new MEDCouplingFieldFloat(ft,td);
+}
+
+MEDCouplingFieldFloat::MEDCouplingFieldFloat(TypeOfField type, TypeOfTimeDiscretization td):MEDCouplingFieldT<float>(type,MEDCouplingTimeDiscretizationFloat::New(td))
+{
+}
+
+MEDCouplingFieldFloat::MEDCouplingFieldFloat(const MEDCouplingFieldFloat& other, bool deepCopy):MEDCouplingFieldT<float>(other,deepCopy)
+{
+}
+
+MEDCouplingFieldFloat::MEDCouplingFieldFloat(NatureOfField n, MEDCouplingTimeDiscretizationFloat *td, MEDCouplingFieldDiscretization *type):MEDCouplingFieldT<float>(type,n,td)
+{
+}
+
+/*!
+ * ** WARINING : This method do not deeply copy neither mesh nor spatial discretization. Only a shallow copy (reference) is done for mesh and spatial discretization ! **
+ */
+MEDCouplingFieldFloat::MEDCouplingFieldFloat(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td):MEDCouplingFieldT<float>(ft,MEDCouplingTimeDiscretizationFloat::New(td),false)
+{
+}
+
+MEDCouplingFieldFloat *MEDCouplingFieldFloat::deepCopy() const
+{
+ return cloneWithMesh(true);
+}
+
+MEDCouplingFieldFloat *MEDCouplingFieldFloat::clone(bool recDeepCpy) const
+{
+ return new MEDCouplingFieldFloat(*this,recDeepCpy);
+}
+
+MEDCouplingFieldDouble *MEDCouplingFieldFloat::convertToDblField() const
+{
+ MCAuto<MEDCouplingFieldTemplate> tmp(MEDCouplingFieldTemplate::New(*this));
+ int t1,t2;
+ double t0(getTime(t1,t2));
+ MCAuto<MEDCouplingFieldDouble> ret(MEDCouplingFieldDouble::New(*tmp,getTimeDiscretization()));
+ ret->setTime(t0,t1,t2);
+ if(getArray())
+ {
+ MCAuto<DataArrayDouble> arr(getArray()->convertToDblArr());
+ ret->setArray(arr);
+ }
+ return ret.retn();
+}
--- /dev/null
+// Copyright (C) 2007-2017 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// Author : Anthony GEAY (EDF R&D)
+
+#ifndef __MEDCOUPLINGFIELDFLOAT_HXX__
+#define __MEDCOUPLINGFIELDFLOAT_HXX__
+
+#include "MEDCoupling.hxx"
+#include "MEDCouplingFieldT.hxx"
+#include "MEDCouplingMemArray.hxx"
+
+#include <string>
+
+namespace MEDCoupling
+{
+ class MEDCouplingFieldDouble;
+ class MEDCouplingFieldTemplate;
+
+ class MEDCouplingFieldFloat : public MEDCouplingFieldT<float>
+ {
+ public:
+ MEDCOUPLING_EXPORT static MEDCouplingFieldFloat *New(TypeOfField type, TypeOfTimeDiscretization td=ONE_TIME);
+ MEDCOUPLING_EXPORT static MEDCouplingFieldFloat *New(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td=ONE_TIME);
+ MEDCOUPLING_EXPORT MEDCouplingFieldFloat *deepCopy() const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldFloat *clone(bool recDeepCpy) const;
+ MEDCOUPLING_EXPORT MEDCouplingFieldDouble *convertToDblField() const;
+ protected:
+ MEDCouplingFieldFloat(TypeOfField type, TypeOfTimeDiscretization td);
+ MEDCouplingFieldFloat(const MEDCouplingFieldFloat& other, bool deepCopy);
+ MEDCouplingFieldFloat(NatureOfField n, MEDCouplingTimeDiscretizationFloat *td, MEDCouplingFieldDiscretization *type);
+ MEDCouplingFieldFloat(const MEDCouplingFieldTemplate& ft, TypeOfTimeDiscretization td);
+ ~MEDCouplingFieldFloat() { }
+ };
+}
+
+#endif
#include "MEDCouplingFieldTemplate.hxx"
#include "MEDCouplingMesh.hxx"
#include "MEDCouplingFieldInt.hxx"
+#include "MEDCouplingFieldFloat.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldDiscretization.hxx"
return new MEDCouplingFieldTemplate(f);
}
+MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldFloat& f)
+{
+ return new MEDCouplingFieldTemplate(f);
+}
+
MEDCouplingFieldTemplate *MEDCouplingFieldTemplate::New(const MEDCouplingFieldInt& f)
{
return new MEDCouplingFieldTemplate(f);
checkConsistencyLight();
}
+MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f):MEDCouplingField(f,false)
+{
+ forceTimeOfThis(f);
+ checkConsistencyLight();
+}
+
MEDCouplingFieldTemplate::MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f):MEDCouplingField(f,false)
{
forceTimeOfThis(f);
namespace MEDCoupling
{
class MEDCouplingFieldInt;
+ class MEDCouplingFieldFloat;
class MEDCouplingFieldDouble;
/*!
* \brief A field template can be seen as a field without the array of values.
{
public:
MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldDouble& f);
+ MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldFloat& f);
MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(const MEDCouplingFieldInt& f);
MEDCOUPLING_EXPORT static MEDCouplingFieldTemplate *New(TypeOfField type);
MEDCOUPLING_EXPORT std::string simpleRepr() const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
private:
MEDCouplingFieldTemplate(const MEDCouplingFieldDouble& f);
+ MEDCouplingFieldTemplate(const MEDCouplingFieldFloat& f);
MEDCouplingFieldTemplate(const MEDCouplingFieldInt& f);
MEDCouplingFieldTemplate(TypeOfField type);
};
template class MEDCoupling::MemArray<double>;
template class MEDCoupling::DataArrayTemplate<int>;
template class MEDCoupling::DataArrayTemplate<double>;
+template class MEDCoupling::DataArrayTemplateClassic<int>;
+template class MEDCoupling::DataArrayTemplateClassic<double>;
template class MEDCoupling::DataArrayTemplateFP<double>;
template<int SPACEDIM>
*/
DataArrayDouble *DataArrayDouble::performCopyOrIncrRef(bool dCpy) const
{
- if(dCpy)
- return deepCopy();
- else
- {
- incrRef();
- return const_cast<DataArrayDouble *>(this);
- }
+ return DataArrayTemplateClassic<double>::PerformCopyOrIncrRef(dCpy,*this);
}
/*!
return _mem.isEqual(other._mem,prec,tmp);
}
-/*!
- * Creates a new DataArrayInt and assigns all (textual and numerical) data of \a this
- * array to the new one.
- * \return DataArrayInt * - the new instance of DataArrayInt.
- */
-DataArrayInt *DataArrayDouble::convertToIntArr() const
-{
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(getNumberOfTuples(),getNumberOfComponents());
- int *dest=ret->getPointer();
- // to make Visual C++ happy : instead of std::size_t nbOfVals=getNbOfElems(); std::copy(src,src+nbOfVals,dest);
- for(const double *src=begin();src!=end();src++,dest++)
- *dest=(int)*src;
- ret->copyStringInfoFrom(*this);
- return ret;
-}
-
/*!
* Returns a new DataArrayDouble holding the same values as \a this array but differently
* arranged in memory. If \a this array holds 2 components of 3 values:
*/
DataArrayInt *DataArrayInt::performCopyOrIncrRef(bool dCpy) const
{
- if(dCpy)
- return deepCopy();
- else
- {
- incrRef();
- return const_cast<DataArrayInt *>(this);
- }
+ return DataArrayTemplateClassic<int>::PerformCopyOrIncrRef(dCpy,*this);
}
/*!
return true;
}
-/*!
- * Creates a new DataArrayDouble and assigns all (textual and numerical) data of \a this
- * array to the new one.
- * \return DataArrayDouble * - the new instance of DataArrayInt.
- */
-DataArrayDouble *DataArrayInt::convertToDblArr() const
-{
- checkAllocated();
- DataArrayDouble *ret=DataArrayDouble::New();
- ret->alloc(getNumberOfTuples(),getNumberOfComponents());
- std::size_t nbOfVals=getNbOfElems();
- const int *src=getConstPointer();
- double *dest=ret->getPointer();
- std::copy(src,src+nbOfVals,dest);
- ret->copyStringInfoFrom(*this);
- return ret;
-}
-
/*!
* Appends components of another array to components of \a this one, tuple by tuple.
* So that the number of tuples of \a this array remains the same and the number of
};
template<class T>
- class DataArrayTemplateFP : public DataArrayTemplate<T>
+ class DataArrayTemplateClassic : public DataArrayTemplate<T>
+ {
+ public:
+ MEDCOUPLING_EXPORT MCAuto<DataArrayDouble> convertToDblArr() const;
+ MEDCOUPLING_EXPORT MCAuto<DataArrayInt> convertToIntArr() const;
+ MEDCOUPLING_EXPORT MCAuto<DataArrayFloat> convertToFloatArr() const;
+ protected:
+ static typename Traits<T>::ArrayType *PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self);
+ private:
+ template<class U>
+ MCAuto< typename Traits<U>::ArrayType > convertToOtherTypeOfArr() const;
+ };
+
+ template<class T>
+ class DataArrayTemplateFP : public DataArrayTemplateClassic<T>
{
public:
MEDCOUPLING_EXPORT bool isUniform(T val, T eps) const;
MEDCOUPLING_EXPORT void reprCppStream(const std::string& varName, std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverview(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprQuickOverviewData(std::ostream& stream, std::size_t maxNbOfByteInRepr) const;
- public:
+ public:// non abstract but essential
MEDCOUPLING_EXPORT std::string reprNotTooLong() const;
MEDCOUPLING_EXPORT void reprNotTooLongStream(std::ostream& stream) const;
MEDCOUPLING_EXPORT void reprNotTooLongWithoutNameStream(std::ostream& stream) const;
- public:
MEDCOUPLING_EXPORT bool isEqual(const DataArrayFloat& other, float prec) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayFloat& other, float prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayFloat& other, float prec) const;
+ MEDCOUPLING_EXPORT DataArrayFloat *performCopyOrIncrRef(bool deepCopy) const;
private:
~DataArrayFloat() { }
DataArrayFloat() { }
MEDCOUPLING_EXPORT bool isEqual(const DataArrayDouble& other, double prec) const;
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const DataArrayDouble& other, double prec, std::string& reason) const;
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const;
- MEDCOUPLING_EXPORT DataArrayInt *convertToIntArr() const;
MEDCOUPLING_EXPORT DataArrayDouble *fromNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayDouble *toNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayDouble *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplateFP<double>::mySelectByTupleId(new2OldBg,new2OldEnd); }
class DataArrayIntIterator;
- class DataArrayInt : public DataArrayTemplate<int>
+ class DataArrayInt : public DataArrayTemplateClassic<int>
{
public:
MEDCOUPLING_EXPORT static DataArrayInt *New();
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const;
MEDCOUPLING_EXPORT DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const;
- MEDCOUPLING_EXPORT DataArrayDouble *convertToDblArr() const;
MEDCOUPLING_EXPORT DataArrayInt *fromNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayInt *toNoInterlace() const;
MEDCOUPLING_EXPORT DataArrayInt *selectByTupleId(const int *new2OldBg, const int *new2OldEnd) const { return DataArrayTemplate<int>::mySelectByTupleId(new2OldBg,new2OldEnd); }
std::reverse(work,work+nbOfCompo);
std::reverse(_info_on_compo.begin(),_info_on_compo.end());
}
+
+ template<class T>
+ template<class U>
+ MCAuto< typename Traits<U>::ArrayType > DataArrayTemplateClassic<T>::convertToOtherTypeOfArr() const
+ {
+ this->checkAllocated();
+ MCAuto<typename Traits<U>::ArrayType> ret(Traits<U>::ArrayType::New());
+ ret->alloc(this->getNumberOfTuples(),this->getNumberOfComponents());
+ std::size_t nbOfVals(this->getNbOfElems());
+ const T *src(this->begin());
+ U *dest(ret->getPointer());
+ // to make Visual C++ happy : instead of std::size_t nbOfVals=getNbOfElems(); std::copy(src,src+nbOfVals,dest);
+ //for(const T *src=this->begin();src!=this->end();src++,dest++)
+ // *dest=(int)*src;
+ std::copy(src,src+nbOfVals,dest);
+ ret->copyStringInfoFrom(*this);
+ return ret;
+ }
+
+ /*!
+ * Creates a new DataArrayDouble and assigns all (textual and numerical) data of \a this
+ * array to the new one.
+ * \return DataArrayDouble * - the new instance of DataArrayInt.
+ */
+ template<class T>
+ MCAuto<DataArrayDouble> DataArrayTemplateClassic<T>::convertToDblArr() const
+ {
+ return convertToOtherTypeOfArr<double>();
+ }
+
+ /*!
+ * Creates a new DataArrayInt and assigns all (textual and numerical) data of \a this
+ * array to the new one.
+ * \return DataArrayInt * - the new instance of DataArrayInt.
+ */
+ template<class T>
+ MCAuto<DataArrayInt> DataArrayTemplateClassic<T>::convertToIntArr() const
+ {
+ return convertToOtherTypeOfArr<int>();
+ }
+
+ /*!
+ * Creates a new DataArrayFloat and assigns all (textual and numerical) data of \a this
+ * array to the new one.
+ * \return DataArrayFloat * - the new instance of DataArrayInt.
+ */
+ template<class T>
+ MCAuto<DataArrayFloat> DataArrayTemplateClassic<T>::convertToFloatArr() const
+ {
+ return convertToOtherTypeOfArr<float>();
+ }
+
+ /*!
+ * Returns either a \a deep or \a shallow copy of this array. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeep and \ref MEDCouplingArrayBasicsCopyShallow.
+ * \param [in] dCpy - if \a true, a deep copy is returned, else, a shallow one.
+ * \return DataArrayDouble * - either a new instance of DataArrayDouble (if \a dCpy
+ * == \a true) or \a this instance (if \a dCpy == \a false).
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *DataArrayTemplateClassic<T>::PerformCopyOrIncrRef(bool dCpy, const typename Traits<T>::ArrayType& self)
+ {
+ if(dCpy)
+ return self.deepCopy();
+ else
+ {
+ self.incrRef();
+ return const_cast<typename Traits<T>::ArrayType *>(&self);
+ }
+ }
/*!
* Checks if all values in \a this array are equal to \a val at precision \a eps.
template class MEDCoupling::MemArray<float>;
template class MEDCoupling::DataArrayTemplate<float>;
+template class MEDCoupling::DataArrayTemplateClassic<float>;
template class MEDCoupling::DataArrayTemplateFP<float>;
DataArrayFloat *DataArrayFloat::New()
std::string tmp;
return _mem.isEqual(other._mem,prec,tmp);
}
+
+/*!
+ * Returns either a \a deep or \a shallow copy of this array. For more info see
+ * \ref MEDCouplingArrayBasicsCopyDeep and \ref MEDCouplingArrayBasicsCopyShallow.
+ * \param [in] dCpy - if \a true, a deep copy is returned, else, a shallow one.
+ * \return DataArrayDouble * - either a new instance of DataArrayDouble (if \a dCpy
+ * == \a true) or \a this instance (if \a dCpy == \a false).
+ */
+DataArrayFloat *DataArrayFloat::performCopyOrIncrRef(bool dCpy) const
+{
+ return DataArrayTemplateClassic<float>::PerformCopyOrIncrRef(dCpy,*this);
+}
}
}
-bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec, std::string& reason) const
+bool MEDCouplingTimeDiscretizationFloat::isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec, std::string& reason) const
{
if(prec!=0)
throw INTERP_KERNEL::Exception("isEqualIfNotWhy : only precision equal to 0 supported for int !");
const MEDCouplingTimeDiscretizationFloat *otherC(dynamic_cast<const MEDCouplingTimeDiscretizationFloat *>(other));
if(!otherC)
throw INTERP_KERNEL::Exception("isEqualIfNotWhy : other is not a MEDCouplingTimeDiscretizationFloat !");
- if(!MEDCouplingTimeDiscretizationTemplate<int>::areStrictlyCompatible(other,reason))
+ if(!MEDCouplingTimeDiscretizationTemplate<float>::areStrictlyCompatible(other,reason))
return false;
if(!_tk.isEqualIfNotWhy(otherC->_tk,_time_tolerance,reason))
return false;
if(_array==other->getArray())
return true;
- return _array->isEqualIfNotWhy(*other->getArray(),reason);
+ return _array->isEqualIfNotWhy(*other->getArray(),prec,reason);
}
-bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec) const
+bool MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec) const
{
if(prec!=0)
throw INTERP_KERNEL::Exception("MEDCouplingTimeDiscretizationFloat::isEqualWithoutConsideringStr : only precision 0 is supported !");
return false;
if(_array==other->getArray())
return true;
- return _array->isEqualWithoutConsideringStr(*(other->getArray()));
+ return _array->isEqualWithoutConsideringStr(*(other->getArray()),prec);
}
////////////////////////
public:
MEDCouplingTimeDiscretizationFloat() { }
MEDCouplingTimeDiscretizationFloat(const MEDCouplingTimeDiscretizationFloat& other, bool deepCopy);
- static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
+ static MEDCouplingTimeDiscretizationFloat *New(TypeOfTimeDiscretization type);
MEDCouplingTimeDiscretizationFloat *performCopyOrIncrRef(bool deepCopy) const;
bool isEqualIfNotWhy(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec, std::string& reason) const;
- bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<int> *other, float prec) const;
+ bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretizationTemplate<float> *other, float prec) const;
private:
static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
};
class DataArrayChar;
class DataArrayByte;
class MEDCouplingFieldDouble;
+ class MEDCouplingFieldFloat;
class MEDCouplingFieldInt;
template<>
static const char NPYStr[];
typedef DataArrayFloat ArrayType;
typedef DataArrayFloat ArrayTypeCh;
- //typedef MEDCouplingFieldFloat FieldType;
+ typedef MEDCouplingFieldFloat FieldType;
};
template<>
arr->setInfoOnComponent(1,"hhhh");
arr->setInfoOnComponent(2,"jj");
arr->setInfoOnComponent(3,"kkkkkk");
- DataArrayInt *arr2=arr->convertToIntArr();
- DataArrayDouble *arr3=arr2->convertToDblArr();
- arr2->decrRef();
+ MCAuto<DataArrayInt> arr2(arr->convertToIntArr());
+ MCAuto<DataArrayDouble> arr3(arr2->convertToDblArr());
CPPUNIT_ASSERT(arr->isEqual(*arr3,1e-14));
- arr3->decrRef();
arr->decrRef();
}
const double expected1[30]={2.,3.,2.,3.,1.,1., 12.,13.,12.,13.,11.,11., 22.,23.,22.,23.,21.,21., 32.,33.,32.,33.,31.,31., 42.,43.,42.,43.,41.,41.};
for(int i=0;i<30;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],a2->getIJ(0,i),1e-14);
- DataArrayInt *a3=a1->convertToIntArr();
+ MCAuto<DataArrayInt> a3(a1->convertToIntArr());
DataArrayInt *a4=static_cast<DataArrayInt *>(a3->keepSelectedComponents(arr2V));
CPPUNIT_ASSERT_EQUAL(6,(int)a4->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(5,(int)a4->getNumberOfTuples());
const double expected2[30]={2.,4.,3.,3.,1.,1., 12.,14.,13.,13.,11.,11., 22.,24.,23.,23.,21.,21., 32.,34.,33.,33.,31.,31., 42.,44.,43.,43.,41.,41.};
for(int i=0;i<30;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected2[i],a2->getIJ(0,i),1e-14);
- DataArrayInt *a6=a5->convertToIntArr();
+ MCAuto<DataArrayInt> a6=a5->convertToIntArr();
a6->setInfoOnComponent(0,"eeee");
a6->setInfoOnComponent(1,"ffff");
a4->setSelectedComponents(a6,arr4V);
arr7V.resize(3);
CPPUNIT_ASSERT_THROW(a2->setSelectedComponents(a1,arr7V),INTERP_KERNEL::Exception);
//
- a6->decrRef();
a5->decrRef();
a4->decrRef();
- a3->decrRef();
a2->decrRef();
a1->decrRef();
}
CPPUNIT_ASSERT_EQUAL(5,(int)da2->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,(int)da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
- DataArrayDouble *da3=da->convertToDblArr();
+ MCAuto<DataArrayDouble> da3=da->convertToDblArr();
DataArrayDouble *da4=da3->fromNoInterlace();
CPPUNIT_ASSERT_EQUAL(5,(int)da4->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,(int)da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
for(int i=0;i<15;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
da4->decrRef();
- da3->decrRef();
da2->decrRef();
da->decrRef();
}
CPPUNIT_ASSERT_EQUAL(5,(int)da2->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,(int)da2->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
CPPUNIT_ASSERT(std::equal(expected1,expected1+15,da2->getConstPointer()));
- DataArrayDouble *da3=da->convertToDblArr();
+ MCAuto<DataArrayDouble> da3=da->convertToDblArr();
DataArrayDouble *da4=da3->toNoInterlace();
CPPUNIT_ASSERT_EQUAL(5,(int)da4->getNumberOfTuples());
CPPUNIT_ASSERT_EQUAL(3,(int)da4->getNumberOfComponents());// it's not a bug. Avoid to have 1 million components !
for(int i=0;i<15;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL((double)expected1[i],da4->getIJ(0,i),1e-14);
da4->decrRef();
- da3->decrRef();
da2->decrRef();
da->decrRef();
}
CPPUNIT_ASSERT(!da->isUniform(1));
da->setIJ(2,0,1);
CPPUNIT_ASSERT(da->isUniform(1));
- DataArrayDouble *da2=da->convertToDblArr();
+ MCAuto<DataArrayDouble> da2=da->convertToDblArr();
CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
da2->setIJ(1,0,1.+1.e-13);
CPPUNIT_ASSERT(da2->isUniform(1.,1e-12));
da2->setIJ(1,0,1.+1.e-11);
CPPUNIT_ASSERT(!da2->isUniform(1.,1e-12));
- da2->decrRef();
da->decrRef();
}
//
da1->fillWithValue(7.);
da2->iota(0.);
- DataArrayDouble *da3=da2->applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
+ MCAuto<DataArrayDouble> da3=da2->applyFunc(3,"10*x*IVec+100*x*JVec+1000*x*KVec");
//
da1->setInfoOnComponent(0,"c0da1");
da1->setInfoOnComponent(1,"c1da1");
for(int i=0;i<35;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da1->getIJ(0,i),1e-10);
//
- DataArrayInt *dai1=da1C->convertToIntArr();
- DataArrayInt *dai3=da3->convertToIntArr();
+ MCAuto<DataArrayInt> dai1=da1C->convertToIntArr();
+ MCAuto<DataArrayInt> dai3=da3->convertToIntArr();
dai1->meldWith(dai3);
CPPUNIT_ASSERT_EQUAL(5,(int)dai1->getNumberOfComponents());
CPPUNIT_ASSERT_EQUAL(7,(int)dai1->getNumberOfTuples());
for(int i=0;i<35;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(expected1[i],da4->getIJ(0,i),1e-10);
// test of static method DataArrayInt::meld
- dai1->decrRef();
dai1=da1C->convertToIntArr();
DataArrayInt *dai4=DataArrayInt::Meld(dai1,dai3);
CPPUNIT_ASSERT_EQUAL(5,(int)dai4->getNumberOfComponents());
//
dai4->decrRef();
da4->decrRef();
- dai3->decrRef();
- dai1->decrRef();
da1C->decrRef();
da1->decrRef();
da2->decrRef();
- da3->decrRef();
}
void MEDCouplingBasicsTest3::testFieldMeld1()
for(int i=0;i<12;i++)
CPPUNIT_ASSERT_EQUAL(i,da1->getIJ(0,i));
//double
- DataArrayDouble *da2=da1->convertToDblArr();
+ MCAuto<DataArrayDouble> da2=da1->convertToDblArr();
da1->decrRef();
const double *ptr2=da2->getConstPointer();
//
CPPUNIT_ASSERT_EQUAL(4,(int)da2->getNumberOfTuples());
for(int i=0;i<12;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i,da2->getIJ(0,i),1e-14);
- da2->decrRef();
}
void MEDCouplingBasicsTest3::testGetDifferentValues1()
c=a->buildPermutationArr(*b);
const int expect2[5]={1,3,4,2,3};
CPPUNIT_ASSERT(std::equal(expect2,expect2+5,c->getConstPointer()));
- DataArrayDouble *d=b->convertToDblArr();
+ MCAuto<DataArrayDouble> d=b->convertToDblArr();
b->sort();
const int expect3[5]={4,4,5,6,8};
CPPUNIT_ASSERT(std::equal(expect3,expect3+5,b->getConstPointer()));
for(int i=0;i<5;i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(double(expect3[i]),d->getIJ(i,0),1e-14);
//
- d->decrRef();
+ b->decrRef();
c->decrRef();
a->decrRef();
- b->decrRef();
}
void MEDCouplingBasicsTest3::testAreCellsIncludedIn2()
d1->deepCopyFrom(*d);
CPPUNIT_ASSERT(d->isEqual(*d1,1e-12));
//
- DataArrayInt *d2=d->convertToIntArr();
+ MCAuto<DataArrayInt> d2=d->convertToIntArr();
DataArrayInt *d4=DataArrayInt::New();
CPPUNIT_ASSERT(!d2->isEqual(*d4));
d4->deepCopyFrom(*d2);
//
d->decrRef();
d1->decrRef();
- d2->decrRef();
d4->decrRef();
}
const double expected1[12]={2.,3.,5.,6.,7.,8.,9.,10.,11.,12.,13.,15.};
d1->alloc(6,2);
std::copy(val1,val1+12,d1->getPointer());
- DataArrayInt *d2=d1->convertToIntArr();
+ MCAuto<DataArrayInt> d2=d1->convertToIntArr();
//
d1->abs();
for(int i=0;i<12;i++)
for(int i=0;i<12;i++)
CPPUNIT_ASSERT_EQUAL(expected2[i],d2->getIJ(0,i));
//
- d2->decrRef();
d1->decrRef();
}
%newobject MEDCoupling::DataArrayInt::__iter__;
%newobject MEDCoupling::DataArrayInt::selectPartDef;
%newobject MEDCoupling::DataArrayInt::convertToDblArr;
+%newobject MEDCoupling::DataArrayInt::convertToFloatArr;
%newobject MEDCoupling::DataArrayInt::performCopyOrIncrRef;
%newobject MEDCoupling::DataArrayInt::subArray;
%newobject MEDCoupling::DataArrayInt::changeNbOfComponents;
%newobject MEDCoupling::DataArrayDouble::__iter__;
%newobject MEDCoupling::DataArrayDouble::selectPartDef;
%newobject MEDCoupling::DataArrayDouble::convertToIntArr;
+%newobject MEDCoupling::DataArrayDouble::convertToFloatArr;
%newobject MEDCoupling::DataArrayDouble::performCopyOrIncrRef;
%newobject MEDCoupling::DataArrayDouble::Aggregate;
%newobject MEDCoupling::DataArrayDouble::Meld;
std::string reprNotTooLong() const throw(INTERP_KERNEL::Exception);
bool isEqual(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
bool isEqualWithoutConsideringStr(const DataArrayDouble& other, double prec) const throw(INTERP_KERNEL::Exception);
- DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *toNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayDouble *subArray(int tupleIdBg, int tupleIdEnd=-1) const throw(INTERP_KERNEL::Exception);
return ret.retn();
}
+ DataArrayFloat *convertToFloatArr() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayFloat> ret(self->convertToFloatArr());
+ return ret.retn();
+ }
+
+ DataArrayInt *convertToIntArr() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayInt> ret(self->convertToIntArr());
+ return ret.retn();
+ }
+
void pushBackValsSilent(PyObject *li) throw(INTERP_KERNEL::Exception)
{
double val;
DataArrayInt *invertArrayO2N2N2O(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayN2O2O2N(int oldNbOfElem) const throw(INTERP_KERNEL::Exception);
DataArrayInt *invertArrayO2N2N2OBis(int newNbOfElem) const throw(INTERP_KERNEL::Exception);
- DataArrayDouble *convertToDblArr() const throw(INTERP_KERNEL::Exception);
DataArrayInt *indicesOfSubPart(const DataArrayInt& partOfThis) const throw(INTERP_KERNEL::Exception);
DataArrayInt *fromNoInterlace() const throw(INTERP_KERNEL::Exception);
DataArrayInt *toNoInterlace() const throw(INTERP_KERNEL::Exception);
{
return MEDCoupling_DataArrayInt_New__SWIG_1(elt0,nbOfTuples,nbOfComp);
}
+
+ DataArrayDouble *convertToDblArr() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayDouble> ret(self->convertToDblArr());
+ return ret.retn();
+ }
+
+ DataArrayFloat *convertToFloatArr() const throw(INTERP_KERNEL::Exception)
+ {
+ MCAuto<DataArrayFloat> ret(self->convertToFloatArr());
+ return ret.retn();
+ }
std::string __str__() const throw(INTERP_KERNEL::Exception)
{