From: ageay Date: Thu, 14 Jun 2012 14:33:16 +0000 (+0000) Subject: Addition of computeSkin method. X-Git-Tag: V6_main_FINAL~646 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ea902667cf84ff8ce80dd118555327a31c990979;p=tools%2Fmedcoupling.git Addition of computeSkin method. --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 49a14be09..992c2aa0d 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -645,7 +645,7 @@ void MEDCouplingUMesh::computeNeighborsOfCellsAdv(const DataArrayInt *desc, cons */ MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception) { - checkFullyDefined(); + checkConnectivityFullyDefined(); int nbOfCells=getNumberOfCells(); int nbOfNodes=getNumberOfNodes(); const int *conn=_nodal_connec->getConstPointer(); @@ -1000,7 +1000,7 @@ void MEDCouplingUMesh::unPolyze() */ DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception) { - checkFullyDefined(); + checkConnectivityFullyDefined(); std::set retS; int nbOfCells=getNumberOfCells(); const int *connIndex=_nodal_connec_index->getConstPointer(); @@ -1803,40 +1803,34 @@ DataArrayInt *MEDCouplingUMesh::findCellsIdsOnBoundary() const throw(INTERP_KERN return ret2; } +/*! + * This method computes the skin of \b this. That is to say the consituting meshdim-1 mesh is built and only the boundary subpart is + * returned. This subpart of meshdim-1 mesh is built using meshdim-1 cells in it shared only one cell in \b this. + * + * \return a newly allocated mesh lying on the same coordinates than \b this. The caller has to deal with returned mesh. + */ +MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const throw(INTERP_KERNEL::Exception) +{ + MEDCouplingAutoRefCountObjectPtr desc=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr descIndx=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr revDesc=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr revDescIndx=DataArrayInt::New(); + // + MEDCouplingAutoRefCountObjectPtr meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); + revDesc=0; desc=0; descIndx=0; + MEDCouplingAutoRefCountObjectPtr revDescIndx2=revDescIndx->deltaShiftIndex(); + MEDCouplingAutoRefCountObjectPtr part=revDescIndx2->getIdsEqual(1); + return static_cast(meshDM1->buildPartOfMySelf(part->begin(),part->end(),true)); +} + /*! * This methods returns set of nodes in a newly allocated array that the caller has to deal with. * The returned nodes ids are those lying on the boundary of \b this. */ DataArrayInt *MEDCouplingUMesh::findBoundaryNodes() const { - DataArrayInt *desc=DataArrayInt::New(); - DataArrayInt *descIndx=DataArrayInt::New(); - DataArrayInt *revDesc=DataArrayInt::New(); - DataArrayInt *revDescIndx=DataArrayInt::New(); - // - MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - revDesc->decrRef(); - desc->decrRef(); - descIndx->decrRef(); - std::set ret; - int nbOfCells=meshDM1->getNumberOfCells(); - const int *revDescIndxC=revDescIndx->getConstPointer(); - std::vector boundaryCells; - for(int i=0;idecrRef(); - const int *conn=meshDM1->getNodalConnectivity()->getConstPointer(); - const int *connIndx=meshDM1->getNodalConnectivityIndex()->getConstPointer(); - for(std::vector::const_iterator iter=boundaryCells.begin();iter!=boundaryCells.end();iter++) - for(int k=connIndx[*iter]+1;kdecrRef(); - // - DataArrayInt *retda=DataArrayInt::New(); - retda->alloc((int)ret.size(),1); - std::copy(ret.begin(),ret.end(),retda->getPointer()); - return retda; + MEDCouplingAutoRefCountObjectPtr skin=computeSkin(); + return skin->computeFetchedNodeIds(); } MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception) diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index d827083c9..dd2453769 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -122,6 +122,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *findBoundaryNodes() const; MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const; MEDCOUPLING_EXPORT DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT MEDCouplingUMesh *computeSkin() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT void renumberNodes2(const int *newNodeNumbers, int newNbOfNodes); MEDCOUPLING_EXPORT void findNodesToDuplicate(MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayInt *& nodeIdsToDuplicate, DataArrayInt *& cellIdsNeededToBeRenum) const throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling_Swig/MEDCoupling.i b/src/MEDCoupling_Swig/MEDCoupling.i index 4728fb379..a017be40e 100644 --- a/src/MEDCoupling_Swig/MEDCoupling.i +++ b/src/MEDCoupling_Swig/MEDCoupling.i @@ -272,6 +272,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingUMesh::keepCellIdsByType; %newobject ParaMEDMEM::MEDCouplingUMesh::Build0DMeshFromCoords; %newobject ParaMEDMEM::MEDCouplingUMesh::findCellsIdsOnBoundary; +%newobject ParaMEDMEM::MEDCouplingUMesh::computeSkin; %newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes; %newobject ParaMEDMEM::MEDCouplingUMesh::buildSetInstanceFromThis; %newobject ParaMEDMEM::MEDCouplingUMesh::getCellIdsCrossingPlane; @@ -1079,6 +1080,7 @@ namespace ParaMEDMEM void shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception); std::vector getQuadraticStatus() const throw(INTERP_KERNEL::Exception); DataArrayInt *findCellsIdsOnBoundary() const throw(INTERP_KERNEL::Exception); + MEDCouplingUMesh *computeSkin() const throw(INTERP_KERNEL::Exception); bool checkConsecutiveCellTypes() const throw(INTERP_KERNEL::Exception); DataArrayInt *rearrange2ConsecutiveCellTypes() throw(INTERP_KERNEL::Exception); DataArrayInt *sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception);