From: Viktor UZLOV Date: Sat, 20 Feb 2021 11:00:27 +0000 (+0300) Subject: vtkIdType collections X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f34ca747e8aa6f37553f00ed3e845235913b8d23;p=modules%2Fgui.git vtkIdType collections --- diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index 04feca42a..989325ba6 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -77,7 +77,7 @@ LightApp_SVTKDataOwner /*! Gets dataowners ids list. */ -const TColStd_IndexedMapOfInteger& +const SVTK_TIndexedMapOfVtkId& LightApp_SVTKDataOwner ::GetIds() const { diff --git a/src/LightApp/LightApp_VTKSelector.h b/src/LightApp/LightApp_VTKSelector.h index c5db9aaf0..66a19569a 100644 --- a/src/LightApp/LightApp_VTKSelector.h +++ b/src/LightApp/LightApp_VTKSelector.h @@ -33,6 +33,7 @@ class SUIT_Desktop; #ifndef DISABLE_VTKVIEWER #include + #include "SVTK_Hash.h" #include "SVTK_Selection.h" #ifndef DISABLE_SALOMEOBJECT #include "SALOME_InteractiveObject.hxx" @@ -57,7 +58,7 @@ class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner #endif /*!Gets dataowners ids list.*/ - const TColStd_IndexedMapOfInteger& GetIds() const; + const SVTK_TIndexedMapOfVtkId& GetIds() const; /*!Gets selection mode.*/ Selection_Mode GetMode() const; @@ -66,7 +67,7 @@ class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner SALOME_Actor* GetActor() const; protected: - mutable TColStd_IndexedMapOfInteger myIds; + mutable SVTK_TIndexedMapOfVtkId myIds; SVTK_ViewWindow* GetActiveViewWindow() const; SUIT_Desktop* myDesktop; diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index 8ed50cef4..70a7c4d3d 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -449,7 +449,7 @@ SALOME_Actor if(mySelector.GetPointer()){ if(mySelectionMode != ActorSelection){ - TColStd_IndexedMapOfInteger aMapIndex; + SVTK_TIndexedMapOfVtkId aMapIndex; mySelector->GetIndex( getIO(), aMapIndex ); switch( mySelectionMode ) { case NodeSelection: @@ -547,11 +547,11 @@ SALOME_Actor vtkIdType anObjId = GetNodeObjId( aVtkId ); myIsPreselected = (anObjId >= 0); if(myIsPreselected){ - const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); + const SVTK_TIndexedMapOfVtkId& aMapIndex = myPreHighlightActor->GetMapIndex(); int anExtent = aMapIndex.Extent(); anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1))); if(anIsChanged){ - TColStd_IndexedMapOfInteger aMapIndex; + SVTK_TIndexedMapOfVtkId aMapIndex; aMapIndex.Add( anObjId ); myPreHighlightActor->GetProperty()->SetRepresentationToPoints(); @@ -578,11 +578,11 @@ SALOME_Actor if ( anObjId >= 0 ) { myIsPreselected = CheckDimensionId(aSelectionMode,this,anObjId); if(myIsPreselected){ - const TColStd_IndexedMapOfInteger& aMapIndex = myPreHighlightActor->GetMapIndex(); + const SVTK_TIndexedMapOfVtkId& aMapIndex = myPreHighlightActor->GetMapIndex(); int anExtent = aMapIndex.Extent(); anIsChanged |= (anExtent == 0 || (anExtent > 0 && anObjId != aMapIndex(1))); if(anIsChanged){ - TColStd_IndexedMapOfInteger aMapIndex; + SVTK_TIndexedMapOfVtkId aMapIndex; aMapIndex.Add( anObjId ); myPreHighlightActor->GetProperty()->SetRepresentationToSurface(); @@ -709,7 +709,7 @@ SALOME_Actor const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myPointAreaPicker->GetPointIdsMap(); SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this); - TColStd_MapOfInteger anIndexes; + SVTK_TVtkIDsMap anIndexes; if(aMapIter != aVectorIdsMap.end()){ const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second; vtkIdType anEnd = (int)aVectorIds.size(); //!< TODO: conversion from size_t to int @@ -785,7 +785,7 @@ SALOME_Actor const SVTK_AreaPicker::TVectorIdsMap& aVectorIdsMap = myCellAreaPicker->GetCellIdsMap(); SVTK_AreaPicker::TVectorIdsMap::const_iterator aMapIter = aVectorIdsMap.find(this); - TColStd_MapOfInteger anIndexes; + SVTK_TVtkIDsMap anIndexes; if(aMapIter != aVectorIdsMap.end()){ const SVTK_AreaPicker::TVectorIds& aVectorIds = aMapIter->second; vtkIdType anEnd = (int)aVectorIds.size(); //!< TODO: conversion from size_t to int diff --git a/src/SVTK/SVTK_Actor.cxx b/src/SVTK/SVTK_Actor.cxx index 3a34619e5..b09bbcbad 100644 --- a/src/SVTK/SVTK_Actor.cxx +++ b/src/SVTK/SVTK_Actor.cxx @@ -96,7 +96,7 @@ SVTK_Actor { } -const TColStd_IndexedMapOfInteger& +const SVTK_TIndexedMapOfVtkId& SVTK_Actor ::GetMapIndex() const { @@ -114,7 +114,7 @@ SVTK_Actor void SVTK_Actor ::MapCells(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) + const SVTK_TIndexedMapOfVtkId& theMapIndex) { myUnstructuredGrid->Initialize(); myUnstructuredGrid->Allocate(); @@ -156,7 +156,7 @@ SVTK_Actor void SVTK_Actor ::MapPoints(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) + const SVTK_TIndexedMapOfVtkId& theMapIndex) { myUnstructuredGrid->Initialize(); myUnstructuredGrid->Allocate(); @@ -185,7 +185,7 @@ SVTK_Actor void SVTK_Actor ::MapEdge(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex) + const SVTK_TIndexedMapOfVtkId& theMapIndex) { myUnstructuredGrid->Initialize(); myUnstructuredGrid->Allocate(); diff --git a/src/SVTK/SVTK_Actor.h b/src/SVTK/SVTK_Actor.h index 9b9d3a0e8..ad35ee7a4 100644 --- a/src/SVTK/SVTK_Actor.h +++ b/src/SVTK/SVTK_Actor.h @@ -72,17 +72,17 @@ public: //! Allow to recostruct selected cells from source SALOME_Actor and map of subindexes virtual void MapCells(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + const SVTK_TIndexedMapOfVtkId& theMapIndex); //! Allow to recostruct selected points from source SALOME_Actor and map of subindexes virtual void MapPoints(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + const SVTK_TIndexedMapOfVtkId& theMapIndex); //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes virtual void MapEdge(SALOME_Actor* theMapActor, - const TColStd_IndexedMapOfInteger& theMapIndex); + const SVTK_TIndexedMapOfVtkId& theMapIndex); //! Allow to recostruct selected edges from source SALOME_Actor and map of subindexes using corner node ids virtual void @@ -90,14 +90,14 @@ public: const SVTK_IndexedMapOfVtkIds& theMapCompositeIndex); - const TColStd_IndexedMapOfInteger& + const SVTK_TIndexedMapOfVtkId& GetMapIndex() const; const SVTK_IndexedMapOfVtkIds& GetMapCompositeIndex() const; protected: - TColStd_IndexedMapOfInteger myMapIndex; + SVTK_TIndexedMapOfVtkId myMapIndex; SVTK_IndexedMapOfVtkIds myMapCompositeIndex; vtkSmartPointer myUnstructuredGrid; diff --git a/src/SVTK/SVTK_Hash.h b/src/SVTK/SVTK_Hash.h index 1daf5579c..fb1562eb9 100644 --- a/src/SVTK/SVTK_Hash.h +++ b/src/SVTK/SVTK_Hash.h @@ -29,8 +29,10 @@ #include #include +#include #include #include +#include typedef std::vector SVTK_ListOfInteger; typedef std::vector SVTK_ListOfVtk; @@ -73,7 +75,23 @@ public: } }; +struct svtkIdHasher +{ + static int HashCode(const vtkIdType theValue, const int theUpperBound) + { + return static_cast ((theValue & std::numeric_limits::max()) % theUpperBound + 1); + } + + static bool IsEqual( const vtkIdType& id1, const vtkIdType& id2 ) + { + return id1 == id2; + } +}; + typedef NCollection_IndexedMap SVTK_IndexedMapOfIds; typedef NCollection_IndexedMap SVTK_IndexedMapOfVtkIds; +typedef NCollection_Map< vtkIdType, svtkIdHasher > SVTK_TVtkIDsMap; +typedef NCollection_Map< vtkIdType, svtkIdHasher >::Iterator SVTK_TVtkIDsMapIterator; +typedef NCollection_IndexedMap SVTK_TIndexedMapOfVtkId; #endif // SVTK_HASH_H diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 363587850..d0360fb92 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1374,7 +1374,7 @@ void SVTK_InteractorStyle::onCursorMove(QPoint /*mousePos*/) if ( aVtkId >= 0 ) { vtkIdType anObjId = anActor->GetNodeObjId( aVtkId ); - TColStd_IndexedMapOfInteger aMapIndex; + SVTK_TIndexedMapOfVtkId aMapIndex; aMapIndex.Add( anObjId ); myHighlightSelectionPointActor->MapPoints( anActor, aMapIndex ); diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index b326d37f5..a33540d49 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -273,7 +273,7 @@ SVTK_SelectorDef void SVTK_SelectorDef ::GetIndex( const Handle(SALOME_InteractiveObject)& theIO, - TColStd_IndexedMapOfInteger& theIndex) + SVTK_TIndexedMapOfVtkId& theIndex) { TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO); if(anIter != myMapIOSubIndex.end()) @@ -294,14 +294,14 @@ SVTK_SelectorDef { TMapIOSubIndex::const_iterator anIter = myMapIOSubIndex.find(theIO); if(anIter != myMapIOSubIndex.end()){ - const TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap; + const SVTK_TIndexedMapOfVtkId& aMapIndex = anIter->second.myMap; return aMapIndex.Contains( theIndex ) == Standard_True; } return false; } -static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theIndex) +static bool removeIndex(SVTK_TIndexedMapOfVtkId& theMapIndex, const int theIndex) { int anId = theMapIndex.FindIndex(theIndex); // i==0 if Index is not in the MapIndex if(anId){ @@ -310,7 +310,7 @@ static bool removeIndex(TColStd_IndexedMapOfInteger& theMapIndex, const int theI if(aLastId == anId) theMapIndex.RemoveLast(); else{ - TColStd_IndexedMapOfInteger aNewMap; + SVTK_TIndexedMapOfVtkId aNewMap; aNewMap.ReSize(theMapIndex.Extent()-1); for(int j = 1; j <= theMapIndex.Extent(); j++){ int anIndex = theMapIndex(j); @@ -355,7 +355,7 @@ static bool removeCompositeIndex( SVTK_IndexedMapOfVtkIds& theMapIndex, const SV bool SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIndices, + const SVTK_TIndexedMapOfVtkId& theIndices, bool theIsModeShift) { TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO); @@ -364,7 +364,7 @@ SVTK_SelectorDef aMapIter = myMapIOSubIndex. insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first; } - TColStd_IndexedMapOfInteger& aMapIndex = aMapIter->second.myMap; + SVTK_TIndexedMapOfVtkId& aMapIndex = aMapIter->second.myMap; if(!theIsModeShift) aMapIndex.Clear(); @@ -390,7 +390,7 @@ SVTK_SelectorDef bool SVTK_SelectorDef ::AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_MapOfInteger& theIndices, + const SVTK_TVtkIDsMap& theIndices, bool theIsModeShift) { TMapIOSubIndex::iterator aMapIter = myMapIOSubIndex.find(theIO); @@ -399,12 +399,12 @@ SVTK_SelectorDef aMapIter = myMapIOSubIndex. insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first; } - TColStd_IndexedMapOfInteger& aMapIndex = aMapIter->second.myMap; + SVTK_TIndexedMapOfVtkId& aMapIndex = aMapIter->second.myMap; if(!theIsModeShift) aMapIndex.Clear(); - TColStd_MapIteratorOfMapOfInteger anIter(theIndices); + SVTK_TVtkIDsMapIterator anIter(theIndices); for(; anIter.More(); anIter.Next()) aMapIndex.Add(anIter.Key()); @@ -435,7 +435,7 @@ SVTK_SelectorDef anIter = myMapIOSubIndex. insert(TMapIOSubIndex::value_type(theIO,anEmpty)).first; } - TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap; + SVTK_TIndexedMapOfVtkId& aMapIndex = anIter->second.myMap; bool anIsConatains = aMapIndex.Contains( theIndex ) == Standard_True; if ( anIsConatains ) @@ -466,7 +466,7 @@ SVTK_SelectorDef { if(IsIndexSelected(theIO,theIndex)){ TMapIOSubIndex::iterator anIter = myMapIOSubIndex.find(theIO); - TColStd_IndexedMapOfInteger& aMapIndex = anIter->second.myMap; + SVTK_TIndexedMapOfVtkId& aMapIndex = anIter->second.myMap; removeIndex(aMapIndex,theIndex); } } diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index 493f1460c..4dbca1183 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -130,20 +130,20 @@ public: virtual void GetIndex( const Handle(SALOME_InteractiveObject)& theIO, - TColStd_IndexedMapOfInteger& theIndex ) = 0; + SVTK_TIndexedMapOfVtkId& theIndex ) = 0; //! Change indices of subselection for given #SALOME_InteractiveObject virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIndices, + const SVTK_TIndexedMapOfVtkId& theIndices, bool theIsModeShift) = 0; //! Change indexes of subslection for given #SALOME_InteractiveObject virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_MapOfInteger& theIndices, + const SVTK_TVtkIDsMap& theIndices, bool theIsModeShift) = 0; //! Change index of subslection for given #SALOME_InteractiveObject diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index 1e2f479c1..fe7b1f6f7 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -106,17 +106,17 @@ public: virtual void GetIndex( const Handle(SALOME_InteractiveObject)& theIO, - TColStd_IndexedMapOfInteger& theIndex ); + SVTK_TIndexedMapOfVtkId& theIndex ); virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_IndexedMapOfInteger& theIndices, + const SVTK_TIndexedMapOfVtkId& theIndices, bool theIsModeShift); virtual bool AddOrRemoveIndex( const Handle(SALOME_InteractiveObject)& theIO, - const TColStd_MapOfInteger& theIndices, + const SVTK_TVtkIDsMap& theIndices, bool theIsModeShift); virtual bool @@ -255,7 +255,7 @@ private: struct TIndexedMapOfInteger { - TColStd_IndexedMapOfInteger myMap; + SVTK_TIndexedMapOfVtkId myMap; TIndexedMapOfInteger() {} TIndexedMapOfInteger(const TIndexedMapOfInteger& theIndexedMapOfInteger) diff --git a/src/VTKViewer/VTKViewer_Actor.h b/src/VTKViewer/VTKViewer_Actor.h index 61000a8b7..a342a8de7 100644 --- a/src/VTKViewer/VTKViewer_Actor.h +++ b/src/VTKViewer/VTKViewer_Actor.h @@ -31,6 +31,10 @@ #include #include +#include + +#include +#include #include #include @@ -394,6 +398,22 @@ class VTKVIEWER_EXPORT VTKViewer_Actor : public vtkLODActor bool myIsHighlighted; }; +struct vtkIdHasher +{ + static int HashCode(const vtkIdType theValue, const int theUpperBound) + { + return static_cast ((theValue & std::numeric_limits::max()) % theUpperBound + 1); + } + + static bool IsEqual( const vtkIdType& id1, const vtkIdType& id2 ) + { + return id1 == id2; + } +}; + +typedef NCollection_Map< vtkIdType, vtkIdHasher > TVtkIDsMap; +typedef NCollection_IndexedMap TIndexedMapOfVtkId; + #ifdef WIN32 #pragma warning ( default:4251 ) #endif diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx index 59933dcb5..8fa4f8138 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.cxx @@ -679,7 +679,7 @@ bool VTKViewer_RenderWindowInteractor::unHighlightAll(){ * else sets visibility to false. * \li Emit render window modified, if flag \a update - true. */ -bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteger& theMapIndex, +bool VTKViewer_RenderWindowInteractor::highlight(const TIndexedMapOfVtkId& theMapIndex, VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, TUpdateActor theFun, bool hilight, bool update) { @@ -702,7 +702,7 @@ bool VTKViewer_RenderWindowInteractor::highlight(const TColStd_IndexedMapOfInteg } /*!Sets actors data.*/ -void VTKViewer_RenderWindowInteractor::setActorData(const TColStd_IndexedMapOfInteger& theMapIndex, +void VTKViewer_RenderWindowInteractor::setActorData(const TIndexedMapOfVtkId& theMapIndex, VTKViewer_Actor * theMapActor, VTKViewer_Actor * theActor, TUpdateActor theFun) diff --git a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h index ca321e38c..e1602572e 100644 --- a/src/VTKViewer/VTKViewer_RenderWindowInteractor.h +++ b/src/VTKViewer/VTKViewer_RenderWindowInteractor.h @@ -104,15 +104,15 @@ public: /** @name Selection Management */ //@{ - bool highlightCell(const TColStd_IndexedMapOfInteger& MapIndex, + bool highlightCell(const TIndexedMapOfVtkId& MapIndex, VTKViewer_Actor* theMapActor, bool hilight, bool update = true ); - bool highlightEdge(const TColStd_IndexedMapOfInteger& MapIndex, + bool highlightEdge(const TIndexedMapOfVtkId& MapIndex, VTKViewer_Actor* theMapActor, bool hilight, bool update = true ); - bool highlightPoint(const TColStd_IndexedMapOfInteger& MapIndex, + bool highlightPoint(const TIndexedMapOfVtkId& MapIndex, VTKViewer_Actor* theMapActor, bool hilight, bool update = true ); @@ -174,7 +174,7 @@ public: VTKViewer_Actor* /*theMapActor*/, VTKViewer_Actor* /*theActor*/) {} - typedef void (*TUpdateActor)(const TColStd_IndexedMapOfInteger& theMapIndex, + typedef void (*TUpdateActor)(const TIndexedMapOfVtkId& theMapIndex, VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor); protected: @@ -184,10 +184,10 @@ public: VTKViewer_InteractorStyle* myInteractorStyle; - bool highlight(const TColStd_IndexedMapOfInteger& theMapIndex, + bool highlight(const TIndexedMapOfVtkId& theMapIndex, VTKViewer_Actor* theMapActor, VTKViewer_Actor* theActor, TUpdateActor theFun, bool hilight, bool update); - void setActorData(const TColStd_IndexedMapOfInteger& theMapIndex, + void setActorData(const TIndexedMapOfVtkId& theMapIndex, VTKViewer_Actor* theMapActor, VTKViewer_Actor *theActor, TUpdateActor theFun);