using namespace ParaMEDMEM;
+MEDCoupling1GTUMesh::MEDCoupling1GTUMesh()
+{
+}
+
MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):_cm(&cm)
{
setName(name);
{
}
+MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh()
+{
+}
+
+MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New()
+{
+ return new MEDCoupling1SGTUMesh;
+}
+
MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
if(type==INTERP_KERNEL::NORM_ERROR)
return nbOfTuples/nbOfNodesPerCell;
}
+int MEDCoupling1SGTUMesh::getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception)
+{
+ return getNumberOfNodesPerCell();
+}
+
int MEDCoupling1SGTUMesh::getNumberOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
{
checkNonDynamicGeoType();
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::isEmptyMesh : not implemented yet !");
}
+void MEDCoupling1SGTUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+{
+ int it,order;
+ double time=getTime(it,order);
+ tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear();
+ //
+ littleStrings.push_back(getName());
+ littleStrings.push_back(getDescription());
+ littleStrings.push_back(getTimeUnit());
+ //
+ std::vector<std::string> littleStrings2,littleStrings3;
+ if((const DataArrayDouble *)_coords)
+ _coords->getTinySerializationStrInformation(littleStrings2);
+ if((const DataArrayInt *)_conn)
+ _conn->getTinySerializationStrInformation(littleStrings3);
+ int sz0((int)littleStrings2.size()),sz1((int)littleStrings3.size());
+ littleStrings.insert(littleStrings.end(),littleStrings2.begin(),littleStrings2.end());
+ littleStrings.insert(littleStrings.end(),littleStrings3.begin(),littleStrings3.end());
+ //
+ tinyInfo.push_back(getCellModelEnum());
+ tinyInfo.push_back(it);
+ tinyInfo.push_back(order);
+ std::vector<int> tinyInfo2,tinyInfo3;
+ if((const DataArrayDouble *)_coords)
+ _coords->getTinySerializationIntInformation(tinyInfo2);
+ if((const DataArrayInt *)_conn)
+ _conn->getTinySerializationIntInformation(tinyInfo3);
+ int sz2((int)tinyInfo2.size()),sz3((int)tinyInfo3.size());
+ tinyInfo.push_back(sz0); tinyInfo.push_back(sz1); tinyInfo.push_back(sz2); tinyInfo.push_back(sz3);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.insert(tinyInfo.end(),tinyInfo3.begin(),tinyInfo3.end());
+ //
+ tinyInfoD.push_back(time);
+}
+
+void MEDCoupling1SGTUMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
+{
+ std::vector<int> tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+tinyInfo[5]);
+ std::vector<int> tinyInfo1(tinyInfo.begin()+7+tinyInfo[5],tinyInfo.begin()+7+tinyInfo[5]+tinyInfo[6]);
+ a1->resizeForUnserialization(tinyInfo1);
+ a2->resizeForUnserialization(tinyInfo2);
+}
+
+void MEDCoupling1SGTUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+{
+ int sz(0);
+ if((const DataArrayInt *)_conn)
+ if(_conn->isAllocated())
+ sz=_conn->getNbOfElems();
+ a1=DataArrayInt::New();
+ a1->alloc(sz,1);
+ if(sz!=0 && (const DataArrayInt *)_conn)
+ std::copy(_conn->begin(),_conn->end(),a1->getPointer());
+ sz=0;
+ if((const DataArrayDouble *)_coords)
+ if(_coords->isAllocated())
+ sz=_coords->getNbOfElems();
+ a2=DataArrayDouble::New();
+ a2->alloc(sz,1);
+ if(sz!=0 && (const DataArrayDouble *)_coords)
+ std::copy(_coords->begin(),_coords->end(),a2->getPointer());
+}
+
+void MEDCoupling1SGTUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ const std::vector<std::string>& littleStrings)
+{
+ INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]);
+ _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt);
+ setName(littleStrings[0].c_str());
+ setDescription(littleStrings[1].c_str());
+ setTimeUnit(littleStrings[2].c_str());
+ setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]);
+ int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]);
+ //
+ _coords=DataArrayDouble::New();
+ std::vector<int> tinyInfo2(tinyInfo.begin()+7,tinyInfo.begin()+7+sz2);
+ _coords->resizeForUnserialization(tinyInfo2);
+ std::copy(a2->begin(),a2->end(),_coords->getPointer());
+ _conn=DataArrayInt::New();
+ std::vector<int> tinyInfo3(tinyInfo.begin()+7+sz2,tinyInfo.begin()+7+sz2+sz3);
+ _conn->resizeForUnserialization(tinyInfo3);
+ std::copy(a1->begin(),a1->end(),_conn->getPointer());
+ std::vector<std::string> littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0);
+ _coords->finishUnserialization(tinyInfo2,littleStrings2);
+ std::vector<std::string> littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1);
+ _conn->finishUnserialization(tinyInfo3,littleStrings3);
+}
+
/*!
* Checks if \a this and \a other meshes are geometrically equivalent with high
* probability, else an exception is thrown. The meshes are considered equivalent if
MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh3D() const throw(INTERP_KERNEL::Exception)
{
- /*static const int DUAL_CONN_TETRA_0[48]={
- 8,5,14,4, 10,4,14,7, 11,7,14,5,
- 8,4,14,5, 9,6,14,4, 12,5,14,6,
- 10,7,14,4, 9,4,14,6, 13,7,14,6,
- 11,5,14,7, 13,7,14,6, 12,6,14,5
- };*/
static const int DUAL_TETRA_0[36]={
4,1,0, 6,0,3, 7,3,1,
4,0,1, 5,2,0, 8,1,2,
- 6,3,0, 5,0,2, 9,3,2,
+ 6,3,0, 5,0,2, 9,2,3,
7,1,3, 9,3,2, 8,2,1
};
static const int DUAL_TETRA_1[36]={
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0;
const int *d2(d2Arr->begin()),*rd2(rd2Arr->begin()),*rdi2(rdi2Arr->begin());
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> edgesBaryArr(edges->getBarycenterAndOwner()),facesBaryArr(faces->getBarycenterAndOwner()),baryArr(getBarycenterAndOwner());
+ const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+faces->getNumberOfCells()),offset1(offset0+edges->getNumberOfCells());
edges=0; faces=0;
std::vector<const DataArrayDouble *> v(4); v[0]=getCoords(); v[1]=facesBaryArr; v[2]=edgesBaryArr; v[3]=baryArr;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0;
- const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+faces->getNumberOfCells()),offset1(offset0+edges->getNumberOfCells());
std::string name("DualOf_"); name+=getName();
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,0); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
for(int i=0;i<nbOfNodes;i++,revNodI++)
{
int nbOfCellsSharingNode(revNodI[1]-revNodI[0]);
int curCellId(revNod[revNodI[0]+j]);
const int *connOfCurCell(nodal+4*curCellId);
std::size_t nodePosInCurCell(std::distance(connOfCurCell,std::find(connOfCurCell,connOfCurCell+4,i)));
+ if(j!=0) cArr->pushBackSilent(-1);
int tmp[14];
//
tmp[0]=d1[6*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+0]-4]+offset0; tmp[1]=d2[4*curCellId+DUAL_TETRA_0[nodePosInCurCell*9+1]]+nbOfNodes;
int kk(0);
for(int k=0;k<4;k++)
{
- if(FACEID_NOT_SH_NODE[k]!=(int)nodePosInCurCell)
+ if(FACEID_NOT_SH_NODE[nodePosInCurCell]!=k)
{
const int *faceId(d2+4*curCellId+k);
if(rdi2[*faceId+1]-rdi2[*faceId]==1)
}
}
}
- ciArr->pushBackSilent(cArr->getNumberOfTuples());
+ ciArr->setIJ(i+1,0,cArr->getNumberOfTuples());
}
ret->setNodalConnectivity(cArr,ciArr);
return ret.retn();
MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const throw(INTERP_KERNEL::Exception)
{
- static const int DUAL_TRI_0[6]={2,0, 0,1, 1,2};
- static const int DUAL_TRI_1[6]={+3,-5, -3,+4, -4,+5};
+ static const int DUAL_TRI_0[6]={0,2, 1,0, 2,1};
+ static const int DUAL_TRI_1[6]={-3,+5, +3,-4, +4,-5};
static const int FACEID_NOT_SH_NODE[3]={1,2,0};
if(getCellModelEnum()!=INTERP_KERNEL::NORM_TRI3)
throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh2D : only TRI3 supported !");
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0;
const int *d2(d2Arr->begin()),*rd2(rd2Arr->begin()),*rdi2(rdi2Arr->begin());
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> edgesBaryArr(edges->getBarycenterAndOwner()),baryArr(getBarycenterAndOwner());
+ const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+edges->getNumberOfCells());
edges=0;
std::vector<const DataArrayDouble *> v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0;
- const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+edges->getNumberOfCells());
std::string name("DualOf_"); name+=getName();
MEDCouplingAutoRefCountObjectPtr<MEDCoupling1DGTUMesh> ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,0); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1);
for(int i=0;i<nbOfNodes;i++,revNodI++)
{
int nbOfCellsSharingNode(revNodI[1]-revNodI[0]);
int kk(0);
for(int k=0;k<3;k++)
{
- if(FACEID_NOT_SH_NODE[k]!=(int)nodePosInCurCell)
+ if(FACEID_NOT_SH_NODE[nodePosInCurCell]!=k)
{
const int *edgeId(d2+3*curCellId+k);
if(rdi2[*edgeId+1]-rdi2[*edgeId]==1)
}
std::vector<int> zePolyg(MEDCoupling1DGTUMesh::BuildAPolygonFromParts(polyg));
cArr->insertAtTheEnd(zePolyg.begin(),zePolyg.end());
- ciArr->pushBackSilent(cArr->getNumberOfTuples());
+ ciArr->setIJ(i+1,0,cArr->getNumberOfTuples());
}
ret->setNodalConnectivity(cArr,ciArr);
return ret.retn();
}
+/*!
+ * This method aggregate the bbox of each cell and put it into bbox
+ *
+ * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
+ *
+ * \throw If \a this is not fully set (coordinates and connectivity).
+ * \throw If a cell in \a this has no valid nodeId.
+ */
+DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree() const
+{
+ int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()),nbOfNodesPerCell(getNumberOfNodesPerCell());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
+ double *bbox(ret->getPointer());
+ for(int i=0;i<nbOfCells*spaceDim;i++)
+ {
+ bbox[2*i]=std::numeric_limits<double>::max();
+ bbox[2*i+1]=-std::numeric_limits<double>::max();
+ }
+ const double *coordsPtr(_coords->getConstPointer());
+ const int *conn(_conn->getConstPointer());
+ for(int i=0;i<nbOfCells;i++)
+ {
+ int kk(0);
+ for(int j=0;j<nbOfNodesPerCell;j++,conn++)
+ {
+ int nodeId(*conn);
+ if(nodeId>=0 && nodeId<nbOfNodes)
+ {
+ for(int k=0;k<spaceDim;k++)
+ {
+ bbox[2*spaceDim*i+2*k]=std::min(bbox[2*spaceDim*i+2*k],coordsPtr[spaceDim*nodeId+k]);
+ bbox[2*spaceDim*i+2*k+1]=std::max(bbox[2*spaceDim*i+2*k+1],coordsPtr[spaceDim*nodeId+k]);
+ }
+ kk++;
+ }
+ }
+ if(kk==0)
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getBoundingBoxForBBTree : cell #" << i << " contains no valid nodeId !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret.retn();
+}
+
//==
+MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New()
+{
+ return new MEDCoupling1DGTUMesh;
+}
+
MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type) throw(INTERP_KERNEL::Exception)
{
if(type==INTERP_KERNEL::NORM_ERROR)
return new MEDCoupling1DGTUMesh(name,cm);
}
+MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh()
+{
+}
+
MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm)
{
}
void MEDCoupling1DGTUMesh::getNodeIdsOfCell(int cellId, std::vector<int>& conn) const
{
- int nbOfCells=getNumberOfCells();//performs checks
+ int nbOfCells(getNumberOfCells());//performs checks
if(cellId>=0 && cellId<nbOfCells)
{
int strt=_conn_indx->getIJ(cellId,0),stp=_conn_indx->getIJ(cellId+1,0);
}
else
{
- std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getNodeIdsOfCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
+ std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::getNodeIdsOfCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+}
+
+int MEDCoupling1DGTUMesh::getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception)
+{
+ int nbOfCells(getNumberOfCells());//performs checks
+ if(cellId>=0 && cellId<nbOfCells)
+ {
+ const int *conn(_conn->begin());
+ int strt=_conn_indx->getIJ(cellId,0),stp=_conn_indx->getIJ(cellId+1,0);
+ return stp-strt-std::count(conn+strt,conn+stp,-1);
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::getNumberOfNodesInCell : request for cellId #" << cellId << " must be in [0," << nbOfCells << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::isEmptyMesh : not implemented yet !");
}
+void MEDCoupling1DGTUMesh::getTinySerializationInformation(std::vector<double>& tinyInfoD, std::vector<int>& tinyInfo, std::vector<std::string>& littleStrings) const
+{
+ int it,order;
+ double time=getTime(it,order);
+ tinyInfo.clear(); tinyInfoD.clear(); littleStrings.clear();
+ //
+ littleStrings.push_back(getName());
+ littleStrings.push_back(getDescription());
+ littleStrings.push_back(getTimeUnit());
+ //
+ std::vector<std::string> littleStrings2,littleStrings3,littleStrings4;
+ if((const DataArrayDouble *)_coords)
+ _coords->getTinySerializationStrInformation(littleStrings2);
+ if((const DataArrayInt *)_conn)
+ _conn->getTinySerializationStrInformation(littleStrings3);
+ if((const DataArrayInt *)_conn_indx)
+ _conn_indx->getTinySerializationStrInformation(littleStrings4);
+ int sz0((int)littleStrings2.size()),sz1((int)littleStrings3.size()),sz2((int)littleStrings4.size());
+ littleStrings.insert(littleStrings.end(),littleStrings2.begin(),littleStrings2.end());
+ littleStrings.insert(littleStrings.end(),littleStrings3.begin(),littleStrings3.end());
+ littleStrings.insert(littleStrings.end(),littleStrings4.begin(),littleStrings4.end());
+ //
+ tinyInfo.push_back(getCellModelEnum());
+ tinyInfo.push_back(it);
+ tinyInfo.push_back(order);
+ std::vector<int> tinyInfo2,tinyInfo3,tinyInfo4;
+ if((const DataArrayDouble *)_coords)
+ _coords->getTinySerializationIntInformation(tinyInfo2);
+ if((const DataArrayInt *)_conn)
+ _conn->getTinySerializationIntInformation(tinyInfo3);
+ if((const DataArrayInt *)_conn_indx)
+ _conn_indx->getTinySerializationIntInformation(tinyInfo4);
+ int sz3((int)tinyInfo2.size()),sz4((int)tinyInfo3.size()),sz5((int)tinyInfo4.size());
+ tinyInfo.push_back(sz0); tinyInfo.push_back(sz1); tinyInfo.push_back(sz2); tinyInfo.push_back(sz3); tinyInfo.push_back(sz4); tinyInfo.push_back(sz5);
+ tinyInfo.insert(tinyInfo.end(),tinyInfo2.begin(),tinyInfo2.end());
+ tinyInfo.insert(tinyInfo.end(),tinyInfo3.begin(),tinyInfo3.end());
+ tinyInfo.insert(tinyInfo.end(),tinyInfo4.begin(),tinyInfo4.end());
+ //
+ tinyInfoD.push_back(time);
+}
+
+void MEDCoupling1DGTUMesh::resizeForUnserialization(const std::vector<int>& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector<std::string>& littleStrings) const
+{
+ std::vector<int> tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+tinyInfo[6]);
+ std::vector<int> tinyInfo1(tinyInfo.begin()+9+tinyInfo[6],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]);
+ std::vector<int> tinyInfo12(tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]+tinyInfo[8]);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p1(DataArrayInt::New()); p1->resizeForUnserialization(tinyInfo1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> p2(DataArrayInt::New()); p2->resizeForUnserialization(tinyInfo12);
+ std::vector<const DataArrayInt *> v(2); v[0]=p1; v[1]=p2;
+ p2=DataArrayInt::Aggregate(v);
+ a2->resizeForUnserialization(tinyInfo2);
+ a1->alloc(p2->getNbOfElems(),1);
+}
+
+void MEDCoupling1DGTUMesh::serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const
+{
+ int sz(0);
+ if((const DataArrayInt *)_conn)
+ if(_conn->isAllocated())
+ sz=_conn->getNbOfElems();
+ if((const DataArrayInt *)_conn_indx)
+ if(_conn_indx->isAllocated())
+ sz+=_conn_indx->getNbOfElems();
+ a1=DataArrayInt::New();
+ a1->alloc(sz,1);
+ int *work(a1->getPointer());
+ if(sz!=0 && (const DataArrayInt *)_conn)
+ work=std::copy(_conn->begin(),_conn->end(),a1->getPointer());
+ if(sz!=0 && (const DataArrayInt *)_conn_indx)
+ std::copy(_conn_indx->begin(),_conn_indx->end(),work);
+ sz=0;
+ if((const DataArrayDouble *)_coords)
+ if(_coords->isAllocated())
+ sz=_coords->getNbOfElems();
+ a2=DataArrayDouble::New();
+ a2->alloc(sz,1);
+ if(sz!=0 && (const DataArrayDouble *)_coords)
+ std::copy(_coords->begin(),_coords->end(),a2->getPointer());
+}
+
+void MEDCoupling1DGTUMesh::unserialization(const std::vector<double>& tinyInfoD, const std::vector<int>& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2,
+ const std::vector<std::string>& littleStrings)
+{
+ INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]);
+ _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt);
+ setName(littleStrings[0].c_str());
+ setDescription(littleStrings[1].c_str());
+ setTimeUnit(littleStrings[2].c_str());
+ setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]);
+ int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]),sz4(tinyInfo[7]),sz5(tinyInfo[8]);
+ //
+ _coords=DataArrayDouble::New();
+ std::vector<int> tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+sz3);
+ _coords->resizeForUnserialization(tinyInfo2);
+ std::copy(a2->begin(),a2->end(),_coords->getPointer());
+ _conn=DataArrayInt::New();
+ std::vector<int> tinyInfo3(tinyInfo.begin()+9+sz3,tinyInfo.begin()+9+sz3+sz4);
+ _conn->resizeForUnserialization(tinyInfo3);
+ std::copy(a1->begin(),a1->begin()+_conn->getNbOfElems(),_conn->getPointer());
+ _conn_indx=DataArrayInt::New();
+ std::vector<int> tinyInfo4(tinyInfo.begin()+9+sz3+sz4,tinyInfo.begin()+9+sz3+sz4+sz5);
+ _conn_indx->resizeForUnserialization(tinyInfo4);
+ std::copy(a1->begin()+_conn->getNbOfElems(),a1->end(),_conn_indx->getPointer());
+ std::vector<std::string> littleStrings2(littleStrings.begin()+3,littleStrings.begin()+3+sz0);
+ _coords->finishUnserialization(tinyInfo2,littleStrings2);
+ std::vector<std::string> littleStrings3(littleStrings.begin()+3+sz0,littleStrings.begin()+3+sz0+sz1);
+ _conn->finishUnserialization(tinyInfo3,littleStrings3);
+ std::vector<std::string> littleStrings4(littleStrings.begin()+3+sz0+sz1,littleStrings.begin()+3+sz0+sz1+sz2);
+ _conn_indx->finishUnserialization(tinyInfo4,littleStrings4);
+}
+
/*!
* Finds nodes not used in any cell and returns an array giving a new id to every node
* by excluding the unused nodes, for which the array holds -1. The result array is
int nodeId=conn[conni[0]+j];
if(nodeId==-1) continue;
if(nodeId>=0 && nodeId<nbOfNodes)
- traducer[*conn]=1;
+ traducer[nodeId]=1;
else
{
std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::getNodeIdsInUse : In cell #" << i << " presence of node id " << nodeId << " not in [0," << nbOfNodes << ") !";
return ret.retn();
}
+/*!
+ * This method aggregate the bbox of each cell and put it into bbox parameter.
+ *
+ * \return DataArrayDouble * - newly created object (to be managed by the caller) \a this number of cells tuples and 2*spacedim components.
+ *
+ * \throw If \a this is not fully set (coordinates and connectivity).
+ * \throw If a cell in \a this has no valid nodeId.
+ */
+DataArrayDouble *MEDCoupling1DGTUMesh::getBoundingBoxForBBTree() const
+{
+ checkFullyDefined();
+ int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
+ double *bbox(ret->getPointer());
+ for(int i=0;i<nbOfCells*spaceDim;i++)
+ {
+ bbox[2*i]=std::numeric_limits<double>::max();
+ bbox[2*i+1]=-std::numeric_limits<double>::max();
+ }
+ const double *coordsPtr(_coords->getConstPointer());
+ const int *conn(_conn->getConstPointer()),*connI(_conn_indx->getConstPointer());
+ for(int i=0;i<nbOfCells;i++)
+ {
+ int offset=connI[i];
+ int nbOfNodesForCell(connI[i+1]-offset),kk(0);
+ for(int j=0;j<nbOfNodesForCell;j++)
+ {
+ int nodeId=conn[offset+j];
+ if(nodeId>=0 && nodeId<nbOfNodes)
+ {
+ for(int k=0;k<spaceDim;k++)
+ {
+ bbox[2*spaceDim*i+2*k]=std::min(bbox[2*spaceDim*i+2*k],coordsPtr[spaceDim*nodeId+k]);
+ bbox[2*spaceDim*i+2*k+1]=std::max(bbox[2*spaceDim*i+2*k+1],coordsPtr[spaceDim*nodeId+k]);
+ }
+ kk++;
+ }
+ }
+ if(kk==0)
+ {
+ std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::getBoundingBoxForBBTree : cell #" << i << " contains no valid nodeId !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return ret.retn();
+}
+
std::vector<int> MEDCoupling1DGTUMesh::BuildAPolygonFromParts(const std::vector< std::vector<int> >& parts) throw(INTERP_KERNEL::Exception)
{
std::vector<int> ret;