X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingMappedExtrudedMesh.cxx;h=b20e45461af92cc112d645de3492b8395126abe7;hb=e7835cba1eb17f50ef4e130c2cb8d0f54bc25083;hp=351daf58c7060481e814235dfad3eb8aaaa094e6;hpb=e7b600309085fa6a411b31ec89c795471f272ae1;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx index 351daf58c..b20e45461 100644 --- a/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx +++ b/src/MEDCoupling/MEDCouplingMappedExtrudedMesh.cxx @@ -20,6 +20,7 @@ #include "MEDCouplingMappedExtrudedMesh.hxx" #include "MEDCouplingUMesh.hxx" +#include "MEDCouplingCMesh.hxx" #include "MEDCouplingMemArray.hxx" #include "MEDCouplingFieldDouble.hxx" #include "MCAuto.hxx" @@ -50,6 +51,11 @@ MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::New(const MEDCoupl return new MEDCouplingMappedExtrudedMesh(mesh3D,mesh2D,cell2DId); } +MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::New(const MEDCouplingCMesh *mesh3D) +{ + return new MEDCouplingMappedExtrudedMesh(mesh3D); +} + /*! * This constructor is here only for unserialisation process. * This constructor is normally completely useless for end user. @@ -95,29 +101,38 @@ void MEDCouplingMappedExtrudedMesh::copyTinyStringsFrom(const MEDCouplingMesh *o MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingUMesh *mesh3D, const MEDCouplingUMesh *mesh2D, int cell2DId) try:_mesh2D(const_cast(mesh2D)),_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(cell2DId) { - if(_mesh2D!=0) + if(_mesh2D.isNotNull()) _mesh2D->incrRef(); computeExtrusion(mesh3D); - setName(mesh3D->getName()); + setName(mesh3D->getName()); setDescription(mesh3D->getDescription()); } catch(INTERP_KERNEL::Exception& e) { - if(_mesh2D) - _mesh2D->decrRef(); - if(_mesh1D) - _mesh1D->decrRef(); - if(_mesh3D_ids) - _mesh3D_ids->decrRef(); throw e; } +MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingCMesh *mesh3D):_mesh1D(MEDCouplingUMesh::New()),_mesh3D_ids(0),_cell_2D_id(0) +{ + if(!mesh3D) + throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh contrct : null input pointer !"); + if(mesh3D->getMeshDimension()!=3) + throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh contrct : input cart mesh must have dimension equal to 3 !"); + MCAuto umesh3D(mesh3D->buildUnstructured()); + MCAuto cmesh2D(MEDCouplingCMesh::New()); cmesh2D->setName(mesh3D->getName()); + cmesh2D->setCoords(mesh3D->getCoordsAt(0),mesh3D->getCoordsAt(1)); + _mesh2D=cmesh2D->buildUnstructured(); + _mesh2D->setCoords(umesh3D->getCoords()); + computeExtrusion(umesh3D); + setName(mesh3D->getName()); setDescription(mesh3D->getDescription()); +} + MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh():_mesh2D(0),_mesh1D(0),_mesh3D_ids(0),_cell_2D_id(-1) { } -MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingMappedExtrudedMesh& other, bool deepCopy):MEDCouplingMesh(other),_cell_2D_id(other._cell_2D_id) +MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingMappedExtrudedMesh& other, bool deepCpy):MEDCouplingMesh(other),_cell_2D_id(other._cell_2D_id) { - if(deepCopy) + if(deepCpy) { _mesh2D=other._mesh2D->clone(true); _mesh1D=other._mesh1D->clone(true); @@ -126,18 +141,12 @@ MEDCouplingMappedExtrudedMesh::MEDCouplingMappedExtrudedMesh(const MEDCouplingMa else { _mesh2D=other._mesh2D; - if(_mesh2D) - _mesh2D->incrRef(); _mesh1D=other._mesh1D; - if(_mesh1D) - _mesh1D->incrRef(); _mesh3D_ids=other._mesh3D_ids; - if(_mesh3D_ids) - _mesh3D_ids->incrRef(); } } -int MEDCouplingMappedExtrudedMesh::getNumberOfCells() const +std::size_t MEDCouplingMappedExtrudedMesh::getNumberOfCells() const { return _mesh2D->getNumberOfCells()*_mesh1D->getNumberOfCells(); } @@ -167,6 +176,11 @@ MEDCouplingMappedExtrudedMesh *MEDCouplingMappedExtrudedMesh::clone(bool recDeep return new MEDCouplingMappedExtrudedMesh(*this,recDeepCpy); } +const DataArrayDouble *MEDCouplingMappedExtrudedMesh::getDirectAccessOfCoordsArrIfInStructure() const +{ + throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getDirectAccessOfCoordsArrIfInStructure : no direct access of DataArrayDouble holding nodes !"); +} + bool MEDCouplingMappedExtrudedMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const { if(!other) @@ -232,15 +246,15 @@ void MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith(const MEDCou throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::checkDeepEquivalOnSameNodesWith : not implemented yet !"); } -INTERP_KERNEL::NormalizedCellType MEDCouplingMappedExtrudedMesh::getTypeOfCell(int cellId) const +INTERP_KERNEL::NormalizedCellType MEDCouplingMappedExtrudedMesh::getTypeOfCell(std::size_t cellId) const { const int *ids(_mesh3D_ids->begin()); - int nbOf3DCells(_mesh3D_ids->getNumberOfTuples()); + std::size_t nbOf3DCells(_mesh3D_ids->getNumberOfTuples()); const int *where(std::find(ids,ids+nbOf3DCells,cellId)); if(where==ids+nbOf3DCells) throw INTERP_KERNEL::Exception("Invalid cellId specified >= getNumberOfCells() !"); - int nbOfCells2D(_mesh2D->getNumberOfCells()); - int locId(((int)std::distance(ids,where))%nbOfCells2D); + std::size_t nbOfCells2D(_mesh2D->getNumberOfCells()); + std::size_t locId((std::distance(ids,where))%nbOfCells2D); INTERP_KERNEL::NormalizedCellType tmp(_mesh2D->getTypeOfCell(locId)); return INTERP_KERNEL::CellModel::GetCellModel(tmp).getExtrudedType(); } @@ -308,11 +322,11 @@ DataArrayInt *MEDCouplingMappedExtrudedMesh::computeEffectiveNbOfNodesPerCell() return computeNbOfNodesPerCell(); } -int MEDCouplingMappedExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const +std::size_t MEDCouplingMappedExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - int ret(0); - int nbOfCells2D(_mesh2D->getNumberOfCells()); - for(int i=0;igetNumberOfCells()); + for(std::size_t i=0;igetTypeOfCell(i)); if(INTERP_KERNEL::CellModel::GetCellModel(t).getExtrudedType()==type) @@ -321,7 +335,7 @@ int MEDCouplingMappedExtrudedMesh::getNumberOfCellsWithType(INTERP_KERNEL::Norma return ret*_mesh1D->getNumberOfCells(); } -void MEDCouplingMappedExtrudedMesh::getNodeIdsOfCell(int cellId, std::vector& conn) const +void MEDCouplingMappedExtrudedMesh::getNodeIdsOfCell(std::size_t cellId, std::vector& conn) const { int nbOfCells2D(_mesh2D->getNumberOfCells()); int nbOfNodes2D(_mesh2D->getNumberOfNodes()); @@ -428,9 +442,13 @@ void MEDCouplingMappedExtrudedMesh::updateTime() const void MEDCouplingMappedExtrudedMesh::renumberCells(const int *old2NewBg, bool check) { - throw INTERP_KERNEL::Exception("Functionnality of renumbering cells unavailable for ExtrudedMesh"); + throw INTERP_KERNEL::Exception("Functionality of renumbering cells unavailable for ExtrudedMesh"); } +/*! + * \b WARNING in case of modif think to update MEDFileUMesh::New implementation ! + * \sa MEDFileUMesh::New + */ MEDCouplingUMesh *MEDCouplingMappedExtrudedMesh::build3DUnstructuredMesh() const { MCAuto mesh2DZC(_mesh2D->deepCopyConnectivityOnly()); @@ -442,6 +460,10 @@ MEDCouplingUMesh *MEDCouplingMappedExtrudedMesh::build3DUnstructuredMesh() const return ret.retn(); } +/*! + * \b WARNING in case of modif think to update MEDFileUMesh::New implementation ! + * \sa MEDFileUMesh::New + */ MEDCouplingUMesh *MEDCouplingMappedExtrudedMesh::buildUnstructured() const { return build3DUnstructuredMesh(); @@ -486,6 +508,11 @@ int MEDCouplingMappedExtrudedMesh::getCellContainingPoint(const double *pos, dou throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellContainingPoint : not implemented yet !"); } +void MEDCouplingMappedExtrudedMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const +{ + throw INTERP_KERNEL::Exception("MEDCouplingMappedExtrudedMesh::getCellsContainingPoint : not implemented yet !"); +} + MEDCouplingMappedExtrudedMesh::~MEDCouplingMappedExtrudedMesh() { } @@ -682,7 +709,7 @@ DataArrayInt *MEDCouplingMappedExtrudedMesh::checkTypeConsistencyAndContig(const throw INTERP_KERNEL::Exception("Not implemented yet !"); } -void MEDCouplingMappedExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType) const +void MEDCouplingMappedExtrudedMesh::splitProfilePerType(const DataArrayInt *profile, std::vector& code, std::vector& idsInPflPerType, std::vector& idsPerType, bool smartPflKiller) const { throw INTERP_KERNEL::Exception("Not implemented yet !"); } @@ -752,7 +779,7 @@ void MEDCouplingMappedExtrudedMesh::getReverseNodalConnectivity(DataArrayInt *re void MEDCouplingMappedExtrudedMesh::computeExtrusionAlg(const MEDCouplingUMesh *mesh3D) { _mesh3D_ids->alloc(mesh3D->getNumberOfCells(),1); - int nbOf1DLev=mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells(); + int nbOf1DLev(mesh3D->getNumberOfCells()/_mesh2D->getNumberOfCells()); _mesh1D->setMeshDimension(1); _mesh1D->allocateCells(nbOf1DLev); int tmpConn[2];