std::vector<const DataArrayDouble *> coo(ms.size());
int spaceDim=(*it)->getSpaceDimension();
coo[0]=(*it++)->getCoords();
+ if(!coo[0]->isAllocated())
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : first element in coordinates is not allocated !");
for(int i=1;it!=ms.end();it++,i++)
{
const DataArrayDouble *tmp=(*it)->getCoords();
if(tmp)
{
- if((*it)->getSpaceDimension()==spaceDim)
- coo[i]=tmp;
+ if(tmp->isAllocated())
+ {
+ if((*it)->getSpaceDimension()==spaceDim)
+ coo[i]=tmp;
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : Mismatch in SpaceDim !");
+ }
else
- throw INTERP_KERNEL::Exception("Mismatch in SpaceDim during call of MergeNodesArray !");
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : Presence of a non allocated array !");
}
else
- throw INTERP_KERNEL::Exception("Empty coords detected during call of MergeNodesArray !");
+ throw INTERP_KERNEL::Exception("MEDCouplingPointSet::MergeNodesArray : Empty coords detected !");
}
return DataArrayDouble::Aggregate(coo);
}
{
DataArrayInt *cellIdsKept=0;
fillCellIdsToKeepFromNodeIds(begin,end,fullyIn,cellIdsKept);
- cellIdsKept->setName(getName());
+ cellIdsKept->setName(getName().c_str());
return cellIdsKept;
}
renumberNodes(traducer->getConstPointer(),newNbOfNodes);
return traducer.retn();
}
+
+/*!
+ * Merges nodes equal within \a precision and returns an array describing the
+ * permutation used to remove duplicate nodes.
+ * \param [in] precision - minimal absolute distance between two nodes at which they are
+ * considered not coincident.
+ * \param [out] areNodesMerged - is set to \c true if any coincident nodes removed.
+ * \param [out] newNbOfNodes - number of nodes remaining after the removal.
+ * \return DataArrayInt * - the permutation array in "Old to New" mode. For more
+ * info on "Old to New" mode see \ref MEDCouplingArrayRenumbering. The caller
+ * is to delete this array using decrRef() as it is no more needed.
+ * \throw If the coordinates array is not set.
+ * \throw If the nodal connectivity of cells is not defined.
+ *
+ * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
+ * \ref py_mcumesh_mergeNodes "Here is a Python example".
+ */
+DataArrayInt *MEDCouplingPointSet::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes);
+ if(areNodesMerged)
+ renumberNodes(ret->begin(),newNbOfNodes);
+ return ret.retn();
+}
+
+/*!
+ * Merges nodes equal within \a precision and returns an array describing the
+ * permutation used to remove duplicate nodes. In contrast to mergeNodes(), location
+ * of merged nodes is changed to be at their barycenter.
+ * \param [in] precision - minimal absolute distance between two nodes at which they are
+ * considered not coincident.
+ * \param [out] areNodesMerged - is set to \c true if any coincident nodes removed.
+ * \param [out] newNbOfNodes - number of nodes remaining after the removal.
+ * \return DataArrayInt * - the permutation array in "Old to New" mode. For more
+ * info on "Old to New" mode see \ref MEDCouplingArrayRenumbering. The caller
+ * is to delete this array using decrRef() as it is no more needed.
+ * \throw If the coordinates array is not set.
+ * \throw If the nodal connectivity of cells is not defined.
+ *
+ * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
+ * \ref py_mcumesh_mergeNodes "Here is a Python example".
+ */
+DataArrayInt *MEDCouplingPointSet::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
+{
+ DataArrayInt *ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes);
+ if(areNodesMerged)
+ renumberNodes2(ret->getConstPointer(),newNbOfNodes);
+ return ret;
+}