X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCoupling1GTUMesh.cxx;h=7dda1671a544aeb7b8aa1848d581350bb3f5ae01;hb=98f7ba20f9cf8c460c43e3ffd2eacc4ec473a9cb;hp=d0596161be89548ca52c3d4abb1691d80402e8ef;hpb=56fddf07c0b7170f79791d38e2b909a8a5b0b872;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index d0596161b..7dda1671a 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2015 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 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 @@ -24,8 +24,10 @@ #include "MEDCouplingCMesh.hxx" #include "SplitterTetra.hxx" +#include "DiameterCalculator.hxx" +#include "InterpKernelAutoPtr.hxx" -using namespace ParaMEDMEM; +using namespace MEDCoupling; const int MEDCoupling1SGTUMesh::HEXA8_FACE_PAIRS[6]={0,1,2,4,3,5}; @@ -93,7 +95,7 @@ int MEDCoupling1GTUMesh::getMeshDimension() const */ DataArrayInt *MEDCoupling1GTUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const { - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); if(type==getCellModelEnum()) ret->alloc(getNumberOfCells(),1); else @@ -181,12 +183,11 @@ void MEDCoupling1GTUMesh::splitProfilePerType(const DataArrayInt *profile, std:: throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile is NULL !"); if(profile->getNumberOfComponents()!=1) throw INTERP_KERNEL::Exception("MEDCoupling1GTUMesh::splitProfilePerType : input profile should have exactly one component !"); - int nbTuples=profile->getNumberOfTuples(); - int nbOfCells=getNumberOfCells(); + int nbTuples(profile->getNumberOfTuples()),nbOfCells(getNumberOfCells()); code.resize(3); idsInPflPerType.resize(1); code[0]=(int)getCellModelEnum(); code[1]=nbTuples; idsInPflPerType.resize(1); - if(profile->isIdentity() && nbTuples==nbOfCells) + if(profile->isIota(nbOfCells)) { code[2]=-1; idsInPflPerType[0]=const_cast(profile); idsInPflPerType[0]->incrRef(); @@ -242,7 +243,7 @@ DataArrayInt *MEDCoupling1GTUMesh::checkTypeConsistencyAndContig(const std::vect void MEDCoupling1GTUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); m->writeVTKLL(ofs,cellData,pointData,byteData); } @@ -295,30 +296,30 @@ bool MEDCoupling1GTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *ot return true; } -void MEDCoupling1GTUMesh::checkCoherency() const +void MEDCoupling1GTUMesh::checkConsistencyLight() const { - MEDCouplingPointSet::checkCoherency(); + MEDCouplingPointSet::checkConsistencyLight(); } -DataArrayDouble *MEDCoupling1GTUMesh::getBarycenterAndOwner() const +DataArrayDouble *MEDCoupling1GTUMesh::computeCellCenterOfMass() const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); - MEDCouplingAutoRefCountObjectPtr ret=m->getBarycenterAndOwner(); + MCAuto m=buildUnstructured(); + MCAuto ret=m->computeCellCenterOfMass(); return ret.retn(); } MEDCouplingFieldDouble *MEDCoupling1GTUMesh::getMeasureField(bool isAbs) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); - MEDCouplingAutoRefCountObjectPtr ret=m->getMeasureField(isAbs); + MCAuto m=buildUnstructured(); + MCAuto ret=m->getMeasureField(isAbs); ret->setMesh(this); return ret.retn(); } MEDCouplingFieldDouble *MEDCoupling1GTUMesh::getMeasureFieldOnNode(bool isAbs) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); - MEDCouplingAutoRefCountObjectPtr ret=m->getMeasureFieldOnNode(isAbs); + MCAuto m=buildUnstructured(); + MCAuto ret=m->getMeasureFieldOnNode(isAbs); ret->setMesh(this); return ret.retn(); } @@ -328,51 +329,60 @@ MEDCouplingFieldDouble *MEDCoupling1GTUMesh::getMeasureFieldOnNode(bool isAbs) c */ int MEDCoupling1GTUMesh::getCellContainingPoint(const double *pos, double eps) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m(buildUnstructured()); return m->getCellContainingPoint(pos,eps); } +/*! + * to improve perf ! + */ +void MEDCoupling1GTUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector& elts) const +{ + MCAuto m(buildUnstructured()); + return m->getCellsContainingPoint(pos,eps,elts); +} + MEDCouplingFieldDouble *MEDCoupling1GTUMesh::buildOrthogonalField() const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); - MEDCouplingAutoRefCountObjectPtr ret=m->buildOrthogonalField(); + MCAuto m=buildUnstructured(); + MCAuto ret=m->buildOrthogonalField(); ret->setMesh(this); return ret.retn(); } DataArrayInt *MEDCoupling1GTUMesh::getCellsInBoundingBox(const double *bbox, double eps) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); return m->getCellsInBoundingBox(bbox,eps); } DataArrayInt *MEDCoupling1GTUMesh::getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); return m->getCellsInBoundingBox(bbox,eps); } MEDCouplingPointSet *MEDCoupling1GTUMesh::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); return m->buildFacePartOfMySelfNode(start,end,fullyIn); } DataArrayInt *MEDCoupling1GTUMesh::findBoundaryNodes() const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); return m->findBoundaryNodes(); } MEDCouplingPointSet *MEDCoupling1GTUMesh::buildBoundaryMesh(bool keepCoords) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); return m->buildBoundaryMesh(keepCoords); } void MEDCoupling1GTUMesh::findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const { - MEDCouplingAutoRefCountObjectPtr m=buildUnstructured(); + MCAuto m=buildUnstructured(); m->findCommonCells(compType,startCellId,commonCellsArr,commonCellsIArr); } @@ -410,7 +420,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(),meshDim)); ret->setDescription(firstPart->getDescription()); + MCAuto 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++) @@ -424,7 +434,7 @@ MEDCouplingUMesh *MEDCoupling1GTUMesh::AggregateOnSameCoordsToUMesh(const std::v nbOfCells+=(*it)->getNumberOfCells(); connSize+=(*it)->getNodalConnectivityLength(); } - MEDCouplingAutoRefCountObjectPtr conn(DataArrayInt::New()),connI(DataArrayInt::New()); + MCAuto conn(DataArrayInt::New()),connI(DataArrayInt::New()); connI->alloc(nbOfCells+1,1); conn->alloc(connSize+nbOfCells,1); int *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0; for(std::vector< const MEDCoupling1GTUMesh *>::const_iterator it=parts.begin();it!=parts.end();it++) @@ -469,7 +479,7 @@ MEDCoupling1SGTUMesh::MEDCoupling1SGTUMesh(const MEDCoupling1SGTUMesh& other, bo { const DataArrayInt *c(other._conn); if(c) - _conn=c->deepCpy(); + _conn=c->deepCopy(); } } @@ -507,11 +517,11 @@ 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(),*gts.begin())); + MCAuto 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); + MCAuto conn(DataArrayInt::New()); conn->alloc(nbCells*nbOfNodesPerCell,1); int *c(conn->getPointer()); const int *cin(m->getNodalConnectivity()->begin()),*ciin(m->getNodalConnectivityIndex()->begin()); for(int i=0;i ret(clone(false)); - MEDCouplingAutoRefCountObjectPtr c(_conn->deepCpy()); + checkConsistencyLight(); + MCAuto ret(clone(false)); + MCAuto c(_conn->deepCopy()); ret->setNodalConnectivity(c); return ret.retn(); } @@ -590,7 +600,7 @@ std::vector MEDCoupling1SGTUMesh::getDirectChildrenWith return ret; } -MEDCouplingMesh *MEDCoupling1SGTUMesh::deepCpy() const +MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::deepCopy() const { return clone(true); } @@ -643,7 +653,7 @@ bool MEDCoupling1SGTUMesh::isEqualWithoutConsideringStr(const MEDCouplingMesh *o return true; } -void MEDCoupling1SGTUMesh::checkCoherencyOfConnectivity() const +void MEDCoupling1SGTUMesh::checkConsistencyOfConnectivity() const { const DataArrayInt *c1(_conn); if(c1) @@ -658,21 +668,21 @@ void MEDCoupling1SGTUMesh::checkCoherencyOfConnectivity() const throw INTERP_KERNEL::Exception("Nodal connectivity array not defined !"); } -void MEDCoupling1SGTUMesh::checkCoherency() const +void MEDCoupling1SGTUMesh::checkConsistencyLight() const { - MEDCouplingPointSet::checkCoherency(); - checkCoherencyOfConnectivity(); + MEDCouplingPointSet::checkConsistencyLight(); + checkConsistencyOfConnectivity(); } -void MEDCoupling1SGTUMesh::checkCoherency1(double eps) const +void MEDCoupling1SGTUMesh::checkConsistency(double eps) const { - checkCoherency(); + checkConsistencyLight(); const DataArrayInt *c1(_conn); int nbOfTuples=c1->getNumberOfTuples(); int nbOfNodesPerCell=(int)_cm->getNumberOfNodes(); if(nbOfTuples%nbOfNodesPerCell!=0) { - std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::checkCoherency1 : the nb of tuples in conn is " << nbOfTuples << " and number of nodes per cell is " << nbOfNodesPerCell << ". But " << nbOfTuples << "%" << nbOfNodesPerCell << " !=0 !"; + std::ostringstream oss; oss << "MEDCoupling1SGTUMesh::checkConsistency : the nb of tuples in conn is " << nbOfTuples << " and number of nodes per cell is " << nbOfNodesPerCell << ". But " << nbOfTuples << "%" << nbOfNodesPerCell << " !=0 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } int nbOfNodes=getNumberOfNodes(); @@ -689,11 +699,6 @@ void MEDCoupling1SGTUMesh::checkCoherency1(double eps) const } } -void MEDCoupling1SGTUMesh::checkCoherency2(double eps) const -{ - checkCoherency1(eps); -} - int MEDCoupling1SGTUMesh::getNumberOfCells() const { int nbOfTuples=getNodalConnectivityLength(); @@ -720,7 +725,7 @@ int MEDCoupling1SGTUMesh::getNumberOfNodesPerCell() const DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfNodesPerCell() const { checkNonDynamicGeoType(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(getNumberOfCells(),1); ret->fillWithValue((int)_cm->getNumberOfNodes()); return ret.retn(); @@ -729,7 +734,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfNodesPerCell() const DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfFacesPerCell() const { checkNonDynamicGeoType(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(getNumberOfCells(),1); ret->fillWithValue((int)_cm->getNumberOfSons()); return ret.retn(); @@ -738,7 +743,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::computeNbOfFacesPerCell() const DataArrayInt *MEDCoupling1SGTUMesh::computeEffectiveNbOfNodesPerCell() const { checkNonDynamicGeoType(); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); int nbCells(getNumberOfCells()); ret->alloc(nbCells,1); int *retPtr(ret->getPointer()); @@ -856,9 +861,9 @@ std::string MEDCoupling1SGTUMesh::advancedRepr() const DataArrayDouble *MEDCoupling1SGTUMesh::computeIsoBarycenterOfNodesPerCell() const { - MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + MCAuto ret=DataArrayDouble::New(); int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells();//checkCoherency() + int nbOfCells=getNumberOfCells();//checkConsistencyLight() int nbOfNodes=getNumberOfNodes(); ret->alloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); @@ -885,15 +890,15 @@ DataArrayDouble *MEDCoupling1SGTUMesh::computeIsoBarycenterOfNodesPerCell() cons void MEDCoupling1SGTUMesh::renumberCells(const int *old2NewBg, bool check) { int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr o2n=DataArrayInt::New(); + MCAuto o2n=DataArrayInt::New(); o2n->useArray(old2NewBg,false,C_DEALLOC,nbCells,1); if(check) o2n=o2n->checkAndPreparePermutation(); // const int *conn=_conn->begin(); - MEDCouplingAutoRefCountObjectPtr n2o=o2n->invertArrayO2N2N2O(nbCells); + MCAuto n2o=o2n->invertArrayO2N2N2O(nbCells); const int *n2oPtr=n2o->begin(); - MEDCouplingAutoRefCountObjectPtr newConn=DataArrayInt::New(); + MCAuto newConn=DataArrayInt::New(); newConn->alloc(_conn->getNumberOfTuples(),1); newConn->copyStringInfoFrom(*_conn); int sz=getNumberOfNodesPerCell(); @@ -921,7 +926,7 @@ void MEDCoupling1SGTUMesh::renumberCells(const int *old2NewBg, bool check) void MEDCoupling1SGTUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const { int nbOfCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr cellIdsKept=DataArrayInt::New(); cellIdsKept->alloc(0,1); + MCAuto cellIdsKept=DataArrayInt::New(); cellIdsKept->alloc(0,1); int tmp=-1; int sz=_conn->getMaxValue(tmp); sz=std::max(sz,0)+1; std::vector fastFinder(sz,false); @@ -956,20 +961,20 @@ MEDCouplingMesh *MEDCoupling1SGTUMesh::mergeMyselfWith(const MEDCouplingMesh *ot MEDCouplingUMesh *MEDCoupling1SGTUMesh::buildUnstructured() const { - MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); + MCAuto ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const int *nodalConn=_conn->begin(); int nbCells=getNumberOfCells(); int nbNodesPerCell=getNumberOfNodesPerCell(); int geoType=(int)getCellModelEnum(); - MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); c->alloc(nbCells*(nbNodesPerCell+1),1); + MCAuto c=DataArrayInt::New(); c->alloc(nbCells*(nbNodesPerCell+1),1); int *cPtr=c->getPointer(); for(int i=0;i cI=DataArrayInt::Range(0,(nbCells+1)*(nbNodesPerCell+1),nbNodesPerCell+1); + MCAuto cI=DataArrayInt::Range(0,(nbCells+1)*(nbNodesPerCell+1),nbNodesPerCell+1); ret->setConnectivity(c,cI,true); try { ret->copyTinyInfoFrom(this); } @@ -1011,16 +1016,16 @@ struct MEDCouplingAccVisit * the format of returned DataArrayInt instance. * * \return a newly allocated DataArrayInt sorted ascendingly of fetched node ids. - * \sa MEDCoupling1SGTUMesh::getNodeIdsInUse + * \sa MEDCoupling1SGTUMesh::getNodeIdsInUse, areAllNodesFetched */ DataArrayInt *MEDCoupling1SGTUMesh::computeFetchedNodeIds() const { - checkCoherencyOfConnectivity(); + checkConsistencyOfConnectivity(); int nbNodes(getNumberOfNodes()); std::vector fetchedNodes(nbNodes,false); computeNodeIdsAlg(fetchedNodes); int sz((int)std::count(fetchedNodes.begin(),fetchedNodes.end(),true)); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(sz,1); + MCAuto ret(DataArrayInt::New()); ret->alloc(sz,1); int *retPtr(ret->getPointer()); for(int i=0;i ret(DataArrayInt::New()); + MCAuto ret(DataArrayInt::New()); ret->alloc(nbOfNodes,1); int *traducer=ret->getPointer(); std::fill(traducer,traducer+nbOfNodes,-1); @@ -1116,7 +1121,7 @@ void MEDCoupling1SGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMapgetNumberOfNodes(), in "Old to New" mode. - * See \ref MEDCouplingArrayRenumbering for more info on renumbering modes. + * See \ref numbering for more info on renumbering modes. * \throw If the nodal connectivity of cells is not defined. */ void MEDCoupling1SGTUMesh::renumberNodesInConn(const int *newNodeNumbersO2N) @@ -1148,7 +1153,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshes(std::vectorgetCellModel())!=cm) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshes : all items must have the same geo type !"); - std::vector< MEDCouplingAutoRefCountObjectPtr > bb(sz); + std::vector< MCAuto > bb(sz); std::vector< const MEDCoupling1SGTUMesh * > aa(sz); int spaceDim=-3; for(std::size_t i=0;igetCoords()) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::Merge1SGTUMeshesOnSameCoords : not lying on same coords !"); } - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh("merge",*cm)); + MCAuto ret(new MEDCoupling1SGTUMesh("merge",*cm)); ret->setCoords(coords); ret->_conn=DataArrayInt::Aggregate(ncs); return ret.retn(); @@ -1222,10 +1227,10 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector aps(a.size()); std::copy(a.begin(),a.end(),aps.begin()); - MEDCouplingAutoRefCountObjectPtr pts=MergeNodesArray(aps); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh("merge",*cm)); + MCAuto pts=MergeNodesArray(aps); + MCAuto ret(new MEDCoupling1SGTUMesh("merge",*cm)); ret->setCoords(pts); - MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); + MCAuto c=DataArrayInt::New(); c->alloc(nbOfCells*nbNodesPerCell,1); int *cPtr=c->getPointer(); int offset=0; @@ -1244,12 +1249,12 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::Merge1SGTUMeshesLL(std::vector ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); + MCAuto ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); std::size_t nbOfElemsRet=std::distance(begin,end); const int *inConn=_conn->getConstPointer(); int sz=getNumberOfNodesPerCell(); - MEDCouplingAutoRefCountObjectPtr connRet=DataArrayInt::New(); connRet->alloc((int)nbOfElemsRet*sz,1); + MCAuto connRet=DataArrayInt::New(); connRet->alloc((int)nbOfElemsRet*sz,1); int *connPtr=connRet->getPointer(); for(const int *work=begin;work!=end;work++,connPtr+=sz) { @@ -1266,15 +1271,15 @@ MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords(const int return ret.retn(); } -MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2(int start, int end, int step) const +MEDCouplingPointSet *MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice(int start, int end, int step) const { int ncell=getNumberOfCells(); - int nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoords2 : "); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); + int nbOfElemsRet=DataArray::GetNumberOfItemGivenBESRelative(start,end,step,"MEDCoupling1SGTUMesh::buildPartOfMySelfKeepCoordsSlice : "); + MCAuto ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); ret->setCoords(_coords); const int *inConn=_conn->getConstPointer(); int sz=getNumberOfNodesPerCell(); - MEDCouplingAutoRefCountObjectPtr connRet=DataArrayInt::New(); connRet->alloc((int)nbOfElemsRet*sz,1); + MCAuto connRet=DataArrayInt::New(); connRet->alloc((int)nbOfElemsRet*sz,1); int *connPtr=connRet->getPointer(); int curId=start; for(int i=0;i& nodeIdsInUse) co MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDim) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); - MEDCouplingAutoRefCountObjectPtr tmp1; + MCAuto ret(new MEDCoupling1SGTUMesh(getName(),*_cm)); + MCAuto tmp1; const DataArrayInt *nodalConn(_conn); if(!nodalConn) { @@ -1321,7 +1326,7 @@ MEDCoupling1SGTUMesh *MEDCoupling1SGTUMesh::buildSetInstanceFromThis(int spaceDi ret->_conn=tmp1; if(!_coords) { - MEDCouplingAutoRefCountObjectPtr coords=DataArrayDouble::New(); coords->alloc(0,spaceDim); + MCAuto coords=DataArrayDouble::New(); coords->alloc(0,spaceDim); ret->setCoords(coords); } else @@ -1334,8 +1339,8 @@ DataArrayInt *MEDCoupling1SGTUMesh::simplexizePol0() int nbOfCells=getNumberOfCells(); if(getCellModelEnum()!=INTERP_KERNEL::NORM_QUAD4) return DataArrayInt::Range(0,nbOfCells,1); - MEDCouplingAutoRefCountObjectPtr newConn=DataArrayInt::New(); newConn->alloc(2*3*nbOfCells,1); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(2*nbOfCells,1); + MCAuto newConn=DataArrayInt::New(); newConn->alloc(2*3*nbOfCells,1); + MCAuto ret=DataArrayInt::New(); ret->alloc(2*nbOfCells,1); const int *c(_conn->begin()); int *retPtr(ret->getPointer()),*newConnPtr(newConn->getPointer()); for(int i=0;i newConn=DataArrayInt::New(); newConn->alloc(2*3*nbOfCells,1); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(2*nbOfCells,1); + MCAuto newConn=DataArrayInt::New(); newConn->alloc(2*3*nbOfCells,1); + MCAuto ret=DataArrayInt::New(); ret->alloc(2*nbOfCells,1); const int *c(_conn->begin()); int *retPtr(ret->getPointer()),*newConnPtr(newConn->getPointer()); for(int i=0;i newConn=DataArrayInt::New(); newConn->alloc(5*4*nbOfCells,1); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(5*nbOfCells,1); + MCAuto newConn=DataArrayInt::New(); newConn->alloc(5*4*nbOfCells,1); + MCAuto ret=DataArrayInt::New(); ret->alloc(5*nbOfCells,1); const int *c(_conn->begin()); int *retPtr(ret->getPointer()),*newConnPtr(newConn->getPointer()); for(int i=0;i newConn=DataArrayInt::New(); newConn->alloc(6*4*nbOfCells,1); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(6*nbOfCells,1); + MCAuto newConn=DataArrayInt::New(); newConn->alloc(6*4*nbOfCells,1); + MCAuto ret=DataArrayInt::New(); ret->alloc(6*nbOfCells,1); const int *c(_conn->begin()); int *retPtr(ret->getPointer()),*newConnPtr(newConn->getPointer()); for(int i=0;ibegin()); - MEDCouplingAutoRefCountObjectPtr ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4)); - MEDCouplingAutoRefCountObjectPtr c(DataArrayInt::New()); c->alloc(nbHexa8*6*4,1); + MCAuto ret(MEDCoupling1SGTUMesh::New(getName(),INTERP_KERNEL::NORM_QUAD4)); + MCAuto c(DataArrayInt::New()); c->alloc(nbHexa8*6*4,1); int *cPtr(c->getPointer()); for(int i=0;i cm(MEDCouplingCMesh::New()); + MCAuto cm(MEDCouplingCMesh::New()); for(int i=0;i tmp(1,i); - MEDCouplingAutoRefCountObjectPtr elt(static_cast(getCoords()->keepSelectedComponents(tmp))); + MCAuto elt(static_cast(getCoords()->keepSelectedComponents(tmp))); elt=elt->getDifferentValues(eps); elt->sort(true); cm->setCoordsAt(i,elt); @@ -1765,7 +1770,7 @@ MEDCouplingCMesh *MEDCoupling1SGTUMesh::structurizeMe(DataArrayInt *& cellPerm, try { cm->copyTinyInfoFrom(this); } catch(INTERP_KERNEL::Exception&) { } - MEDCouplingAutoRefCountObjectPtr um(cm->buildUnstructured()),self(buildUnstructured()); + MCAuto um(cm->buildUnstructured()),self(buildUnstructured()); self->checkGeoEquivalWith(um,12,eps,cellPerm,nodePerm); return cm.retn(); } @@ -1854,13 +1859,13 @@ bool UpdateHexa8Cell(int validAxis, int neighId, const int *validConnQuad4NeighS */ DataArrayInt *MEDCoupling1SGTUMesh::sortHexa8EachOther() { - MEDCouplingAutoRefCountObjectPtr quads(explodeEachHexa8To6Quad4());//checks that only hexa8 + MCAuto quads(explodeEachHexa8To6Quad4());//checks that only hexa8 int nbHexa8(getNumberOfCells()),*cQuads(quads->getNodalConnectivity()->getPointer()); - MEDCouplingAutoRefCountObjectPtr neighOfQuads(DataArrayInt::New()); neighOfQuads->alloc(nbHexa8*6,1); neighOfQuads->fillWithValue(-1); + MCAuto neighOfQuads(DataArrayInt::New()); neighOfQuads->alloc(nbHexa8*6,1); neighOfQuads->fillWithValue(-1); int *ptNeigh(neighOfQuads->getPointer()); {//neighOfQuads tells for each face of each Quad8 which cell (if!=-1) is connected to this face. - MEDCouplingAutoRefCountObjectPtr quadsTmp(quads->buildUnstructured()); - MEDCouplingAutoRefCountObjectPtr ccSafe,cciSafe; + MCAuto quadsTmp(quads->buildUnstructured()); + MCAuto ccSafe,cciSafe; DataArrayInt *cc(0),*cci(0); quadsTmp->findCommonCells(3,0,cc,cci); ccSafe=cc; cciSafe=cci; @@ -1868,7 +1873,7 @@ DataArrayInt *MEDCoupling1SGTUMesh::sortHexa8EachOther() for(int i=0;i ret(DataArrayInt::New()); ret->alloc(0,1); + MCAuto ret(DataArrayInt::New()); ret->alloc(0,1); std::vector fetched(nbHexa8,false); std::vector::iterator it(std::find(fetched.begin(),fetched.end(),false)); while(it!=fetched.end())//it will turns as time as number of connected zones @@ -1931,24 +1936,24 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh3D() const if(getCellModelEnum()!=INTERP_KERNEL::NORM_TETRA4) throw INTERP_KERNEL::Exception("MEDCoupling1SGTUMesh::computeDualMesh3D : only TETRA4 supported !"); checkFullyDefined(); - MEDCouplingAutoRefCountObjectPtr thisu(buildUnstructured()); - MEDCouplingAutoRefCountObjectPtr revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New()); + MCAuto thisu(buildUnstructured()); + MCAuto revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New()); thisu->getReverseNodalConnectivity(revNodArr,revNodIArr); const int *revNod(revNodArr->begin()),*revNodI(revNodIArr->begin()),*nodal(_conn->begin()); - MEDCouplingAutoRefCountObjectPtr d1Arr(DataArrayInt::New()),di1Arr(DataArrayInt::New()),rd1Arr(DataArrayInt::New()),rdi1Arr(DataArrayInt::New()); - MEDCouplingAutoRefCountObjectPtr edges(thisu->explode3DMeshTo1D(d1Arr,di1Arr,rd1Arr,rdi1Arr)); + MCAuto d1Arr(DataArrayInt::New()),di1Arr(DataArrayInt::New()),rd1Arr(DataArrayInt::New()),rdi1Arr(DataArrayInt::New()); + MCAuto edges(thisu->explode3DMeshTo1D(d1Arr,di1Arr,rd1Arr,rdi1Arr)); const int *d1(d1Arr->begin()); - MEDCouplingAutoRefCountObjectPtr d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New()); - MEDCouplingAutoRefCountObjectPtr faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; + MCAuto d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New()); + MCAuto faces(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; const int *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin()); - MEDCouplingAutoRefCountObjectPtr edgesBaryArr(edges->getBarycenterAndOwner()),facesBaryArr(faces->getBarycenterAndOwner()),baryArr(getBarycenterAndOwner()); + MCAuto edgesBaryArr(edges->computeCellCenterOfMass()),facesBaryArr(faces->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass()); const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+faces->getNumberOfCells()),offset1(offset0+edges->getNumberOfCells()); edges=0; faces=0; std::vector 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; + MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; facesBaryArr=0; std::string name("DualOf_"); name+=getName(); - 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); + MCAuto ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYHED)); ret->setCoords(zeArr); + MCAuto 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 thisu(buildUnstructured()); - MEDCouplingAutoRefCountObjectPtr revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New()); + MCAuto thisu(buildUnstructured()); + MCAuto revNodArr(DataArrayInt::New()),revNodIArr(DataArrayInt::New()); thisu->getReverseNodalConnectivity(revNodArr,revNodIArr); const int *revNod(revNodArr->begin()),*revNodI(revNodIArr->begin()),*nodal(_conn->begin()); - MEDCouplingAutoRefCountObjectPtr d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New()); - MEDCouplingAutoRefCountObjectPtr edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; + MCAuto d2Arr(DataArrayInt::New()),di2Arr(DataArrayInt::New()),rd2Arr(DataArrayInt::New()),rdi2Arr(DataArrayInt::New()); + MCAuto edges(thisu->buildDescendingConnectivity(d2Arr,di2Arr,rd2Arr,rdi2Arr)); thisu=0; const int *d2(d2Arr->begin()),*rdi2(rdi2Arr->begin()); - MEDCouplingAutoRefCountObjectPtr edgesBaryArr(edges->getBarycenterAndOwner()),baryArr(getBarycenterAndOwner()); + MCAuto edgesBaryArr(edges->computeCellCenterOfMass()),baryArr(computeCellCenterOfMass()); const int nbOfNodes(getNumberOfNodes()),offset0(nbOfNodes+edges->getNumberOfCells()); edges=0; std::vector v(3); v[0]=getCoords(); v[1]=edgesBaryArr; v[2]=baryArr; - MEDCouplingAutoRefCountObjectPtr zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; + MCAuto zeArr(DataArrayDouble::Aggregate(v)); baryArr=0; edgesBaryArr=0; std::string name("DualOf_"); name+=getName(); - 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); + MCAuto ret(MEDCoupling1DGTUMesh::New(name,INTERP_KERNEL::NORM_POLYGON)); ret->setCoords(zeArr); + MCAuto 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 ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); for(int i=0;i ret(MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME)); + int nbCells(getNumberOfCells()); + MCAuto arr(DataArrayDouble::New()); + arr->alloc(nbCells,1); + INTERP_KERNEL::AutoCppPtr dc(_cm->buildInstanceOfDiameterCalulator(getSpaceDimension())); + dc->computeFor1SGTUMeshFrmt(nbCells,_conn->begin(),getCoords()->begin(),arr->getPointer()); + ret->setMesh(this); + ret->setArray(arr); + ret->setName("Diameter"); + return ret.retn(); +} + //== MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::New() @@ -2141,16 +2166,16 @@ MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const std::string& name, const INTERP { } -MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn(other._conn) +MEDCoupling1DGTUMesh::MEDCoupling1DGTUMesh(const MEDCoupling1DGTUMesh& other, bool recDeepCpy):MEDCoupling1GTUMesh(other,recDeepCpy),_conn_indx(other._conn_indx),_conn(other._conn) { if(recDeepCpy) { const DataArrayInt *c(other._conn); if(c) - _conn=c->deepCpy(); + _conn=c->deepCopy(); c=other._conn_indx; if(c) - _conn_indx=c->deepCpy(); + _conn_indx=c->deepCopy(); } } @@ -2160,17 +2185,17 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::clone(bool recDeepCpy) const } /*! - * This method behaves mostly like MEDCoupling1DGTUMesh::deepCpy method, except that only nodal connectivity arrays are deeply copied. + * This method behaves mostly like MEDCoupling1DGTUMesh::deepCopy method, except that only nodal connectivity arrays are deeply copied. * The coordinates are shared between \a this and the returned instance. * - * \return MEDCouplingUMesh * - A new object instance holding the copy of \a this (deep for connectivity, shallow for coordiantes) - * \sa MEDCoupling1DGTUMesh::deepCpy + * \return MEDCoupling1DGTUMesh * - A new object instance holding the copy of \a this (deep for connectivity, shallow for coordiantes) + * \sa MEDCoupling1DGTUMesh::deepCopy */ -MEDCouplingPointSet *MEDCoupling1DGTUMesh::deepCpyConnectivityOnly() const +MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::deepCopyConnectivityOnly() const { - checkCoherency(); - MEDCouplingAutoRefCountObjectPtr ret(clone(false)); - MEDCouplingAutoRefCountObjectPtr c(_conn->deepCpy()),ci(_conn_indx->deepCpy()); + checkConsistencyLight(); + MCAuto ret(clone(false)); + MCAuto c(_conn->deepCopy()),ci(_conn_indx->deepCopy()); ret->setNodalConnectivity(c,ci); return ret.retn(); } @@ -2199,7 +2224,7 @@ std::vector MEDCoupling1DGTUMesh::getDirectChildrenWith return ret; } -MEDCouplingMesh *MEDCoupling1DGTUMesh::deepCpy() const +MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::deepCopy() const { return clone(true); } @@ -2315,7 +2340,7 @@ void MEDCoupling1DGTUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, do } } -void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const +void MEDCoupling1DGTUMesh::checkConsistencyOfConnectivity() const { const DataArrayInt *c1(_conn); if(c1) @@ -2341,7 +2366,7 @@ void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const if(c1->getInfoOnComponent(0)!="") throw INTERP_KERNEL::Exception("Nodal connectivity index array is expected to have no info on its single component !"); int f=c1->front(),ll=c1->back(); - if(f<0 || f>=sz2) + if(f<0 || (sz2>0 && f>=sz2)) { std::ostringstream oss; oss << "Nodal connectivity index array first value (" << f << ") is expected to be exactly in [0," << sz2 << ") !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); @@ -2362,7 +2387,7 @@ void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const int szOfC1Exp=_conn_indx->back(); if(sz2getNumberOfTuples() << " !"; + std::ostringstream oss; oss << "MEDCoupling1DGTUMesh::checkConsistencyOfConnectivity : The expected length of nodal connectivity array regarding index is " << szOfC1Exp << " but the actual size of it is " << c1->getNumberOfTuples() << " !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); } } @@ -2372,18 +2397,18 @@ void MEDCoupling1DGTUMesh::checkCoherencyOfConnectivity() const * In addition you are sure that the length of nodal connectivity index array is bigger than or equal to one. * In addition you are also sure that length of nodal connectivity is coherent with the content of the last value in the index array. */ -void MEDCoupling1DGTUMesh::checkCoherency() const +void MEDCoupling1DGTUMesh::checkConsistencyLight() const { - MEDCouplingPointSet::checkCoherency(); - checkCoherencyOfConnectivity(); + MEDCouplingPointSet::checkConsistencyLight(); + checkConsistencyOfConnectivity(); } -void MEDCoupling1DGTUMesh::checkCoherency1(double eps) const +void MEDCoupling1DGTUMesh::checkConsistency(double eps) const { - checkCoherency(); + checkConsistencyLight(); const DataArrayInt *c1(_conn),*c2(_conn_indx); if(!c2->isMonotonic(true)) - throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkCoherency1 : the nodal connectivity index is expected to be increasing monotinic !"); + throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::checkConsistency : the nodal connectivity index is expected to be increasing monotinic !"); // int nbOfTuples=c1->getNumberOfTuples(); int nbOfNodes=getNumberOfNodes(); @@ -2399,14 +2424,9 @@ void MEDCoupling1DGTUMesh::checkCoherency1(double eps) const } } -void MEDCoupling1DGTUMesh::checkCoherency2(double eps) const -{ - checkCoherency1(eps); -} - int MEDCoupling1DGTUMesh::getNumberOfCells() const { - checkCoherencyOfConnectivity();//do not remove + checkConsistencyOfConnectivity();//do not remove return _conn_indx->getNumberOfTuples()-1; } @@ -2420,13 +2440,13 @@ int MEDCoupling1DGTUMesh::getNumberOfCells() const */ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfNodesPerCell() const { - checkCoherency(); + checkConsistencyLight(); _conn_indx->checkMonotonic(true); if(getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED) return _conn_indx->deltaShiftIndex(); // for polyhedrons int nbOfCells=_conn_indx->getNumberOfTuples()-1; - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr=ret->getPointer(); const int *ci=_conn_indx->begin(),*c=_conn->begin(); @@ -2443,19 +2463,19 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfNodesPerCell() const */ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const { - checkCoherency(); + checkConsistencyLight(); _conn_indx->checkMonotonic(true); if(getCellModelEnum()!=INTERP_KERNEL::NORM_POLYHED && getCellModelEnum()!=INTERP_KERNEL::NORM_QPOLYG) return _conn_indx->deltaShiftIndex(); if(getCellModelEnum()==INTERP_KERNEL::NORM_QPOLYG) { - MEDCouplingAutoRefCountObjectPtr ret=_conn_indx->deltaShiftIndex(); + MCAuto ret=_conn_indx->deltaShiftIndex(); ret->applyDivideBy(2); return ret.retn(); } // for polyhedrons int nbOfCells=_conn_indx->getNumberOfTuples()-1; - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr=ret->getPointer(); const int *ci=_conn_indx->begin(),*c=_conn->begin(); @@ -2473,10 +2493,10 @@ DataArrayInt *MEDCoupling1DGTUMesh::computeNbOfFacesPerCell() const */ DataArrayInt *MEDCoupling1DGTUMesh::computeEffectiveNbOfNodesPerCell() const { - checkCoherency(); + checkConsistencyLight(); _conn_indx->checkMonotonic(true); int nbOfCells(_conn_indx->getNumberOfTuples()-1); - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); int *retPtr(ret->getPointer()); const int *ci(_conn_indx->begin()),*c(_conn->begin()); @@ -2562,7 +2582,7 @@ std::string MEDCoupling1DGTUMesh::simpleRepr() const ret << msg0 << "\n"; ret << "Number of cells : "; bool isOK=true; - try { checkCoherency(); } catch(INTERP_KERNEL::Exception& /* e */) + try { checkConsistencyLight(); } catch(INTERP_KERNEL::Exception& /* e */) { ret << "Nodal connectivity arrays are not set or badly set !\n"; isOK=false; @@ -2585,7 +2605,7 @@ std::string MEDCoupling1DGTUMesh::advancedRepr() const ret << "\n\nNodal Connectivity : \n____________________\n\n"; // bool isOK=true; - try { checkCoherency1(); } catch(INTERP_KERNEL::Exception& /* e */) + try { checkConsistency(); } catch(INTERP_KERNEL::Exception& /* e */) { ret << "Nodal connectivity arrays are not set or badly set !\n"; isOK=false; @@ -2605,9 +2625,9 @@ std::string MEDCoupling1DGTUMesh::advancedRepr() const DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() const { - MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); + MCAuto ret=DataArrayDouble::New(); int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells();//checkCoherency() + int nbOfCells=getNumberOfCells();//checkConsistencyLight() int nbOfNodes=getNumberOfNodes(); ret->alloc(nbOfCells,spaceDim); double *ptToFill=ret->getPointer(); @@ -2683,15 +2703,15 @@ DataArrayDouble *MEDCoupling1DGTUMesh::computeIsoBarycenterOfNodesPerCell() cons void MEDCoupling1DGTUMesh::renumberCells(const int *old2NewBg, bool check) { int nbCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr o2n=DataArrayInt::New(); + MCAuto o2n=DataArrayInt::New(); o2n->useArray(old2NewBg,false,C_DEALLOC,nbCells,1); if(check) o2n=o2n->checkAndPreparePermutation(); // const int *o2nPtr=o2n->getPointer(); const int *conn=_conn->begin(),*conni=_conn_indx->begin(); - MEDCouplingAutoRefCountObjectPtr newConn=DataArrayInt::New(); - MEDCouplingAutoRefCountObjectPtr newConnI=DataArrayInt::New(); + MCAuto newConn=DataArrayInt::New(); + MCAuto newConnI=DataArrayInt::New(); newConn->alloc(_conn->getNumberOfTuples(),1); newConnI->alloc(nbCells,1); newConn->copyStringInfoFrom(*_conn); newConnI->copyStringInfoFrom(*_conn_indx); // @@ -2708,7 +2728,7 @@ void MEDCoupling1DGTUMesh::renumberCells(const int *old2NewBg, bool check) throw INTERP_KERNEL::Exception(oss.str().c_str()); } } - newConnI->computeOffsets2(); newCI=newConnI->getPointer(); + newConnI->computeOffsetsFull(); newCI=newConnI->getPointer(); // for(int i=0;i ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); + MCAuto ret=MEDCouplingUMesh::New(getName(),getMeshDimension()); ret->setCoords(getCoords()); const int *nodalConn=_conn->begin(),*nodalConnI=_conn_indx->begin(); - int nbCells=getNumberOfCells();//checkCoherency + int nbCells=getNumberOfCells();//checkConsistencyLight int geoType=(int)getCellModelEnum(); - MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); c->alloc(nbCells+_conn->getNumberOfTuples(),1); - MEDCouplingAutoRefCountObjectPtr cI=DataArrayInt::New(); cI->alloc(nbCells+1); + MCAuto c=DataArrayInt::New(); c->alloc(nbCells+_conn->getNumberOfTuples(),1); + MCAuto cI=DataArrayInt::New(); cI->alloc(nbCells+1); int *cPtr=c->getPointer(),*ciPtr=cI->getPointer(); ciPtr[0]=0; for(int i=0;i ret=DataArrayInt::New(); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfCells,1); ret->iota(0); return ret.retn(); @@ -2783,7 +2803,7 @@ void MEDCoupling1DGTUMesh::reprQuickOverview(std::ostream& stream) const stream << " Space dimension : " << _coords->getNumberOfComponents() << "." << std::endl; stream << "Number of nodes : " << _coords->getNumberOfTuples() << "."; bool isOK=true; - try { checkCoherency(); } catch(INTERP_KERNEL::Exception& /* e */) + try { checkConsistencyLight(); } catch(INTERP_KERNEL::Exception& /* e */) { stream << std::endl << "Nodal connectivity NOT set properly !\n"; isOK=false; @@ -2817,31 +2837,31 @@ MEDCouplingPointSet *MEDCoupling1DGTUMesh::mergeMyselfWithOnSameCoords(const MED MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const { - checkCoherency(); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); + checkConsistencyLight(); + MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); DataArrayInt *c=0,*ci=0; MEDCouplingUMesh::ExtractFromIndexedArrays(begin,end,_conn,_conn_indx,c,ci); - MEDCouplingAutoRefCountObjectPtr cSafe(c),ciSafe(ci); + MCAuto cSafe(c),ciSafe(ci); ret->setNodalConnectivity(c,ci); return ret.retn(); } -MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoords2(int start, int end, int step) const +MEDCouplingPointSet *MEDCoupling1DGTUMesh::buildPartOfMySelfKeepCoordsSlice(int start, int end, int step) const { - checkCoherency(); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); + checkConsistencyLight(); + MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); ret->setCoords(_coords); DataArrayInt *c=0,*ci=0; - MEDCouplingUMesh::ExtractFromIndexedArrays2(start,end,step,_conn,_conn_indx,c,ci); - MEDCouplingAutoRefCountObjectPtr cSafe(c),ciSafe(ci); + MEDCouplingUMesh::ExtractFromIndexedArraysSlice(start,end,step,_conn,_conn_indx,c,ci); + MCAuto cSafe(c),ciSafe(ci); ret->setNodalConnectivity(c,ci); return ret.retn(); } void MEDCoupling1DGTUMesh::computeNodeIdsAlg(std::vector& nodeIdsInUse) const { - checkCoherency2(); + checkConsistency(); int sz((int)nodeIdsInUse.size()); for(const int *conn=_conn->begin();conn!=_conn->end();conn++) { @@ -2969,8 +2989,8 @@ void MEDCoupling1DGTUMesh::resizeForUnserialization(const std::vector& tiny std::vector tinyInfo2(tinyInfo.begin()+9,tinyInfo.begin()+9+tinyInfo[6]); std::vector tinyInfo1(tinyInfo.begin()+9+tinyInfo[6],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]); std::vector tinyInfo12(tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7],tinyInfo.begin()+9+tinyInfo[6]+tinyInfo[7]+tinyInfo[8]); - MEDCouplingAutoRefCountObjectPtr p1(DataArrayInt::New()); p1->resizeForUnserialization(tinyInfo1); - MEDCouplingAutoRefCountObjectPtr p2(DataArrayInt::New()); p2->resizeForUnserialization(tinyInfo12); + MCAuto p1(DataArrayInt::New()); p1->resizeForUnserialization(tinyInfo1); + MCAuto p2(DataArrayInt::New()); p2->resizeForUnserialization(tinyInfo12); std::vector v(2); v[0]=p1; v[1]=p2; p2=DataArrayInt::Aggregate(v); a2->resizeForUnserialization(tinyInfo2); @@ -3046,16 +3066,16 @@ void MEDCoupling1DGTUMesh::unserialization(const std::vector& tinyInfoD, * \throw If the coordinates array is not set. * \throw If the nodal connectivity of cells is not defined. * \throw If the nodal connectivity includes an invalid id. - * \sa MEDCoupling1DGTUMesh::computeFetchedNodeIds + * \sa MEDCoupling1DGTUMesh::getNodeIdsInUse, areAllNodesFetched */ DataArrayInt *MEDCoupling1DGTUMesh::computeFetchedNodeIds() const { - checkCoherency2(); + checkConsistency(); int nbNodes(getNumberOfNodes()); std::vector fetchedNodes(nbNodes,false); computeNodeIdsAlg(fetchedNodes); int sz((int)std::count(fetchedNodes.begin(),fetchedNodes.end(),true)); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayInt::New()); ret->alloc(sz,1); + MCAuto ret(DataArrayInt::New()); ret->alloc(sz,1); int *retPtr(ret->getPointer()); for(int i=0;i ret=DataArrayInt::New(); + int nbOfCells=getNumberOfCells();//checkConsistencyLight + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfNodes,1); int *traducer=ret->getPointer(); std::fill(traducer,traducer+nbOfNodes,-1); @@ -3173,7 +3193,7 @@ void MEDCoupling1DGTUMesh::renumberNodesInConn(const INTERP_KERNEL::HashMapgetNumberOfNodes(), in "Old to New" mode. - * See \ref MEDCouplingArrayRenumbering for more info on renumbering modes. + * See \ref numbering for more info on renumbering modes. * \throw If the nodal connectivity of cells is not defined. */ void MEDCoupling1DGTUMesh::renumberNodesInConn(const int *newNodeNumbersO2N) @@ -3211,7 +3231,7 @@ void MEDCoupling1DGTUMesh::renumberNodesInConn(const int *newNodeNumbersO2N) void MEDCoupling1DGTUMesh::fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const { int nbOfCells=getNumberOfCells(); - MEDCouplingAutoRefCountObjectPtr cellIdsKept=DataArrayInt::New(); cellIdsKept->alloc(0,1); + MCAuto cellIdsKept=DataArrayInt::New(); cellIdsKept->alloc(0,1); int tmp=-1; int sz=_conn->getMaxValue(tmp); sz=std::max(sz,0)+1; std::vector fastFinder(sz,false); @@ -3333,10 +3353,10 @@ DataArrayInt *MEDCoupling1DGTUMesh::getNodalConnectivityIndex() const */ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool& isShallowCpyOfNodalConnn) const { - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); + MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); DataArrayInt *nc=0,*nci=0; isShallowCpyOfNodalConnn=retrievePackedNodalConnectivity(nc,nci); - MEDCouplingAutoRefCountObjectPtr ncs(nc),ncis(nci); + MCAuto ncs(nc),ncis(nci); ret->_conn=ncs; ret->_conn_indx=ncis; ret->setCoords(getCoords()); return ret.retn(); @@ -3361,11 +3381,11 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::copyWithNodalConnectivityPacked(bool * \return bool - an indication of the content of the 2 output parameters. If true, \a this looks packed (general case), if true, \a this is not packed then * output parameters are newly created objects. * - * \throw if \a this does not pass MEDCoupling1DGTUMesh::checkCoherency test + * \throw if \a this does not pass MEDCoupling1DGTUMesh::checkConsistencyLight test */ bool MEDCoupling1DGTUMesh::retrievePackedNodalConnectivity(DataArrayInt *&nodalConn, DataArrayInt *&nodalConnIndx) const { - if(isPacked())//performs the checkCoherency + if(isPacked())//performs the checkConsistencyLight { const DataArrayInt *c0(_conn),*c1(_conn_indx); nodalConn=const_cast(c0); nodalConnIndx=const_cast(c1); @@ -3373,8 +3393,8 @@ bool MEDCoupling1DGTUMesh::retrievePackedNodalConnectivity(DataArrayInt *&nodalC return true; } int bg=_conn_indx->front(),end=_conn_indx->back(); - MEDCouplingAutoRefCountObjectPtr nc(_conn->selectByTupleId2(bg,end,1)); - MEDCouplingAutoRefCountObjectPtr nci(_conn_indx->deepCpy()); + MCAuto nc(_conn->selectByTupleIdSafeSlice(bg,end,1)); + MCAuto nci(_conn_indx->deepCopy()); nci->applyLin(1,-bg); nodalConn=nc.retn(); nodalConnIndx=nci.retn(); return false; @@ -3386,11 +3406,11 @@ bool MEDCoupling1DGTUMesh::retrievePackedNodalConnectivity(DataArrayInt *&nodalC * If nodal connectivity index points to a subpart of nodal connectivity index false will be returned. * \return bool - true if \a this looks packed, false is not. * - * \throw if \a this does not pass MEDCoupling1DGTUMesh::checkCoherency test + * \throw if \a this does not pass MEDCoupling1DGTUMesh::checkConsistencyLight test */ bool MEDCoupling1DGTUMesh::isPacked() const { - checkCoherency(); + checkConsistencyLight(); return _conn_indx->front()==0 && _conn_indx->back()==_conn->getNumberOfTuples(); } @@ -3416,7 +3436,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshes(std::vectorgetCellModel())!=cm) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshes : all items must have the same geo type !"); - std::vector< MEDCouplingAutoRefCountObjectPtr > bb(sz); + std::vector< MCAuto > bb(sz); std::vector< const MEDCoupling1DGTUMesh * > aa(sz); int spaceDim=-3; for(std::size_t i=0;i::const_iterator it=a.begin(); if(!(*it)) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : null instance in the first element of input vector !"); - std::vector< MEDCouplingAutoRefCountObjectPtr > objs(a.size()); + std::vector< MCAuto > objs(a.size()); std::vector ncs(a.size()),ncis(a.size()); (*it)->getNumberOfCells();//to check that all is OK const DataArrayDouble *coords=(*it)->getCoords(); @@ -3468,7 +3488,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords(std::ve if(coords!=(*it)->getCoords()) throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::Merge1DGTUMeshesOnSameCoords : not lying on same coords !"); } - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh("merge",*cm)); + MCAuto ret(new MEDCoupling1DGTUMesh("merge",*cm)); ret->setCoords(coords); ret->_conn=DataArrayInt::Aggregate(ncs); ret->_conn_indx=DataArrayInt::AggregateIndexes(ncis); @@ -3482,7 +3502,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesLL(std::vector > objs(a.size()); + std::vector< MCAuto > objs(a.size()); std::vector ncs(a.size()),ncis(a.size()); std::vector::const_iterator it=a.begin(); std::vector nbNodesPerElt(a.size()); @@ -3506,8 +3526,8 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesLL(std::vector aps(a.size()); std::copy(a.begin(),a.end(),aps.begin()); - MEDCouplingAutoRefCountObjectPtr pts=MergeNodesArray(aps); - MEDCouplingAutoRefCountObjectPtr ret(new MEDCoupling1DGTUMesh("merge",*cm)); + MCAuto pts=MergeNodesArray(aps); + MCAuto ret(new MEDCoupling1DGTUMesh("merge",*cm)); ret->setCoords(pts); ret->_conn=AggregateNodalConnAndShiftNodeIds(ncs,nbNodesPerElt); ret->_conn_indx=DataArrayInt::AggregateIndexes(ncis); @@ -3516,8 +3536,8 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::Merge1DGTUMeshesLL(std::vector ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); - MEDCouplingAutoRefCountObjectPtr tmp1,tmp2; + MCAuto ret(new MEDCoupling1DGTUMesh(getName(),*_cm)); + MCAuto tmp1,tmp2; const DataArrayInt *nodalConn(_conn),*nodalConnI(_conn_indx); if(!nodalConn) { @@ -3537,7 +3557,7 @@ MEDCoupling1DGTUMesh *MEDCoupling1DGTUMesh::buildSetInstanceFromThis(int spaceDi // if(!_coords) { - MEDCouplingAutoRefCountObjectPtr coords=DataArrayDouble::New(); coords->alloc(0,spaceDim); + MCAuto coords=DataArrayDouble::New(); coords->alloc(0,spaceDim); ret->setCoords(coords); } else @@ -3559,7 +3579,7 @@ DataArrayDouble *MEDCoupling1DGTUMesh::getBoundingBoxForBBTree(double arcDetEps) { checkFullyDefined(); int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); - MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + MCAuto ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); double *bbox(ret->getPointer()); for(int i=0;i MEDCoupling1DGTUMesh::BuildAPolygonFromParts(const std::vector< std::vector >& parts) { std::vector ret; @@ -3648,7 +3678,7 @@ DataArrayInt *MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds(const std: throw INTERP_KERNEL::Exception("MEDCoupling1DGTUMesh::AggregateNodalConnAndShiftNodeIds : presence of array with not exactly one component !"); nbOfTuples+=(*it)->getNumberOfTuples(); } - MEDCouplingAutoRefCountObjectPtr ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1); + MCAuto ret=DataArrayInt::New(); ret->alloc(nbOfTuples,1); int *pt=ret->getPointer(); int i=0; for(std::vector::const_iterator it=nodalConns.begin();it!=nodalConns.end();it++,i++) @@ -3675,11 +3705,11 @@ 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(),*gts.begin())); + MCAuto 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); + MCAuto conn(DataArrayInt::New()),connI(DataArrayInt::New()); + conn->alloc(m->getNodalConnectivityArrayLen()-nbCells,1); connI->alloc(nbCells+1,1); int *c(conn->getPointer()),*ci(connI->getPointer()); *ci=0; const int *cin(m->getNodalConnectivity()->begin()),*ciin(m->getNodalConnectivityIndex()->begin()); for(int i=0;i