From 54aee0f7bd36fc4d7e431fd00551bf92fb05dc0a Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 6 Oct 2009 12:49:49 +0000 Subject: [PATCH] Patch for VTK 5.1 and newer (merge from BR_PARAVIS_DEV) --- src/CONVERTOR/VISU_MergeFilterUtilities.cxx | 40 ++++++++++++++++++- src/OBJECT/VISU_Actor.cxx | 4 ++ src/OBJECT/VISU_Actor.h | 8 ++++ src/OBJECT/VISU_MeshAct.cxx | 24 +++++++++++ src/OBJECT/VISU_ScalarMapAct.cxx | 16 ++++++++ .../VISU_DeformedShapeAndScalarMapPL.cxx | 4 +- src/PIPELINE/VISU_XYPlotActor.cxx | 34 +++++++++++++--- 7 files changed, 122 insertions(+), 8 deletions(-) diff --git a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx index 63a9b040..126effbf 100644 --- a/src/CONVERTOR/VISU_MergeFilterUtilities.cxx +++ b/src/CONVERTOR/VISU_MergeFilterUtilities.cxx @@ -44,6 +44,10 @@ #include #include +#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); } diff --git a/src/OBJECT/VISU_Actor.cxx b/src/OBJECT/VISU_Actor.cxx index 68b879e2..c6087f4c 100644 --- a/src/OBJECT/VISU_Actor.cxx +++ b/src/OBJECT/VISU_Actor.cxx @@ -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), diff --git a/src/OBJECT/VISU_Actor.h b/src/OBJECT/VISU_Actor.h index 76cc277e..f29a20f8 100644 --- a/src/OBJECT/VISU_Actor.h +++ b/src/OBJECT/VISU_Actor.h @@ -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 myAnnotationMapper; +#if (VTK_XVERSION < 0x050100) vtkSmartPointer myAnnotationActor; +#else + vtkSmartPointer myAnnotationActor; +#endif vtkSmartPointer myTextActor; diff --git a/src/OBJECT/VISU_MeshAct.cxx b/src/OBJECT/VISU_MeshAct.cxx index 10315b1b..ee575ff0 100644 --- a/src/OBJECT/VISU_MeshAct.cxx +++ b/src/OBJECT/VISU_MeshAct.cxx @@ -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; diff --git a/src/OBJECT/VISU_ScalarMapAct.cxx b/src/OBJECT/VISU_ScalarMapAct.cxx index 35d3f3da..ce5a4e76 100644 --- a/src/OBJECT/VISU_ScalarMapAct.cxx +++ b/src/OBJECT/VISU_ScalarMapAct.cxx @@ -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; diff --git a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx index 3297e520..4107e078 100644 --- a/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx +++ b/src/PIPELINE/VISU_DeformedShapeAndScalarMapPL.cxx @@ -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(); } diff --git a/src/PIPELINE/VISU_XYPlotActor.cxx b/src/PIPELINE/VISU_XYPlotActor.cxx index a151b2fe..bbdabd9b 100644 --- a/src/PIPELINE/VISU_XYPlotActor.cxx +++ b/src/PIPELINE/VISU_XYPlotActor.cxx @@ -41,6 +41,10 @@ #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(); -- 2.39.2