/*!
* Checks if \a this mesh is well defined. If no exception is thrown by this method,
- * then \a this mesh is most probably is writable, exchangeable and available for all
+ * then \a this mesh is informatically clean, most probably is writable, exchangeable and available for all
* algorithms. <br> In addition to the checks performed by checkConsistencyLight(), this
- * method thoroughly checks the nodal connectivity.
+ * method thoroughly checks the nodal connectivity. For more geometrical checking
+ * checkGeomConsistency method is better than this.
+ *
+ * \sa MEDCouplingUMesh::checkGeomConsistency
+ *
* \param [in] eps - a not used parameter.
* \throw If the mesh dimension is not set.
* \throw If the coordinates array is not set (if mesh dimension != -1 ).
}
}
+/*!
+ * This method adds some geometrical checks in addition to the informatical check of checkConsistency method.
+ * This method in particular checks that a same node is not repeated several times in a cell.
+ *
+ * \throw If there is a presence a multiple same node ID in nodal connectivity of cell.
+ */
+void MEDCouplingUMesh::checkGeomConsistency(double eps) const
+{
+ this->checkConsistency(eps);
+ auto nbOfCells(getNumberOfCells());
+ const mcIdType *ptr(_nodal_connec->begin()),*ptrI(_nodal_connec_index->begin());
+ for(auto icell = 0 ; icell < nbOfCells ; ++icell)
+ {
+ std::set<mcIdType> s(ptr+ptrI[icell]+1,ptr+ptrI[icell+1]);
+ if(s.size()==ptrI[icell+1]-ptrI[icell]-1)
+ continue;
+ std::ostringstream oss; oss << "MEDCouplingUMesh::checkGeomConsistency : for cell #" << icell << " presence of multiple same nodeID !";
+ throw INTERP_KERNEL::Exception(oss.str());
+ }
+}
+
+
/*!
* Sets dimension of \a this mesh. The mesh dimension in general depends on types of
* elements contained in the mesh. For more info on the mesh dimension see
MEDCOUPLING_EXPORT void checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const;
MEDCOUPLING_EXPORT void checkConsistencyLight() const;
MEDCOUPLING_EXPORT void checkConsistency(double eps=1e-12) const;
+ MEDCOUPLING_EXPORT void checkGeomConsistency(double eps=1e-12) const;
MEDCOUPLING_EXPORT void setMeshDimension(int meshDim);
MEDCOUPLING_EXPORT void allocateCells(mcIdType nbOfCells=0);
MEDCOUPLING_EXPORT void insertNextCell(INTERP_KERNEL::NormalizedCellType type, mcIdType size, const mcIdType *nodalConnOfCell);
m.advancedRepr()
repr(m)
+ def testCheckGeomConsistency0(self):
+ """Test of MEDCouplingUMesh.checkGeomConsistency"""
+ m = MEDCouplingUMesh("",2)
+ m.setCoords(DataArrayDouble([(0,0),(1,0),(2,0),(0,1),(1,1),(2,1)]))
+ m.allocateCells()
+ m.insertNextCell(NORM_TRI6,[0,1,2,3,4,5])
+ m.insertNextCell(NORM_TRI6,[0,1,3,3,4,5])
+ m.checkConsistency()
+ self.assertRaises(InterpKernelException,m.checkGeomConsistency) # cell1 is incorrect because node 3 is repeated twice
+ m.getNodalConnectivity()[10]=2 # replace 3 by 2 for cell#1 to fix the problem
+ m.checkConsistency()
+ m.checkGeomConsistency() # now m is OK
+
pass
if __name__ == '__main__':
static MEDCouplingUMesh *New();
static MEDCouplingUMesh *New(const char *meshName, int meshDim);
void checkConsistencyLight() const;
+ void checkGeomConsistency(double eps=1e-12) const;
void setMeshDimension(int meshDim);
void allocateCells(int nbOfCells=0);
void finishInsertingCells();