*/
void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const
{
- int nbOfNodes=(int)nodeIdsInUse.size();
- int nbOfCells=getNumberOfCells();
- const int *connIndex=_nodal_connec_index->getConstPointer();
- const int *conn=_nodal_connec->getConstPointer();
+ int nbOfNodes((int)nodeIdsInUse.size()),nbOfCells(getNumberOfCells());
+ const int *connIndex(_nodal_connec_index->getConstPointer()),*conn(_nodal_connec->getConstPointer());
for(int i=0;i<nbOfCells;i++)
for(int j=connIndex[i]+1;j<connIndex[i+1];j++)
if(conn[j]>=0)
nodeIdsInUse[conn[j]]=true;
else
{
- std::ostringstream oss; oss << "MEDCouplingUMesh::getNodeIdsInUse : In cell #" << i << " presence of node id " << conn[j] << " not in [0," << nbOfNodes << ") !";
+ std::ostringstream oss; oss << "MEDCouplingUMesh::computeNodeIdsAlg : In cell #" << i << " presence of node id " << conn[j] << " not in [0," << nbOfNodes << ") !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
* \ref cpp_mcumesh_getNodeIdsInUse "Here is a C++ example".<br>
* \ref py_mcumesh_getNodeIdsInUse "Here is a Python example".
* \endif
- * \sa computeNodeIdsAlg()
+ * \sa computeFetchedNodeIds, computeNodeIdsAlg()
*/
DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
{
nbrOfNodesInUse=-1;
- int nbOfNodes=getNumberOfNodes();
+ int nbOfNodes(getNumberOfNodes());
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(nbOfNodes,1);
int *traducer=ret->getPointer();
duplicateNodesInConn(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,nbOfNodes);
}
+/*!
+ * This method renumbers only nodal connectivity in \a this. The renumbering is only an offset applied. So this method is a specialization of
+ * \a renumberNodesInConn. \b WARNING, this method does not check that the resulting node ids in the nodal connectivity is in a valid range !
+ *
+ * \param [in] offset - specifies the offset to be applied on each element of connectivity.
+ *
+ * \sa renumberNodesInConn
+ */
+void MEDCouplingUMesh::renumberNodesWithOffsetInConn(int offset)
+{
+ checkConnectivityFullyDefined();
+ int *conn(getNodalConnectivity()->getPointer());
+ const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
+ int nbOfCells(getNumberOfCells());
+ for(int i=0;i<nbOfCells;i++)
+ for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+ {
+ int& node=conn[iconn];
+ if(node>=0)//avoid polyhedron separator
+ {
+ node+=offset;
+ }
+ }
+ _nodal_connec->declareAsNew();
+ updateTime();
+}
+
+/*!
+ * Same than renumberNodesInConn(const int *) except that here the format of old-to-new traducer is using map instead
+ * of array. This method is dedicated for renumbering from a big set of nodes the a tiny set of nodes which is the case during extraction
+ * of a big mesh.
+ */
+void MEDCouplingUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMap<int,int>& newNodeNumbersO2N)
+{
+ checkConnectivityFullyDefined();
+ int *conn(getNodalConnectivity()->getPointer());
+ const int *connIndex(getNodalConnectivityIndex()->getConstPointer());
+ int nbOfCells(getNumberOfCells());
+ for(int i=0;i<nbOfCells;i++)
+ for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
+ {
+ int& node=conn[iconn];
+ if(node>=0)//avoid polyhedron separator
+ {
+ INTERP_KERNEL::HashMap<int,int>::const_iterator it(newNodeNumbersO2N.find(node));
+ if(it!=newNodeNumbersO2N.end())
+ {
+ node=(*it).second;
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::renumberNodesInConn(map) : presence in connectivity for cell #" << i << " of node #" << node << " : Not in map !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ _nodal_connec->declareAsNew();
+ updateTime();
+}
+
/*!
* Changes ids of nodes within the nodal connectivity arrays according to a permutation
* array in "Old to New" mode. The node coordinates array is \b not changed by this method.
checkConnectivityFullyDefined();
int *conn=getNodalConnectivity()->getPointer();
const int *connIndex=getNodalConnectivityIndex()->getConstPointer();
- int nbOfCells=getNumberOfCells();
+ int nbOfCells(getNumberOfCells());
for(int i=0;i<nbOfCells;i++)
for(int iconn=connIndex[i]+1;iconn!=connIndex[i+1];iconn++)
{
/**
* Provides a renumbering of the cells of this (which has to be a piecewise connected 1D line), so that
* the segments of the line are indexed in consecutive order (i.e. cells \a i and \a i+1 are neighbors).
- * This doesn't modify the mesh.
+ * This doesn't modify the mesh. This method only works using nodal connectivity consideration. Coordinates of nodes are ignored here.
* The caller is to deal with the resulting DataArrayInt.
* \throw If the coordinate array is not set.
* \throw If the nodal connectivity of the cells is not defined.
DataArrayInt *MEDCouplingUMesh::orderConsecutiveCells1D() const
{
checkFullyDefined();
- if(getMeshDimension()!=1 || getSpaceDimension()!=2)
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D works on unstructured mesh with (meshdim, spacedim) = (1,2)!");
+ if(getMeshDimension()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::orderConsecutiveCells1D works on unstructured mesh with meshdim = 1 !");
// Check that this is a line (and not a more complex 1D mesh) - each point is used at most by 2 segments:
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _d(DataArrayInt::New()),_dI(DataArrayInt::New());