From: ageay Date: Tue, 24 Apr 2012 15:39:13 +0000 (+0000) Subject: MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords X-Git-Tag: TRIPOLI_323~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5e708db40f3afbd23bd5af456f6adc66f721f470;p=tools%2Fmedcoupling.git MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index a0fb11f79..c3722695a 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -5057,6 +5057,59 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vector& meshes) throw(INTERP_KERNEL::Exception) +{ + std::size_t sz=meshes.size(); + if(sz==0 || sz==1) + return; + std::vector< const DataArrayDouble * > coords(meshes.size()); + std::vector< const DataArrayDouble * >::iterator it2=coords.begin(); + for(std::vector::const_iterator it=meshes.begin();it!=meshes.end();it++,it2++) + { + if((*it)) + { + (*it)->checkConnectivityFullyDefined(); + const DataArrayDouble *coo=(*it)->getCoords(); + if(coo) + *it2=coo; + else + { + std::ostringstream oss; oss << " MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords : Item #" << std::distance(meshes.begin(),it) << " inside the vector of length " << meshes.size(); + oss << " has no coordinate array defined !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + else + { + std::ostringstream oss; oss << " MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords : Item #" << std::distance(meshes.begin(),it) << " inside the vector of length " << meshes.size(); + oss << " is null !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + } + MEDCouplingAutoRefCountObjectPtr res=DataArrayDouble::Aggregate(coords); + std::vector::const_iterator it=meshes.begin(); + (*it)->setCoords(res); + int offset=(*it++)->getNumberOfNodes(); + for(;it!=meshes.end();it++) + { + (*it)->setCoords(res); + (*it)->shiftNodeNumbersInConn(offset); + offset+=(*it)->getNumberOfNodes(); + } +} + /*! * This method takes in input a cell defined by its MEDcouplingUMesh connectivity [connBg,connEnd) and returns its extruded cell by inserting the result at the end of ret. * @param nbOfNodesPerLev in parameter that specifies the number of nodes of one slice of global dataset diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 1fe716996..33cef4419 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -184,6 +184,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static MEDCouplingUMesh *MergeUMeshesOnSameCoords(const std::vector& meshes); MEDCOUPLING_EXPORT static MEDCouplingUMesh *FuseUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr); + MEDCOUPLING_EXPORT static void PutUMeshesOnSameAggregatedCoords(const std::vector& meshes) throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT static bool IsPolygonWellOriented(bool isQuadratic, const double *vec, const int *begin, const int *end, const double *coords); MEDCOUPLING_EXPORT static bool IsPolyhedronWellOriented(const int *begin, const int *end, const double *coords); MEDCOUPLING_EXPORT static void TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index f4d20e66d..c2520d3b3 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -1273,6 +1273,13 @@ namespace ParaMEDMEM return ret; } + static void PutUMeshesOnSameAggregatedCoords(PyObject *ms) throw(INTERP_KERNEL::Exception) + { + std::vector meshes; + convertPyObjToVecUMeshes(ms,meshes); + MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(meshes); + } + PyObject *are2DCellsNotCorrectlyOriented(PyObject *vec, bool polyOnly) const throw(INTERP_KERNEL::Exception) { std::vector cells; diff --git a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i index f9e28d3e4..3eb7900eb 100644 --- a/src/MEDCoupling_Swig/MEDCouplingTypemaps.i +++ b/src/MEDCoupling_Swig/MEDCouplingTypemaps.i @@ -567,6 +567,35 @@ void convertPyObjToVecUMeshesCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) +{ + if(PyList_Check(ms)) + { + int size=PyList_Size(ms); + v.resize(size); + for(int i=0;i(argp); + v[i]=arg; + } + } + else + { + const char msg[]="convertPyObjToVecUMeshes : not a list"; + PyErr_SetString(PyExc_TypeError,msg); + throw INTERP_KERNEL::Exception(msg); + } +} + void convertPyObjToVecMeshesCst(PyObject *ms, std::vector& v) throw(INTERP_KERNEL::Exception) { if(PyList_Check(ms))