return MEDMeshMultiLev::New(mst->getTheMesh(),a0,a1,a2);
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStructItem::getGeoTypes(const MEDFileMesh *m) const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ if(_type==ON_NODES)
+ {
+ if(!_items.empty() && _items[0].getPflName().empty())
+ {
+ if(m)
+ return m->getAllGeoTypes();
+ else
+ return ret;
+ }
+ else
+ return ret;
+ }
+ for(std::vector< MEDFileField1TSStructItem2 >::const_iterator it=_items.begin();it!=_items.end();it++)
+ {
+ INTERP_KERNEL::NormalizedCellType elt((*it).getGeo());
+ std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it2(std::find(ret.begin(),ret.end(),elt));
+ if(it2==ret.end())
+ ret.push_back(elt);
+ }
+ return ret;
+}
+
MEDFileField1TSStructItem MEDFileField1TSStructItem::BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt)
{
TypeOfField atype;
return true;
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileField1TSStruct::getGeoTypes(const MEDFileMesh *m) const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ for(std::vector<MEDFileField1TSStructItem>::const_iterator it=_already_checked.begin();it!=_already_checked.end();it++)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret2((*it).getGeoTypes(m));
+ for(std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator it2=ret2.begin();it2!=ret2.end();it2++)
+ {
+ if(*it2==INTERP_KERNEL::NORM_ERROR)
+ continue;
+ std::vector<INTERP_KERNEL::NormalizedCellType>::iterator it3(std::find(ret.begin(),ret.end(),*it2));
+ if(it3==ret.end())
+ ret.push_back(*it2);
+ }
+ }
+ return ret;
+}
+
/*!
* Returns true if presence in \a this of discretization ON_CELLS, ON_GAUSS_PT, ON_GAUSS_NE.
* If true is returned the pos of the easiest is returned. The easiest is the first element in \a this having the less splitted subparts.
const MEDFileField1TSStruct *objRef(_f1ts_cmps[timeStepId-1]);
return objRef->isDataSetSupportFastlyEqualTo(*obj,globs);
}
+
+int MEDFileFastCellSupportComparator::getNumberOfTS() const
+{
+ return _f1ts_cmps.size();
+}
+
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileFastCellSupportComparator::getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const
+{
+ if(timeStepId<0 || timeStepId>=(int)_f1ts_cmps.size())
+ {
+ std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " is not in [0," << _f1ts_cmps.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ const MEDFileField1TSStruct *elt(_f1ts_cmps[timeStepId]);
+ if(!elt)
+ {
+ std::ostringstream oss; oss << "MEDFileFastCellSupportComparator::getGeoTypesAt : requested time step id #" << timeStepId << " points to a NULL pointer !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ return elt->getGeoTypes(m);
+}
MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const;
bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const;
bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const;
+ std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes(const MEDFileMesh *m) const;
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
private:
bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const;
+ std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypes(const MEDFileMesh *m) const;
private:
MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
bool presenceOfCellDiscr(int& pos) const;
MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
+ MEDLOADER_EXPORT int getNumberOfTS() const;
+ MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const;
bool isEqual(const MEDFileAnyTypeFieldMultiTS *other);
bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other);
std::size_t getHeapMemorySizeWithoutChildren() const;
}
}
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileMesh::getAllGeoTypes() const
+{
+ std::vector<int> levs(getNonEmptyLevels());
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ for(std::vector<int>::const_iterator it=levs.begin();it!=levs.end();it++)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> elts(getGeoTypesAtLevel(*it));
+ ret.insert(ret.end(),elts.begin(),elts.end());
+ }
+ return ret;
+}
+
std::vector<int> MEDFileMesh::getDistributionOfTypes(int meshDimRelToMax) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingMesh> mLev(getGenMeshAtLevel(meshDimRelToMax));
MEDLOADER_EXPORT double getTimeValue() const { return _time; }
MEDLOADER_EXPORT void setTimeUnit(const std::string& unit) { _dt_unit=unit; }
MEDLOADER_EXPORT std::string getTimeUnit() const { return _dt_unit; }
+ MEDLOADER_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
MEDLOADER_EXPORT virtual int getNumberOfNodes() const = 0;
MEDLOADER_EXPORT virtual std::vector<INTERP_KERNEL::NormalizedCellType> getGeoTypesAtLevel(int meshDimRelToMax) const = 0;
MEDLOADER_EXPORT virtual std::vector<int> getNonEmptyLevels() const = 0;
return res;
}
+ PyObject *getAllGeoTypes() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result(self->getAllGeoTypes());
+ std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res=PyList_New(result.size());
+ for(int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
+
PyObject *getGeoTypesAtLevel(int meshDimRelToMax) const throw(INTERP_KERNEL::Exception)
{
std::vector<INTERP_KERNEL::NormalizedCellType> result(self->getGeoTypesAtLevel(meshDimRelToMax));
static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
+ int getNumberOfTS() const throw(INTERP_KERNEL::Exception);
protected:
~MEDFileFastCellSupportComparator();
+ public:
+ %extend
+ {
+ PyObject *getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< INTERP_KERNEL::NormalizedCellType > result(self->getGeoTypesAt(timeStepId,m));
+ std::vector< INTERP_KERNEL::NormalizedCellType >::const_iterator iL(result.begin());
+ PyObject *res(PyList_New(result.size()));
+ for(int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
+ }
};
}
mst=MEDFileMeshStruct.New(ms[0])
#
fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ self.assertEqual([NORM_QUAD4],fcscp.getGeoTypesAt(0,ms[0]))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
mst=MEDFileMeshStruct.New(ms[0])
#
fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ self.assertEqual([NORM_TRI3,NORM_SEG2],fcscp.getGeoTypesAt(0,ms[0]))#contains all cell types of underlying mesh because only nodes with no profiles
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
mst=MEDFileMeshStruct.New(ms[0])
# emulate first click
fcscp=allFMTSLeavesPerCommonSupport1[0][1]
+ self.assertEqual([NORM_SEG2],fcscp.getGeoTypesAt(0,ms[0]))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))
del fff0
# emulate second click
fcscp=allFMTSLeavesPerCommonSupport1[1][1]
+ self.assertEqual([NORM_QUAD4],fcscp.getGeoTypesAt(0,ms[0]))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDUMeshMultiLev))