X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VtkCellIterator.cxx;h=24f49ae7333de1040937b09362a5849e7d806e28;hp=55570417b330d78381b627a807b41c431ef8a48f;hb=499f29d24922cec66e41b41a0039a954993bc6df;hpb=6d32f944a0a115b6419184c50b57bf7c4eef5786 diff --git a/src/SMDS/SMDS_VtkCellIterator.cxx b/src/SMDS/SMDS_VtkCellIterator.cxx index 55570417b..24f49ae73 100644 --- a/src/SMDS/SMDS_VtkCellIterator.cxx +++ b/src/SMDS/SMDS_VtkCellIterator.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2019 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -23,37 +23,39 @@ #include #include -_GetVtkNodes::_GetVtkNodes( vtkIdList* _vtkIdList, +_GetVtkNodes::_GetVtkNodes( TVtkIdList& vtkIds, SMDS_Mesh* mesh, - int vtkCellId, - SMDSAbs_EntityType aType ) + vtkIdType vtkCellId, + SMDSAbs_EntityType type ) { - vtkUnstructuredGrid* grid = mesh->GetGrid(); - const std::vector& interlace = SMDS_MeshCell::fromVtkOrder( aType ); + vtkUnstructuredGrid* grid = mesh->GetGrid(); + const std::vector& interlace = SMDS_MeshCell::fromVtkOrder( type ); + vtkIdType npts; + vtkIdType const *pts(nullptr); + grid->GetCellPoints( vtkCellId, npts, pts ); + vtkIds.resize( npts ); if ( interlace.empty() ) { - grid->GetCellPoints( vtkCellId, _vtkIdList ); + vtkIds.assign( pts, pts + npts ); } else { - vtkIdType npts, *pts; - grid->GetCellPoints( vtkCellId, npts, pts ); - _vtkIdList->SetNumberOfIds( npts ); - for (int i = 0; i < npts; i++) - _vtkIdList->SetId(i, pts[interlace[i]]); + for (vtkIdType i = 0; i < npts; i++) + vtkIds[ i ] = pts[ interlace[i] ]; } } -_GetVtkNodesToUNV::_GetVtkNodesToUNV( vtkIdList* _vtkIdList, +_GetVtkNodesToUNV::_GetVtkNodesToUNV( TVtkIdList& vtkIds, SMDS_Mesh* mesh, - int vtkCellId, - SMDSAbs_EntityType aType ) + vtkIdType vtkCellId, + SMDSAbs_EntityType type ) { - vtkIdType * pts, npts; vtkUnstructuredGrid* grid = mesh->GetGrid(); - grid->GetCellPoints( (vtkIdType)vtkCellId, npts, pts ); + vtkIdType npts; + vtkIdType const *pts(nullptr); + grid->GetCellPoints( vtkCellId, npts, pts ); const int *ids = 0; - switch (aType) + switch ( type ) { case SMDSEntity_Quad_Edge: { @@ -115,49 +117,48 @@ _GetVtkNodesToUNV::_GetVtkNodesToUNV( vtkIdList* _vtkIdList, case SMDSEntity_Polyhedra: case SMDSEntity_Quad_Polyhedra: default: - const std::vector& i = SMDS_MeshCell::interlacedSmdsOrder( aType, npts ); + const std::vector& i = SMDS_MeshCell::interlacedSmdsOrder( type, npts ); if ( !i.empty() ) ids = & i[0]; } - _vtkIdList->SetNumberOfIds( npts ); + vtkIds.resize( npts ); if ( ids ) for (int i = 0; i < npts; i++) - _vtkIdList->SetId(i, pts[ids[i]]); + vtkIds[ i ] = pts[ ids[i] ]; else - for (int i = 0; i < npts; i++) - _vtkIdList->SetId(i, pts[i]); + vtkIds.assign( pts, pts + npts ); } -_GetVtkNodesPolyh::_GetVtkNodesPolyh( vtkIdList* _vtkIdList, +_GetVtkNodesPolyh::_GetVtkNodesPolyh( TVtkIdList& vtkIds, SMDS_Mesh* mesh, - int vtkCellId, - SMDSAbs_EntityType aType ) + vtkIdType vtkCellId, + SMDSAbs_EntityType type ) { vtkUnstructuredGrid* grid = mesh->GetGrid(); - switch (aType) + switch ( type ) { case SMDSEntity_Polyhedra: { vtkIdType nFaces = 0; - vtkIdType* ptIds = 0; + vtkIdType const *ptIds(nullptr); grid->GetFaceStream( vtkCellId, nFaces, ptIds ); int id = 0, nbNodesInFaces = 0; - for (int i = 0; i < nFaces; i++) + for ( int i = 0; i < nFaces; i++ ) { int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] nbNodesInFaces += nodesInFace; id += (nodesInFace + 1); } - _vtkIdList->SetNumberOfIds( nbNodesInFaces ); + vtkIds.resize( nbNodesInFaces ); id = 0; int n = 0; - for (int i = 0; i < nFaces; i++) + for ( int i = 0; i < nFaces; i++ ) { int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] - for (int k = 1; k <= nodesInFace; k++) - _vtkIdList->SetId(n++, ptIds[id + k]); + for ( int k = 1; k <= nodesInFace; k++ ) + vtkIds[ n++ ] = ptIds[ id + k ]; id += (nodesInFace + 1); } break;