]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Patch for VTK 5.1 and newer (merge from BR_PARAVIS_DEV)
authorvsr <vsr@opencascade.com>
Tue, 6 Oct 2009 12:49:49 +0000 (12:49 +0000)
committervsr <vsr@opencascade.com>
Tue, 6 Oct 2009 12:49:49 +0000 (12:49 +0000)
src/CONVERTOR/VISU_MergeFilterUtilities.cxx
src/OBJECT/VISU_Actor.cxx
src/OBJECT/VISU_Actor.h
src/OBJECT/VISU_MeshAct.cxx
src/OBJECT/VISU_ScalarMapAct.cxx
src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx
src/PIPELINE/VISU_XYPlotActor.cxx

index 63a9b040b3ccea94608ff21ccde1692882a73721..126effbf9f0ace2d6dfb0abba8b0d53e107e6880 100644 (file)
 #include <set>
 #include <map>
 
+#if !defined(VTK_XVERSION)
+#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
+#endif
+
 namespace
 {
 
@@ -372,7 +376,29 @@ namespace
 
   //---------------------------------------------------------------
   typedef vtkDataArray* (vtkDataSetAttributes::* TGetAttribute)();
+#if (VTK_XVERSION < 0x050100)
   typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkDataArray*);
+#else
+  typedef int (vtkDataSetAttributes::* TSetAttribute)(vtkAbstractArray*);
+  typedef int (vtkDataSetAttributes::* TSetDataAttribute)(vtkDataArray*);
+#endif
+
+
+#if (VTK_XVERSION >= 0x050100)
+  inline
+  void
+  CopyArray(vtkDataArray* theDataArray,
+           vtkDataSetAttributes* theOutput, 
+           TSetDataAttribute theSetAttribute,
+           vtkIdType theFixedNbTuples)
+  {
+    if(theDataArray){
+      vtkIdType aNbTuples = theDataArray->GetNumberOfTuples();
+      if(theFixedNbTuples == aNbTuples)
+       (theOutput->*theSetAttribute)(theDataArray);
+    }
+  }
+#endif
 
   inline
   void
@@ -395,7 +421,11 @@ namespace
   CopyAttribute(vtkDataSetAttributes* theInput, 
                TGetAttribute theGetAttribute,
                vtkDataSetAttributes* theOutput, 
+#if (VTK_XVERSION < 0x050100)
                TSetAttribute theSetAttribute,
+#else
+               TSetDataAttribute theSetAttribute,
+#endif
                vtkIdType theFixedNbTuples)
   {
     CopyArray((theInput->*theGetAttribute)(),
@@ -410,7 +440,11 @@ namespace
   CopyDataSetAttribute(vtkDataSet *theInput,
                       TGetAttribute theGetAttribute,
                       vtkDataSet *theOutput, 
+#if (VTK_XVERSION < 0x050100)
                       TSetAttribute theSetAttribute,
+#else
+                      TSetDataAttribute theSetAttribute,
+#endif
                       vtkIdType theNbPoints, 
                       vtkIdType theNbCells)
   {
@@ -437,7 +471,11 @@ namespace
   {
     CopyArray(theInput->GetArray(theFieldName),
              theOutput,
-             &vtkDataSetAttributes::AddArray,
+#if (VTK_XVERSION < 0x050100)
+        &vtkDataSetAttributes::AddArray,
+#else
+             &vtkFieldData::AddArray,
+#endif
              theFixedNbTuples);
   }
 
index 68b879e2568d425726c78c113188698250a5746b..c6087f4ce141aa138f7fb7a25e25883ec29c62ce 100644 (file)
@@ -113,7 +113,11 @@ VISU_Actor
   myIsShrinkable(false),
   myShrinkFilter(VTKViewer_ShrinkFilter::New()),
   myAnnotationMapper(vtkTextMapper::New()),
+#if (VTK_XVERSION < 0x050100)
   myAnnotationActor(vtkTextActor::New()),
+#else
+  myAnnotationActor(vtkActor2D::New()),
+#endif
   myTextActor(VTKViewer_FramedTextActor::New()),
   myIsFeatureEdgesAllowed(false),
   myIsFeatureEdgesEnabled(false),
index 76cc277e55e4614bcb5d66cea1291297f96acc8a..f29a20f8e249a7eee69893eebd6fee15ef063d70 100644 (file)
@@ -58,6 +58,10 @@ class vtkActor2D;
 
 class VTKViewer_FramedTextActor;
 
+#if !defined(VTK_XVERSION)
+#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
+#endif
+
 namespace SVTK
 {
   namespace Representation
@@ -382,7 +386,11 @@ class VISU_OBJECT_EXPORT VISU_Actor : public VISU_ActorBase
   bool myIsShrunk;
 
   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
+#if (VTK_XVERSION < 0x050100)
   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
+#else
+  vtkSmartPointer<vtkActor2D>  myAnnotationActor;
+#endif
 
   vtkSmartPointer<VTKViewer_FramedTextActor> myTextActor;
 
index 10315b1bb18687dc169784e717cd9790d4c27dac..ee575ff09f42cb48678666cabb313582e798a154 100644 (file)
@@ -381,27 +381,51 @@ VISU_MeshAct
   switch(GetRepresentation()){
   case Points : 
     myNodeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     myNodeActor->RenderTranslucentGeometry(ren);
+#else
+    myNodeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case Wireframe : 
   case Insideframe : 
     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     myEdgeActor->RenderTranslucentGeometry(ren);
+#else
+    myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case Surface : 
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case Surfaceframe : 
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
 
     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+#if (VTK_XVERSION < 0x050100)
     myEdgeActor->RenderTranslucentGeometry(ren);
+#else
+    myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   case FeatureEdges :
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
   }
   return 1;
index 35d3f3da85f607018bb4ede928c606ddb0139e37..ce5a4e76d7e70c72809533a84e78cbb270421a57 100644 (file)
@@ -632,20 +632,36 @@ VISU_ScalarMapAct
 
   case Surfaceframe:
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
 
     myEdgeActor->SetAllocatedRenderTime(this->AllocatedRenderTime/2.0,ren);
+#if (VTK_XVERSION < 0x050100)
     myEdgeActor->RenderTranslucentGeometry(ren);
+#else
+    myEdgeActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
 
   case Points:
     myPointsActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     myPointsActor->RenderTranslucentGeometry(ren);
+#else
+    myPointsActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
     break;
 
   default:
     mySurfaceActor->SetAllocatedRenderTime(this->AllocatedRenderTime,ren);
+#if (VTK_XVERSION < 0x050100)
     mySurfaceActor->RenderTranslucentGeometry(ren);
+#else
+    mySurfaceActor->RenderTranslucentPolygonalGeometry(ren);
+#endif
   }
 
   return 1;
index 3297e52037fde6bb73265a1555be67a3c424a46b..4107e078c3d829992c55234263cde99698680545 100644 (file)
@@ -143,7 +143,7 @@ VISU_DeformedShapeAndScalarMapPL
                        myCellDataToPointData,
                        GetMergedInput());
   
-  myScalars = GetMergedInput();
+  myScalars = vtkUnstructuredGrid::SafeDownCast(GetMergedInput());
 
   UpdateScalars();
 
@@ -258,7 +258,7 @@ VISU_DeformedShapeAndScalarMapPL
   if(GetScalars() == theScalars)
     return;
   
-  myScalars = theScalars;
+  myScalars = vtkUnstructuredGrid::SafeDownCast(theScalars);
   UpdateScalars();
 }
 
index a151b2fefff75703eaeb9daf3cbc2f1b4ec9c302..bbdabd9b59074a7447657202a7ae2a518aa5fad1 100644 (file)
 
 #define VTK_MAX_PLOTS 50
 
+#if !defined(VTK_XVERSION)
+#define VTK_XVERSION (VTK_MAJOR_VERSION<<16)+(VTK_MINOR_VERSION<<8)+(VTK_BUILD_VERSION)
+#endif
+
 using namespace std;
 
 vtkCxxRevisionMacro(VISU_XYPlotActor, "$Revision$");
@@ -747,12 +751,16 @@ int VISU_XYPlotActor::RenderOpaqueGeometry(vtkViewport *viewport)
           this->TitleTextProperty);
         }
 
