-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+// 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
#include "MEDLoader.hxx"
#include "MEDLoaderBase.hxx"
#include "MEDFileUtilities.hxx"
+#include "MEDLoaderNS.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileMesh.hxx"
#include "MEDFileField.hxx"
#include "MEDCouplingMemArray.hxx"
#include "MEDCouplingFieldDouble.hxx"
#include "MEDCouplingGaussLocalization.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "MCAuto.hxx"
#include "InterpKernelAutoPtr.hxx"
#include <iterator>
#include <algorithm>
-/*! \class MEDLoader
- *
- * \brief Static class offering the "basic" API to read and write MED files/
- *
- * This class implements only static methods and offers the high level API to access MED files.
- * Take a look at \ref medloader for more details.
- *
- */
med_geometry_type typmai[MED_N_CELL_FIXED_GEO] = { MED_POINT1,
MED_SEG2,
using namespace MEDCoupling;
-/// @cond INTERNAL
-
-namespace MEDLoaderNS
-{
- int readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities);
- void dispatchElems(int nbOfElemCell, int nbOfElemFace, int& nbOfElem, med_entity_type& whichEntity);
- void writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch);
- med_int getIdFromMeshName(med_idt fid, const std::string& meshName, std::string& trueMeshName);
- std::vector<std::string> getMeshNamesFid(med_idt fid);
-}
-
-/// @endcond
-
-
/// @cond INTERNAL
/*!
int MEDLoaderNS::readUMeshDimFromFile(const std::string& fileName, const std::string& meshName, std::vector<int>& possibilities)
{
possibilities.clear();
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
int ret;
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
std::string MEDCoupling::MEDFileVersionStr()
{
- return std::string(MED_VERSION_STR);
+ const int SZ=20;
+ char buf[SZ];
+ std::fill(buf,buf+SZ,'\0');
+ const char START_EXPECTED[]="MED-";
+ med_err ret(MEDlibraryStrVersion(buf));
+ if(ret!=0)
+ throw INTERP_KERNEL::Exception("MEDFileVersionStr : fail to find version of MED file ! It looks very bad !");
+ std::string zeRet(buf);
+ std::size_t pos(zeRet.find(START_EXPECTED,0));
+ if(pos!=0)
+ {
+ std::ostringstream oss; oss << "MEDFileVersionStr : internal error ! The MEDFile returned version (\"" << zeRet << "\") has not the right pattern !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ return zeRet.substr(sizeof(START_EXPECTED)-1,std::string::npos);
+}
+
+std::string MEDCoupling::MEDFileVersionOfFileStr(const std::string& fileName)
+{
+#if MED_NUM_MAJEUR>=3 && MED_NUM_MINEUR>=2 && MED_NUM_RELEASE>=1
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ const int SZ=20;
+ const char START_EXPECTED[]="MED-";
+ char buf[SZ];
+ std::fill(buf,buf+SZ,'\0');
+ MEDFILESAFECALLERRD0(MEDfileStrVersionRd,(fid,buf));
+ std::string ret(buf);
+ std::size_t pos(ret.find(START_EXPECTED,0));
+ if(pos!=0)
+ {
+ std::ostringstream oss; oss << "MEDFileVersionOfFileStr : internal error ! The MEDFile returned version (\"" << ret << "\") has not the right pattern !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ return ret.substr(sizeof(START_EXPECTED)-1,std::string::npos);
+#else
+ std::ostringstream oss; oss << "MEDFileVersionOfFileStr : is implemented with MEDFile " << MEDFileVersionStr() << " ! If you need this feature please use version >= 3.2.1.";
+ throw INTERP_KERNEL::Exception(oss.str());
+#endif
}
void MEDCoupling::MEDFileVersion(int& major, int& minor, int& release)
{
- major=MED_NUM_MAJEUR;
- minor=MED_NUM_MINEUR;
- release=MED_NUM_RELEASE;
+ med_int majj,minn,rell;
+ med_err ret(MEDlibraryNumVersion(&majj,&minn,&rell));
+ if(ret!=0)
+ throw INTERP_KERNEL::Exception("MEDFileVersion : fail to call MEDlibraryNumVersion ! It looks very bad !");
+ major=majj;
+ minor=minn;
+ release=rell;
}
/*!
*/
std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > MEDCoupling::GetUMeshGlobalInfo(const std::string& fileName, const std::string& meshName, int &meshDim, int& spaceDim, int& numberOfNodes)
{
- CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
std::set<int> poss;
char nommaa[MED_NAME_SIZE+1];
char maillage_description[MED_COMMENT_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshNames(const std::string& fileName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- std::vector<std::string> ret=MEDLoaderNS::getMeshNamesFid(fid);
- return ret;
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ return MEDLoaderNS::getMeshNamesFid(fid);
}
std::vector< std::pair<std::string,std::string> > MEDCoupling::GetComponentsNamesOfField(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields(MEDnField(fid));
std::vector<std::string> fields(nbFields);
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetMeshNamesOnField(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
//
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetMeshFamiliesNames(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret(nfam);
char nomfam[MED_NAME_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshFamiliesNamesOnGroup(const std::string& fileName, const std::string& meshName, const std::string& grpName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
std::vector<std::string> MEDCoupling::GetMeshGroupsNamesOnFamily(const std::string& fileName, const std::string& meshName, const std::string& famName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
- med_int nfam=MEDnFamily(fid,meshName.c_str());
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
+ med_int nfam(MEDnFamily(fid,meshName.c_str()));
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
med_int numfam;
std::vector<std::string> MEDCoupling::GetMeshGroupsNames(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nfam=MEDnFamily(fid,meshName.c_str());
std::vector<std::string> ret;
char nomfam[MED_NAME_SIZE+1];
std::vector<MEDCoupling::TypeOfField> MEDCoupling::GetTypesOfField(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
std::vector<MEDCoupling::TypeOfField> ret;
- MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> fs(MEDFileAnyTypeFieldMultiTS::New(fileName,fieldName,false));
+ MCAuto<MEDFileAnyTypeFieldMultiTS> fs(MEDFileAnyTypeFieldMultiTS::New(fileName,fieldName,false));
if(fs->getMeshName()!=meshName)
{
std::ostringstream oss; oss << "GetTypesOfField : The field \"" << fieldName << "\" in file \"" << fileName << "\" is not lying on mesh \"" << meshName << "\"";
return ret;
for(int i=0;i<nbTS;i++)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TS> f1ts(fs->getTimeStepAtPos(i));
+ MCAuto<MEDFileAnyTypeField1TS> f1ts(fs->getTimeStepAtPos(i));
std::vector<MEDCoupling::TypeOfField> tof(f1ts->getTypesOfFieldAvailable());
for(std::vector<MEDCoupling::TypeOfField>::const_iterator it=tof.begin();it!=tof.end();it++)
if(std::find(ret.begin(),ret.end(),*it)==ret.end())
std::vector<std::string> MEDCoupling::GetAllFieldNames(const std::string& fileName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
med_field_type typcha;
for(int i=0;i<nbFields;i++)
std::vector<std::string> MEDCoupling::GetAllFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetCellFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector<std::string> MEDCoupling::GetNodeFieldNamesOnMesh(const std::string& fileName, const std::string& meshName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector<std::string> ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
char pflname[MED_NAME_SIZE+1]="";
char locname[MED_NAME_SIZE+1]="";
std::vector< std::pair< std::pair<int,int>, double> > MEDCoupling::GetAllFieldIterations(const std::string& fileName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::vector< std::pair< std::pair<int,int>, double > > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
double MEDCoupling::GetTimeAttachedOnFieldIteration(const std::string& fileName, const std::string& fieldName, int iteration, int order)
{
- MEDCoupling::CheckFileForRead(fileName);
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector< std::pair<int,int> > MEDCoupling::GetCellFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
std::vector< std::pair<int,int> > MEDCoupling::GetNodeFieldIterations(const std::string& fileName, const std::string& meshName, const std::string& fieldName)
{
- MEDCoupling::CheckFileForRead(fileName);
std::string meshNameCpp(meshName);
std::vector< std::pair<int,int> > ret;
- MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName.c_str(),MED_ACC_RDONLY);
+ MEDFileUtilities::AutoFid fid(MEDCoupling::OpenMEDFileForRead(fileName));
med_int nbFields=MEDnField(fid);
//
med_field_type typcha;
MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(mmuPtr)
MEDCoupling::MEDCouplingMesh *MEDCoupling::ReadMeshFromFile(const std::string& fileName, int meshDimRelToMax)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(mmuPtr)
MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& fileName, const std::string& meshName, int meshDimRelToMax)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFile(const std::string& fileName, int meshDimRelToMax)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromFamilies(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& fams)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
MEDCoupling::MEDCouplingUMesh *MEDCoupling::ReadUMeshFromGroups(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::vector<std::string>& grps)
{
MEDCoupling::CheckFileForRead(fileName);
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+ MCAuto<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
return std::vector<MEDCoupling::MEDCouplingFieldDouble *>();
MEDCoupling::CheckFileForRead(fileName);
std::vector<MEDCoupling::MEDCouplingFieldDouble *> ret(its.size());
- std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> > retSafe(its.size());
+ std::vector< MCAuto<MEDCouplingFieldDouble> > retSafe(its.size());
if(its.empty())
return ret;
//Retrieving mesh of rank 0 and field on rank 0 too.
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
+ MCAuto<MEDFileMesh> mm=MEDFileMesh::New(fileName,meshName);
MEDFileMesh *mmPtr(mm);
MEDFileUMesh *mmuPtr=dynamic_cast<MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
throw INTERP_KERNEL::Exception("ReadFieldsOnSameMesh : only unstructured mesh is managed !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m=mmuPtr->getMeshAtLevel(meshDimRelToMax);
+ MCAuto<MEDCouplingUMesh> m=mmuPtr->getMeshAtLevel(meshDimRelToMax);
const DataArrayInt *o2n=mmuPtr->getNumberFieldAtLevel(meshDimRelToMax);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m2(m->clone(true));
+ MCAuto<MEDCouplingUMesh> m2(m->clone(true));
if(o2n)
m2->renumberCells(o2n->begin(),true);
int i=0;
for(std::vector<std::pair<int,int> >::const_iterator it=its.begin();it!=its.end();it++,i++)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,(*it).first,(*it).second);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> retElt=ff->getFieldOnMeshAtLevel(type,m);
+ MCAuto<MEDFileField1TS> ff=MEDFileField1TS::New(fileName,fieldName,(*it).first,(*it).second);
+ MCAuto<MEDCouplingFieldDouble> retElt=ff->getFieldOnMeshAtLevel(type,m);
if(o2n)
retElt->renumberCells(o2n->begin(),true);
retElt->setMesh(m2);
MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldCell(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+ MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
MEDFileMesh *mPtr(mm);
MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_CELLS,m));
+ MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_CELLS,m));
if(muPtr)
{
const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldNode(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+ MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
MEDFileMesh *mPtr(mm);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
+ MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_NODES,m));
MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
if(ff->getPflsReallyUsed().empty())
{
else
{
DataArrayInt *pfl=0,*arr2=0;
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflSafe(pfl);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr2Safe(arr2);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> pflSorted(pflSafe->deepCpy()); pflSorted->sort(true);
+ MCAuto<DataArrayDouble> arr(ff->getFieldWithProfile(ON_NODES,meshDimRelToMax,mm,pfl));
+ MCAuto<DataArrayInt> pflSafe(pfl);
+ MCAuto<DataArrayInt> mp(m->getCellIdsFullyIncludedInNodeIds(pfl->begin(),pfl->end()));
+ MCAuto<MEDCouplingUMesh> mzip(static_cast<MEDCouplingUMesh *>(m->buildPartAndReduceNodes(mp->begin(),mp->end(),arr2)));
+ MCAuto<DataArrayInt> arr2Safe(arr2);
+ MCAuto<DataArrayInt> arr3(arr2->invertArrayO2N2N2O(mzip->getNumberOfNodes()));
+ MCAuto<DataArrayInt> pflSorted(pflSafe->deepCopy()); pflSorted->sort(true);
if(!arr3->isEqualWithoutConsideringStr(*pflSorted))
throw INTERP_KERNEL::Exception("ReadFieldNode : not implemented yet !");
if(!arr3->isEqualWithoutConsideringStr(*pflSafe))
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
+ MCAuto<DataArrayInt> o2n2(pflSafe->checkAndPreparePermutation());
+ MCAuto<DataArrayInt> n2o2(o2n2->invertArrayO2N2N2O(o2n2->getNumberOfTuples()));
mzip->renumberNodes(n2o2->begin(),n2o2->getNumberOfTuples());
arr->setName("");
ret->setArray(arr);
MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGauss(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+ MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
MEDFileMesh *mPtr(mm);
MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_PT,m));
+ MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_PT,m));
if(muPtr)
{
const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
MEDCoupling::MEDCouplingFieldDouble *MEDCoupling::ReadFieldGaussNE(const std::string& fileName, const std::string& meshName, int meshDimRelToMax, const std::string& fieldName, int iteration, int order)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
+ MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New(fileName,fieldName,iteration,order));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,meshName));
+ MCAuto<MEDCouplingMesh> m(mm->getMeshAtLevel(meshDimRelToMax,false));
MEDFileMesh *mPtr(mm);
MEDFileUMesh *muPtr=dynamic_cast<MEDFileUMesh *>(mPtr);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_NE,m));
+ MCAuto<MEDCouplingFieldDouble> ret(ff->getFieldOnMeshAtLevel(ON_GAUSS_NE,m));
if(muPtr)
{
const DataArrayInt *num(muPtr->getNumberFieldAtLevel(meshDimRelToMax));
const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(mesh));
if(um2)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*mmu);
mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
mmu->write(fileName,mod);
const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(mesh));
if(um3)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc(MEDFileCMesh::New());
+ MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New());
AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
mmc->write(fileName,mod);
const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(mesh));
if(um4)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
+ MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
mmc->write(fileName,mod);
if(!mesh)
throw INTERP_KERNEL::Exception("WriteUMesh : input mesh is null !");
int mod=writeFromScratch?2:0;
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*m);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mcpy(static_cast<MEDCouplingUMesh *>(mesh->deepCpy()));
+ MCAuto<MEDCouplingUMesh> mcpy(static_cast<MEDCouplingUMesh *>(mesh->deepCopy()));
m->setMeshAtLevel(0,mcpy,true);
m->write(fileName,mod);
}
std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*m);
m->setGroupsFromScratch(0,meshes,true);
m->setName(meshNameC);
void MEDCoupling::WriteUMeshes(const std::string& fileName, const std::vector<const MEDCoupling::MEDCouplingUMesh *>& meshes, bool writeFromScratch)
{
int mod=writeFromScratch?2:0;
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> m(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> m(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*m);
m->setMeshes(meshes,true);
m->write(fileName,mod);
void MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(const std::string& fileName, const MEDCoupling::MEDCouplingFieldDouble *f, bool writeFromScratch)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> ff(MEDFileField1TS::New());
+ MCAuto<MEDFileField1TS> ff(MEDFileField1TS::New());
AssignStaticWritePropertiesTo(*ff);
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
+ MCAuto<MEDCouplingFieldDouble> f2(f->deepCopy());
const MEDCouplingMesh *m(f2->getMesh());
const MEDCouplingUMesh *um(dynamic_cast<const MEDCouplingUMesh *>(m));
const MEDCoupling1GTUMesh *um2(dynamic_cast<const MEDCoupling1GTUMesh *>(m));
const MEDCouplingCMesh *um3(dynamic_cast<const MEDCouplingCMesh *>(m));
const MEDCouplingCurveLinearMesh *um4(dynamic_cast<const MEDCouplingCurveLinearMesh *>(m));
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm;
+ MCAuto<MEDFileMesh> mm;
int mod=writeFromScratch?2:0;
if(um)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*mmu);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(um->getRenumArrForMEDFileFrmt());
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples()));
+ MCAuto<DataArrayInt> o2n(um->getRenumArrForMEDFileFrmt());
+ MCAuto<DataArrayInt> n2o(o2n->invertArrayO2N2N2O(o2n->getNumberOfTuples()));
f2->renumberCells(o2n->begin(),false);
mmu->setMeshAtLevel(0,const_cast<MEDCouplingUMesh *>(static_cast<const MEDCouplingUMesh *>(f2->getMesh())));
mmu->setRenumFieldArr(0,n2o);
}
else if(um2)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileUMesh> mmu(MEDFileUMesh::New());
+ MCAuto<MEDFileUMesh> mmu(MEDFileUMesh::New());
AssignStaticWritePropertiesTo(*mmu);
mmu->setMeshAtLevel(0,const_cast<MEDCoupling1GTUMesh *>(um2));
ff->setFieldNoProfileSBT(f2);
}
else if(um3)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCMesh> mmc(MEDFileCMesh::New());
+ MCAuto<MEDFileCMesh> mmc(MEDFileCMesh::New());
AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCMesh *>(um3));
ff->setFieldNoProfileSBT(f2);
}
else if(um4)
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
+ MCAuto<MEDFileCurveLinearMesh> mmc(MEDFileCurveLinearMesh::New());
AssignStaticWritePropertiesTo(*mmc);
mmc->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(um4));
ff->setFieldNoProfileSBT(f2);
{
if(!f)
throw INTERP_KERNEL::Exception("WriteField : input field is NULL !");
- f->checkCoherency();
+ f->checkConsistencyLight();
int status=MEDLoaderBase::getStatusOfFile(fileName);
if(status!=MEDLoaderBase::EXIST_RW && status!=MEDLoaderBase::NOT_EXIST)
{
MEDLoaderNS::writeFieldWithoutReadingAndMappingOfMeshInFile(fileName,f,false);
else
{
- MEDCouplingAutoRefCountObjectPtr<MEDFileMesh> mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str()));
+ MCAuto<MEDFileMesh> mm(MEDFileMesh::New(fileName,f->getMesh()->getName().c_str()));
AssignStaticWritePropertiesTo(*mm);
const MEDFileMesh *mmPtr(mm);
const MEDFileUMesh *mmuPtr=dynamic_cast<const MEDFileUMesh *>(mmPtr);
if(!mmuPtr)
throw INTERP_KERNEL::Exception("WriteField : only umeshes are supported now !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
+ MCAuto<MEDCouplingFieldDouble> f2(f->deepCopy());
MEDCouplingUMesh *m=dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f2->getMesh()));
if(!m)
throw INTERP_KERNEL::Exception("WriteField : only umesh in input field supported !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=m->getRenumArrForMEDFileFrmt();
+ MCAuto<DataArrayInt> o2n=m->getRenumArrForMEDFileFrmt();
f2->renumberCells(o2n->begin(),false);
m=static_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f2->getMesh()));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mread=mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension());
+ MCAuto<MEDCouplingUMesh> mread=mmuPtr->getMeshAtLevel(m->getMeshDimension()-mm->getMeshDimension());
if(f2->getTypeOfField()!=ON_NODES)
{
m->tryToShareSameCoordsPermute(*mread,_EPS_FOR_NODE_COMP);
DataArrayInt *part=0;
bool b=mread->areCellsIncludedIn(m,_COMP_FOR_CELL,part);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> partSafe(part);
+ MCAuto<DataArrayInt> partSafe(part);
if(!b)
{
std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart) with the mesh you intend to write ! This is maybe due to a too strict policy ! Try with to lease it by calling SetCompPolicyForCell !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ MCAuto<MEDFileField1TS> f1ts(MEDFileField1TS::New());
AssignStaticWritePropertiesTo(*f1ts);
- if(part->isIdentity2(mread->getNumberOfCells()))
+ if(part->isIota(mread->getNumberOfCells()))
f1ts->setFieldNoProfileSBT(f2);
else
{
{
DataArrayInt *part=0;
bool b=mread->getCoords()->areIncludedInMe(m->getCoords(),_EPS_FOR_NODE_COMP,part);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> partSafe(part);
+ MCAuto<DataArrayInt> partSafe(part);
if(!b)
{
std::ostringstream oss; oss << "WriteField : The file \""<< fileName << "\" already contains a mesh named \""<< f->getMesh()->getName() << "\" and this mesh in the file is not compatible (a subpart regarding nodes) with the mesh you intend to write ! This is maybe due to a too strict epsilon ! Try with to lease it by calling SetEpsilonForNodeComp !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ MCAuto<MEDFileField1TS> f1ts(MEDFileField1TS::New());
AssignStaticWritePropertiesTo(*f1ts);
- if(part->isIdentity2(mread->getNumberOfNodes()))
+ if(part->isIota(mread->getNumberOfNodes()))
f1ts->setFieldNoProfileSBT(f2);
else
{
{
if(!f)
throw INTERP_KERNEL::Exception("WriteFieldUsingAlreadyWrittenMesh : input field is null !");
- f->checkCoherency();
+ f->checkConsistencyLight();
int status=MEDLoaderBase::getStatusOfFile(fileName);
if(status!=MEDLoaderBase::EXIST_RW)
{
std::ostringstream oss; oss << "File with name \'" << fileName << "\' has not valid permissions or not exists !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- MEDCouplingAutoRefCountObjectPtr<MEDFileField1TS> f1ts(MEDFileField1TS::New());
+ MCAuto<MEDFileField1TS> f1ts(MEDFileField1TS::New());
AssignStaticWritePropertiesTo(*f1ts);
MEDCouplingUMesh *m(dynamic_cast<MEDCouplingUMesh *>(const_cast<MEDCouplingMesh *>(f->getMesh())));
if(m)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n(m->getRenumArrForMEDFileFrmt());
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> f2(f->deepCpy());
+ MCAuto<DataArrayInt> o2n(m->getRenumArrForMEDFileFrmt());
+ MCAuto<MEDCouplingFieldDouble> f2(f->deepCopy());
f2->renumberCells(o2n->begin(),false);
f1ts->setFieldNoProfileSBT(f2);
}