]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
fix SVTK, new collection with vtkIdType
authorViktor UZLOV <vuzlov@debian10-01.nnov.opencascade.com>
Mon, 15 Feb 2021 13:29:23 +0000 (16:29 +0300)
committerViktor UZLOV <vuzlov@debian10-01.nnov.opencascade.com>
Mon, 15 Feb 2021 13:29:23 +0000 (16:29 +0300)
src/SVTK/SALOME_Actor.cxx
src/SVTK/SVTK_Actor.cxx
src/SVTK/SVTK_Actor.h
src/SVTK/SVTK_Hash.h
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_Selector.h
src/SVTK/SVTK_SelectorDef.h

index 74435febbea14d1d6d1906779e26fbe41d788c70..8c91d9d3a15d8acd5a9388223212e8e588964fc2 100644 (file)
@@ -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 );
index a534ea44abe059e08a40ffa45db7b9a83b76555a..1b4ee45710fc50cf2dc440419904515dd54c74a6 100644 (file)
@@ -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();
 
index a42db7998ef561f4effdecf1c7b5e7cde5a0cf2f..9b9d3a0e8c7f9dbfdc6b0cc2d2109d1bd5865aa3 100644 (file)
@@ -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<vtkUnstructuredGrid> myUnstructuredGrid;
 
index afd6227ef3c7c332c6eca374abda9320b9ea28ff..1daf5579c7dd3ccca90aea83536045a615286c72 100644 (file)
 #include <vector>
 #include <NCollection_IndexedMap.hxx>
 #include <Standard_Integer.hxx>
+#include <vtkType.h>
 
 typedef std::vector<Standard_Integer> SVTK_ListOfInteger;
+typedef std::vector<vtkIdType> SVTK_ListOfVtk;
 
 class SVTK_Hasher {
 
@@ -52,6 +54,26 @@ public:
     }
 };
 
+class SVTK_vtkHasher {
+
+public:
+    static vtkIdType HashCode(const std::vector<vtkIdType> 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_ListOfInteger,SVTK_Hasher> SVTK_IndexedMapOfIds;
+typedef NCollection_IndexedMap<SVTK_ListOfVtk, SVTK_vtkHasher> SVTK_IndexedMapOfVtkIds;
 
 #endif // SVTK_HASH_H
index dae45cfeb7049afc5636cec84be5c018b0d5845b..b326d37f5adb21f885292780d043e93c0ef31572 100644 (file)
@@ -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;
index a61e90f73f4dae666d3c020b09d6d5479fc3720b..493f1460c0079a026a897f2e443b0a937c5f4d07 100644 (file)
@@ -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
index 81eb6d5f7a3f0e0f2646ef592fd7c510fd38b474..1e2f479c19d702664363bd796a217594e12bc1c6 100644 (file)
@@ -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<Handle(SALOME_InteractiveObject),
-                   SVTK_IndexedMapOfIds,
+                   SVTK_IndexedMapOfVtkIds,
                    TIOLessThan> TMapIOSubCompositeIndex;
   TMapIOSubCompositeIndex myMapIOSubCompositeIndex;