X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VtkCellIterator.cxx;h=5c6aec32ddb1b2dbaea01f0ee1be646bd175a011;hp=2fc70ee8783d36959448b986e36ac6e893c6c347;hb=63d5619b14edc450a51d92f059879bee1c1fa12d;hpb=7eda9ca931ed2a11cb5e4637e4ffe19f5c061115 diff --git a/src/SMDS/SMDS_VtkCellIterator.cxx b/src/SMDS/SMDS_VtkCellIterator.cxx index 2fc70ee87..5c6aec32d 100644 --- a/src/SMDS/SMDS_VtkCellIterator.cxx +++ b/src/SMDS/SMDS_VtkCellIterator.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2019 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 @@ -20,59 +20,40 @@ #include "SMDS_VtkCellIterator.hxx" #include "utilities.h" -SMDS_VtkCellIterator::SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : - _mesh(mesh), _cellId(vtkCellId), _index(0), _type(aType) +#include +#include + +_GetVtkNodes::_GetVtkNodes( TVtkIdList& vtkIds, + SMDS_Mesh* mesh, + int vtkCellId, + SMDSAbs_EntityType type ) { - vtkUnstructuredGrid* grid = _mesh->getGrid(); - _vtkIdList = vtkIdList::New(); - const std::vector& interlace = SMDS_MeshCell::fromVtkOrder( aType ); + vtkUnstructuredGrid* grid = mesh->GetGrid(); + const std::vector& interlace = SMDS_MeshCell::fromVtkOrder( type ); + vtkIdType npts, *pts; + grid->GetCellPoints( vtkCellId, npts, pts ); + vtkIds.resize( npts ); if ( interlace.empty() ) { - grid->GetCellPoints(_cellId, _vtkIdList); - _nbNodes = _vtkIdList->GetNumberOfIds(); + vtkIds.assign( pts, pts + npts ); } else { - vtkIdType npts, *pts; - grid->GetCellPoints( _cellId, npts, pts ); - _vtkIdList->SetNumberOfIds( _nbNodes = npts ); - for (int i = 0; i < _nbNodes; i++) - _vtkIdList->SetId(i, pts[interlace[i]]); + for (vtkIdType i = 0; i < npts; i++) + vtkIds[ i ] = pts[ interlace[i] ]; } } -SMDS_VtkCellIterator::~SMDS_VtkCellIterator() -{ - _vtkIdList->Delete(); -} - -bool SMDS_VtkCellIterator::more() -{ - return (_index < _nbNodes); -} - -const SMDS_MeshElement* SMDS_VtkCellIterator::next() +_GetVtkNodesToUNV::_GetVtkNodesToUNV( TVtkIdList& vtkIds, + SMDS_Mesh* mesh, + int vtkCellId, + SMDSAbs_EntityType type ) { - vtkIdType id = _vtkIdList->GetId(_index++); - return _mesh->FindNodeVtk(id); -} - -SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : - SMDS_VtkCellIterator() -{ - _mesh = mesh; - _cellId = vtkCellId; - _index = 0; - _type = aType; - //MESSAGE("SMDS_VtkCellInterlacedIterator (UNV)" << _type); - - _vtkIdList = vtkIdList::New(); - vtkIdType* pts; - vtkUnstructuredGrid* grid = _mesh->getGrid(); - grid->GetCellPoints((vtkIdType)_cellId, (vtkIdType&)_nbNodes, pts); - _vtkIdList->SetNumberOfIds(_nbNodes); + vtkUnstructuredGrid* grid = mesh->GetGrid(); + vtkIdType npts, *pts; + grid->GetCellPoints( vtkCellId, npts, pts ); const int *ids = 0; - switch (_type) + switch ( type ) { case SMDSEntity_Quad_Edge: { @@ -85,7 +66,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel { static int id[] = { 0, 3, 1, 4, 2, 5 }; ids = id; - _nbNodes = 6; + npts = 6; break; } case SMDSEntity_Quad_Quadrangle: @@ -93,7 +74,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel { static int id[] = { 0, 4, 1, 5, 2, 6, 3, 7 }; ids = id; - _nbNodes = 8; + npts = 8; break; } case SMDSEntity_Quad_Tetra: @@ -115,6 +96,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel break; } case SMDSEntity_Quad_Penta: + case SMDSEntity_BiQuad_Penta: //TODO: check { static int id[] = { 0, 8, 2, 7, 1, 6, 12, 14, 13, 3, 11, 5, 10, 4, 9 }; ids = id; @@ -125,7 +107,7 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel { static int id[] = { 0, 8, 1, 9, 2, 10, 3, 11, 16, 17, 18, 19, 4, 12, 5, 13, 6, 14, 7, 15 }; ids = id; - _nbNodes = 20; + npts = 20; break; } case SMDSEntity_Polygon: @@ -133,69 +115,48 @@ SMDS_VtkCellIteratorToUNV::SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCel case SMDSEntity_Polyhedra: case SMDSEntity_Quad_Polyhedra: default: - const std::vector& i = SMDS_MeshCell::interlacedSmdsOrder(aType, _nbNodes); + const std::vector& i = SMDS_MeshCell::interlacedSmdsOrder( type, npts ); if ( !i.empty() ) ids = & i[0]; } + vtkIds.resize( npts ); + if ( ids ) - for (int i = 0; i < _nbNodes; i++) - _vtkIdList->SetId(i, pts[ids[i]]); + for (int i = 0; i < npts; i++) + vtkIds[ i ] = pts[ ids[i] ]; else - for (int i = 0; i < _nbNodes; i++) - _vtkIdList->SetId(i, pts[i]); + vtkIds.assign( pts, pts + npts ); } -bool SMDS_VtkCellIteratorToUNV::more() +_GetVtkNodesPolyh::_GetVtkNodesPolyh( TVtkIdList& vtkIds, + SMDS_Mesh* mesh, + int vtkCellId, + SMDSAbs_EntityType type ) { - return SMDS_VtkCellIterator::more(); -} - -const SMDS_MeshNode* SMDS_VtkCellIteratorToUNV::next() -{ - return static_cast< const SMDS_MeshNode* >( SMDS_VtkCellIterator::next() ); -} - -SMDS_VtkCellIteratorToUNV::~SMDS_VtkCellIteratorToUNV() -{ -} - -SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType) : - SMDS_VtkCellIterator() -{ - _mesh = mesh; - _cellId = vtkCellId; - _index = 0; - _type = aType; - //MESSAGE("SMDS_VtkCellIteratorPolyH " << _type); - _vtkIdList = vtkIdList::New(); - vtkUnstructuredGrid* grid = _mesh->getGrid(); - grid->GetCellPoints(_cellId, _vtkIdList); - _nbNodes = _vtkIdList->GetNumberOfIds(); - switch (_type) + vtkUnstructuredGrid* grid = mesh->GetGrid(); + switch ( type ) { case SMDSEntity_Polyhedra: { - //MESSAGE("SMDS_VtkCellIterator Polyhedra"); vtkIdType nFaces = 0; vtkIdType* ptIds = 0; - grid->GetFaceStream(_cellId, nFaces, ptIds); - int id = 0; - _nbNodesInFaces = 0; - for (int i = 0; i < nFaces; i++) + grid->GetFaceStream( vtkCellId, nFaces, ptIds ); + int id = 0, nbNodesInFaces = 0; + for ( int i = 0; i < nFaces; i++ ) { int nodesInFace = ptIds[id]; // nodeIds in ptIds[id+1 .. id+nodesInFace] - _nbNodesInFaces += 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; @@ -204,12 +165,3 @@ SMDS_VtkCellIteratorPolyH::SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCel assert(0); } } - -SMDS_VtkCellIteratorPolyH::~SMDS_VtkCellIteratorPolyH() -{ -} - -bool SMDS_VtkCellIteratorPolyH::more() -{ - return (_index < _nbNodesInFaces); -}