+MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair<mcIdType,mcIdType> >& cellPart) const
+{
+ checkConsistencyLight();
+ int dim(getSpaceDimension());
+ std::vector<mcIdType> dims(getMeshDimension());
+ if(dim!=ToIdType(cellPart.size()))
+ {
+ std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::buildStructuredSubPart : the space dimension is " << dim << " and cell part size is " << cellPart.size() << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ std::vector< std::pair<mcIdType,mcIdType> > nodePartFormat(cellPart);
+ for(std::vector< std::pair<mcIdType,mcIdType> >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++)
+ (*it).second++;
+ MCAuto<DataArrayIdType> tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat));
+ MCAuto<MEDCouplingCurveLinearMesh> ret(dynamic_cast<MEDCouplingCurveLinearMesh *>(deepCopy()));
+ const DataArrayDouble *coo(ret->getCoords());
+ if(coo)
+ {
+ MCAuto<DataArrayDouble> coo2(coo->selectByTupleIdSafe(tmp1->begin(),tmp1->end()));
+ ret->setCoords(coo2);
+ }
+ for(int i=0;i<dim;i++)
+ {
+ dims[i]=cellPart[i].second-cellPart[i].first+1;
+ if(dims[i]<1)
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::buildStructuredSubPart : invalid input cellPart !");
+ }
+ ret->setNodeGridStructure(&dims[0],&dims[0]+dims.size());
+ return ret.retn();
+}
+