using namespace MEDCoupling;
+MEDFileUMeshPerTypeCommon *MEDFileUMeshPerTypeCommon::New()
+{
+ return new MEDFileUMeshPerTypeCommon;
+}
+
+void MEDFileUMeshPerTypeCommon::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int curNbOfElem, med_geometry_type geoElt,
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
+{
+ med_bool changement,transformation;
+ _fam=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellFamilyFieldReading())
+ {
+ _fam=DataArrayInt::New();
+ _fam->alloc(curNbOfElem,1);
+ if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
+ std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
+ }
+ }
+ _num=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellNumFieldReading())
+ {
+ _num=DataArrayInt::New();
+ _num->alloc(curNbOfElem,1);
+ if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
+ _num=0;
+ }
+ }
+ _names=0;
+ if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0)
+ {
+ if(!mrs || mrs->isCellNameFieldReading())
+ {
+ _names=DataArrayAsciiChar::New();
+ _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
+ if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
+ _names=0;
+ else
+ _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
+ }
+ }
+}
+
+std::size_t MEDFileUMeshPerTypeCommon::getHeapMemorySizeWithoutChildren() const
+{
+ return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDFileUMeshPerTypeCommon::getDirectChildrenWithNull() const
+{
+ std::vector<const BigMemoryObject *> ret;
+ ret.push_back((const DataArrayInt *)_num);
+ ret.push_back((const DataArrayInt *)_fam);
+ ret.push_back((const DataArrayAsciiChar *)_names);
+ return ret;
+}
+
MEDFileUMeshPerType *MEDFileUMeshPerType::New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs)
{
med_entity_type whichEntity;
std::size_t MEDFileUMeshPerType::getHeapMemorySizeWithoutChildren() const
{
- return 0;
+ return MEDFileUMeshPerTypeCommon::getHeapMemorySizeWithoutChildren()+0;
}
std::vector<const BigMemoryObject *> MEDFileUMeshPerType::getDirectChildrenWithNull() const
{
- std::vector<const BigMemoryObject *> ret;
+ std::vector<const BigMemoryObject *> ret(MEDFileUMeshPerTypeCommon::getDirectChildrenWithNull());
ret.push_back((const MEDCoupling1GTUMesh *)_m);
- ret.push_back((const DataArrayInt *)_num);
- ret.push_back((const DataArrayInt *)_fam);
- ret.push_back((const DataArrayAsciiChar *)_names);
return ret;
}
}
MEDFileUMeshPerType::MEDFileUMeshPerType(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
- med_entity_type entity, MEDFileMeshReadSelector *mrs):_entity(entity)
+ med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
int curNbOfElem(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_CONNECTIVITY,MED_NODAL,&changement,&transformation));
MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName,dt,it,entity,geoElt,MED_NODAL,MED_FULL_INTERLACE,conn->getPointer()));
std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
mc->setNodalConnectivity(conn);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,geoElt,entity,mrs);
}
void MEDFileUMeshPerType::loadPartStaticType(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType type,
loadPartOfCellCommonPart(fid,mName,strt,end,step,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
}
-void MEDFileUMeshPerType::loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt,
- med_entity_type entity, MEDFileMeshReadSelector *mrs)
-{
- med_bool changement,transformation;
- _fam=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellFamilyFieldReading())
- {
- _fam=DataArrayInt::New();
- _fam->alloc(curNbOfElem,1);
- if(MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,entity,geoElt,_fam->getPointer())!=0)
- std::fill(_fam->getPointer(),_fam->getPointer()+curNbOfElem,0);
- }
- }
- _num=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellNumFieldReading())
- {
- _num=DataArrayInt::New();
- _num->alloc(curNbOfElem,1);
- if(MEDmeshEntityNumberRd(fid,mName,dt,it,entity,geoElt,_num->getPointer())!=0)
- _num=0;
- }
- }
- _names=0;
- if(MEDmeshnEntity(fid,mName,dt,it,entity,geoElt,MED_NAME,MED_NODAL,&changement,&transformation)>0)
- {
- if(!mrs || mrs->isCellNameFieldReading())
- {
- _names=DataArrayAsciiChar::New();
- _names->alloc(curNbOfElem+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
- if(MEDmeshEntityNameRd(fid,mName,dt,it,entity,geoElt,_names->getPointer())!=0)
- _names=0;
- else
- _names->reAlloc(curNbOfElem);//not a bug to avoid the memory corruption due to last \0 at the end
- }
- }
-}
-
void MEDFileUMeshPerType::loadPartOfCellCommonPart(med_idt fid, const char *mName, int strt, int stp, int step, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs)
{
med_bool changement,transformation;
std::transform(conn->begin(),conn->end(),conn->getPointer(),std::bind2nd(std::plus<int>(),-1));
std::transform(connI->begin(),connI->end(),connI->getPointer(),std::bind2nd(std::plus<int>(),-1));
mc->setNodalConnectivity(conn,connI);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,geoElt,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,geoElt,entity,mrs);
}
void MEDFileUMeshPerType::loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
}
}
mc->setNodalConnectivity(conn,connI);
- loadCommonPart(fid,mName,dt,it,mdim,curNbOfElem,MED_POLYHEDRON,entity,mrs);
+ loadCommonPart(fid,mName,dt,it,curNbOfElem,MED_POLYHEDRON,entity,mrs);
}
void MEDFileUMeshPerType::Write(med_idt fid, const std::string& mname, int mdim, const MEDCoupling1GTUMesh *m, const DataArrayInt *fam, const DataArrayInt *num, const DataArrayAsciiChar *names)
class MEDCouplingUMesh;
class MEDFileMeshReadSelector;
- class MEDFileUMeshPerType : public RefCountObject
+ class MEDFileUMeshPerTypeCommon : public RefCountObject
+ {
+ public:
+ static MEDFileUMeshPerTypeCommon *New();
+ void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int curNbOfElem, med_geometry_type geoElt,
+ med_entity_type entity, MEDFileMeshReadSelector *mrs);
+ std::size_t getHeapMemorySizeWithoutChildren() const;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
+ protected:
+ MCAuto<DataArrayInt> _num;
+ MCAuto<DataArrayInt> _fam;
+ MCAuto<DataArrayAsciiChar> _names;
+ };
+
+ class MEDFileUMeshPerType : public MEDFileUMeshPerTypeCommon
{
public:
static MEDFileUMeshPerType *New(med_idt fid, const char *mName, int dt, int it, int mdim, med_geometry_type geoElt, INTERP_KERNEL::NormalizedCellType geoElt2, MEDFileMeshReadSelector *mrs);
med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPolyh(med_idt fid, const char *mName, int dt, int it, int mdim, int connFaceLgth, med_geometry_type geoElt,
med_entity_type entity, MEDFileMeshReadSelector *mrs);
- void loadCommonPart(med_idt fid, const char *mName, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
void loadPartOfCellCommonPart(med_idt fid, const char *mName, int strt, int stp, int step, int dt, int it, int mdim, int curNbOfElem, med_geometry_type geoElt, med_entity_type entity, MEDFileMeshReadSelector *mrs);
private:
MCAuto<MEDCoupling1GTUMesh> _m;
- MCAuto<DataArrayInt> _num;
- MCAuto<DataArrayInt> _fam;
- MCAuto<DataArrayAsciiChar> _names;
MCAuto<PartDefinition> _pd;
- med_entity_type _entity;
};
}
#include "MEDLoaderBase.hxx"
#include "MEDFileSafeCaller.txx"
#include "MEDFileMeshReadSelector.hxx"
+#include "MEDFileStructureElement.hxx"
+#include "MEDFileMeshSupport.hxx"
#include "MEDCouplingUMesh.hxx"
if(m)
m->setCoords(coords);
}
+
+MEDFileEltStruct4Mesh *MEDFileEltStruct4Mesh::New(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ return new MEDFileEltStruct4Mesh(fid,mName,dt,it,iterOnStEltOfMesh,mrs);
+}
+
+std::size_t MEDFileEltStruct4Mesh::getHeapMemorySizeWithoutChildren() const
+{
+ return _geo_type_name.capacity();
+}
+
+std::vector<const MEDCoupling::BigMemoryObject*> MEDFileEltStruct4Mesh::getDirectChildrenWithNull() const
+{
+ std::vector<const MEDCoupling::BigMemoryObject*> ret;
+ ret.push_back(_conn);
+ ret.push_back(_common);
+ return ret;
+}
+
+MEDFileEltStruct4Mesh::MEDFileEltStruct4Mesh(med_idt fid, const std::string& mName, int dt, int it, int iterOnStEltOfMesh, MEDFileMeshReadSelector *mrs)
+{
+ med_geometry_type geoType;
+ INTERP_KERNEL::AutoPtr<char> geoTypeName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
+ MEDFILESAFECALLERRD0(MEDmeshEntityInfo,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,iterOnStEltOfMesh+1,geoTypeName,&geoType));
+ _geo_type=geoType;
+ _geo_type_name=MEDLoaderBase::buildStringFromFortran(geoTypeName,MED_NAME_SIZE);
+ int nCells(0);
+ {
+ med_bool chgt=MED_FALSE,trsf=MED_FALSE;
+ nCells=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,geoType,MED_CONNECTIVITY,MED_NODAL,&chgt,&trsf);
+ }
+ MCAuto<MEDFileMeshSupports> mss(MEDFileMeshSupports::New(fid));
+ MCAuto<MEDFileStructureElements> mse(MEDFileStructureElements::New(fid,mss));
+ int nbOfNodesPerCell(mse->getNumberOfNodesPerCellOf(_geo_type_name));
+ _conn=DataArrayInt::New(); _conn->alloc(nCells,nbOfNodesPerCell);
+ MEDFILESAFECALLERRD0(MEDmeshElementConnectivityRd,(fid,mName.c_str(),dt,it,MED_STRUCT_ELEMENT,_geo_type,MED_NODAL,MED_FULL_INTERLACE,_conn->getPointer()));
+ _common=MEDFileUMeshPerTypeCommon::New();
+ _common->loadCommonPart(fid,mName.c_str(),dt,it,nCells,geoType,MED_STRUCT_ELEMENT,mrs);
+ //MEDFILESAFECALLERRD0(MEDmeshElementRd,(mName.c_str(),dt,it,MED_STRUCT_ELEMENT,geoType,MED_NODAL,MED_FULL_INTERLACE,conn,));
+}