X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VtkCellIterator.hxx;h=650b0ea9ef73ab9c3f13f342714459ea3b90e4a9;hp=1581785d4e64297a4688b862ed97447cde0f8aa2;hb=HEAD;hpb=5d68554076bbca0e1e95fb0db215a6c2b84b6c54 diff --git a/src/SMDS/SMDS_VtkCellIterator.hxx b/src/SMDS/SMDS_VtkCellIterator.hxx index 1581785d4..3fa804f23 100644 --- a/src/SMDS/SMDS_VtkCellIterator.hxx +++ b/src/SMDS/SMDS_VtkCellIterator.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2010-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2024 CEA, EDF, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,50 +25,71 @@ #include "SMDSAbs_ElementType.hxx" #include -#include -class SMDS_VtkCellIterator: public SMDS_ElemIterator +typedef std::vector< vtkIdType > TVtkIdList; + +//-------------------------------------------------------------------------------- +/*! + * \brief Retrieve nodes of a cell + */ +struct _GetVtkNodes +{ + _GetVtkNodes( TVtkIdList& nodeIds, SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType type); +}; +struct _GetVtkNodesToUNV +{ + _GetVtkNodesToUNV( TVtkIdList& nodeIds, SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType type); +}; +struct _GetVtkNodesPolyh +{ + _GetVtkNodesPolyh( TVtkIdList& nodeIds, SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType type); +}; + +//-------------------------------------------------------------------------------- +/*! + * \brief Iterator on nodes of a cell + */ +template< class SMDS_ITERATOR = SMDS_ElemIterator, class GET_VTK_NODES = _GetVtkNodes > +class SMDS_VtkCellIterator: public SMDS_ITERATOR { public: - SMDS_VtkCellIterator(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType); - virtual ~SMDS_VtkCellIterator(); - virtual bool more(); - virtual const SMDS_MeshElement* next(); - inline void exchange(vtkIdType a, vtkIdType b) + typedef typename SMDS_ITERATOR::value_type result_type; + + SMDS_VtkCellIterator(SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType aType) + : _mesh(mesh), _index(0) { - vtkIdType t = _vtkIdList->GetId(a); - _vtkIdList->SetId(a, _vtkIdList->GetId(b)); - _vtkIdList->SetId(b, t); + GET_VTK_NODES getNodes( _vtkIdList, mesh, vtkCellId, aType ); + } + virtual ~SMDS_VtkCellIterator() {} + virtual bool more() { return ( _index < _vtkIdList.size() ); } + virtual result_type next() { + vtkIdType id = _vtkIdList[ _index++ ]; + return static_cast( _mesh->FindNodeVtk( id )); } - protected: - SMDS_VtkCellIterator() {}; - SMDS_Mesh* _mesh; - int _cellId; - int _index; - int _nbNodes; - SMDSAbs_EntityType _type; - vtkIdList* _vtkIdList; + size_t _index; + TVtkIdList _vtkIdList; }; -class SMDS_VtkCellIteratorToUNV: public SMDS_NodeIterator, protected SMDS_VtkCellIterator +//-------------------------------------------------------------------------------- +template< class SMDS_ITERATOR = SMDS_ElemIterator > +class SMDS_VtkCellIteratorToUNV: public SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesToUNV > { + typedef SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesToUNV > parent_t; public: - SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType); - virtual const SMDS_MeshNode* next(); - virtual bool more(); - virtual ~SMDS_VtkCellIteratorToUNV(); + SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType type): + parent_t( mesh, vtkCellId, type ) {} }; -class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator +//-------------------------------------------------------------------------------- +template< class SMDS_ITERATOR = SMDS_ElemIterator > +class SMDS_VtkCellIteratorPolyH: public SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesPolyh > { + typedef SMDS_VtkCellIterator< SMDS_ITERATOR, _GetVtkNodesPolyh > parent_t; public: - SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType aType); - virtual ~SMDS_VtkCellIteratorPolyH(); - virtual bool more(); -protected: - int _nbNodesInFaces; + SMDS_VtkCellIteratorPolyH(SMDS_Mesh* mesh, vtkIdType vtkCellId, SMDSAbs_EntityType type): + parent_t( mesh, vtkCellId, type ) {} }; #endif