m->findCommonCells(compType,startCellId,commonCellsArr,commonCellsIArr);
}
+int MEDCoupling1GTUMesh::getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception)
+{
+ const DataArrayInt *c1(getNodalConnectivity());
+ if(!c1)
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : no connectivity set !");
+ if(c1->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : Nodal connectivity array set must have exactly one component !");
+ if(!c1->isAllocated())
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::getNodalConnectivityLength : Nodal connectivity array must be allocated !");
+ return c1->getNumberOfTuples();
+}
+
+/*!
+ * This method aggregates all the meshes in \a parts to put them in a single unstructured mesh (those returned).
+ * The order of cells is the returned instance is those in the order of instances in \a parts.
+ *
+ * \param [in] parts - all not null parts of single geo type meshes to be aggreagated having the same mesh dimension and same coordinates.
+ * \return MEDCouplingUMesh * - new object to be dealt by the caller.
+ *
+ * \throw If one element is null in \a parts.
+ * \throw If not all the parts do not have the same mesh dimension.
+ * \throw If not all the parts do not share the same coordinates.
+ * \throw If not all the parts have their connectivity set properly.
+ * \throw If \a parts is empty.
+ */
+MEDCouplingUMesh *MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(const std::vector< const MEDCoupling1GTUMesh *>& parts) throw(INTERP_KERNEL::Exception)
+{
+ if(parts.empty())
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : input parts vector is empty !");
+ const MEDCoupling1GTUMesh *firstPart(parts[0]);
+ if(!firstPart)
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : the first instance in input parts is null !");
+ const DataArrayDouble *coords(firstPart->getCoords());
+ int meshDim(firstPart->getMeshDimension());
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret(MEDCouplingUMesh::New(firstPart->getName(),meshDim));
+ ret->setCoords(coords);
+ int nbOfCells(0),connSize(0);
+ for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++)
+ {
+ if(!(*it))
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : presence of null pointer in input vector !");
+ if((*it)->getMeshDimension()!=meshDim)
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances in input vector must have same mesh dimension !");
+ if((*it)->getCoords()!=coords)
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : all the instances must share the same coordinates pointer !");
+ nbOfCells+=(*it)->getNumberOfCells();
+ connSize+=(*it)->getNodalConnectivityLength();
+ }
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> conn(DataArrayInt::New()),connI(DataArrayInt::New());
+ connI->alloc(nbOfCells+1,1); conn->alloc(connSize+nbOfCells,1);
+ int *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0;
+ for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++)
+ {
+ int curNbCells((*it)->getNumberOfCells());
+ int geoType((int)(*it)->getCellModelEnum());
+ const int *cinPtr((*it)->getNodalConnectivity()->begin());
+ const MEDCoupling1SGTUMesh *ps(dynamic_cast<const MEDCoupling1SGTUMesh *>(*it));
+ const MEDCoupling1DGTUMesh *pd(dynamic_cast<const MEDCoupling1DGTUMesh *>(*it));
+ if(ps && !pd)
+ {
+ int nNodesPerCell(ps->getNumberOfNodesPerCell());
+ for(int i=0;i<curNbCells;i++,ci++,cinPtr+=nNodesPerCell)
+ {
+ *c++=geoType;
+ c=std::copy(cinPtr,cinPtr+nNodesPerCell,c);
+ ci[1]=ci[0]+nNodesPerCell+1;
+ }
+ }
+ else if(!ps && pd)
+ {
+ const int *ciinPtr(pd->getNodalConnectivityIndex()->begin());
+ for(int i=0;i<curNbCells;i++,ci++,ciinPtr++)
+ {
+ *c++=geoType;
+ c=std::copy(cinPtr+ciinPtr[0],cinPtr+ciinPtr[1],c);
+ ci[1]=ci[0]+ciinPtr[1]-ciinPtr[0]+1;
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : presence of instance which type is not in [MEDCoupling1SGTUMesh,MEDCoupling1DGTUMesh] !");
+ }
+ ret->setConnectivity(conn,connI,true);
+ return ret.retn();
+}
+
//==
MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn(other._conn)
return (int)_cm->getNumberOfNodes();
}
-int MEDCoupling1SGTUMesh::getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception)
-{
- const DataArrayInt *c1(_conn);
- if(!c1)
- throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : no connectivity set !");
- if(c1->getNumberOfComponents()!=1)
- throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : Nodal connectivity array set must have exactly one component !");
- if(!c1->isAllocated())
- throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::getNodalConnectivityLength : Nodal connectivity array must be allocated !");
- return c1->getNumberOfTuples();
-}
-
DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
{
checkNonDynamicGeoType();
MEDCOUPLING_EXPORT std::string getVTKDataSetType() const throw(INTERP_KERNEL::Exception);
//
MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const;
+ MEDCOUPLING_EXPORT int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT bool isEqualWithoutConsideringStr(const MEDCouplingMesh *other, double prec) const;
MEDCOUPLING_EXPORT void checkCoherency() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *findBoundaryNodes() const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
MEDCOUPLING_EXPORT void findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const throw(INTERP_KERNEL::Exception);
+ MEDCOUPLING_EXPORT static MEDCouplingUMesh *AggregateOnSameCoordsToUMesh(const std::vector< const MEDCoupling1GTUMesh *>& parts) throw(INTERP_KERNEL::Exception);
public:
MEDCOUPLING_EXPORT virtual void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception) = 0;
MEDCOUPLING_EXPORT virtual void insertNextCell(const int *nodalConnOfCellBg, const int *nodalConnOfCellEnd) throw(INTERP_KERNEL::Exception) = 0;
+ MEDCOUPLING_EXPORT virtual DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception) = 0;
protected:
MEDCOUPLING_EXPORT MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm);
MEDCOUPLING_EXPORT MEDCoupling1GTUMesh(const MEDCoupling1GTUMesh& other, bool recDeepCpy);
public://specific
MEDCOUPLING_EXPORT void setNodalConnectivity(DataArrayInt *nodalConn) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception);
- MEDCOUPLING_EXPORT int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT int getNumberOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(const MEDCoupling1SGTUMesh *mesh1, const MEDCoupling1SGTUMesh *mesh2) throw(INTERP_KERNEL::Exception);
MEDCOUPLING_EXPORT static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(std::vector<const MEDCoupling1SGTUMesh *>& a) throw(INTERP_KERNEL::Exception);
%newobject ParaMEDMEM::MEDCouplingUMeshCellByTypeEntry::__iter__;
%newobject ParaMEDMEM::MEDCouplingUMeshCellEntry::__iter__;
%newobject ParaMEDMEM::MEDCoupling1GTUMesh::New;
+%newobject ParaMEDMEM::MEDCoupling1GTUMesh::getNodalConnectivity;
+%newobject ParaMEDMEM::MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh;
%newobject ParaMEDMEM::MEDCoupling1SGTUMesh::New;
-%newobject ParaMEDMEM::MEDCoupling1SGTUMesh::getNodalConnectivity;
%newobject ParaMEDMEM::MEDCoupling1SGTUMesh::buildSetInstanceFromThis;
%newobject ParaMEDMEM::MEDCoupling1SGTUMesh::Merge1SGTUMeshes;
%newobject ParaMEDMEM::MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords;
%newobject ParaMEDMEM::MEDCoupling1DGTUMesh::New;
-%newobject ParaMEDMEM::MEDCoupling1DGTUMesh::getNodalConnectivity;
%newobject ParaMEDMEM::MEDCoupling1DGTUMesh::getNodalConnectivityIndex;
%newobject ParaMEDMEM::MEDCoupling1DGTUMesh::buildSetInstanceFromThis;
%newobject ParaMEDMEM::MEDCoupling1DGTUMesh::Merge1DGTUMeshes;
public:
static MEDCoupling1GTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
INTERP_KERNEL::NormalizedCellType getCellModelEnum() const throw(INTERP_KERNEL::Exception);
+ int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
virtual void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception);
%extend
{
const int *tmp=convertObjToPossibleCpp1_Safe(li,sw,szArr,iTypppArr,stdvecTyyppArr);
self->insertNextCell(tmp,tmp+szArr);
}
+
+ virtual DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception)
+ {
+ DataArrayInt *ret=self->getNodalConnectivity();
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ static MEDCouplingUMesh *AggregateOnSameCoordsToUMesh(PyObject *li) throw(INTERP_KERNEL::Exception)
+ {
+ std::vector< const MEDCoupling1GTUMesh *> parts;
+ convertFromPyObjVectorOfObj<const ParaMEDMEM::MEDCoupling1GTUMesh *>(li,SWIGTYPE_p_ParaMEDMEM__MEDCoupling1GTUMesh,"MEDCoupling1GTUMesh",parts);
+ return MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(parts);
+ }
}
};
public:
static MEDCoupling1GTUMesh *New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception);
void setNodalConnectivity(DataArrayInt *nodalConn) throw(INTERP_KERNEL::Exception);
- int getNodalConnectivityLength() const throw(INTERP_KERNEL::Exception);
int getNumberOfNodesPerCell() const throw(INTERP_KERNEL::Exception);
static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(const MEDCoupling1SGTUMesh *mesh1, const MEDCoupling1SGTUMesh *mesh2) throw(INTERP_KERNEL::Exception);
MEDCoupling1SGTUMesh *buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception);
return oss.str();
}
- DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret=self->getNodalConnectivity();
- if(ret) ret->incrRef();
- return ret;
- }
-
static MEDCoupling1SGTUMesh *Merge1SGTUMeshes(PyObject *li) throw(INTERP_KERNEL::Exception)
{
std::vector<const ParaMEDMEM::MEDCoupling1SGTUMesh *> tmp;
return oss.str();
}
- DataArrayInt *getNodalConnectivity() const throw(INTERP_KERNEL::Exception)
- {
- DataArrayInt *ret=self->getNodalConnectivity();
- if(ret) ret->incrRef();
- return ret;
- }
-
DataArrayInt *getNodalConnectivityIndex() const throw(INTERP_KERNEL::Exception)
{
DataArrayInt *ret=self->getNodalConnectivityIndex();