//
// Author : Anthony Geay (CEA/DEN)
-#include "MEDFileField.hxx"
+#include "MEDFileField.txx"
#include "MEDFileMesh.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDLoaderTraits.hxx"
using namespace MEDCoupling;
+template class MEDFileField1TSTemplateWithoutSDA<int>;
+template class MEDFileField1TSTemplateWithoutSDA<double>;
+
const char MEDFileField1TSWithoutSDA::TYPE_STR[]="FLOAT64";
const char MEDFileIntField1TSWithoutSDA::TYPE_STR[]="INT32";
}
/*!
- * dts = level 1 meshes to aggregate. Level 2 all geo type. Level 3 pair specifying geo type and number of elem in geotype.
+ * \param [in,out] start - Integer that gives the current position in the final aggregated array
+ * \param [in] pms - list of elements to aggregate. integer gives the mesh id
+ * \param [in] dts - (Distribution of types) = level 1 : meshes to aggregate. Level 2 : all geo type. Level 3 pair specifying geo type and number of elem in geotype.
+ * \param [out] extractInfo - Gives information about the where the data comes from. It is a vector of triplet. First element in the triplet the mesh pos. The 2nd one the start pos. The 3rd the end pos.
*/
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> MEDFileFieldPerMeshPerTypePerDisc::Aggregate(int &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
{
MCAuto<MEDFileFieldPerMeshPerTypePerDisc> ret(new MEDFileFieldPerMeshPerTypePerDisc(father,tof));
+ if(pms.empty())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : empty input vector !");
for(std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it=pms.begin();it!=pms.end();it++)
{
+ if(!(*it).second)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : presence of null pointer !");
if(!(*it).second->getProfile().empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for profiles !");
if(!(*it).second->getLocalization().empty())
throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for gauss pts !");
- //getNumberOfTuples
}
+ INTERP_KERNEL::NormalizedCellType gt(pms[0].second->getGeoType());
+ std::size_t i(0);
+ std::vector< std::pair<int,int> > filteredDTS;
+ for(std::vector< std::vector< std::pair<int,int> > >::const_iterator it=dts.begin();it!=dts.end();it++,i++)
+ for(std::vector< std::pair<int,int> >::const_iterator it2=(*it).begin();it2!=(*it).end();it2++)
+ if((*it2).first==gt)
+ filteredDTS.push_back(std::pair<int,int>(i,(*it2).second));
+ if(pms.size()!=filteredDTS.size())
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles !");
+ std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >::const_iterator it1(pms.begin());
+ std::vector< std::pair<int,int> >::const_iterator it2(filteredDTS.begin());
+ int zeStart(start),nval(0);
+ for(;it1!=pms.end();it1++,it2++)
+ {
+ if((*it1).first!=(*it2).first)
+ throw INTERP_KERNEL::Exception("MEDFileFieldPerMeshPerTypePerDisc::Aggregate : not implemented yet for generated profiles 2 !");
+ int s1((*it1).second->getStart()),e1((*it1).second->getEnd());
+ extractInfo.push_back(std::pair<int, std::pair<int,int> >((*it1).first,std::pair<int,int>(s1,e1)));
+ start+=e1-s1;
+ nval+=((*it1).second)->getNumberOfVals();
+ }
+ ret->_start=zeStart; ret->_end=start; ret->_nval=nval;
return ret;
}
return ret;
}
-MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
+MCAuto<MEDFileFieldPerMesh> MEDFileFieldPerMesh::Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo)
{
MCAuto<MEDFileFieldPerMesh> ret(new MEDFileFieldPerMesh(father,pms[0]->getMeshName(),pms[0]->getMeshIteration(),pms[0]->getMeshOrder()));
std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > > m;
m[gt].push_back(std::pair<int,const MEDFileFieldPerMeshPerType *>(i,*it2));
}
}
- int start(0);
for(std::map<INTERP_KERNEL::NormalizedCellType, std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> > >::const_iterator it=m.begin();it!=m.end();it++)
{
MCAuto<MEDFileFieldPerMeshPerType> agg(MEDFileFieldPerMeshPerType::Aggregate(start,(*it).second,dts,(*it).first,ret,extractInfo));
return ret;
}
-/*!
- * Returns a pointer to the underground DataArrayDouble instance. So the
- * caller should not decrRef() it. This method allows for a direct access to the field
- * values. This method is quite unusable if there is more than a nodal field or a cell
- * field on single geometric cell type.
- * \return DataArrayDouble * - the pointer to the field values array.
- */
-DataArrayDouble *MEDFileField1TSWithoutSDA::getUndergroundDataArrayDouble() const
-{
- const DataArrayDouble *ret=_arr;
- if(ret)
- return const_cast<DataArrayDouble *>(ret);
- else
- return 0;
-}
-
const char *MEDFileField1TSWithoutSDA::getTypeStr() const
{
return TYPE_STR;
return ret.retn();
}
-void MEDFileField1TSWithoutSDA::aggregate(const std::vector<const MEDFileField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
-{
- if(f1tss.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : empty vector !");
- std::vector<const MEDFileFieldPerMesh *> pms;
- for(std::vector<const MEDFileField1TSWithoutSDA *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++)
- {
- if(!*it)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : presence of null pointer in input vector !");
- if((*it)->_field_per_mesh.empty())
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::aggregate : no info !");
- pms.push_back((*it)->_field_per_mesh[0]);
- }
- std::vector<std::pair< int, std::pair<int,int> > > extractInfo;
- MCAuto<MEDFileFieldPerMesh> fpm(MEDFileFieldPerMesh::Aggregate(pms,dts,this,extractInfo));
- _field_per_mesh.push_back(fpm);
- int iteration,order;
- double tv(f1tss[0]->getTime(iteration,order));
- _iteration=iteration; _order=order; _dt=tv;
-
-}
-
-/*!
- * Returns a pointer to the underground DataArrayDouble instance. So the
- * caller should not decrRef() it. This method allows for a direct access to the field
- * values. This method is quite unusable if there is more than a nodal field or a cell
- * field on single geometric cell type.
- * \return DataArrayDouble * - the pointer to the field values array.
- */
-DataArray *MEDFileField1TSWithoutSDA::getUndergroundDataArray() const
-{
- return getUndergroundDataArrayDouble();
-}
-
/*!
* Returns a pointer to the underground DataArrayDouble instance and a
* sequence describing parameters of a support of each part of \a this field. The
if(_field_per_mesh[0]==0)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
_field_per_mesh[0]->getUndergroundDataArrayExt(entries);
- return getUndergroundDataArrayDouble();
+ return getUndergroundDataArrayTemplate();
}
/*!
return getUndergroundDataArrayDoubleExt(entries);
}
-MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
+MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<double>(fieldName,csit,iteration,order)
{
- DataArrayDouble *arr(getOrCreateAndGetArrayDouble());
+ DataArrayDouble *arr(getOrCreateAndGetArrayTemplate());
arr->setInfoAndChangeNbOfCompo(infos);
}
-MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
+MEDFileField1TSWithoutSDA::MEDFileField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<double>()
{
}
return ret.retn();
}
-void MEDFileField1TSWithoutSDA::setArray(DataArray *arr)
-{
- if(!arr)
- {
- _nb_of_tuples_to_be_allocated=-1;
- _arr=0;
- return ;
- }
- DataArrayDouble *arrC=dynamic_cast<DataArrayDouble *>(arr);
- if(!arrC)
- throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
- else
- _nb_of_tuples_to_be_allocated=-3;
- arrC->incrRef();
- _arr=arrC;
-}
-
-DataArray *MEDFileField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
-{
- return DataArrayDouble::New();
-}
-
-DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble()
-{
- DataArrayDouble *ret=_arr;
- if(ret)
- return ret;
- _arr=DataArrayDouble::New();
- return _arr;
-}
-
-DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray()
-{
- return getOrCreateAndGetArrayDouble();
-}
-
-const DataArrayDouble *MEDFileField1TSWithoutSDA::getOrCreateAndGetArrayDouble() const
-{
- const DataArrayDouble *ret=_arr;
- if(ret)
- return ret;
- DataArrayDouble *ret2=DataArrayDouble::New();
- const_cast<MEDFileField1TSWithoutSDA *>(this)->_arr=DataArrayDouble::New();
- return ret2;
-}
-
-const DataArray *MEDFileField1TSWithoutSDA::getOrCreateAndGetArray() const
-{
- return getOrCreateAndGetArrayDouble();
-}
-
//= MEDFileIntField1TSWithoutSDA
MEDFileIntField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
return new MEDFileIntField1TSWithoutSDA(fieldName,csit,iteration,order,infos);
}
-MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA()
+MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA():MEDFileField1TSTemplateWithoutSDA<int>()
{
}
MEDFileIntField1TSWithoutSDA::MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order,
- const std::vector<std::string>& infos):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order)
+ const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<int>(fieldName,csit,iteration,order)
{
- DataArrayInt *arr(getOrCreateAndGetArrayInt());
+ DataArrayInt *arr(getOrCreateAndGetArrayTemplate());
arr->setInfoAndChangeNbOfCompo(infos);
}
return ret.retn();
}
-/*!
- * Returns a pointer to the underground DataArrayInt instance. So the
- * caller should not decrRef() it. This method allows for a direct access to the field
- * values. This method is quite unusable if there is more than a nodal field or a cell
- * field on single geometric cell type.
- * \return DataArrayInt * - the pointer to the field values array.
- */
-DataArray *MEDFileIntField1TSWithoutSDA::getUndergroundDataArray() const
-{
- return getUndergroundDataArrayInt();
-}
-
-/*!
- * Returns a pointer to the underground DataArrayInt instance. So the
- * caller should not decrRef() it. This method allows for a direct access to the field
- * values. This method is quite unusable if there is more than a nodal field or a cell
- * field on single geometric cell type.
- * \return DataArrayInt * - the pointer to the field values array.
- */
-DataArrayInt *MEDFileIntField1TSWithoutSDA::getUndergroundDataArrayInt() const
-{
- const DataArrayInt *ret=_arr;
- if(ret)
- return const_cast<DataArrayInt *>(ret);
- else
- return 0;
-}
-
/*!
* Returns a pointer to the underground DataArrayInt instance and a
* sequence describing parameters of a support of each part of \a this field. The
if(_field_per_mesh[0]==0)
throw INTERP_KERNEL::Exception("MEDFileField1TSWithoutSDA::getUndergroundDataArrayExt : no field specified !");
_field_per_mesh[0]->getUndergroundDataArrayExt(entries);
- return getUndergroundDataArrayInt();
+ return getUndergroundDataArrayTemplate();
}
MEDFileAnyTypeField1TSWithoutSDA *MEDFileIntField1TSWithoutSDA::shallowCpy() const
return ret.retn();
}
-void MEDFileIntField1TSWithoutSDA::setArray(DataArray *arr)
-{
- if(!arr)
- {
- _nb_of_tuples_to_be_allocated=-1;
- _arr=0;
- return ;
- }
- DataArrayInt *arrC=dynamic_cast<DataArrayInt *>(arr);
- if(!arrC)
- throw INTERP_KERNEL::Exception("MEDFileIntField1TSWithoutSDA::setArray : the input not null array is not of type DataArrayInt !");
- else
- _nb_of_tuples_to_be_allocated=-3;
- arrC->incrRef();
- _arr=arrC;
-}
-
-DataArray *MEDFileIntField1TSWithoutSDA::createNewEmptyDataArrayInstance() const
-{
- return DataArrayInt::New();
-}
-
-DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt()
-{
- DataArrayInt *ret=_arr;
- if(ret)
- return ret;
- _arr=DataArrayInt::New();
- return _arr;
-}
-
-DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray()
-{
- return getOrCreateAndGetArrayInt();
-}
-
-const DataArrayInt *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArrayInt() const
-{
- const DataArrayInt *ret=_arr;
- if(ret)
- return ret;
- DataArrayInt *ret2=DataArrayInt::New();
- const_cast<MEDFileIntField1TSWithoutSDA *>(this)->_arr=DataArrayInt::New();
- return ret2;
-}
-
-const DataArray *MEDFileIntField1TSWithoutSDA::getOrCreateAndGetArray() const
-{
- return getOrCreateAndGetArrayInt();
-}
-
MEDFileAnyTypeField1TS::MEDFileAnyTypeField1TS()
{
}
DataArrayDouble *MEDFileField1TS::getUndergroundDataArray() const
{
- return contentNotNull()->getUndergroundDataArrayDouble();
+ return contentNotNull()->getUndergroundDataArrayTemplate();
}
DataArrayDouble *MEDFileField1TS::getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const
DataArrayInt *MEDFileIntField1TS::getUndergroundDataArray() const
{
- return contentNotNull()->getUndergroundDataArrayInt();
+ return contentNotNull()->getUndergroundDataArrayTemplate();
}
//= MEDFileAnyTypeFieldMultiTSWithoutSDA
#include "MEDFileUtilities.hxx"
#include "MCAuto.hxx"
+#include "MEDLoaderTraits.hxx"
+#include "MEDCouplingTraits.hxx"
#include "MEDCouplingRefCountObject.hxx"
#include "MEDCouplingFieldInt.hxx"
#include "MEDCouplingMemArray.hxx"
void getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId);
const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const;
- static MCAuto<MEDFileFieldPerMesh> Aggregate(const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo);
+ static MCAuto<MEDFileFieldPerMesh> Aggregate(int &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,int> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<int,int> > >& extractInfo);
private:
int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
class MEDFileIntField1TSWithoutSDA;
+ template<class T>
+ class MEDFileField1TSTemplateWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
+ {
+ protected:
+ MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,csit,iteration,order) { }
+ MEDFileField1TSTemplateWithoutSDA():MEDFileAnyTypeField1TSWithoutSDA() { }
+ public:
+ MEDLOADER_EXPORT void setArray(DataArray *arr);
+ MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
+ MEDLOADER_EXPORT typename Traits<T>::ArrayType *getOrCreateAndGetArrayTemplate();
+ MEDLOADER_EXPORT typename Traits<T>::ArrayType const *getOrCreateAndGetArrayTemplate() const;
+ MEDLOADER_EXPORT typename Traits<T>::ArrayType *getUndergroundDataArrayTemplate() const;
+ MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
+ MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
+ MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
+ MEDLOADER_EXPORT void aggregate(const typename std::vector< typename MLFieldTraits<T>::F1TSWSDAType const * >& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
+ protected:
+ MCAuto< typename Traits<T>::ArrayType > _arr;
+ };
+
/*!
* SDA is for Shared Data Arrays such as profiles.
*/
- class MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
+ class MEDFileField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA<double>
{
public:
MEDLOADER_EXPORT const char *getTypeStr() const;
- MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
- MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDouble() const;
MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax);
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const;
- MEDLOADER_EXPORT void setArray(DataArray *arr);
- MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
- MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
- MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
- MEDLOADER_EXPORT DataArrayDouble *getOrCreateAndGetArrayDouble();
- MEDLOADER_EXPORT const DataArrayDouble *getOrCreateAndGetArrayDouble() const;
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const;
- MEDLOADER_EXPORT void aggregate(const std::vector<const MEDFileField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
- protected:
- MCAuto< DataArrayDouble > _arr;
public:
static const char TYPE_STR[];
};
/*!
* SDA is for Shared Data Arrays such as profiles.
*/
- class MEDFileIntField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
+ class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA<int>
{
public:
MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA();
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const;
MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
MEDLOADER_EXPORT const char *getTypeStr() const;
- MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
- MEDLOADER_EXPORT void setArray(DataArray *arr);
- MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
- MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
- MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
- MEDLOADER_EXPORT DataArrayInt *getOrCreateAndGetArrayInt();
- MEDLOADER_EXPORT const DataArrayInt *getOrCreateAndGetArrayInt() const;
- MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayInt() const;
MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const;
- MEDLOADER_EXPORT void aggregate(const std::vector<const MEDFileIntField1TSWithoutSDA *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
protected:
MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
- protected:
- MCAuto< DataArrayInt > _arr;
public:
MEDLOADER_EXPORT static const char TYPE_STR[];
};
--- /dev/null
+// Copyright (C) 2007-2016 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 __MEDFILEFIELD_TXX__
+#define __MEDFILEFIELD_TXX__
+
+#include "MEDFileField.hxx"
+#include "MEDCouplingTraits.hxx"
+
+namespace MEDCoupling
+{
+ template<class T>
+ void MEDFileField1TSTemplateWithoutSDA<T>::setArray(DataArray *arr)
+ {
+ if(!arr)
+ {
+ _nb_of_tuples_to_be_allocated=-1;
+ _arr=0;
+ return ;
+ }
+ typename Traits<T>::ArrayType *arrC=dynamic_cast<typename Traits<T>::ArrayType *>(arr);
+ if(!arrC)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::setArray : the input not null array is not of type DataArrayDouble !");
+ else
+ _nb_of_tuples_to_be_allocated=-3;
+ arrC->incrRef();
+ _arr=arrC;
+ }
+
+ /*!
+ * Returns a pointer to the underground DataArrayTemplate<T> instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayTemplate<T> * - the pointer to the field values array.
+ */
+ template<class T>
+ DataArray *MEDFileField1TSTemplateWithoutSDA<T>::getOrCreateAndGetArray()
+ {
+ return getOrCreateAndGetArrayTemplate();
+ }
+
+ template<class T>
+ const DataArray *MEDFileField1TSTemplateWithoutSDA<T>::getOrCreateAndGetArray() const
+ {
+ return getOrCreateAndGetArrayTemplate();
+ }
+
+ template<class T>
+ DataArray *MEDFileField1TSTemplateWithoutSDA<T>::createNewEmptyDataArrayInstance() const
+ {
+ return Traits<T>::ArrayType::New();
+ }
+
+ template<class T>
+ typename Traits<T>::ArrayType const *MEDFileField1TSTemplateWithoutSDA<T>::getOrCreateAndGetArrayTemplate() const
+ {
+ typename Traits<T>::ArrayType const *ret(_arr);
+ if(ret)
+ return ret;
+ (const_cast< MEDFileField1TSTemplateWithoutSDA<T> *>(this))->_arr=Traits<T>::ArrayType::New();
+ return _arr;
+ }
+
+ template<class T>
+ typename Traits<T>::ArrayType *MEDFileField1TSTemplateWithoutSDA<T>::getOrCreateAndGetArrayTemplate()
+ {
+ typename Traits<T>::ArrayType *ret(_arr);
+ if(ret)
+ return ret;
+ _arr=Traits<T>::ArrayType::New();
+ return _arr;
+ }
+
+ /*!
+ * Returns a pointer to the underground DataArrayTemplate<T> instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayTemplate<T> * - the pointer to the field values array.
+ */
+ template<class T>
+ typename Traits<T>::ArrayType *MEDFileField1TSTemplateWithoutSDA<T>::getUndergroundDataArrayTemplate() const
+ {
+ typename Traits<T>::ArrayType const *ret(_arr);
+ if(ret)
+ return const_cast<typename Traits<T>::ArrayType *>(ret);
+ else
+ return 0;
+ }
+
+ /*!
+ * Returns a pointer to the underground DataArrayDouble instance. So the
+ * caller should not decrRef() it. This method allows for a direct access to the field
+ * values. This method is quite unusable if there is more than a nodal field or a cell
+ * field on single geometric cell type.
+ * \return DataArrayDouble * - the pointer to the field values array.
+ */
+ template<class T>
+ DataArray *MEDFileField1TSTemplateWithoutSDA<T>::getUndergroundDataArray() const
+ {
+ return getUndergroundDataArrayTemplate();
+ }
+
+ template<class T>
+ void MEDFileField1TSTemplateWithoutSDA<T>::aggregate(const std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts)
+ {
+ if(f1tss.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : empty vector !");
+ std::size_t sz(f1tss.size()),ii(0);
+ std::vector<const MEDFileFieldPerMesh *> pms;
+ std::vector<const DataArray *> das(sz);
+ for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,ii)
+ {
+ if(!*it)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : presence of null pointer in input vector !");
+ if((*it)->_field_per_mesh.empty())
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : no info !");
+ const typename Traits<T>::ArrayType *arr((*it)->getUndergroundDataArrayTemplate());
+ if(!arr)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : presence of null array !");
+ das[ii]=arr;
+ pms.push_back((*it)->_field_per_mesh[0]);
+ }
+ typename MLFieldTraits<T>::F1TSWSDAType const *refPt(f1tss[0]);
+ const DataArray *arr(refPt->getUndergroundDataArray());
+ int nbCompo(arr->getNumberOfComponents());
+ for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++)
+ {
+ const typename Traits<T>::ArrayType *myArr((*it)->getUndergroundDataArrayTemplate());
+ if(myArr->getNumberOfComponents()!=nbCompo)
+ throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : arrays must have same number of components !");
+ }
+ std::vector<std::pair< int, std::pair<int,int> > > extractInfo;
+ int start(0);
+ MCAuto<MEDFileFieldPerMesh> fpm(MEDFileFieldPerMesh::Aggregate(start,pms,dts,this,extractInfo));
+ _field_per_mesh.push_back(fpm);
+ int iteration,order;
+ double tv(f1tss[0]->getTime(iteration,order));
+ _iteration=iteration; _order=order; _dt=tv;
+ _arr=Traits<T>::ArrayType::New();
+ _arr->alloc(start,nbCompo); _arr->copyStringInfoFrom(*arr);
+ start=0;
+ for(std::vector<std::pair< int, std::pair<int,int> > >::const_iterator it=extractInfo.begin();it!=extractInfo.end();it++)
+ {
+ const DataArray *zeArr(das[(*it).first]);
+ _arr->setContigPartOfSelectedValuesSlice(start,zeArr,(*it).second.first,(*it).second.second,1);
+ start=(*it).second.second-(*it).second.first;
+ }
+ }
+}
+
+#endif