From 65ba50c8708a65f8b82ef39fc821b17e25273737 Mon Sep 17 00:00:00 2001 From: Viktor UZLOV Date: Mon, 15 Feb 2021 16:29:23 +0300 Subject: [PATCH] fix SVTK, new collection with vtkIdType --- src/SVTK/SALOME_Actor.cxx | 14 +++++++------- src/SVTK/SVTK_Actor.cxx | 4 ++-- src/SVTK/SVTK_Actor.h | 6 +++--- src/SVTK/SVTK_Hash.h | 22 ++++++++++++++++++++++ src/SVTK/SVTK_Selector.cxx | 30 +++++++++++++++--------------- src/SVTK/SVTK_Selector.h | 10 +++++----- src/SVTK/SVTK_SelectorDef.h | 12 ++++++------ 7 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 74435febb..8c91d9d3a 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -466,7 +466,7 @@ SALOME_Actor myHighlightActor->MapCells( this, aMapIndex ); break; case EdgeOfCellSelection: - SVTK_IndexedMapOfIds aMapCompositeIndex; + SVTK_IndexedMapOfVtkIds aMapCompositeIndex; mySelector->GetCompositeIndex( getIO(), aMapCompositeIndex ); myHighlightActor->GetProperty()->SetRepresentationToWireframe(); myHighlightActor->MapEdge( this, aMapCompositeIndex ); @@ -609,13 +609,13 @@ SALOME_Actor if(myIsPreselected){ vtkIdType aFNObjId = GetNodeObjId( aFNId ); vtkIdType aSNObjId = GetNodeObjId( aSNId ); - const SVTK_IndexedMapOfIds& aMapIds = myPreHighlightActor->GetMapCompositeIndex(); + const SVTK_IndexedMapOfVtkIds& aMapIds = myPreHighlightActor->GetMapCompositeIndex(); int anExtent = aMapIds.Extent(); anIsChanged |= (anExtent == 0 || (anExtent > 0 && aMapIds(1).size() == 2 && (aFNObjId != aMapIds(1)[0] || aSNObjId != aMapIds(1)[1] ) ) ); if( anIsChanged ) { - SVTK_IndexedMapOfIds aMapIds; - SVTK_ListOfInteger aCompositeID; + SVTK_IndexedMapOfVtkIds aMapIds; + SVTK_ListOfVtk aCompositeID; aCompositeID.push_back( aFNObjId ); aCompositeID.push_back( aSNObjId ); aMapIds.Add( aCompositeID ); @@ -823,7 +823,7 @@ SALOME_Actor const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myCellAreaPicker->GetCellIdsMap(); SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this); - SVTK_IndexedMapOfIds anIndexes; + SVTK_IndexedMapOfVtkIds anIndexes; if(aMapIter != aVectorIdsMap.end()){ const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second; vtkIdType anEnd = (int)aVectorIds.size(); //!< TODO: conversion from size_t to int @@ -837,7 +837,7 @@ SALOME_Actor vtkIdType aFNId, aSNId; int anEdgeId = GetEdgeAndNodesId(this,myCellPicker.GetPointer(),anObjId,aFNId,aSNId); if( anEdgeId < 0 ) { - SVTK_ListOfInteger aCompositeID; + SVTK_ListOfVtk aCompositeID; aCompositeID.push_back( GetNodeObjId( aFNId ) ); aCompositeID.push_back( GetNodeObjId( aSNId ) ); anIndexes.Add( aCompositeID ); @@ -910,7 +910,7 @@ SALOME_Actor vtkIdType aFNId, aSNId; int anEdgeId = GetEdgeAndNodesId(this,myCellPicker.GetPointer(),anObjId,aFNId,aSNId); if( hasIO() && anEdgeId < 0 ) { - SVTK_ListOfInteger aCompositeID; + SVTK_ListOfVtk aCompositeID; aCompositeID.push_back( GetNodeObjId( aFNId ) ); aCompositeID.push_back( GetNodeObjId( aSNId ) ); mySelector->AddOrRemoveCompositeIndex( myIO, aCompositeID, anIsShift ); diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index a534ea44a..1b4ee4571 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -104,7 +104,7 @@ SVTK_Actor } -const SVTK_IndexedMapOfIds& +const SVTK_IndexedMapOfVtkIds& SVTK_Actor ::GetMapCompositeIndex() const { @@ -224,7 +224,7 @@ SVTK_Actor void SVTK_Actor ::MapEdge( SALOME_Actor* theMapActor, - const SVTK_IndexedMapOfIds& theMapCompositeIndex) { + const SVTK_IndexedMapOfVtkIds& theMapCompositeIndex) { myUnstructuredGrid->Initialize(); myUnstructuredGrid->Allocate(); diff --git a/src/SVTK/SVTK_Actor.h b/src/SVTK/SVTK_Actor.h index a42db7998..9b9d3a0e8 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -87,18 +87,18 @@ public: //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes using corner node ids virtual void MapEdge(SALOME_Actor* theMapActor, - const SVTK_IndexedMapOfIds& theMapCompositeIndex); + const SVTK_IndexedMapOfVtkIds& theMapCompositeIndex); const TColStd_IndexedMapOfInteger& GetMapIndex() const; - const SVTK_IndexedMapOfIds& + const SVTK_IndexedMapOfVtkIds& GetMapCompositeIndex() const; protected: TColStd_IndexedMapOfInteger myMapIndex; - SVTK_IndexedMapOfIds myMapCompositeIndex; + SVTK_IndexedMapOfVtkIds myMapCompositeIndex; vtkSmartPointer myUnstructuredGrid; diff --git a/src/SVTK/SVTK_Hash.h b/src/SVTK/SVTK_Hash.h index afd6227ef..1daf5579c 100644 --- a/src/SVTK/SVTK_Hash.h +++ b/src/SVTK/SVTK_Hash.h @@ -30,8 +30,10 @@ #include #include #include +#include typedef std::vector SVTK_ListOfInteger; +typedef std::vector SVTK_ListOfVtk; class SVTK_Hasher { @@ -52,6 +54,26 @@ public: } }; +class SVTK_vtkHasher { + +public: + static vtkIdType HashCode(const std::vector ids, + const vtkIdType upper) { + vtkIdType seed = (vtkIdType)ids.size(); + for( vtkIdType i = 0; i < ids.size(); i++) { + vtkIdType v = ids[i]; + seed ^= v + 0x9e3779b97f4a7c15 + ( seed << 6 ) + ( seed >> 2 ); + } + return ::HashCode(seed, upper); + } + + static vtkIdType IsEqual(const SVTK_ListOfVtk& theKey1, + const SVTK_ListOfVtk& theKey2) { + return theKey1 == theKey2; + } +}; + typedef NCollection_IndexedMap SVTK_IndexedMapOfIds; +typedef NCollection_IndexedMap SVTK_IndexedMapOfVtkIds; #endif // SVTK_HASH_H diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index dae45cfeb..b326d37f5 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -323,19 +323,19 @@ static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theI return anId != 0; } -static bool removeCompositeIndex( SVTK_IndexedMapOfIds& theMapIndex, const SVTK_ListOfInteger theIds ) +static bool removeCompositeIndex( SVTK_IndexedMapOfVtkIds& theMapIndex, const SVTK_ListOfVtk theIds ) { int anId = theMapIndex.FindIndex( theIds ); // i==0 if Index is not in the MapIndex if( anId ) { // only the last key can be removed - SVTK_ListOfInteger aLastIds = theMapIndex.FindKey( theMapIndex.Extent() ); + SVTK_ListOfVtk aLastIds = theMapIndex.FindKey( theMapIndex.Extent() ); if( aLastIds == theIds ) theMapIndex.RemoveLast(); else { - SVTK_IndexedMapOfIds aNewMap; + SVTK_IndexedMapOfVtkIds aNewMap; aNewMap.ReSize(theMapIndex.Extent()-1); for( int j = 1; j <= theMapIndex.Extent(); j++ ){ - SVTK_ListOfInteger anIds = theMapIndex( j ); + SVTK_ListOfVtk anIds = theMapIndex( j ); if ( anIds != theIds ) aNewMap.Add( anIds ); } @@ -499,7 +499,7 @@ SVTK_SelectorDef void SVTK_SelectorDef ::GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_IndexedMapOfIds& theIds ) + SVTK_IndexedMapOfVtkIds& theIds ) { TMapIOSubCompositeIndex::const_iterator anIter = myMapIOSubCompositeIndex.find( theIO ); if( anIter != myMapIOSubCompositeIndex.end() ) @@ -517,15 +517,15 @@ SVTK_SelectorDef bool SVTK_SelectorDef ::AddOrRemoveCompositeIndex( const Handle( SALOME_InteractiveObject )& theIO, - const SVTK_IndexedMapOfIds& theIds, + const SVTK_IndexedMapOfVtkIds& theIds, bool theIsModeShift) { TMapIOSubCompositeIndex::iterator aMapIter = myMapIOSubCompositeIndex.find( theIO ); if( aMapIter == myMapIOSubCompositeIndex.end() ) { - SVTK_IndexedMapOfIds anEmpty; + SVTK_IndexedMapOfVtkIds anEmpty; aMapIter = myMapIOSubCompositeIndex.insert( TMapIOSubCompositeIndex::value_type( theIO, anEmpty ) ).first; } - SVTK_IndexedMapOfIds& aMapIndex = aMapIter->second; + SVTK_IndexedMapOfVtkIds& aMapIndex = aMapIter->second; if( !theIsModeShift ) aMapIndex.Clear(); @@ -549,16 +549,16 @@ SVTK_SelectorDef bool SVTK_SelectorDef ::AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds, + SVTK_ListOfVtk theIds, bool theIsModeShift) { TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); if( anIter == myMapIOSubCompositeIndex.end() ) { - SVTK_IndexedMapOfIds anEmpty; + SVTK_IndexedMapOfVtkIds anEmpty; anIter = myMapIOSubCompositeIndex.insert(TMapIOSubCompositeIndex::value_type( theIO,anEmpty ) ).first; } - SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + SVTK_IndexedMapOfVtkIds& aMapIndex = anIter->second; bool anIsContains = aMapIndex.Contains( theIds ) == Standard_True; if ( anIsContains ) @@ -584,11 +584,11 @@ SVTK_SelectorDef void SVTK_SelectorDef ::RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds ) + SVTK_ListOfVtk theIds ) { if(IsCompositeIndexSelected( theIO, theIds ) ) { TMapIOSubCompositeIndex::iterator anIter = myMapIOSubCompositeIndex.find( theIO ); - SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + SVTK_IndexedMapOfVtkIds& aMapIndex = anIter->second; removeCompositeIndex( aMapIndex,theIds ); } } @@ -601,11 +601,11 @@ SVTK_SelectorDef bool SVTK_SelectorDef ::IsCompositeIndexSelected( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds ) const + SVTK_ListOfVtk theIds ) const { TMapIOSubCompositeIndex::const_iterator anIter = myMapIOSubCompositeIndex.find( theIO ); if( anIter != myMapIOSubCompositeIndex.end() ) { - const SVTK_IndexedMapOfIds& aMapIndex = anIter->second; + const SVTK_IndexedMapOfVtkIds& aMapIndex = anIter->second; return aMapIndex.Contains( theIds ) == Standard_True; } return false; diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index a61e90f73..493f1460c 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -179,33 +179,33 @@ public: virtual void GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_IndexedMapOfIds& theIds ) = 0; + SVTK_IndexedMapOfVtkIds& theIds ) = 0; //! Change composite indices of subselection for given #SALOME_InteractiveObject virtual bool AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - const SVTK_IndexedMapOfIds& theIds, + const SVTK_IndexedMapOfVtkIds& theIds, bool theIsModeShift) = 0; //! Change composite index of subslection for given #SALOME_InteractiveObject virtual bool AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger ids, + SVTK_ListOfVtk ids, bool theIsModeShift) = 0; //! Change composite index of subslection for given #SALOME_InteractiveObject virtual void RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger ids ) = 0; + SVTK_ListOfVtk ids ) = 0; //! Check, if the given composite index is present in subselection virtual bool IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger ids ) const = 0; + SVTK_ListOfVtk ids ) const = 0; //! Clear composite indexes subselection virtual diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index 81eb6d5f7..1e2f479c1 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -144,28 +144,28 @@ public: virtual void GetCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_IndexedMapOfIds& theIds ); + SVTK_IndexedMapOfVtkIds& theIds ); virtual bool AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - const SVTK_IndexedMapOfIds& theIds, + const SVTK_IndexedMapOfVtkIds& theIds, bool theIsModeShift); virtual bool AddOrRemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds, + SVTK_ListOfVtk theIds, bool theIsModeShift); virtual void RemoveCompositeIndex( const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds ); + SVTK_ListOfVtk theIds ); virtual bool IsCompositeIndexSelected(const Handle(SALOME_InteractiveObject)& theIO, - SVTK_ListOfInteger theIds ) const; + SVTK_ListOfVtk theIds ) const; virtual void @@ -280,7 +280,7 @@ private: TMapIOSubIndex myMapIOSubIndex; typedef std::map TMapIOSubCompositeIndex; TMapIOSubCompositeIndex myMapIOSubCompositeIndex; -- 2.39.2