X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCoupling1GTUMesh.cxx;h=0724620a53155ffd4880dfcd4301b4d3e9260ab6;hb=f13ce72017fd205546293a53f7b041824cb50eec;hp=ca92e2fa09a7705d8683bee975ebd47159153356;hpb=9c9d2e33fdeb3caafa49498c77f11c20302b3b53;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index ca92e2fa0..0724620a5 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2014 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. +// 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 @@ -28,11 +28,11 @@ using namespace ParaMEDMEM; const int MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[6]={0,1,2,4,3,5}; -MEDCoupling1GTUMesh::MEDCoupling1GTUMesh() +MEDCoupling1GTUMesh::MEDCoupling1GTUMesh():_cm(0) { } -MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):_cm(&cm) +MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):_cm(&cm) { setName(name); } @@ -41,7 +41,7 @@ MEDCoupling1GTUMesh::MEDCoupling1GTUMesh(const MEDCoupling1GTUMesh& other, bool { } -MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type) +MEDCoupling1GTUMesh *MEDCoupling1GTUMesh::New(const std::string& name, INTERP_KERNEL::NormalizedCellType type) { if(type==INTERP_KERNEL::NORM_ERROR) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::New : NORM_ERROR is not a valid type to be used as base geometric type for a mesh !"); @@ -404,7 +404,7 @@ MEDCouplingUMesh *MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(const std::v throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh : the first instance in input parts is null !"); const DataArrayDouble *coords(firstPart->getCoords()); int meshDim(firstPart->getMeshDimension()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingUMesh::New(firstPart->getName().c_str(),meshDim)); ret->setDescription(firstPart->getDescription().c_str()); + MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingUMesh::New(firstPart->getName(),meshDim)); ret->setDescription(firstPart->getDescription()); ret->setCoords(coords); int nbOfCells(0),connSize(0); for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++) @@ -467,7 +467,7 @@ MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bo } } -MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const char *name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm) +MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const std::string& name, const INTERP_KERNEL::CellModel& cm):MEDCoupling1GTUMesh(name,cm) { } @@ -480,7 +480,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New() return new MEDCoupling1SGTUMesh; } -MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const char *name, INTERP_KERNEL::NormalizedCellType type) +MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const std::string& name, INTERP_KERNEL::NormalizedCellType type) { if(type==INTERP_KERNEL::NORM_ERROR) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : NORM_ERROR is not a valid type to be used as base geometric type for a mesh !"); @@ -501,8 +501,8 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::New(const MEDCouplingUMesh *m) if(gts.size()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::New : input mesh must have exactly one geometric type !"); int geoType((int)*gts.begin()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(m->getName().c_str(),*gts.begin())); - ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str()); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(m->getName(),*gts.begin())); + ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription()); int nbCells(m->getNumberOfCells()); int nbOfNodesPerCell(ret->getNumberOfNodesPerCell()); MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()); conn->alloc(nbCells*nbOfNodesPerCell,1); @@ -826,15 +826,15 @@ std::string MEDCoupling1SGTUMesh::advancedRepr() const { if(_conn->getNumberOfComponents()==1) { - int nbOfCells=getNumberOfCells(); - int sz=getNumberOfNodesPerCell(); - const int *connPtr=_conn->begin(); - for(int i=0;i(ret," ")); - ret << "\n"; - } + int nbOfCells=getNumberOfCells(); + int sz=getNumberOfNodesPerCell(); + const int *connPtr=_conn->begin(); + for(int i=0;i(ret," ")); + ret << "\n"; + } } else ret << "Nodal connectivity array specified and allocated but with not exactly one component !" << "\n"; @@ -949,7 +949,7 @@ MEDCouplingMesh *MEDCoupling1SGTUMesh::mergeMyselfWith(const MEDCouplingMesh *ot MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const { - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension()); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const int *nodalConn=_conn->begin(); int nbCells=getNumberOfCells(); @@ -970,18 +970,18 @@ MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const DataArrayInt *MEDCoupling1SGTUMesh::simplexize(int policy) { switch(policy) - { + { case 0: return simplexizePol0(); case 1: return simplexizePol1(); case (int) INTERP_KERNEL::PLANAR_FACE_5: - return simplexizePlanarFace5(); + return simplexizePlanarFace5(); case (int) INTERP_KERNEL::PLANAR_FACE_6: - return simplexizePlanarFace6(); + return simplexizePlanarFace6(); default: throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::simplexize : unrecognized policy ! Must be :\n - 0 or 1 (only available for meshdim=2) \n - PLANAR_FACE_5, PLANAR_FACE_6 (only for meshdim=3)"); - } + } } /// @cond INTERNAL @@ -1168,7 +1168,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); std::size_t nbOfElemsRet=std::distance(begin,end); const int *inConn=_conn->getConstPointer(); @@ -1194,7 +1194,7 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2(int star { int ncell=getNumberOfCells(); int nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2 : "); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); const int *inConn=_conn->getConstPointer(); int sz=getNumberOfNodesPerCell(); @@ -1237,7 +1237,7 @@ void MEDCoupling1SGTUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) co MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDim) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); MEDCouplingAutoRefCountObjectPtr tmp1; const DataArrayInt *nodalConn(_conn); if(!nodalConn) @@ -1442,9 +1442,9 @@ void MEDCoupling1SGTUMesh::unserialization(const std::vector& tinyInfoD, { INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt); - setName(littleStrings[0].c_str()); - setDescription(littleStrings[1].c_str()); - setTimeUnit(littleStrings[2].c_str()); + setName(littleStrings[0]); + setDescription(littleStrings[1]); + setTimeUnit(littleStrings[2]); setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]); int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]); // @@ -1624,14 +1624,14 @@ MEDCoupling1GTUMesh *MEDCoupling1SGTUMesh::computeDualMesh() const if(!cm.isSimplex()) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh : this mesh is not a simplex mesh ! Please invoke simplexize of tetrahedrize on this before calling this method !"); switch(getMeshDimension()) - { + { case 3: return computeDualMesh3D(); case 2: return computeDualMesh2D(); default: throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh : meshdimension must be in [2,3] !"); - } + } } /*! @@ -1648,7 +1648,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4() const throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::explodeEachHexa8To6Quad4 : this method can be applied only on HEXA8 mesh !"); int nbHexa8(getNumberOfCells()); const int *inConnPtr(getNodalConnectivity()->begin()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName().c_str(),INTERP_KERNEL::NORM_QUAD4)); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4)); MEDCouplingAutoRefCountObjectPtr c(DataArrayInt::New()); c->alloc(nbHexa8*6*4,1); int *cPtr(c->getPointer()); for(int i=0;i v(4); v[0]=getCoords(); v[1]=facesBaryArr; v[2]=edgesBaryArr; v[3]=baryArr; MEDCouplingAutoRefCountObjectPtr zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0; std::string name("DualOf_"); name+=getName(); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr); MEDCouplingAutoRefCountObjectPtr cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1); for(int i=0;i v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr; MEDCouplingAutoRefCountObjectPtr zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; std::string name("DualOf_"); name+=getName(); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(name.c_str(),INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr); MEDCouplingAutoRefCountObjectPtr cArr(DataArrayInt::New()),ciArr(DataArrayInt::New()); ciArr->alloc(nbOfNodes+1,1); ciArr->setIJ(0,0,0); cArr->alloc(0,1); for(int i=0;igetRepr() << "\n"; @@ -2481,10 +2481,10 @@ std::string MEDCoupling1DGTUMesh::advancedRepr() const // bool isOK=true; try { checkCoherency1(); } catch(INTERP_KERNEL::Exception& /* e */) - { + { ret << "Nodal connectivity arrays are not set or badly set !\n"; isOK=false; - } + } if(!isOK) return ret.str(); int nbOfCells=getNumberOfCells(); @@ -2624,7 +2624,7 @@ MEDCouplingMesh *MEDCoupling1DGTUMesh::mergeMyselfWith(const MEDCouplingMesh *ot MEDCouplingUMesh *MEDCoupling1DGTUMesh::buildUnstructured() const { - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(getName().c_str(),getMeshDimension()); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const int *nodalConn=_conn->begin(),*nodalConnI=_conn_indx->begin(); int nbCells=getNumberOfCells();//checkCoherency @@ -2676,10 +2676,10 @@ void MEDCoupling1DGTUMesh::reprQuickOverview(std::ostream& stream) const stream << "Number of nodes : " << _coords->getNumberOfTuples() << "."; bool isOK=true; try { checkCoherency(); } catch(INTERP_KERNEL::Exception& /* e */) - { + { stream << std::endl << "Nodal connectivity NOT set properly !\n"; isOK=false; - } + } if(isOK) stream << std::endl << "Number of cells : " << getNumberOfCells() << "."; } @@ -2710,7 +2710,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords(const MED MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const { checkCoherency(); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); DataArrayInt *c=0,*ci=0; MEDCouplingUMesh::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci); @@ -2722,7 +2722,7 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords2(int start, int end, int step) const { checkCoherency(); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); DataArrayInt *c=0,*ci=0; MEDCouplingUMesh::ExtractFromIndexedArrays2(start,end,step,_conn,_conn_indx,c,ci); @@ -2900,9 +2900,9 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, { INTERP_KERNEL::NormalizedCellType gt((INTERP_KERNEL::NormalizedCellType)tinyInfo[0]); _cm=&INTERP_KERNEL::CellModel::GetCellModel(gt); - setName(littleStrings[0].c_str()); - setDescription(littleStrings[1].c_str()); - setTimeUnit(littleStrings[2].c_str()); + setName(littleStrings[0]); + setDescription(littleStrings[1]); + setTimeUnit(littleStrings[2]); setTime(tinyInfoD[0],tinyInfo[1],tinyInfo[2]); int sz0(tinyInfo[3]),sz1(tinyInfo[4]),sz2(tinyInfo[5]),sz3(tinyInfo[6]),sz4(tinyInfo[7]),sz5(tinyInfo[8]); // @@ -3139,7 +3139,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::getNodalConnectivityIndex() const */ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); DataArrayInt *nc=0,*nci=0; isShallowCpyOfNodalConnn=retrievePackedNodalConnectivity(nc,nci); MEDCouplingAutoRefCountObjectPtr ncs(nc),ncis(nci); @@ -3322,7 +3322,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesLL(std::vector ret(new MEDCoupling1DGTUMesh(getName().c_str(),*_cm)); + MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); MEDCouplingAutoRefCountObjectPtr tmp1,tmp2; const DataArrayInt *nodalConn(_conn),*nodalConnI(_conn_indx); if(!nodalConn) @@ -3481,8 +3481,8 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New(const MEDCouplingUMesh *m) if(gts.size()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::New : input mesh must have exactly one geometric type !"); int geoType((int)*gts.begin()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(m->getName().c_str(),*gts.begin())); - ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription().c_str()); + MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1DGTUMesh::New(m->getName(),*gts.begin())); + ret->setCoords(m->getCoords()); ret->setDescription(m->getDescription()); int nbCells(m->getNumberOfCells()); MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()),connI(DataArrayInt::New()); conn->alloc(m->getMeshLength()-nbCells,1); connI->alloc(nbCells+1,1);