X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshVolume.cxx;h=ee9eb939fa0a11fbe1e681b9aff2753162271ad5;hb=e3019524b4caa444880639745b22f30d577aba2c;hp=755285447cb721d880293adb649e1a32a9fcedea;hpb=4c16067d4281f56bd07d3f92fb63fff9c0c1d169;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshVolume.cxx b/src/SMDS/SMDS_MeshVolume.cxx index 755285447..ee9eb939f 100644 --- a/src/SMDS/SMDS_MeshVolume.cxx +++ b/src/SMDS/SMDS_MeshVolume.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -75,6 +75,45 @@ void SMDS_MeshVolume::init( const std::vector& vtkNodeIds ) SMDS_MeshCell::init( aType, vtkNodeIds ); } +bool SMDS_MeshVolume::ChangeNodes(const std::vector& nodes, + const std::vector& quantities) const +{ + if ( !IsPoly() ) + return false; + + vtkIdType nFaces = 0; + vtkIdType* ptIds = 0; + getGrid()->GetFaceStream( GetVtkID(), nFaces, ptIds ); + + // stream size and nb faces should not change + + if ((int) quantities.size() != nFaces ) + { + return false; + } + int id = 0, nbPoints = 0; + for ( int i = 0; i < nFaces; i++ ) + { + int nodesInFace = ptIds[id]; + nbPoints += nodesInFace; + id += (nodesInFace + 1); + } + if ((int) nodes.size() != nbPoints ) + { + return false; + } + + // update ptIds + size_t iP = 0, iN = 0; + for ( size_t i = 0; i < quantities.size(); ++i ) + { + ptIds[ iP++ ] = quantities[ i ]; // nb face nodes + for ( int j = 0; j < quantities[ i ]; ++j ) + ptIds[ iP++ ] = nodes[ iN++ ]->GetVtkID(); + } + return true; +} + const SMDS_MeshNode* SMDS_MeshVolume::GetNode(const int ind) const { if ( !IsPoly() ) @@ -88,7 +127,7 @@ const SMDS_MeshNode* SMDS_MeshVolume::GetNode(const int ind) const { int nodesInFace = ptIds[id]; if ( ind < nbPoints + nodesInFace ) - return GetMesh()->FindNodeVtk( ptIds[ ind + i ]); + return GetMesh()->FindNodeVtk( ptIds[ 1 + ind + i ]); nbPoints += nodesInFace; id += (nodesInFace + 1); }