%newobject ParaMEDMEM::MEDCouplingMesh::buildUnstructured;
%newobject ParaMEDMEM::MEDCouplingMesh::MergeMeshes;
%newobject ParaMEDMEM::MEDCouplingPointSet::zipCoordsTraducer;
+%newobject ParaMEDMEM::MEDCouplingPointSet::findBoundaryNodes;
%newobject ParaMEDMEM::MEDCouplingPointSet::buildBoundaryMesh;
%newobject ParaMEDMEM::MEDCouplingPointSet::MergeNodesArray;
%newobject ParaMEDMEM::MEDCouplingPointSet::BuildInstanceFromMeshType;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildExtrudedMesh;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes;
%newobject ParaMEDMEM::MEDCouplingUMesh::MergeUMeshesOnSameCoords;
+%newobject ParaMEDMEM::MEDCouplingUMesh::ComputeSpreadZoneGradually;
%newobject ParaMEDMEM::MEDCouplingUMesh::buildNewNumberingFromCommNodesFrmt;
%newobject ParaMEDMEM::MEDCouplingUMesh::rearrange2ConsecutiveCellTypes;
%newobject ParaMEDMEM::MEDCouplingUMesh::sortCellsInMEDFileFrmt;
const std::vector<std::string>& littleStrings) throw(INTERP_KERNEL::Exception);
virtual void getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps, std::vector<int>& elems) throw(INTERP_KERNEL::Exception) = 0;
virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception) = 0;
+ virtual DataArrayInt *findBoundaryNodes() const = 0;
%extend
{
std::string __str__() const
return convertMesh(ret, SWIG_POINTER_OWN | 0 );
}
}
- PyObject *findBoundaryNodes() const throw(INTERP_KERNEL::Exception)
- {
- std::vector<int> nodes;
- self->findBoundaryNodes(nodes);
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc((int)nodes.size(),1);
- std::copy(nodes.begin(),nodes.end(),ret->getPointer());
- return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
- }
+
void renumberNodes(PyObject *li, int newNbOfNodes) throw(INTERP_KERNEL::Exception)
{
void *da=0;
return SWIG_NewPointerObj(SWIG_as_voidptr(ret),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 );
}
+ void duplicateNodesInCoords(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return self->duplicateNodesInCoords(&singleVal,&singleVal+1);
+ case 2:
+ return self->duplicateNodesInCoords(&multiVal[0],&multiVal[0]+multiVal.size());
+ case 4:
+ return self->duplicateNodesInCoords(daIntTyypp->begin(),daIntTyypp->end());
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::duplicateNodesInCoords : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
static void Rotate2DAlg(PyObject *center, double angle, int nbNodes, PyObject *coords) throw(INTERP_KERNEL::Exception)
{
int sz;
static MEDCouplingUMesh *Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception);
+ static DataArrayInt *ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception);
%extend {
std::string __str__() const
{
}
}
+ void __setitem__(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ int nbc=self->getNumberOfCells();
+ convertObjToPossibleCpp2(li,nbc,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ if(singleVal>=nbc)
+ {
+ std::ostringstream oss;
+ oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(singleVal>=0)
+ {
+ self->setPartOfMySelf(&singleVal,&singleVal+1,otherOnSameCoordsThanThis);
+ break;
+ }
+ else
+ {
+ if(nbc+singleVal>0)
+ {
+ int tmp=nbc+singleVal;
+ self->setPartOfMySelf(&tmp,&tmp+1,otherOnSameCoordsThanThis);
+ break;
+ }
+ else
+ {
+ std::ostringstream oss;
+ oss << "Requesting for cell id " << singleVal << " having only " << nbc << " cells !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ case 2:
+ {
+ self->setPartOfMySelf(&multiVal[0],&multiVal[0]+multiVal.size(),otherOnSameCoordsThanThis);
+ break;
+ }
+ case 3:
+ {
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::Range(slic.first,slic.second.first,slic.second.second);
+ self->setPartOfMySelf(d0->begin(),d0->end(),otherOnSameCoordsThanThis);
+ break;
+ }
+ case 4:
+ {
+ if(!daIntTyypp)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__setitem__ : null instance has been given in input !");
+ daIntTyypp->checkAllocated();
+ self->setPartOfMySelf(daIntTyypp->begin(),daIntTyypp->end(),otherOnSameCoordsThanThis);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::__setitem__ : unrecognized type in input ! Possibilities are : int, list or tuple of int DataArrayInt instance !");
+ }
+ }
+
void insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, PyObject *li) throw(INTERP_KERNEL::Exception)
{
int sz;
return ret;
}
+ PyObject *findNodesToDuplicate(MEDCouplingUMesh& otherDimM1OnSameCoords) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *tmp0=0,*tmp1=0;
+ self->findNodesToDuplicate(otherDimM1OnSameCoords,tmp0,tmp1);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(tmp0),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(tmp1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ void duplicateNodes(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return self->duplicateNodes(&singleVal,&singleVal+1);
+ case 2:
+ return self->duplicateNodes(&multiVal[0],&multiVal[0]+multiVal.size());
+ case 4:
+ return self->duplicateNodes(daIntTyypp->begin(),daIntTyypp->end());
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::duplicateNodes : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
+ void duplicateNodesInConn(PyObject *li, int offset) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(li,self->getNumberOfNodes(),sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return self->duplicateNodesInConn(&singleVal,&singleVal+1,offset);
+ case 2:
+ return self->duplicateNodesInConn(&multiVal[0],&multiVal[0]+multiVal.size(),offset);
+ case 4:
+ return self->duplicateNodesInConn(daIntTyypp->begin(),daIntTyypp->end(),offset);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::duplicateNodesInConn : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
void renumberNodesInConn(PyObject *li) throw(INTERP_KERNEL::Exception)
{
void *da=0;
return ret;
}
+ static PyObject *AggregateSortedByTypeMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
+ convertPyObjToVecUMeshesCst(ms,meshes);
+ DataArrayInt *ret1=0,*ret2=0;
+ MEDCouplingUMesh *ret0=MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(meshes,ret1,ret2);
+ PyObject *ret=PyTuple_New(3);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__MEDCouplingUMesh, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(ret1),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,2,SWIG_NewPointerObj(SWIG_as_voidptr(ret2),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
static PyObject *MergeUMeshesOnSameCoords(PyObject *ms) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh *> meshes;
MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(meshes,eps);
}
+ static bool RemoveIdsFromIndexedArrays(PyObject *li, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval=0) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ if(!arrIndx)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : null pointer as arrIndex !");
+ convertObjToPossibleCpp2(li,arrIndx->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&singleVal,&singleVal+1,arr,arrIndx,offsetForRemoval);
+ case 2:
+ return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arr,arrIndx,offsetForRemoval);
+ case 4:
+ return MEDCouplingUMesh::RemoveIdsFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arr,arrIndx,offsetForRemoval);
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
+ static PyObject *ExtractFromIndexedArrays(PyObject *li, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : null pointer as arrIndxIn !");
+ convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingUMesh::ExtractFromIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ case 2:
+ {
+ MEDCouplingUMesh::ExtractFromIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ case 4:
+ {
+ MEDCouplingUMesh::ExtractFromIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,arrOut,arrIndexOut);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static PyObject *SetPartOfIndexedArrays(PyObject *li,
+ const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *arrOut=0,*arrIndexOut=0;
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : null pointer as arrIndex !");
+ convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArrays(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ case 2:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArrays(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ case 4:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArrays(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex,arrOut,arrIndexOut);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArrays : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(arrOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(arrIndexOut),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
+ static void SetPartOfIndexedArraysSameIdx(PyObject *li, DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ const DataArrayInt *srcArr, const DataArrayInt *srcArrIndex) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ if(!arrIndxIn)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : null pointer as arrIndex !");
+ convertObjToPossibleCpp2(li,arrIndxIn->getNumberOfTuples()-1,sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&singleVal,&singleVal+1,arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ case 2:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(&multiVal[0],&multiVal[0]+multiVal.size(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ case 4:
+ {
+ MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx(daIntTyypp->begin(),daIntTyypp->end(),arrIn,arrIndxIn,srcArr,srcArrIndex);
+ break;
+ }
+ default:
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception)
{
std::vector<int> cells;
return ret;
}
+ PyObject *computeNeighborsOfCellsAdv(const DataArrayInt *desc, const DataArrayInt *descI, const DataArrayInt *revDesc, const DataArrayInt *revDescI) const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *neighbors=0,*neighborsIdx=0;
+ self->computeNeighborsOfCellsAdv(desc,descI,revDesc,revDescI,neighbors,neighborsIdx);
+ PyObject *ret=PyTuple_New(2);
+ PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(neighbors),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ PyTuple_SetItem(ret,1,SWIG_NewPointerObj(SWIG_as_voidptr(neighborsIdx),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 ));
+ return ret;
+ }
+
PyObject *emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> d0=DataArrayInt::New();
DataArrayDouble *__setitem__(PyObject *obj, PyObject *value) throw(INTERP_KERNEL::Exception)
{
self->checkAllocated();
- const char msg[]="Unexpected situation in __setitem__ !";
+ const char msg[]="Unexpected situation in DataArrayDouble::__setitem__ !";
int nbOfTuples=self->getNumberOfTuples();
int nbOfComponents=self->getNumberOfComponents();
int sw1,sw2;
}
}
+ DataArrayInt *getIdsEqualList(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return self->getIdsEqualList(&singleVal,&singleVal+1);
+ case 2:
+ return self->getIdsEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
+ case 4:
+ return self->getIdsEqualList(daIntTyypp->begin(),daIntTyypp->end());
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
+ DataArrayInt *getIdsNotEqualList(PyObject *obj) throw(INTERP_KERNEL::Exception)
+ {
+ int sw;
+ int singleVal;
+ std::vector<int> multiVal;
+ std::pair<int, std::pair<int,int> > slic;
+ ParaMEDMEM::DataArrayInt *daIntTyypp=0;
+ convertObjToPossibleCpp2(obj,self->getNumberOfTuples(),sw,singleVal,multiVal,slic,daIntTyypp);
+ switch(sw)
+ {
+ case 1:
+ return self->getIdsNotEqualList(&singleVal,&singleVal+1);
+ case 2:
+ return self->getIdsNotEqualList(&multiVal[0],&multiVal[0]+multiVal.size());
+ case 4:
+ return self->getIdsNotEqualList(daIntTyypp->begin(),daIntTyypp->end());
+ default:
+ throw INTERP_KERNEL::Exception("DataArrayInt::getIdsNotEqualList : unrecognized type entered, expected list of int, tuple of int or DataArrayInt !");
+ }
+ }
+
PyObject *splitByValueRange(PyObject *li) const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret0=0,*ret1=0,*ret2=0;
const DataArrayInt *MEDFileUMesh::getFamilyFieldAtLevel(int meshDimRelToMaxExt) const throw(INTERP_KERNEL::Exception)
{
if(meshDimRelToMaxExt==1)
- {
- if(!((const DataArrayInt *)_fam_coords))
- throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamilyFieldAtLevel : no coordinates specified !");
- return _fam_coords;
- }
+ return _fam_coords;
const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
return l1->getFamilyField();
}
}
std::vector<int> famIds=getFamiliesIds(fams);
const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getFamilyPart(famIds,renum);
+ if(!famIds.empty())
+ return l1->getFamilyPart(&famIds[0],&famIds[0]+famIds.size(),renum);
+ else
+ return l1->getFamilyPart(0,0,renum);
}
DataArrayInt *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std::vector<std::string>& fams, bool renum) const throw(INTERP_KERNEL::Exception)
{
if((const DataArrayInt *)_fam_coords)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_coords->getIdsEqualList(famIds);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+ if(!famIds.empty())
+ da=_fam_coords->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+ else
+ da=_fam_coords->getIdsEqualList(0,0);
if(renum)
return MEDFileUMeshSplitL1::Renumber(_num_coords,da);
else
throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamiliesArr : no family array specified on nodes !");
}
const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
- return l1->getFamilyPartArr(famIds,renum);
+ if(!famIds.empty())
+ return l1->getFamilyPartArr(&famIds[0],&famIds[0]+famIds.size(),renum);
+ else
+ return l1->getFamilyPartArr(0,0,renum);
}
MEDCouplingUMesh *MEDFileUMesh::getMeshAtLevel(int meshDimRelToMaxExt, bool renum) const throw(INTERP_KERNEL::Exception)
void MEDFileUMesh::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
{
+ if(!coords)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::setCoords : null pointer in input !");
coords->checkAllocated();
int nbOfTuples=coords->getNumberOfTuples();
_coords=coords;
_groups.erase(*it);
}
+void MEDFileUMesh::duplicateNodesOnM1Group(const char *grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified) throw(INTERP_KERNEL::Exception)
+{
+ std::vector<int> levs=getNonEmptyLevels();
+ if(std::find(levs.begin(),levs.end(),0)==levs.end() || std::find(levs.begin(),levs.end(),-1)==levs.end())
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : This method works only for mesh definied on level 0 and -1 !");
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m0=getMeshAtLevel(0);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1=getMeshAtLevel(-1);
+ int nbNodes=m0->getNumberOfNodes();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m11=getGroup(-1,grpNameM1);
+ DataArrayInt *tmp00=0,*tmp11=0;
+ m0->findNodesToDuplicate(*m11,tmp00,tmp11);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeIdsToDuplicate(tmp00);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellsToModifyConn0(tmp11);
+ m11=getGroup(-1,grpNameM1);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp0=static_cast<MEDCouplingUMesh *>(m0->buildPartOfMySelf(cellsToModifyConn0->begin(),cellsToModifyConn0->end(),true));
+ tmp0->duplicateNodes(nodeIdsToDuplicate->begin(),nodeIdsToDuplicate->end());
+ m0->setCoords(tmp0->getCoords());
+ m0->setPartOfMySelf(cellsToModifyConn0->begin(),cellsToModifyConn0->end(),*tmp0);
+ m1->setCoords(m0->getCoords());
+ const DataArrayInt *fam=getFamilyFieldAtLevel(1);
+ fam->incrRef();
+ _coords=m0->getCoords(); _coords->incrRef();
+ DataArrayInt *famTmp=const_cast<DataArrayInt *>(getFamilyFieldAtLevel(1));
+ famTmp->setPartOfValues1(fam,0,fam->getNumberOfTuples(),1,0,1,1,true);
+ fam->decrRef();
+ //
+ m11->duplicateNodesInConn(nodeIdsToDuplicate->begin(),nodeIdsToDuplicate->end(),nbNodes); m11->setCoords(m0->getCoords());
+ std::vector<const MEDCouplingUMesh *> v(2); v[0]=m1; v[1]=m11;
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> newm1=MEDCouplingUMesh::AggregateSortedByTypeMeshesOnSameCoords(v,tmp00,tmp11);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> szOfCellGrpOfSameType(tmp00);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> idInMsOfCellGrpOfSameType(tmp11);
+ //
+ newm1->setName(getName());
+ fam=getFamilyFieldAtLevel(-1);
+ if(!fam)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::duplicateNodesOnM1Group : internal problem !");
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newFam=DataArrayInt::New();
+ newFam->alloc(newm1->getNumberOfCells(),1);
+ int idd=getMaxFamilyId()+1;
+ int globStart=0,start=0,end,globEnd;
+ int nbOfChunks=szOfCellGrpOfSameType->getNumberOfTuples();
+ for(int i=0;i<nbOfChunks;i++)
+ {
+ globEnd=globStart+szOfCellGrpOfSameType->getIJ(i,0);
+ if(idInMsOfCellGrpOfSameType->getIJ(i,0)==0)
+ {
+ end=start+szOfCellGrpOfSameType->getIJ(i,0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> part=fam->selectByTupleId2(start,end,1);
+ newFam->setPartOfValues1(part,globStart,globEnd,1,0,1,1,true);
+ start=end;
+ }
+ else
+ {
+ newFam->setPartOfValuesSimple1(idd,globStart,globEnd,1,0,1,1);
+ }
+ globStart=globEnd;
+ }
+ newm1->setCoords(getCoords());
+ setMeshAtLevel(-1,newm1);
+ setFamilyFieldArr(-1,newFam);
+ std::ostringstream famName; famName << "Family_" << idd;
+ std::string grpName2(grpNameM1); grpName2+="_dup";
+ addFamily(famName.str().c_str(),idd);
+ addFamilyOnGrp(grpName2.c_str(),famName.str().c_str());
+ //
+ fam=_fam_coords;
+ if(fam)
+ {
+ int newNbOfNodes=getCoords()->getNumberOfTuples();
+ newFam=DataArrayInt::New(); newFam->alloc(newNbOfNodes,1);
+ newFam->setPartOfValues1(fam,0,nbNodes,1,0,1,1,true);
+ newFam->setPartOfValuesSimple1(0,nbNodes,newNbOfNodes,1,0,1,1);
+ _fam_coords=newFam;
+ }
+ nodesDuplicated=nodeIdsToDuplicate; nodeIdsToDuplicate->incrRef();
+ cellsModified=cellsToModifyConn0; cellsToModifyConn0->incrRef();
+}
+
void MEDFileUMesh::addNodeGroup(const std::string& name, const std::vector<int>& ids) throw(INTERP_KERNEL::Exception)
{
const DataArrayDouble *coords=_coords;
{
if((const DataArrayInt *)_fam_nodes)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_nodes->getIdsEqualList(famIds);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+ if(!famIds.empty())
+ da=_fam_nodes->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+ else
+ da=_fam_nodes->getIdsEqualList(0,0);
if(renum)
return MEDFileUMeshSplitL1::Renumber(_num_nodes,da);
else
{
if((const DataArrayInt *)_fam_cells)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da=_fam_cells->getIdsEqualList(famIds);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> da;
+ if(!famIds.empty())
+ da=_fam_cells->getIdsEqualList(&famIds[0],&famIds[0]+famIds.size());
+ else
+ da=_fam_cells->getIdsEqualList(0,0);
if(renum)
return MEDFileUMeshSplitL1::Renumber(_num_cells,da);
else