* Returns a set of all cell types available in \a this mesh.
* \return std::set<INTERP_KERNEL::NormalizedCellType> - the set of cell types.
* \warning this method does not throw any exception even if \a this is not defined.
+ * \sa MEDCouplingUMesh::getAllGeoTypesSorted
*/
std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getAllGeoTypes() const
{
return _types;
}
+/*!
+ * This method returns the sorted list of geometric types in \a this.
+ * Sorted means in the same order than the cells in \a this. A single entry in return vector means the maximal chunk of consecutive cells in \a this
+ * having the same geometric type. So a same geometric type can appear more than once if the cells are not sorted per geometric type.
+ *
+ * \throw if connectivity in \a this is not correctly defined.
+ *
+ * \sa MEDCouplingMesh::getAllGeoTypes
+ */
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getAllGeoTypesSorted() const
+{
+ std::vector<INTERP_KERNEL::NormalizedCellType> ret;
+ checkConnectivityFullyDefined();
+ int nbOfCells(getNumberOfCells());
+ if(nbOfCells==0)
+ return ret;
+ if(getMeshLength()<1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::getAllGeoTypesSorted : the connectivity in this seems invalid !");
+ const int *c(_nodal_connec->begin()),*ci(_nodal_connec_index->begin());
+ ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci++]);
+ for(int i=1;i<nbOfCells;i++,ci++)
+ if(ret.back()!=((INTERP_KERNEL::NormalizedCellType)c[*ci]))
+ ret.push_back((INTERP_KERNEL::NormalizedCellType)c[*ci]);
+ return ret;
+}
+
/*!
* This method is a method that compares \a this and \a other.
* This method compares \b all attributes, even names and component names.
MEDCOUPLING_EXPORT MEDCouplingUMeshCellIterator *cellIterator();
MEDCOUPLING_EXPORT MEDCouplingUMeshCellByTypeEntry *cellsByType();
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getAllGeoTypes() const;
+ MEDCOUPLING_EXPORT std::vector<INTERP_KERNEL::NormalizedCellType> getAllGeoTypesSorted() const;
MEDCOUPLING_EXPORT std::set<INTERP_KERNEL::NormalizedCellType> getTypesOfPart(const int *begin, const int *end) const;
MEDCOUPLING_EXPORT void setConnectivity(DataArrayInt *conn, DataArrayInt *connIndex, bool isComputingTypes=true);
MEDCOUPLING_EXPORT const DataArrayInt *getNodalConnectivity() const { return _nodal_connec; }
m=MEDCouplingUMesh("toto",3)
m.allocateCells(0)
m.insertNextCell(NORM_TETRA4,[0,1,2,3])
+ self.assertEqual([NORM_TETRA4],m.getAllGeoTypesSorted())
m.insertNextCell(NORM_HEXA8,[4,5,6,7,8,9,10,11])
+ self.assertEqual([NORM_TETRA4,NORM_HEXA8],m.getAllGeoTypesSorted())
m.insertNextCell(NORM_HEXA8,[12,13,14,15,16,17,18,19])
+ self.assertEqual([NORM_TETRA4,NORM_HEXA8],m.getAllGeoTypesSorted())
m.insertNextCell(NORM_TETRA4,[20,21,22,23])
+ self.assertEqual([NORM_TETRA4,NORM_HEXA8,NORM_TETRA4],m.getAllGeoTypesSorted())
c1=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,0.,0.,0.,0.,1.],4,3)
c2=DataArrayDouble([0.,0.,0.,0.,1.,0.,1.,1.,0.,1.,0.,0., 0.,0.,1.,0.,1.,1.,1.,1.,1.,1.,0.,1.],8,3) ; c2+=[2.,0.,0.]
c3=c2+[2.,0.,0.]
{
return self->cellIterator();
}
+
+ PyObject *getAllGeoTypesSorted() const throw(INTERP_KERNEL::Exception)
+ {
+ std::vector<INTERP_KERNEL::NormalizedCellType> result=self->getAllGeoTypesSorted();
+ std::vector<INTERP_KERNEL::NormalizedCellType>::const_iterator iL=result.begin();
+ PyObject *res=PyList_New(result.size());
+ for(int i=0;iL!=result.end(); i++, iL++)
+ PyList_SetItem(res,i,PyInt_FromLong(*iL));
+ return res;
+ }
void setPartOfMySelf(PyObject *li, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
{