_nval=field->getArray()->getNumberOfTuples();
}
-MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid,type,profileIt);
+ return new MEDFileFieldPerMeshPerTypePerDisc(fath,fid,type,profileIt,ft);
}
MEDFileFieldPerMeshPerTypePerDisc *MEDFileFieldPerMeshPerTypePerDisc::New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId)
return new MEDFileFieldPerMeshPerTypePerDisc(fath,type,locId);
}
-MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField atype, int profileIt) throw(INTERP_KERNEL::Exception)
+MEDFileFieldPerMeshPerTypePerDisc::MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField atype, int profileIt, int ft) throw(INTERP_KERNEL::Exception)
try:_type(atype),_father(fath),_profile_it(profileIt)
{
INTERP_KERNEL::AutoPtr<char> locname=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
pflname,&profilesize,locname,&nbi);
_arr=DataArrayDouble::New();
_arr->alloc(_nval*nbi,infos.size());
- MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
- pflname,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(_arr->getPointer()));
+ switch(ft)
+ {
+ case 0:
+ {
+ MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
+ pflname,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>(_arr->getPointer()));
+ break;
+ }
+ case 1:
+ {
+ INTERP_KERNEL::AutoPtr<int> tmpp=new int[_nval*nbi*infos.size()];
+ MEDfieldValueWithProfileRd(fid,fieldName.c_str(),iteration,order,menti,mgeoti,MED_COMPACT_PFLMODE,
+ pflname,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,reinterpret_cast<unsigned char*>((int *)tmpp));
+ std::copy((const int *)tmpp,(const int *)tmpp+_nval*nbi*infos.size(),_arr->getPointer());
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("Error on array reading ! Unrecognized type of field ! Should be in FLOAT64 or INT32 !");
+ }
_profile=MEDLoaderBase::buildStringFromFortran(pflname,MED_NAME_SIZE);
_localization=MEDLoaderBase::buildStringFromFortran(locname,MED_NAME_SIZE);
if(type==ON_CELLS && !_localization.empty())
{
}
-void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMeshPerType::finishLoading(med_idt fid, TypeOfField type, int ft) throw(INTERP_KERNEL::Exception)
{
INTERP_KERNEL::NormalizedCellType geoType=getGeoType();
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
_field_pm_pt_pd.resize(nbProfiles);
for(int i=0;i<nbProfiles;i++)
{
- _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::New(this,fid,type,i+1);
+ _field_pm_pt_pd[i]=MEDFileFieldPerMeshPerTypePerDisc::New(this,fid,type,i+1,ft);
}
}
_field_pm_pt[pos]->assignNodeFieldProfile(pfl,field,glob);
}
-void MEDFileFieldPerMesh::finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception)
+void MEDFileFieldPerMesh::finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception)
{
INTERP_KERNEL::AutoPtr<char> meshName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
INTERP_KERNEL::AutoPtr<char> pflName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
_field_pm_pt.resize(_field_pm_pt.size()+1);
_field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,typmai2[i]);
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
- _field_pm_pt.back()->finishLoading(fid,ON_CELLS);
+ _field_pm_pt.back()->finishLoading(fid,ON_CELLS,ft);
}
nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE_ELEMENT,typmai[i],_mesh_csit,meshName,pflName,locName);
if(nbProfile>0)
_field_pm_pt.resize(_field_pm_pt.size()+1);
_field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,typmai2[i]);
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
- _field_pm_pt.back()->finishLoading(fid,ON_GAUSS_NE);
+ _field_pm_pt.back()->finishLoading(fid,ON_GAUSS_NE,ft);
}
}
int nbProfile=MEDfield23nProfile(fid,getName().c_str(),getIteration(),getOrder(),MED_NODE,MED_NONE,_mesh_csit,meshName,pflName,locName);
_field_pm_pt.resize(_field_pm_pt.size()+1);
_field_pm_pt.back()=MEDFileFieldPerMeshPerType::New(this,INTERP_KERNEL::NORM_ERROR);
_mesh_name=MEDLoaderBase::buildStringFromFortran(meshName,MED_NAME_SIZE+1);
- _field_pm_pt.back()->finishLoading(fid,ON_NODES);
+ _field_pm_pt.back()->finishLoading(fid,ON_NODES,ft);
}
}
return code;
}
-MEDFileField1TSWithoutDAS *MEDFileField1TSWithoutDAS::New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos)
+MEDFileField1TSWithoutDAS *MEDFileField1TSWithoutDAS::New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos)
{
- return new MEDFileField1TSWithoutDAS(fieldName,csit,iteration,order,infos);
+ return new MEDFileField1TSWithoutDAS(fieldName,csit,fieldtype,iteration,order,infos);
}
void MEDFileField1TSWithoutDAS::copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception)
for(int i=0;i<nmesh;i++)
_field_per_mesh[i]=MEDFileFieldPerMesh::New(this,i+1,meshnumdt,meshnumit);
for(int i=0;i<nmesh;i++)
- _field_per_mesh[i]->finishLoading(fid);
+ _field_per_mesh[i]->finishLoading(fid,_field_type);
}
std::vector<std::string> MEDFileField1TSWithoutDAS::getPflsReallyUsed2() const
return _field_per_mesh[0]->getUndergroundDataArrayExt(entries);
}
-MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order,
- const std::vector<std::string>& infos):_name(fieldName),_infos(infos),_csit(csit),_iteration(iteration),_order(order)
+MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int fieldtype, int iteration, int order,
+ const std::vector<std::string>& infos):_name(fieldName),_infos(infos),_csit(csit),_field_type(fieldtype),_iteration(iteration),_order(order)
{
}
-MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS()
+MEDFileField1TSWithoutDAS::MEDFileField1TSWithoutDAS():_csit(-1),_field_type(-1)
{
}
}
MEDFileField1TS::MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception)
-try:MEDFileField1TSWithoutDAS(fieldName,-1,iteration,order,std::vector<std::string>()),MEDFieldFieldGlobsReal(fileName)
+try:MEDFileField1TSWithoutDAS(fieldName,-1,-1,iteration,order,std::vector<std::string>()),MEDFieldFieldGlobsReal(fileName)
{
MEDFileUtilities::CheckFileForRead(fileName);
MEDFileUtilities::AutoFid fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
{
found=true;
_csit=i+1;
+ _field_type=MEDFileUtilities::TraduceFieldType(typcha);
}
else
dtits[i]=std::pair<int,int>(numdt,numit);
MEDFileField1TSWithoutDAS::setFieldProfile(field,mesh,meshDimRelToMax,profile,*this);
}
-MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
+MEDFileFieldMultiTSWithoutDAS *MEDFileFieldMultiTSWithoutDAS::New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
{
- return new MEDFileFieldMultiTSWithoutDAS(fid,fieldName,id,infos,nbOfStep);
+ return new MEDFileFieldMultiTSWithoutDAS(fid,fieldName,id,ft,infos,nbOfStep);
}
-MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS()
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS():_field_type(-1)
{
}
-MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(const char *fieldName):_name(fieldName)
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(const char *fieldName):_name(fieldName),_field_type(-1)
{
}
-MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
-try:_name(fieldName),_infos(infos)
+MEDFileFieldMultiTSWithoutDAS::MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception)
+try:_name(fieldName),_infos(infos),_field_type(ft)
{
finishLoading(fid,nbOfStep);
}
med_int meshIt=0,meshOrder=0;
med_float dt=0.0;
MEDfieldComputingStepMeshInfo(fid,_name.c_str(),i+1,&numdt,&numo,&dt,&meshIt,&meshOrder);
- _time_steps[i]=MEDFileField1TSWithoutDAS::New(_name.c_str(),i+1,numdt,numo,_infos);
+ _time_steps[i]=MEDFileField1TSWithoutDAS::New(_name.c_str(),i+1,_field_type,numdt,numo,_infos);
_time_steps[i]->finishLoading(fid);
}
}
if(found)
{
nbstep2=nbOfStep;
+ _field_type=_field_type=MEDFileUtilities::TraduceFieldType(typcha);
_infos.resize(ncomp);
for(int j=0;j<ncomp;j++)
_infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
med_bool localMesh;
int nbOfStep;
MEDfieldInfo(fid,i+1,nomcha,nomMaa,&localMesh,&typcha,comp,unit,dtunit,&nbOfStep);
+ int ft=MEDFileUtilities::TraduceFieldType(typcha);
std::vector<std::string> infos(ncomp);
for(int j=0;j<ncomp;j++)
infos[j]=MEDLoaderBase::buildUnionUnit((char *)comp+j*MED_SNAME_SIZE,MED_SNAME_SIZE,(char *)unit+j*MED_SNAME_SIZE,MED_SNAME_SIZE);
- _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i+1,infos,nbOfStep);
+ _fields[i]=MEDFileFieldMultiTSWithoutDAS::New(fid,nomcha,i+1,ft,infos,nbOfStep);
}
loadAllGlobals(fid);
}
class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt, int ft) throw(INTERP_KERNEL::Exception);
static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
void assignFieldNoProfile(int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void assignFieldProfile(const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void fillValues(int discId, int& startTupleId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries, double *vals) const;
static int ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception);
private:
- MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, med_idt fid, TypeOfField type, int profileIt, int ft) throw(INTERP_KERNEL::Exception);
MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt);
private:
TypeOfField _type;
void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
const MEDFileFieldPerMesh *getFather() const;
- void finishLoading(med_idt fid, TypeOfField type) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, TypeOfField type, int ft) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
void getDimension(int& dim) const;
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
void assignFieldNoProfileNoRenum(const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldNoProfile(const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
void assignNodeFieldProfile(const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFieldFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
- void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
+ void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception);
void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
std::vector< std::vector<const DataArrayDouble *> > getFieldSplitedByType(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 throw(INTERP_KERNEL::Exception);
const std::vector<std::string>& getInfo() const { return _infos; }
std::vector<std::string>& getInfo() { return _infos; }
//
- static MEDFileField1TSWithoutDAS *New(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ static MEDFileField1TSWithoutDAS *New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
virtual void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
std::vector<std::string> getPflsReallyUsed2() const;
protected:
int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception);
- MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
+ MEDFileField1TSWithoutDAS(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
public:
MEDFileField1TSWithoutDAS();
protected:
std::string _dt_unit;
std::vector<std::string> _infos;
std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh;
- int _csit;
+ //! only useable on reading
+ mutable int _csit;
+ //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
+ mutable int _field_type;
int _iteration;
int _order;
double _dt;
class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutDAS : public RefCountObject, public MEDFileWritable
{
public:
- static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
+ static MEDFileFieldMultiTSWithoutDAS *New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
int getNumberOfTS() const;
std::vector< std::pair<int,int> > getIterations() const;
std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
MEDFileFieldMultiTSWithoutDAS();
MEDFileFieldMultiTSWithoutDAS(const char *fieldName);
- MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
+ MEDFileFieldMultiTSWithoutDAS(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception);
void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception);
protected:
std::string _name;
std::vector<std::string> _infos;
+ //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
+ mutable int _field_type;
std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutDAS> > _time_steps;
};