//=
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev()
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev():_is_internal(true)
{
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev):_is_internal(true)
{
// ids fields management
_cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
}
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities)
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities),_is_internal(true)
{
// ids fields management
_cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true;
}
}
+MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true)
+{
+}
+
void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes)
{
if(!pflNodes || !pflNodes->isAllocated())
_pfls[0]=cellIdsSafe;
}
-MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other)
-{
-}
-
//=
MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector<int>& levs)
if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts))
{
MEDCouplingAutoRefCountObjectPtr<MEDCMeshMultiLev> ret(new MEDCMeshMultiLev(*this));
+ ret->_is_internal=false;
if(nr)
{ nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
ret->_nb_entities[0]=pfl->getNumberOfTuples();
}
}
-std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays() const
+/*!
+ * \a param [out] isInternal if true the returned pointers are those in main data structure. If false those pointers have been built espacially for that method.
+ */
+std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const
{
+ isInternal=_is_internal;
std::size_t sz(_coords.size());
std::vector< DataArrayDouble * > ret(sz);
for(std::size_t i=0;i<sz;i++)
MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const
{
- const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction);
+ const DataArrayInt *pfl(0),*nr(_node_reduction);
+ if(!_pfls.empty())
+ pfl=_pfls[0];
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nnr;
std::vector<int> cgs,ngs(getNodeGridStructure());
cgs.resize(ngs.size());
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts));
MEDCouplingAutoRefCountObjectPtr<MEDCurveLinearMeshMultiLev> ret(new MEDCurveLinearMeshMultiLev(*this));
+ ret->_is_internal=false;
if(nr)
{ nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); }
ret->_nb_entities[0]=pfl->getNumberOfTuples();
}
}
-void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const
+void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const
{
+ isInternal=_is_internal;
nodeStrct=_structure;
const DataArrayDouble *coo(_coords);
if(!coo)
MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector<int>& lev);
MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
+ protected:
+ bool _is_internal;
};
class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
std::vector<int> getNodeGridStructure() const;
MEDMeshMultiLev *prepare() const;
- MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const;
+ MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays(bool& isInternal) const;
private:
MEDCMeshMultiLev(const MEDCMeshMultiLev& other);
MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities);
std::vector<int> getNodeGridStructure() const;
MEDMeshMultiLev *prepare() const;
- MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const;
+ MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct, bool& isInternal) const;
private:
MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other);
MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
{
PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception)
{
- std::vector< DataArrayDouble * > objs(self->buildVTUArrays());
+ bool isInternal;
+ std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal));
std::size_t sz(objs.size());
- PyObject *ret=PyList_New(sz);
+ PyObject *ret(PyTuple_New(2));
+ PyObject *ret0=PyList_New(sz);
for(std::size_t i=0;i<sz;i++)
- PyList_SetItem(ret,i,SWIG_NewPointerObj(SWIG_as_voidptr(objs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyList_SetItem(ret0,i,SWIG_NewPointerObj(SWIG_as_voidptr(objs[i]),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,0,ret0);
+ PyObject *ret1Py(isInternal?Py_True:Py_False);
+ Py_XINCREF(ret1Py);
+ PyTuple_SetItem(ret,1,ret1Py);
return ret;
}
}
{
DataArrayDouble *ret0(0);
std::vector<int> ret1;
- self->buildVTUArrays(ret0,ret1);
+ bool ret2;
+ self->buildVTUArrays(ret0,ret1,ret2);
std::size_t sz(ret1.size());
- PyObject *ret=PyTuple_New(2);
+ PyObject *ret=PyTuple_New(3);
PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 ));
PyObject *ret1Py=PyList_New(sz);
for(std::size_t i=0;i<sz;i++)
PyList_SetItem(ret1Py,i,SWIG_From_int(ret1[i]));
PyTuple_SetItem(ret,1,ret1Py);
+ PyObject *ret2Py(ret2?Py_True:Py_False);
+ Py_XINCREF(ret2Py);
+ PyTuple_SetItem(ret,2,ret2Py);
return ret;
}
}
fcscp=allFMTSLeavesPerCommonSupport[0][1]
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
- a,b=mml2.buildVTUArrays()
+ (a,b),c=mml2.buildVTUArrays()
+ self.assertTrue(c)# c is True here because the returned array is directly those coming from internal structure
self.assertTrue(a.isEqual(coordsX,1e-12))
self.assertTrue(b.isEqual(coordsY,1e-12))
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev))
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev)) # here the 2nd support is a part of CMesh that is also a CMesh -> CMesh not a UMesh
- a,b=mml2.buildVTUArrays()
+ (a,b),c=mml2.buildVTUArrays()
+ self.assertTrue(not c)# c is False because this a sub support specialy built for buildVTUArrays
self.assertTrue(a.isEqual(coordsX[[2,3,4]],1e-12))
self.assertTrue(b.isEqual(coordsY,1e-12))
a6,a7=mml2.retrieveFamilyIdsOnCells()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev))
- a,b=mml2.buildVTUArrays()
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(c)#True here because a is directly coming from internal data without copy
self.assertTrue(a.isEqual(a0Exp,1e-12))
self.assertEqual(b,[5,3])
a6,a7=mml2.retrieveFamilyIdsOnCells()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev)) # here the 2nd support is a part of CMesh that is also a CMesh -> CMesh not a UMesh
- a,b=mml2.buildVTUArrays()
+ a,b,c=mml2.buildVTUArrays()
+ self.assertTrue(not c)#False here because a is the result of a computation not the internal strucutre
self.assertTrue(a.isEqual(a0Exp[pfl2],1e-12))
self.assertEqual(b,[3,3])
a6,a7=mml2.retrieveFamilyIdsOnCells()
mml=fcscp.buildFromScratchDataSetSupport(0,fields)
mml2=mml.prepare()
self.assertTrue(isinstance(mml2,MEDCMeshMultiLev))
- a,b,c=mml2.buildVTUArrays()
+ (a,b,c),d=mml2.buildVTUArrays()
+ self.assertTrue(d)#d is True because the a,b and c are directly those in the internal data structure
self.assertTrue(a.isEqual(arr0,1e-12))
self.assertTrue(b.isEqual(arr1,1e-12))
self.assertTrue(c.isEqual(arr2,1e-12))