X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingNormalizedUnstructuredMesh.txx;h=9c5aab27c3f28208b3aefce0f652577defcedbdf;hb=b607ffc713080a567fb90595118069ac18181e99;hp=745137a968a7616946a2f08a59f4481a98e2242d;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx index 745137a96..9c5aab27c 100644 --- a/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx +++ b/src/MEDCoupling/MEDCouplingNormalizedUnstructuredMesh.txx @@ -1,31 +1,37 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 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 -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay (CEA/DEN) + #ifndef __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ #define __MEDCOUPLINGNORMALIZEDUNSTRUCTUREDMESH_TXX__ #include "MEDCouplingNormalizedUnstructuredMesh.hxx" +#include "InterpKernelAssert.hxx" #include "MEDCouplingUMesh.hxx" -#include "MemArray.hxx" +#include "MEDCoupling1GTUMesh.hxx" +#include "MEDCouplingMemArray.hxx" + +#include template -MEDCouplingNormalizedUnstructuredMesh::MEDCouplingNormalizedUnstructuredMesh(ParaMEDMEM::MEDCouplingUMesh *mesh):_mesh(mesh) +MEDCouplingNormalizedUnstructuredMesh::MEDCouplingNormalizedUnstructuredMesh(const MEDCoupling::MEDCouplingPointSet *mesh):_mesh(mesh) { if(_mesh) _mesh->incrRef(); @@ -40,13 +46,13 @@ void MEDCouplingNormalizedUnstructuredMesh::getBoundingBox(dou boundingBox[i]=std::numeric_limits::max(); boundingBox[SPACEDIM+i]=-std::numeric_limits::max(); } - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); - const double *ptr=array->getPointer(); - int nbOfPts=array->getNbOfElems()/SPACEDIM; + const MEDCoupling::DataArrayDouble *array=_mesh->getCoords(); + const double *ptr=array->getConstPointer(); + mcIdType nbOfPts=ToIdType(array->getNbOfElems())/SPACEDIM; for(int j=0;j*work) boundingBox[j]=*work; @@ -57,31 +63,31 @@ void MEDCouplingNormalizedUnstructuredMesh::getBoundingBox(dou } template -INTERP_KERNEL::NormalizedCellType MEDCouplingNormalizedUnstructuredMesh::getTypeOfElement(int eltId) const +INTERP_KERNEL::NormalizedCellType MEDCouplingNormalizedUnstructuredMesh::getTypeOfElement(mcIdType eltId) const { return _mesh->getTypeOfCell(eltId); } template -unsigned char MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodesOfElement(int eltId) const +mcIdType MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodesOfElement(mcIdType eltId) const { return _mesh->getNumberOfNodesInCell(eltId); } template -unsigned long MEDCouplingNormalizedUnstructuredMesh::getNumberOfElements() const +mcIdType MEDCouplingNormalizedUnstructuredMesh::getNumberOfElements() const { - return _mesh->getNumberOfCells(); + return ToIdType(_mesh->getNumberOfCells()); } template -unsigned long MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodes() const +mcIdType MEDCouplingNormalizedUnstructuredMesh::getNumberOfNodes() const { return _mesh->getNumberOfNodes(); } template -const int *MEDCouplingNormalizedUnstructuredMesh::getConnectivityPtr() const +const mcIdType *MEDCouplingNormalizedUnstructuredMesh::getConnectivityPtr() const { return _conn_for_interp; } @@ -89,18 +95,18 @@ const int *MEDCouplingNormalizedUnstructuredMesh::getConnectiv template const double *MEDCouplingNormalizedUnstructuredMesh::getCoordinatesPtr() const { - ParaMEDMEM::DataArrayDouble *array=_mesh->getCoords(); - return array->getPointer(); + const MEDCoupling::DataArrayDouble *array=_mesh->getCoords(); + return array->getConstPointer(); } template -const int *MEDCouplingNormalizedUnstructuredMesh::getConnectivityIndexPtr() const +const mcIdType *MEDCouplingNormalizedUnstructuredMesh::getConnectivityIndexPtr() const { return _conn_index_for_interp; } template -void MEDCouplingNormalizedUnstructuredMesh::ReleaseTempArrays() +void MEDCouplingNormalizedUnstructuredMesh::releaseTempArrays() { delete [] _conn_for_interp; delete [] _conn_index_for_interp; @@ -113,30 +119,60 @@ MEDCouplingNormalizedUnstructuredMesh::~MEDCouplingNormalizedU { if(_mesh) _mesh->decrRef(); - ReleaseTempArrays(); + releaseTempArrays(); } template void MEDCouplingNormalizedUnstructuredMesh::prepare() { - int nbOfCell=_mesh->getNumberOfCells(); - int initialConnSize=_mesh->getNodalConnectivity()->getNbOfElems(); - _conn_for_interp=new int[initialConnSize-nbOfCell]; - _conn_index_for_interp=new int[nbOfCell+1]; - _conn_index_for_interp[0]=0; - const int *work_conn=_mesh->getNodalConnectivity()->getPointer()+1; - const int *work_conn_index=_mesh->getNodalConnectivityIndex()->getPointer(); - int *work_conn_for_interp=_conn_for_interp; - int *work_conn_index_for_interp=_conn_index_for_interp; - for(int i=0;igetSpaceDimension()==SPACEDIM); + const MEDCoupling::MEDCouplingUMesh *m1(dynamic_cast(_mesh)); + if(m1) + { + mcIdType nbOfCell=ToIdType(m1->getNumberOfCells()); + mcIdType initialConnSize=ToIdType(m1->getNodalConnectivity()->getNbOfElems()); + _conn_for_interp=new mcIdType[initialConnSize-nbOfCell]; + _conn_index_for_interp=new mcIdType[nbOfCell+1]; + _conn_index_for_interp[0]=0; + const mcIdType *work_conn=m1->getNodalConnectivity()->getConstPointer()+1; + const mcIdType *work_conn_index=m1->getNodalConnectivityIndex()->getConstPointer(); + mcIdType *work_conn_for_interp=_conn_for_interp; + mcIdType *work_conn_index_for_interp=_conn_index_for_interp; + for(mcIdType i=0;i(_mesh)); + if(m2) + { + mcIdType nbOfCell=ToIdType(m2->getNumberOfCells()); + _conn_index_for_interp=new mcIdType[nbOfCell+1]; + const mcIdType *conni(m2->getNodalConnectivityIndex()->begin()); + std::copy(conni,conni+nbOfCell+1,_conn_index_for_interp); + _conn_for_interp=new mcIdType[m2->getNodalConnectivity()->getNumberOfTuples()]; + std::copy(m2->getNodalConnectivity()->begin(),m2->getNodalConnectivity()->end(),_conn_for_interp); + return ; + } + const MEDCoupling::MEDCoupling1SGTUMesh *m3(dynamic_cast(_mesh)); + if(m3) { - int nbOfValsToCopy=work_conn_index[1]-work_conn_index[0]-1; - work_conn_for_interp=std::copy(work_conn,work_conn+nbOfValsToCopy,work_conn_for_interp); - work_conn_index_for_interp[1]=work_conn_index_for_interp[0]+nbOfValsToCopy; - work_conn_index++; - work_conn+=nbOfValsToCopy+1; - work_conn_index_for_interp++; + mcIdType nbOfCell=ToIdType(m3->getNumberOfCells()),nbNodesPerCell(m3->getNumberOfNodesPerCell()); + _conn_index_for_interp=new mcIdType[nbOfCell+1]; _conn_index_for_interp[0]=0; + mcIdType *work(_conn_index_for_interp); + for(mcIdType i=0;igetNodalConnectivity()->getNumberOfTuples()]; + std::copy(m3->getNodalConnectivity()->begin(),m3->getNodalConnectivity()->end(),_conn_for_interp); + return ; } + throw INTERP_KERNEL::Exception("MEDCouplingNormalizedUnstructuredMesh::prepare : Unrecognized unstructured mesh ! Type must be in MEDCouplingUMesh, MEDCoupling1DGTUMesh, MEDCoupling1SGTUMesh !"); } #endif