X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingStructuredMesh.cxx;h=ffd9c27c6e31b8a11b22e0390e8f181e9387e9bd;hb=f1a947b32a36d8dc8e3079b25305bb50e8cb59a0;hp=4d02d732b9c8bb04d9be523b481080742e434786;hpb=887d0e1efce4f46f68d2596dcd801f02f5c1f99e;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 4d02d732b..ffd9c27c6 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -71,45 +71,42 @@ INTERP_KERNEL::NormalizedCellType MEDCouplingStructuredMesh::getTypeOfCell(int c std::set MEDCouplingStructuredMesh::getAllGeoTypes() const { - INTERP_KERNEL::NormalizedCellType ret; - switch(getMeshDimension()) - { - case 3: - ret=INTERP_KERNEL::NORM_HEXA8; - break; - case 2: - ret=INTERP_KERNEL::NORM_QUAD4; - break; - case 1: - ret=INTERP_KERNEL::NORM_SEG2; - break; - default: - throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::getAllGeoTypes !"); - } std::set ret2; - ret2.insert(ret); + ret2.insert(getTypeOfCell(0)); return ret2; } int MEDCouplingStructuredMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { int ret=getNumberOfCells(); - int dim=getMeshDimension(); - switch(type) + if(type==getTypeOfCell(0)) + return ret; + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::getNumberOfCellsWithType : no specified type ! Type available is " << cm.getRepr() << " !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); +} + +DataArrayInt *MEDCouplingStructuredMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + if(getTypeOfCell(0)==type) { - case INTERP_KERNEL::NORM_HEXA8: - if(dim==3) - return ret; - case INTERP_KERNEL::NORM_QUAD4: - if(dim==2) - return ret; - case INTERP_KERNEL::NORM_SEG2: - if(dim==1) - return ret; - default: - throw INTERP_KERNEL::Exception("Unexpected dimension for MEDCouplingStructuredMesh::getTypeOfCell !"); + ret->alloc(getNumberOfCells(),1); + ret->iota(0); } - return 0; + else + ret->alloc(0,1); + return ret.retn(); +} + +DataArrayInt *MEDCouplingStructuredMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception) +{ + int nbCells=getNumberOfCells(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + ret->alloc(nbCells,1); + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(getTypeOfCell(0)); + ret->fillWithValue((int)cm.getNumberOfNodes()); + return ret.retn(); } void MEDCouplingStructuredMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const