0028488: VIS - fix compilation with VTK 8.2
authorkgv <kgv@opencascade.com>
Fri, 15 Feb 2019 08:27:15 +0000 (11:27 +0300)
committerapn <apn@opencascade.com>
Fri, 15 Feb 2019 12:52:14 +0000 (15:52 +0300)
Occurrences of removed method vtkDataArray::InsertNextTupleValue() have been replaced by InsertNextTypedTuple().
Fixed misprint in vtkTypeMacro usage for class IVtkTools_ShapeObject.
Patch #0030452 (SelectMgr_ViewerSelector::Deactivate() raises exception when called twice) has been propagated to IVtkOCC_ViewerSelector.

src/IVtkOCC/IVtkOCC_ViewerSelector.cxx
src/IVtkTools/IVtkTools_ShapeObject.hxx
src/IVtkVTK/IVtkVTK_ShapeData.cxx
src/IVtkVTK/IVtkVTK_ShapeData.hxx

index 94804ac..56d7cc0 100644 (file)
@@ -193,10 +193,12 @@ void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSel
     aSelEntIter.Value()->SetActiveForSelection();
   }
 
     aSelEntIter.Value()->SetActiveForSelection();
   }
 
-  theSelection->SetSelectionState (SelectMgr_SOS_Activated);
-
-  myTolerances.Add (theSelection->Sensitivity());
-  myToUpdateTolerance = Standard_True;
+  if (theSelection->GetSelectionState() != SelectMgr_SOS_Activated)
+  {
+    theSelection->SetSelectionState (SelectMgr_SOS_Activated);
+    myTolerances.Add (theSelection->Sensitivity());
+    myToUpdateTolerance = Standard_True;
+  }
 }
 
 //============================================================================
 }
 
 //============================================================================
@@ -210,8 +212,10 @@ void IVtkOCC_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theS
     aSelEntIter.Value()->ResetSelectionActiveStatus();
   }
 
     aSelEntIter.Value()->ResetSelectionActiveStatus();
   }
 
-  theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
-
-  myTolerances.Decrement (theSelection->Sensitivity());
-  myToUpdateTolerance = Standard_True;
+  if (theSelection->GetSelectionState() == SelectMgr_SOS_Activated)
+  {
+    theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
+    myTolerances.Decrement (theSelection->Sensitivity());
+    myToUpdateTolerance = Standard_True;
+  }
 }
 }
index 34753a1..4624f84 100644 (file)
@@ -50,7 +50,7 @@ class IVtkTools_ShapeDataSource;
 class Standard_EXPORT IVtkTools_ShapeObject :  public vtkDataObject
 {
 public:
 class Standard_EXPORT IVtkTools_ShapeObject :  public vtkDataObject
 {
 public:
-  vtkTypeMacro (IVtkTools_ShapeObject, vtkObject)
+  vtkTypeMacro (IVtkTools_ShapeObject, vtkDataObject)
 
   static IVtkTools_ShapeObject* New(); 
 
 
   static IVtkTools_ShapeObject* New(); 
 
index bf2d63e..97b10da 100644 (file)
@@ -22,7 +22,6 @@
 #include <vtkCellData.h>
 #include <vtkDoubleArray.h>
 #include <vtkIdList.h>
 #include <vtkCellData.h>
 #include <vtkDoubleArray.h>
 #include <vtkIdList.h>
-#include <vtkIdTypeArray.h>
 #include <vtkPoints.h>
 #include <vtkPolyData.h>
 #ifdef _MSC_VER
 #include <vtkPoints.h>
 #include <vtkPolyData.h>
 #ifdef _MSC_VER
@@ -80,10 +79,7 @@ void IVtkVTK_ShapeData::InsertVertex (const IVtk_IdType theShapeID,
 {
   vtkIdType aPointIdVTK = thePointId;
   myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
 {
   vtkIdType aPointIdVTK = thePointId;
   myPolyData->InsertNextCell (VTK_VERTEX, 1, &aPointIdVTK);
-  const vtkIdType aShapeIDVTK = theShapeID;
-  mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
-  const vtkIdType aType = theMeshType;
-  myMeshTypes->InsertNextTupleValue (&aType);
+  insertNextSubShapeId (theShapeID, theMeshType);
 }
 
 //================================================================
 }
 
 //================================================================
@@ -97,10 +93,7 @@ void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType   theShapeID,
 {
   vtkIdType aPoints[2] = { thePointId1, thePointId2 };
   myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
 {
   vtkIdType aPoints[2] = { thePointId1, thePointId2 };
   myPolyData->InsertNextCell (VTK_LINE, 2, aPoints);
-  const vtkIdType aShapeIDVTK = theShapeID;
-  mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
-  const vtkIdType aType = theMeshType;
-  myMeshTypes->InsertNextTupleValue (&aType);
+  insertNextSubShapeId (theShapeID, theMeshType);
 }
 
 //================================================================
 }
 
 //================================================================
@@ -124,10 +117,7 @@ void IVtkVTK_ShapeData::InsertLine (const IVtk_IdType       theShapeID,
     }
 
     myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
     }
 
     myPolyData->InsertNextCell (VTK_POLY_LINE, anIdList);
-    const vtkIdType aShapeIDVTK = theShapeID;
-    mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
-    const vtkIdType aType = theMeshType;
-    myMeshTypes->InsertNextTupleValue (&aType);
+    insertNextSubShapeId (theShapeID, theMeshType);
   }
 }
 
   }
 }
 
