From 0115246c96be37462cdd8a481d1fa47edaf9c46d Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 20 Dec 2012 10:19:51 +0000 Subject: [PATCH] Fix for 32-bit platforms - int GetElementIds( int* ids ) const; + template< typename IDTYPE > + int GetElementIds( IDTYPE* ids ) const + { + return getElementIds( (void*)ids, sizeof(IDTYPE)); + } --- src/SMESHDS/SMESHDS_GroupOnFilter.cxx | 17 +++++++++-------- src/SMESHDS/SMESHDS_GroupOnFilter.hxx | 8 +++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/SMESHDS/SMESHDS_GroupOnFilter.cxx b/src/SMESHDS/SMESHDS_GroupOnFilter.cxx index 3850da28b..80082af0d 100644 --- a/src/SMESHDS/SMESHDS_GroupOnFilter.cxx +++ b/src/SMESHDS/SMESHDS_GroupOnFilter.cxx @@ -228,18 +228,18 @@ std::vector< int > SMESHDS_GroupOnFilter::GetMeshInfo() const */ //================================================================================ -int SMESHDS_GroupOnFilter::GetElementIds( int* ids ) const +int SMESHDS_GroupOnFilter::getElementIds( void* ids, size_t idSize ) const { SMESHDS_GroupOnFilter* me = const_cast( this ); - int* curID = ids; + char* curID = (char*) ids; SMDS_ElemIteratorPtr elIt = GetElements(); if ( elIt->more() ) { if ( IsUpToDate() ) { - while ( elIt->more() ) - *curID++ = elIt->next()->GetID(); + for ( ; elIt->more(); curID += idSize ) + (*(int*) curID) = elIt->next()->GetID(); } else { @@ -250,18 +250,19 @@ int SMESHDS_GroupOnFilter::GetElementIds( int* ids ) const me->myMeshInfo.assign( SMDSEntity_Last, 0 ); me->myMeshInfo[ firstOkElem->GetEntityType() ]++; - *curID++ = firstOkElem->GetID(); - while ( elIt->more() ) + + (*(int*) curID) = firstOkElem->GetID(); + for ( curID += idSize; elIt->more(); curID += idSize ) { const SMDS_MeshElement* e = elIt->next(); + (*(int*) curID) = e->GetID(); me->myMeshInfo[ e->GetEntityType() ]++; - *curID++ = e->GetID(); } } } me->setChanged( false ); - return curID - ids; + return ( curID - (char*)ids ) / idSize; } //================================================================================ diff --git a/src/SMESHDS/SMESHDS_GroupOnFilter.hxx b/src/SMESHDS/SMESHDS_GroupOnFilter.hxx index 17b347a21..9200744d2 100644 --- a/src/SMESHDS/SMESHDS_GroupOnFilter.hxx +++ b/src/SMESHDS/SMESHDS_GroupOnFilter.hxx @@ -48,7 +48,12 @@ class SMESHDS_EXPORT SMESHDS_GroupOnFilter: public SMESHDS_GroupBase std::vector< int > GetMeshInfo() const; - int GetElementIds( int* ids ) const; + template< typename IDTYPE > + int GetElementIds( IDTYPE* ids ) const + { + return getElementIds( (void*)ids, sizeof(IDTYPE)); + } + virtual int Extent() const; @@ -69,6 +74,7 @@ class SMESHDS_EXPORT SMESHDS_GroupOnFilter: public SMESHDS_GroupBase void update() const; void setChanged(bool changed=true); const SMDS_MeshElement* setNbElemToSkip( SMDS_ElemIteratorPtr& elIt ); + int getElementIds( void* ids, size_t idSize ) const; SMESH_PredicatePtr myPredicate; std::vector< int > myMeshInfo;