DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const
{
checkConnectivityFullyDefined();
- int nbOfCells=getNumberOfCells();
- const int *connIndex=_nodal_connec_index->getConstPointer();
- const int *conn=_nodal_connec->getConstPointer();
- const int *maxEltPt=std::max_element(_nodal_connec->begin(),_nodal_connec->end());
- int maxElt=maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1;
+ const int *maxEltPt(std::max_element(_nodal_connec->begin(),_nodal_connec->end()));
+ int maxElt(maxEltPt==_nodal_connec->end()?0:std::abs(*maxEltPt)+1);
std::vector<bool> retS(maxElt,false);
- for(int i=0;i<nbOfCells;i++)
- for(int j=connIndex[i]+1;j<connIndex[i+1];j++)
- if(conn[j]>=0)
- retS[conn[j]]=true;
- int sz=0;
- for(int i=0;i<maxElt;i++)
- if(retS[i])
- sz++;
- DataArrayInt *ret=DataArrayInt::New();
- ret->alloc(sz,1);
- int *retPtr=ret->getPointer();
- for(int i=0;i<maxElt;i++)
- if(retS[i])
- *retPtr++=i;
- return ret;
+ computeNodeIdsAlg(retS);
+ return DataArrayInt::BuildListOfSwitchedOn(retS);
}
/*!
* The keys of \a extractDef is level relative to max ext of \a mm mesh.
*
* \return A new object that the caller is responsible to deallocate.
+ * \sa MEDFileUMesh::deduceNodeSubPartFromCellSubPart
*/
MEDFileField1TS *MEDFileField1TS::extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const
{
return ret.retn();
}
+/*!
+ * This method is a const method. It computes the minimal set of node ids covered by the cell extraction of \a this.
+ * The extraction of \a this is specified by the extractDef \a input map.
+ * This map tells for each level of cells, the cells kept in the extraction.
+ *
+ * \return - a new reference of DataArrayInt that represents sorted node ids, the extraction is lying on.
+ * \sa MEDFileField1TS::extractPart
+ */
+DataArrayInt *MEDFileUMesh::deduceNodeSubPartFromCellSubPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef) const
+{
+ std::vector<int> levs(getNonEmptyLevels());
+ std::vector<bool> fetchedNodes(getNumberOfNodes(),false);
+ for(std::map<int, MCAuto<DataArrayInt> >::const_iterator it=extractDef.begin();it!=extractDef.end();it++)
+ {
+ if((*it).first>1)
+ throw INTERP_KERNEL::Exception("MEDFileUMesh::deduceNodeSubPartFromCellSubPart : invalid key ! Must be <=1 !");
+ if((*it).first==1)
+ continue;
+ if(std::find(levs.begin(),levs.end(),(*it).first)==levs.end())
+ {
+ std::ostringstream oss; oss << "MEDFileUMesh::deduceNodeSubPartFromCellSubPart : invalid level " << (*it).first << " ! Not present in this !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+ MCAuto<MEDCouplingUMesh> m(getMeshAtLevel((*it).first));
+ MCAuto<MEDCouplingUMesh> mPart(m->buildPartOfMySelf((*it).second->begin(),(*it).second->end(),true));
+ mPart->computeNodeIdsAlg(fetchedNodes);
+ }
+ return DataArrayInt::BuildListOfSwitchedOn(fetchedNodes);
+}
+
/*!
* This method performs an extrusion along a path defined by \a m1D.
* \a this is expected to be a mesh with max mesh dimension equal to 2.
MEDLOADER_EXPORT void buildInnerBoundaryAlongM1Group(const std::string& grpNameM1, DataArrayInt *&nodesDuplicated, DataArrayInt *&cellsModified, DataArrayInt *&cellsNotModified);
MEDLOADER_EXPORT bool unPolyze(std::vector<int>& oldCode, std::vector<int>& newCode, DataArrayInt *& o2nRenumCell);
MEDLOADER_EXPORT DataArrayInt *zipCoords();
+ MEDLOADER_EXPORT DataArrayInt *deduceNodeSubPartFromCellSubPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef) const;
MEDLOADER_EXPORT MEDFileUMesh *buildExtrudedMesh(const MEDCouplingUMesh *m1D, int policy) const;
MEDLOADER_EXPORT MEDFileUMesh *linearToQuadratic(int conversionType=0, double eps=1e-12) const;
MEDLOADER_EXPORT MEDFileUMesh *quadraticToLinear(double eps=1e-12) const;
%newobject MEDCoupling::MEDFileUMesh::extractFamilyFieldOnGeoType;
%newobject MEDCoupling::MEDFileUMesh::extractNumberFieldOnGeoType;
%newobject MEDCoupling::MEDFileUMesh::zipCoords;
+%newobject MEDCoupling::MEDFileUMesh::deduceNodeSubPartFromCellSubPart;
%newobject MEDCoupling::MEDFileUMesh::buildExtrudedMesh;
%newobject MEDCoupling::MEDFileUMesh::linearToQuadratic;
%newobject MEDCoupling::MEDFileUMesh::quadraticToLinear;
self->removeMeshAtLevel(meshDimRelToMax);
}
+ DataArrayInt *deduceNodeSubPartFromCellSubPart(PyObject *extractDef) const throw(INTERP_KERNEL::Exception)
+ {
+ std::map<int, MCAuto<DataArrayInt> > extractDefCpp;
+ convertToMapIntDataArrayInt(extractDef,extractDefCpp);
+ return self->deduceNodeSubPartFromCellSubPart(extractDefCpp);
+ }
+
void setMeshes(PyObject *li, bool renum=false) throw(INTERP_KERNEL::Exception)
{
std::vector<const MEDCouplingUMesh *> ms;