@@ -143,8 +133,5 @@ void IVtkVTK_ShapeData::InsertTriangle (const IVtk_IdType   theShapeID,
 {
   vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
   myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
 {
   vtkIdType aPoints[3] = { thePointId1, thePointId2, thePointId3 };
   myPolyData->InsertNextCell (VTK_TRIANGLE, 3, aPoints);
-  const vtkIdType aShapeIDVTK = theShapeID;
-  mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
-  const vtkIdType aType = theMeshType;
-  myMeshTypes->InsertNextTupleValue (&aType);
+  insertNextSubShapeId (theShapeID, theMeshType);
 }
 }
index cb9fa37..04ceac3 100644 (file)
@@ -24,6 +24,7 @@
 #endif
 #include <vtkPolyData.h>
 #include <vtkSmartPointer.h>
 #endif
 #include <vtkPolyData.h>
 #include <vtkSmartPointer.h>
+#include <vtkIdTypeArray.h>
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
@@ -105,6 +106,23 @@ public: //! @name Specific methods
   vtkPolyData* getVtkPolyData() const
   { return myPolyData; }
 
   vtkPolyData* getVtkPolyData() const
   { return myPolyData; }
 
+private:
+
+  //! Wrapper over vtkGenericDataArray::InsertNextTypedTuple().
+  void insertNextSubShapeId (IVtk_IdType theShapeID,
+                             IVtk_MeshType theMeshType)
+  {
+    const vtkIdType aShapeIDVTK = theShapeID;
+    const vtkIdType aType = theMeshType;
+  #if (VTK_MAJOR_VERSION > 7) || (VTK_MAJOR_VERSION == 7 && VTK_MINOR_VERSION >= 1)
+    mySubShapeIDs->InsertNextTypedTuple (&aShapeIDVTK);
+    myMeshTypes->InsertNextTypedTuple (&aType);
+  #else
+    mySubShapeIDs->InsertNextTupleValue (&aShapeIDVTK);
+    myMeshTypes->InsertNextTupleValue (&aType);
+  #endif
+  }
+
 private:
   vtkSmartPointer< vtkPolyData >    myPolyData;    //!< Shape geometry as vtkPolyData
   vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids
 private:
   vtkSmartPointer< vtkPolyData >    myPolyData;    //!< Shape geometry as vtkPolyData
   vtkSmartPointer< vtkIdTypeArray > mySubShapeIDs; //!< Array of sub-shapes ids