X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_VtkCellIterator.hxx;h=92fdc17a240187f3c466e85421c76222a1d573a3;hb=5e2c97c386dc03e51e072c7f9909803a86307872;hp=ce151099dbf95f6790fdf4e163512b82375a4620;hpb=bd4e115a78b52e3fbc016e5e30bb0e19b2a9e7d6;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_VtkCellIterator.hxx b/src/SMDS/SMDS_VtkCellIterator.hxx index ce151099d..92fdc17a2 100644 --- a/src/SMDS/SMDS_VtkCellIterator.hxx +++ b/src/SMDS/SMDS_VtkCellIterator.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2010-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2010-2016 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 // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -27,46 +27,68 @@ #include #include -class SMDS_VtkCellIterator: public SMDS_ElemIterator +//-------------------------------------------------------------------------------- +/*! + * \brief Retrieve nodes of a cell + */ +struct _GetVtkNodes +{ + _GetVtkNodes( vtkIdList* nodeIds, SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type); +}; +struct _GetVtkNodesToUNV +{ + _GetVtkNodesToUNV( vtkIdList* nodeIds, SMDS_Mesh* mesh, int vtkCellId, SMDSAbs_EntityType type); +}; +struct _GetVtkNodesPolyh +{ + _GetVtkNodesPolyh( vtkIdList* nodeIds, SMDS_Mesh* mesh, int 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, int vtkCellId, SMDSAbs_EntityType aType) + : _mesh(mesh), _index(0), _vtkIdList( vtkIdList::New() ) { - 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() { _vtkIdList->Delete(); } + virtual bool more() { return ( _index < _vtkIdList->GetNumberOfIds() ); } + virtual result_type next() { + vtkIdType id = _vtkIdList->GetId( _index++ ); + return static_cast( _mesh->FindNodeVtk( id )); } - protected: - SMDS_VtkCellIterator() {}; - SMDS_Mesh* _mesh; - int _cellId; - int _index; - int _nbNodes; - SMDSAbs_EntityType _type; + int _index; vtkIdList* _vtkIdList; }; -class SMDS_VtkCellIteratorToUNV: public 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 ~SMDS_VtkCellIteratorToUNV(); + SMDS_VtkCellIteratorToUNV(SMDS_Mesh* mesh, int 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, int vtkCellId, SMDSAbs_EntityType type): + parent_t( mesh, vtkCellId, type ) {} }; #endif