+      
+#if (VTK_XVERSION < 0x050100)
+      //VSV:  Function is not supported in VTK 5.2 and high
       vtkAxisActor2D::SetFontSize(viewport, 
                                   this->TitleMapper, 
                                   size, 
                                   1.0,
                                   stringSize);
-
+#endif
+      
       this->TitleActor->GetPositionCoordinate()->SetValue(
         pos[0] + 0.5 * (pos2[0] - pos[0]) - stringSize[0] / 2.0, 
         pos2[1] - stringSize[1] / 2.0);
@@ -1715,14 +1723,22 @@ void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size,
   // Estimate the padding around the X and Y axes
   tprop->ShallowCopy(axisX->GetTitleTextProperty());
   textMapper->SetInput(axisX->GetTitle());
+    
+#if (VTK_XVERSION < 0x050100)
+  //VSV:  Function is not supported in VTK 5.2 and high
   vtkAxisActor2D::SetFontSize(
     viewport, textMapper, size, fontFactorX, titleSizeX);
-
+#endif
+      
   tprop->ShallowCopy(axisY->GetTitleTextProperty());
   textMapper->SetInput(axisY->GetTitle());
+     
+#if (VTK_XVERSION < 0x050100)
+  //VSV:  Function is not supported in VTK 5.2 and high
   vtkAxisActor2D::SetFontSize(
     viewport, textMapper, size, fontFactorY, titleSizeY);
-
+#endif
+      
   // At this point the thing to do would be to actually ask the Y axis
   // actor to return the largest label.
   // In the meantime, let's try with the min and max
@@ -1730,17 +1746,25 @@ void VISU_XYPlotActor::PlaceAxes(vtkViewport *viewport, int *size,
   sprintf(str2, axisY->GetLabelFormat(), axisY->GetAdjustedRange()[1]);
   tprop->ShallowCopy(axisY->GetLabelTextProperty());
   textMapper->SetInput(strlen(str1) > strlen(str2) ? str1 : str2);
+      
+#if (VTK_XVERSION < 0x050100)
+  //VSV:  Function is not supported in VTK 5.2 and high
   vtkAxisActor2D::SetFontSize(
     viewport, textMapper, size, labelFactorY * fontFactorY, labelSizeY);
-
+#endif
+      
   // We do only care of the height of the label in the X axis, so let's
   // use the min for example
   sprintf(str1, axisX->GetLabelFormat(), axisX->GetAdjustedRange()[0]);
   tprop->ShallowCopy(axisX->GetLabelTextProperty());
   textMapper->SetInput(str1);
+      
+#if (VTK_XVERSION < 0x050100)
+  //VSV:  Function is not supported in VTK 5.2 and high
   vtkAxisActor2D::SetFontSize(
     viewport, textMapper, size, labelFactorX * fontFactorX, labelSizeX);
-
+#endif
+     
   tickOffsetX = axisX->GetTickOffset();
   tickOffsetY = axisY->GetTickOffset();
   tickLengthX = axisX->GetTickLength();