-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020 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
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingFieldFloat.hxx"
-#include "MEDCouplingFieldInt.hxx"
+#include "MEDCouplingFieldInt32.hxx"
#include "MEDCouplingGaussLocalization.hxx"
#include "MEDCouplingTraits.hxx"
#include "MCAuto.hxx"
#include <numeric>
#include <iterator>
#include <algorithm>
-
+#include <memory>
med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
MED_SEG2,
INTERP_KERNEL::NORM_QPOLYG,
INTERP_KERNEL::NORM_POLYHED };
-med_geometry_type typmai3[34] = { MED_POINT1,//0
+med_geometry_type typmai3[INTERP_KERNEL::NORM_MAXTYPE] = { MED_POINT1,//0
MED_SEG2,//1
MED_SEG3,//2
MED_TRIA3,//3
MED_NONE,//29
MED_HEXA20,//30
MED_POLYHEDRON,//31
- MED_POLYGON2,//32
- MED_NONE//33
+ MED_POLYGON2//32
};
double _EPS_FOR_NODE_COMP=1.e-12;
/// @cond INTERNAL
+INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype)
+{
+ INTERP_KERNEL::NormalizedCellType result=INTERP_KERNEL::NORM_ERROR;
+ for(int i=0; i<MED_N_CELL_FIXED_GEO; i++)
+ {
+ if (typmai[i]==geotype)
+ {
+ result=typmai2[i];
+ break;
+ }
+ }
+ return result;
+}
+
/*!
* This method returns a first quick overview of mesh with name \a meshName into the file \a fileName.
* @param possibilities the relativeToMeshDim authorized to returned maxdim. This vector is systematically cleared at the begin of this method.
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
+// see reference : https://en.cppreference.com/w/cpp/iterator/iterator
+class MEDVectorStringIterator : public std::iterator< std::input_iterator_tag, long, long, const std::string*, std::string >
+{
+ long _num = 0;
+ char *_data = nullptr;
+public:
+ explicit MEDVectorStringIterator(long num , char *data) : _num(num),_data(data) {}
+ MEDVectorStringIterator& operator++() { ++_num; return *this;}
+ bool operator==(const MEDVectorStringIterator& other) const {return _num == other._num;}
+ bool operator!=(const MEDVectorStringIterator& other) const {return !(*this == other);}
+ reference operator*() const {return MEDLoaderBase::buildStringFromFortran(_data+_num*MED_LNAME_SIZE,MED_LNAME_SIZE);}
+};
+
+void MEDCoupling::GetFamiliesGroupsInfo(const std::string& fileName, const std::string& meshName, std::map<std::string,mcIdType>& families, std::map<std::string,std::vector<std::string>>& groupsOnFam)
+{
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ med_int nbFams(MEDnFamily(fid,meshName.c_str()));
+ char nomfam[MED_NAME_SIZE+1];
+ for(med_int i=0;i<nbFams;++i)
+ {
+ med_int nbGrps(MEDnFamilyGroup(fid,meshName.c_str(),i+1)),famId;
+ std::unique_ptr<char[]> gro{new char[MED_LNAME_SIZE*nbGrps+1]};
+ MEDFILESAFECALLERRD0(MEDfamilyInfo,(fid,meshName.c_str(),i+1,nomfam,&famId,gro.get()));
+ std::string fam(MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE));
+ families[fam] = FromMedInt<mcIdType>(famId);
+ std::vector<std::string> v(nbGrps);
+ std::copy(MEDVectorStringIterator(0,gro.get()),MEDVectorStringIterator(nbGrps,gro.get()),v.begin());
+ groupsOnFam[fam] = v;
+ }
+}
+
std::vector<std::string> MEDCoupling::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName)
{
std::vector<std::string> ret;
}
}
{
- MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+ MCAuto<MEDFileInt32Field1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileInt32Field1TS>(f));
if(f1.isNotNull())
{
- MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(f1->field(mesh));
- return MEDCoupling::DynamicCast<MEDCouplingFieldInt,MEDCouplingField>(ret);
+ MCAuto<MEDCoupling::MEDCouplingFieldInt32> ret(f1->field(mesh));
+ return MEDCoupling::DynamicCast<MEDCouplingFieldInt32,MEDCouplingField>(ret);
}
}
{
}
}
{
- MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+ MCAuto<MEDFileInt32Field1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileInt32Field1TS>(f));
if(f1.isNotNull())
{
- MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(ReadFieldCellLikeT<int>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+ MCAuto<MEDCoupling::MEDCouplingFieldInt32> ret(ReadFieldCellLikeT<int>(f1,type,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
return ret.retn();
}
}
}
}
{
- MCAuto<MEDFileIntField1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileIntField1TS>(f));
+ MCAuto<MEDFileInt32Field1TS> f1(MEDCoupling::DynamicCast<MEDFileAnyTypeField1TS,MEDFileInt32Field1TS>(f));
if(f1.isNotNull())
{
- MCAuto<MEDCoupling::MEDCouplingFieldInt> ret(ReadFieldNodeT<int>(f1,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
+ MCAuto<MEDCoupling::MEDCouplingFieldInt32> ret(ReadFieldNodeT<int>(f1,fileName,meshName,meshDimRelToMax,fieldName,iteration,order));
return ret.retn();
}
}
}
}
{
- const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt *>(f));
+ const MEDCoupling::MEDCouplingFieldInt32 *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt32 *>(f));
if(f1)
{
WriteFieldT<int>(fileName,f1,writeFromScratch);
return ;
}
{
- const MEDCoupling::MEDCouplingFieldInt *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt *>(f));
+ const MEDCoupling::MEDCouplingFieldInt32 *f1(dynamic_cast<const MEDCoupling::MEDCouplingFieldInt32 *>(f));
if(f1)
WriteFieldUsingAlreadyWrittenMeshT<int>(fileName,f1);
return ;