From 68154ac56770644a62a6ed2303c83eb8a0735d79 Mon Sep 17 00:00:00 2001 From: Jean Fechter <jean.fechter@kitware.com> Date: Wed, 4 Dec 2024 13:51:51 +0100 Subject: [PATCH] Remove 9.3 deprecated APIs --- .../Vtkm/Core/vtkmlib/DataArrayConverters.h | 56 - Accelerators/Vtkm/Filters/vtkmClip.h | 11 - Charts/Core/vtkPlot.cxx | 6 + Charts/Core/vtkPlot.h | 18 +- Charts/Core/vtkPlotArea.cxx | 7 + Charts/Core/vtkPlotArea.h | 4 +- Charts/Core/vtkPlotBar.cxx | 6 + Charts/Core/vtkPlotBar.h | 7 +- Charts/Core/vtkPlotStacked.cxx | 6 + Charts/Core/vtkPlotStacked.h | 7 +- Common/Core/vtkNumberToString.h | 5 - Common/Core/vtkOutputWindow.h | 13 - Common/Core/vtkStdString.h | 4 - Common/DataModel/vtkAbstractCellLinks.cxx | 9 - Common/DataModel/vtkAbstractCellLinks.h | 7 - Common/DataModel/vtkCompositeDataSet.cxx | 7 - Common/DataModel/vtkCompositeDataSet.h | 7 - Common/DataModel/vtkDataObjectTree.cxx | 7 - Common/DataModel/vtkDataObjectTree.h | 7 - Common/DataModel/vtkDataSet.cxx | 19 - Common/DataModel/vtkDataSet.h | 34 - Common/DataModel/vtkPolygon.cxx | 9 - Common/DataModel/vtkPolygon.h | 11 - Common/DataModel/vtkQuadraticPolygon.cxx | 9 - Common/DataModel/vtkQuadraticPolygon.h | 3 - Common/DataModel/vtkRectilinearGrid.cxx | 7 - Common/DataModel/vtkRectilinearGrid.h | 8 - Common/DataModel/vtkStructuredGrid.cxx | 9 - Common/DataModel/vtkStructuredGrid.h | 9 - Common/DataModel/vtkUniformGrid.h | 7 - Common/DataModel/vtkUniformGridAMR.cxx | 7 - Common/DataModel/vtkUniformGridAMR.h | 7 - Common/DataModel/vtkUnstructuredGrid.cxx | 6 - Common/DataModel/vtkUnstructuredGrid.h | 16 - .../ExecutionModel/vtkTemporalAlgorithm.txx | 17 +- .../release/dev/remove-9-3-deprecated-APIs.md | 3 + Examples/GUI/QML/QtQuickProperty/main.cpp | 7 +- Filters/Core/vtkQuadricDecimation.cxx | 35 - Filters/Core/vtkQuadricDecimation.h | 4 - Filters/Core/vtkThreshold.cxx | 78 - Filters/Core/vtkThreshold.h | 49 - .../Cxx/TestTemporalPathLineFilter.cxx | 69 +- Filters/General/vtkTableFFT.h | 37 - Filters/General/vtkTemporalPathLineFilter.cxx | 14 - Filters/General/vtkTemporalPathLineFilter.h | 17 - Filters/Geometry/vtkDataSetSurfaceFilter.cxx | 8 - Filters/Geometry/vtkDataSetSurfaceFilter.h | 5 - Filters/Geometry/vtkGeometryFilter.cxx | 34 - Filters/Geometry/vtkGeometryFilter.h | 6 - Filters/HyperTree/vtkHyperTreeGridGradient.h | 5 - Filters/HyperTree/vtkHyperTreeGridThreshold.h | 14 - Filters/Parallel/CMakeLists.txt | 2 - Filters/Parallel/vtkPCellDataToPointData.cxx | 13 - Filters/Parallel/vtkPCellDataToPointData.h | 39 - Filters/Parallel/vtkProcessIdScalars.cxx | 158 -- Filters/Parallel/vtkProcessIdScalars.h | 90 - Filters/Sources/CMakeLists.txt | 1 - Filters/Sources/vtkCapsuleSource.cxx | 339 --- Filters/Sources/vtkCapsuleSource.h | 127 - GUISupport/QtQuick/CMakeLists.txt | 10 - .../QtQuick/QQuickVTKInteractiveWidget.cxx | 66 - .../QtQuick/QQuickVTKInteractiveWidget.h | 75 - .../QtQuick/QQuickVTKInteractorAdapter.cxx | 155 -- .../QtQuick/QQuickVTKInteractorAdapter.h | 87 - GUISupport/QtQuick/QQuickVTKRenderItem.cxx | 319 --- GUISupport/QtQuick/QQuickVTKRenderItem.h | 257 -- GUISupport/QtQuick/QQuickVTKRenderWindow.cxx | 414 ---- GUISupport/QtQuick/QQuickVTKRenderWindow.h | 290 --- GUISupport/QtQuick/Testing/Cxx/CMakeLists.txt | 20 - .../QtQuick/Testing/Cxx/TestQQuickVTK.qrc | 3 - .../Testing/Cxx/TestQQuickVTKRenderItem.cxx | 99 - .../Cxx/TestQQuickVTKRenderItem.qml.in | 74 - .../Cxx/TestQQuickVTKRenderItemWidget.cxx | 208 -- .../Cxx/TestQQuickVTKRenderItemWidget.qml.in | 89 - .../Testing/Cxx/TestQQuickVTKRenderWindow.cxx | 166 -- .../Testing/Cxx/TestQQuickVTKRenderWindow.qml | 79 - .../Cxx/TestQQuickVTKRenderWindow.qml.in | 79 - GUISupport/QtQuick/qml/CMakeLists.txt | 153 -- GUISupport/QtQuick/qml/QQmlVTKPlugin.cxx | 42 - GUISupport/QtQuick/qml/QQmlVTKPlugin.h | 96 - GUISupport/QtQuick/qml/plugins.qmltypes | 51 - GUISupport/QtQuick/qml/qmldir.in | 4 - IO/IOSS/vtkIOSSWriter.h | 38 - IO/OCCT/vtkOCCTReader.h | 3 - Infovis/Core/CMakeLists.txt | 1 - Infovis/Core/vtkDataObjectToTable.cxx | 119 - Infovis/Core/vtkDataObjectToTable.h | 63 - .../Widgets/vtk3DCursorRepresentation.cxx | 15 - .../Widgets/vtk3DCursorRepresentation.h | 12 - ...kDisplaySizedImplicitPlaneRepresentation.h | 9 - .../vtkImplicitCylinderRepresentation.h | 12 - Rendering/ANARI/vtkAnariViewNodeFactory.cxx | 2 - Rendering/Annotation/vtkAxisActor.cxx | 19 - Rendering/Annotation/vtkAxisActor.h | 8 +- Rendering/Annotation/vtkCubeAxesActor.cxx | 30 - Rendering/Annotation/vtkCubeAxesActor.h | 8 +- Rendering/Annotation/vtkPolarAxesActor.cxx | 70 - Rendering/Annotation/vtkPolarAxesActor.h | 38 - Rendering/Core/vtkCompositePolyDataMapper.cxx | 29 +- Rendering/Core/vtkCompositePolyDataMapper.h | 5 - Rendering/Core/vtkPointGaussianMapper.h | 5 - Rendering/OpenGL2/CMakeLists.txt | 4 +- Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt | 16 - .../Testing/Cxx/TestBlockVisibility.cxx | 8 +- .../Cxx/TestCompositePolyDataMapper2.cxx | 191 -- ...mpositePolyDataMapper2CameraShiftScale.cxx | 161 -- ...estCompositePolyDataMapper2CellScalars.cxx | 174 -- ...stCompositePolyDataMapper2CustomShader.cxx | 157 -- ...olyDataMapper2MixedGeometryCellScalars.cxx | 194 -- ...ositePolyDataMapper2MixedGeometryEdges.cxx | 194 -- ...TestCompositePolyDataMapper2NaNPartial.cxx | 98 - ...mpositePolyDataMapper2PartialFieldData.cxx | 119 - ...mpositePolyDataMapper2PartialPointData.cxx | 102 - ...estCompositePolyDataMapper2Pickability.cxx | 242 -- .../TestCompositePolyDataMapper2Picking.cxx | 312 --- .../TestCompositePolyDataMapper2Scalars.cxx | 168 -- ...tePolyDataMapper2ScalarsSurfaceOpacity.cxx | 209 -- ...estCompositePolyDataMapper2SharedArray.cxx | 154 -- .../TestCompositePolyDataMapper2Spheres.cxx | 182 -- .../TestCompositePolyDataMapper2Vertices.cxx | 167 -- Rendering/OpenGL2/vtkCompositeMapperHelper2.h | 172 -- .../OpenGL2/vtkCompositePolyDataMapper2.cxx | 2202 ----------------- .../OpenGL2/vtkCompositePolyDataMapper2.h | 251 -- Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx | 9 - Rendering/OpenGL2/vtkXOpenGLRenderWindow.h | 8 - Rendering/RayTracing/CMakeLists.txt | 1 - .../vtkOSPRayCompositePolyDataMapper2Node.cxx | 212 -- .../vtkOSPRayCompositePolyDataMapper2Node.h | 67 - .../RayTracing/vtkOSPRayViewNodeFactory.cxx | 2 - Rendering/UI/CMakeLists.txt | 39 +- .../UI/vtkSDL2RenderWindowInteractor.cxx | 393 --- Rendering/UI/vtkSDL2RenderWindowInteractor.h | 95 - 132 files changed, 61 insertions(+), 11090 deletions(-) create mode 100644 Documentation/release/dev/remove-9-3-deprecated-APIs.md delete mode 100644 Filters/Parallel/vtkPCellDataToPointData.cxx delete mode 100644 Filters/Parallel/vtkPCellDataToPointData.h delete mode 100644 Filters/Parallel/vtkProcessIdScalars.cxx delete mode 100644 Filters/Parallel/vtkProcessIdScalars.h delete mode 100644 Filters/Sources/vtkCapsuleSource.cxx delete mode 100644 Filters/Sources/vtkCapsuleSource.h delete mode 100644 GUISupport/QtQuick/QQuickVTKInteractiveWidget.cxx delete mode 100644 GUISupport/QtQuick/QQuickVTKInteractiveWidget.h delete mode 100644 GUISupport/QtQuick/QQuickVTKInteractorAdapter.cxx delete mode 100644 GUISupport/QtQuick/QQuickVTKInteractorAdapter.h delete mode 100644 GUISupport/QtQuick/QQuickVTKRenderItem.cxx delete mode 100644 GUISupport/QtQuick/QQuickVTKRenderItem.h delete mode 100644 GUISupport/QtQuick/QQuickVTKRenderWindow.cxx delete mode 100644 GUISupport/QtQuick/QQuickVTKRenderWindow.h delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.cxx delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.qml.in delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.cxx delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.qml.in delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.cxx delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml delete mode 100644 GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml.in delete mode 100644 GUISupport/QtQuick/qml/CMakeLists.txt delete mode 100644 GUISupport/QtQuick/qml/QQmlVTKPlugin.cxx delete mode 100644 GUISupport/QtQuick/qml/QQmlVTKPlugin.h delete mode 100644 GUISupport/QtQuick/qml/plugins.qmltypes delete mode 100644 GUISupport/QtQuick/qml/qmldir.in delete mode 100644 Infovis/Core/vtkDataObjectToTable.cxx delete mode 100644 Infovis/Core/vtkDataObjectToTable.h delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CameraShiftScale.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CellScalars.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CustomShader.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryCellScalars.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryEdges.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2NaNPartial.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialFieldData.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialPointData.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Pickability.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Picking.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Scalars.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2ScalarsSurfaceOpacity.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2SharedArray.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Spheres.cxx delete mode 100644 Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Vertices.cxx delete mode 100644 Rendering/OpenGL2/vtkCompositeMapperHelper2.h delete mode 100644 Rendering/OpenGL2/vtkCompositePolyDataMapper2.cxx delete mode 100644 Rendering/OpenGL2/vtkCompositePolyDataMapper2.h delete mode 100644 Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.cxx delete mode 100644 Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.h delete mode 100644 Rendering/UI/vtkSDL2RenderWindowInteractor.cxx delete mode 100644 Rendering/UI/vtkSDL2RenderWindowInteractor.h diff --git a/Accelerators/Vtkm/Core/vtkmlib/DataArrayConverters.h b/Accelerators/Vtkm/Core/vtkmlib/DataArrayConverters.h index ba9b904b871..f7ef105bf2d 100644 --- a/Accelerators/Vtkm/Core/vtkmlib/DataArrayConverters.h +++ b/Accelerators/Vtkm/Core/vtkmlib/DataArrayConverters.h @@ -143,62 +143,6 @@ vtkm::cont::UnknownArrayHandle vtkDataArrayToUnknownArrayHandle(DataArrayType* i return vtkDataArrayToArrayHandle(input); } -template <typename DataArrayType, vtkm::IdComponent NumComponents> -struct DataArrayToArrayHandle; - -template <typename T, vtkm::IdComponent NumComponents> -struct DataArrayToArrayHandle<vtkAOSDataArrayTemplate<T>, NumComponents> -{ - using ValueType = - typename std::conditional<NumComponents == 1, T, vtkm::Vec<T, NumComponents>>::type; - using StorageType = vtkm::cont::internal::Storage<ValueType, vtkm::cont::StorageTagBasic>; - using ArrayHandleType = vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagBasic>; - - VTK_DEPRECATED_IN_9_3_0("Use vtkDataArrayToArrayHandle or vtkAOSDataArrayToFlatArrayHandle.") - static ArrayHandleType Wrap(vtkAOSDataArrayTemplate<T>* input) - { - return vtkm::cont::make_ArrayHandle(reinterpret_cast<ValueType*>(input->GetPointer(0)), - input->GetNumberOfTuples(), vtkm::CopyFlag::Off); - } -}; - -template <typename T, vtkm::IdComponent NumComponents> -struct DataArrayToArrayHandle<vtkSOADataArrayTemplate<T>, NumComponents> -{ - using ValueType = vtkm::Vec<T, NumComponents>; - using StorageType = vtkm::cont::internal::Storage<ValueType, vtkm::cont::StorageTagSOA>; - using ArrayHandleType = vtkm::cont::ArrayHandle<ValueType, vtkm::cont::StorageTagSOA>; - - VTK_DEPRECATED_IN_9_3_0("Use vtkDataArrayToArrayHandle or vtkSOADataArrayToComponentArrayHandle.") - static ArrayHandleType Wrap(vtkSOADataArrayTemplate<T>* input) - { - vtkm::Id numValues = input->GetNumberOfTuples(); - vtkm::cont::ArrayHandleSOA<ValueType> handle; - for (vtkm::IdComponent i = 0; i < NumComponents; ++i) - { - handle.SetArray(i, - vtkm::cont::make_ArrayHandle<T>(reinterpret_cast<T*>(input->GetComponentArrayPointer(i)), - numValues, vtkm::CopyFlag::Off)); - } - - return std::move(handle); - } -}; - -template <typename T> -struct DataArrayToArrayHandle<vtkSOADataArrayTemplate<T>, 1> -{ - using StorageType = vtkm::cont::internal::Storage<T, vtkm::cont::StorageTagBasic>; - using ArrayHandleType = vtkm::cont::ArrayHandle<T, vtkm::cont::StorageTagBasic>; - - VTK_DEPRECATED_IN_9_3_0("Use vtkDataArrayToArrayHandle or vtkSOADataArrayToComponentArrayHandle.") - static ArrayHandleType Wrap(vtkSOADataArrayTemplate<T>* input) - { - return vtkm::cont::make_ArrayHandle( - input->GetComponentArrayPointer(0), input->GetNumberOfTuples(), vtkm::CopyFlag::Off); - } -}; - enum class FieldsFlag { None = 0x0, diff --git a/Accelerators/Vtkm/Filters/vtkmClip.h b/Accelerators/Vtkm/Filters/vtkmClip.h index 769a8ab4937..020b6f031f1 100644 --- a/Accelerators/Vtkm/Filters/vtkmClip.h +++ b/Accelerators/Vtkm/Filters/vtkmClip.h @@ -15,7 +15,6 @@ #define vtkmClip_h #include "vtkAcceleratorsVTKmFiltersModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkTableBasedClipDataSet.h" #include "vtkmlib/vtkmInitializer.h" // Need for initializing vtk-m @@ -32,16 +31,6 @@ public: vtkTypeMacro(vtkmClip, vtkTableBasedClipDataSet); void PrintSelf(ostream& os, vtkIndent indent) override; - /** - * The scalar value to use when clipping the dataset. Values greater than - * ClipValue are preserved in the output dataset. Default is 0. - */ - VTK_DEPRECATED_IN_9_3_0("Please use GetValue instead.") - double GetClipValue() { return this->GetValue(); } - - VTK_DEPRECATED_IN_9_3_0("Please use SetValue instead.") - void SetClipValue(double v) { this->SetValue(v); } - /** * If true, all input point data arrays will be mapped onto the output * dataset. Default is true. diff --git a/Charts/Core/vtkPlot.cxx b/Charts/Core/vtkPlot.cxx index 441c8e446aa..af2cb7743b8 100644 --- a/Charts/Core/vtkPlot.cxx +++ b/Charts/Core/vtkPlot.cxx @@ -229,6 +229,12 @@ void vtkPlot::SetColor(unsigned char r, unsigned char g, unsigned char b, unsign this->Pen->SetColor(r, g, b, a); } +//------------------------------------------------------------------------------ +void vtkPlot::SetColor(unsigned char r, unsigned char g, unsigned char b) +{ + this->Pen->SetColor(r, g, b); +} + //------------------------------------------------------------------------------ void vtkPlot::SetColorF(double r, double g, double b, double a) { diff --git a/Charts/Core/vtkPlot.h b/Charts/Core/vtkPlot.h index 020e85e88e9..7f38c5a555a 100644 --- a/Charts/Core/vtkPlot.h +++ b/Charts/Core/vtkPlot.h @@ -18,7 +18,6 @@ #include "vtkChartsCoreModule.h" // For export macro #include "vtkContextItem.h" #include "vtkContextPolygon.h" // For vtkContextPolygon -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkRect.h" // For vtkRectd ivar #include "vtkSmartPointer.h" // Needed to hold SP ivars #include "vtkStdString.h" // Needed to hold TooltipLabelFormat ivar @@ -126,11 +125,14 @@ public: */ virtual bool SelectPointsInPolygon(const vtkContextPolygon& polygon); + ///@{ /** * Set the plot color with integer values (comprised between 0 and 255) */ VTK_MARSHALSETTER(ColorRGBA) virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a); + virtual void SetColor(unsigned char r, unsigned char g, unsigned char b); + ///@} ///@{ /** @@ -140,20 +142,13 @@ public: virtual void SetColorF(double r, double g, double b, double a); VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT) virtual void SetColorF(double r, double g, double b); - - // If removed, please remplace it with the following function: - // SetColor(unsigned char r, unsigned char g, unsigned char b) - // here and in the inheriting classes overriding it - VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT) - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.") - virtual void SetColor(double r, double g, double b) { this->SetColorF(r, g, b); } ///@} ///@{ /** * Get the plot color as integer rgb values (comprised between 0 and 255) */ - void GetColor(unsigned char rgb[3]); + virtual void GetColor(unsigned char rgb[3]); VTK_MARSHALGETTER(ColorRGBA) void GetColorRGBA(unsigned char rgba[4]); ///@} @@ -164,11 +159,6 @@ public: */ VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT) virtual void GetColorF(double rgb[3]); - - // If removed, please make GetColor(unsigned char rgb[3]) virtual - VTK_MARSHALEXCLUDE(VTK_MARSHAL_EXCLUDE_REASON_IS_REDUNDANT) - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.") - virtual void GetColor(double rgb[3]) { this->GetColorF(rgb); } ///@ /** diff --git a/Charts/Core/vtkPlotArea.cxx b/Charts/Core/vtkPlotArea.cxx index 6a33a88ef30..cd36c4ad20a 100644 --- a/Charts/Core/vtkPlotArea.cxx +++ b/Charts/Core/vtkPlotArea.cxx @@ -637,6 +637,13 @@ void vtkPlotArea::SetColor(unsigned char r, unsigned char g, unsigned char b, un this->Superclass::SetColor(r, g, b, a); } +//------------------------------------------------------------------------------ +void vtkPlotArea::SetColor(unsigned char r, unsigned char g, unsigned char b) +{ + this->Brush->SetColor(r, g, b); + this->Superclass::SetColor(r, g, b); +} + //------------------------------------------------------------------------------ void vtkPlotArea::SetColorF(double r, double g, double b, double a) { diff --git a/Charts/Core/vtkPlotArea.h b/Charts/Core/vtkPlotArea.h index 75c4d606e89..5d29a09f5dc 100644 --- a/Charts/Core/vtkPlotArea.h +++ b/Charts/Core/vtkPlotArea.h @@ -40,6 +40,7 @@ public: * Set the plot color with integer values (comprised between 0 and 255) */ void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; + void SetColor(unsigned char r, unsigned char g, unsigned char b) override; ///@{ /** @@ -47,9 +48,6 @@ public: */ void SetColorF(double r, double g, double b, double a) override; void SetColorF(double r, double g, double b) override; - - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.") - void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); } ///@} ///@{ diff --git a/Charts/Core/vtkPlotBar.cxx b/Charts/Core/vtkPlotBar.cxx index 3b15fc879e9..de43f2c25f4 100644 --- a/Charts/Core/vtkPlotBar.cxx +++ b/Charts/Core/vtkPlotBar.cxx @@ -700,6 +700,12 @@ void vtkPlotBar::SetColor(unsigned char r, unsigned char g, unsigned char b, uns this->Brush->SetColor(r, g, b, a); } +//------------------------------------------------------------------------------ +void vtkPlotBar::SetColor(unsigned char r, unsigned char g, unsigned char b) +{ + this->Brush->SetColor(r, g, b); +} + //------------------------------------------------------------------------------ void vtkPlotBar::SetColorF(double r, double g, double b, double a) { diff --git a/Charts/Core/vtkPlotBar.h b/Charts/Core/vtkPlotBar.h index a296e189c3d..e57400e664e 100644 --- a/Charts/Core/vtkPlotBar.h +++ b/Charts/Core/vtkPlotBar.h @@ -66,6 +66,7 @@ public: * Set the plot color with integer values (comprised between 0 and 255) */ void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; + void SetColor(unsigned char r, unsigned char g, unsigned char b) override; ///@{ /** @@ -73,9 +74,6 @@ public: */ void SetColorF(double r, double g, double b, double a) override; void SetColorF(double r, double g, double b) override; - - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.") - void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); } ///@} ///@{ @@ -83,9 +81,6 @@ public: * Get the plot color as floating rgb values (comprised between 0.0 and 1.0) */ void GetColorF(double rgb[3]) override; - - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.") - void GetColor(double rgb[3]) override { this->GetColorF(rgb); } ///@} ///@{ diff --git a/Charts/Core/vtkPlotStacked.cxx b/Charts/Core/vtkPlotStacked.cxx index 4fc4684d7b6..e387513c904 100644 --- a/Charts/Core/vtkPlotStacked.cxx +++ b/Charts/Core/vtkPlotStacked.cxx @@ -561,6 +561,12 @@ void vtkPlotStacked::SetColor(unsigned char r, unsigned char g, unsigned char b, this->Brush->SetColor(r, g, b, a); } +//------------------------------------------------------------------------------ +void vtkPlotStacked::SetColor(unsigned char r, unsigned char g, unsigned char b) +{ + this->Brush->SetColor(r, g, b); +} + //------------------------------------------------------------------------------ void vtkPlotStacked::SetColorF(double r, double g, double b, double a) { diff --git a/Charts/Core/vtkPlotStacked.h b/Charts/Core/vtkPlotStacked.h index f48d2642cfa..0a9533adc68 100644 --- a/Charts/Core/vtkPlotStacked.h +++ b/Charts/Core/vtkPlotStacked.h @@ -43,6 +43,7 @@ public: * Set the plot color with integer values (comprised between 0 and 255) */ void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; + void SetColor(unsigned char r, unsigned char g, unsigned char b) override; ///@{ /** @@ -50,9 +51,6 @@ public: */ void SetColorF(double r, double g, double b, double a) override; void SetColorF(double r, double g, double b) override; - - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetColorF method instead.") - void SetColor(double r, double g, double b) override { this->SetColorF(r, g, b); } ///@} ///@{ @@ -60,9 +58,6 @@ public: * Get the plot color as floating rgb values (comprised between 0.0 and 1.0) */ void GetColorF(double rgb[3]) override; - - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetColorF method instead.") - void GetColor(double rgb[3]) override { this->GetColorF(rgb); } ///@} /** diff --git a/Common/Core/vtkNumberToString.h b/Common/Core/vtkNumberToString.h index 242109c96ba..5a29bc913bd 100644 --- a/Common/Core/vtkNumberToString.h +++ b/Common/Core/vtkNumberToString.h @@ -47,7 +47,6 @@ #define vtkNumberToString_h #include "vtkCommonCoreModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkTypeTraits.h" #include <ostream> @@ -157,10 +156,6 @@ public: { return val; } - VTK_DEPRECATED_IN_9_3_0("Use vtkNumberToString::Convert instead.") - TagDouble operator()(const double& val) const { return TagDouble(val); } - VTK_DEPRECATED_IN_9_3_0("Use vtkNumberToString::Convert instead.") - TagFloat operator()(const float& val) const { return TagFloat(val); } private: int LowExponent = -6; diff --git a/Common/Core/vtkOutputWindow.h b/Common/Core/vtkOutputWindow.h index 7c4fe9724f1..ea58436551a 100644 --- a/Common/Core/vtkOutputWindow.h +++ b/Common/Core/vtkOutputWindow.h @@ -15,22 +15,9 @@ #include "vtkCommonCoreModule.h" // For export macro #include "vtkDebugLeaksManager.h" // Must be included before singletons -#include "vtkDeprecation.h" // For `VTK_DEPRECATED_IN_9_3_0` #include "vtkObject.h" VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0( - "`vtkOutputWindowCleanup` is no longer necessary") VTKCOMMONCORE_EXPORT vtkOutputWindowCleanup -{ -public: - vtkOutputWindowCleanup() = default; - ~vtkOutputWindowCleanup() = default; - -private: - vtkOutputWindowCleanup(const vtkOutputWindowCleanup& other) = delete; - vtkOutputWindowCleanup& operator=(const vtkOutputWindowCleanup& rhs) = delete; -}; - class vtkOutputWindowPrivateAccessor; class VTKCOMMONCORE_EXPORT vtkOutputWindow : public vtkObject { diff --git a/Common/Core/vtkStdString.h b/Common/Core/vtkStdString.h index ead3deada08..82b23c51b63 100644 --- a/Common/Core/vtkStdString.h +++ b/Common/Core/vtkStdString.h @@ -13,7 +13,6 @@ #define vtkStdString_h #include "vtkCommonCoreModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkSystemIncludes.h" // For VTKCOMMONCORE_EXPORT. #include <string> // For the superclass. #include <utility> // For std::move @@ -58,9 +57,6 @@ public: : std::string(s, pos, n) { } - - VTK_DEPRECATED_IN_9_3_0("Call `.c_str()` explicitly") - operator const char*() { return this->c_str(); } }; VTK_ABI_NAMESPACE_END diff --git a/Common/DataModel/vtkAbstractCellLinks.cxx b/Common/DataModel/vtkAbstractCellLinks.cxx index 7e5734d6fbe..af2bfc8e16b 100644 --- a/Common/DataModel/vtkAbstractCellLinks.cxx +++ b/Common/DataModel/vtkAbstractCellLinks.cxx @@ -1,7 +1,5 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkAbstractCellLinks.h" @@ -56,13 +54,6 @@ int vtkAbstractCellLinks::ComputeType( return vtkAbstractCellLinks::STATIC_CELL_LINKS_IDTYPE; } -//------------------------------------------------------------------------------ -void vtkAbstractCellLinks::BuildLinks(vtkDataSet* dataset) -{ - this->SetDataSet(dataset); - this->BuildLinks(); -} - //------------------------------------------------------------------------------ void vtkAbstractCellLinks::PrintSelf(ostream& os, vtkIndent indent) { diff --git a/Common/DataModel/vtkAbstractCellLinks.h b/Common/DataModel/vtkAbstractCellLinks.h index d8d5b1b4d1f..bd905759e05 100644 --- a/Common/DataModel/vtkAbstractCellLinks.h +++ b/Common/DataModel/vtkAbstractCellLinks.h @@ -20,7 +20,6 @@ #define vtkAbstractCellLinks_h #include "vtkCommonDataModelModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkObject.h" VTK_ABI_NAMESPACE_BEGIN @@ -47,12 +46,6 @@ public: vtkGetObjectMacro(DataSet, vtkDataSet); ///@} - /** - * Set the input dataset and build the link list array. - */ - VTK_DEPRECATED_IN_9_3_0("Use SetDataSet() and BuildLinks() instead.") - void BuildLinks(vtkDataSet* data); - /** * Build the link list array from the input dataset. */ diff --git a/Common/DataModel/vtkCompositeDataSet.cxx b/Common/DataModel/vtkCompositeDataSet.cxx index b31ab22e6a3..1c82b417af7 100644 --- a/Common/DataModel/vtkCompositeDataSet.cxx +++ b/Common/DataModel/vtkCompositeDataSet.cxx @@ -51,13 +51,6 @@ void vtkCompositeDataSet::CompositeShallowCopy(vtkCompositeDataSet* src) this->Superclass::ShallowCopy(src); } -//------------------------------------------------------------------------------ -void vtkCompositeDataSet::RecursiveShallowCopy(vtkDataObject* src) -{ - VTK_LEGACY_REPLACED_BODY(RecursiveShallowCopy, "VTK 9.3", ShallowCopy); - this->ShallowCopy(src); -} - //------------------------------------------------------------------------------ void vtkCompositeDataSet::Initialize() { diff --git a/Common/DataModel/vtkCompositeDataSet.h b/Common/DataModel/vtkCompositeDataSet.h index dee6e094ca2..9123eb60a5a 100644 --- a/Common/DataModel/vtkCompositeDataSet.h +++ b/Common/DataModel/vtkCompositeDataSet.h @@ -23,7 +23,6 @@ #include "vtkCommonDataModelModule.h" // For export macro #include "vtkDataObject.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO #include <vector> // For GetDataSets @@ -114,12 +113,6 @@ public: */ virtual void CompositeShallowCopy(vtkCompositeDataSet* src); - /** - * @deprecated RecursiveShallowCopy method, @see ShallowCopy - */ - VTK_DEPRECATED_IN_9_3_0("Use ShallowCopy instead.") - virtual void RecursiveShallowCopy(vtkDataObject* src); - /** * Returns the total number of points of all blocks. This will * iterate over all blocks and call GetNumberOfPoints() so it diff --git a/Common/DataModel/vtkDataObjectTree.cxx b/Common/DataModel/vtkDataObjectTree.cxx index e6858ccdc1d..44205fcb94f 100644 --- a/Common/DataModel/vtkDataObjectTree.cxx +++ b/Common/DataModel/vtkDataObjectTree.cxx @@ -622,13 +622,6 @@ void vtkDataObjectTree::ShallowCopy(vtkDataObject* src) this->Modified(); } -//------------------------------------------------------------------------------ -void vtkDataObjectTree::RecursiveShallowCopy(vtkDataObject* src) -{ - VTK_LEGACY_REPLACED_BODY(RecursiveShallowCopy, "VTK 9.3", ShallowCopy); - this->ShallowCopy(src); -} - //------------------------------------------------------------------------------ void vtkDataObjectTree::Initialize() { diff --git a/Common/DataModel/vtkDataObjectTree.h b/Common/DataModel/vtkDataObjectTree.h index f5e2fe63cbc..fa259de02e4 100644 --- a/Common/DataModel/vtkDataObjectTree.h +++ b/Common/DataModel/vtkDataObjectTree.h @@ -23,7 +23,6 @@ #include "vtkCommonDataModelModule.h" // For export macro #include "vtkCompositeDataSet.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO VTK_ABI_NAMESPACE_BEGIN @@ -122,12 +121,6 @@ public: void DeepCopy(vtkDataObject* src) override; ///@} - /** - * @deprecated RecursiveShallowCopy method, @see ShallowCopy - */ - VTK_DEPRECATED_IN_9_3_0("Please use ShallowCopy instead.") - void RecursiveShallowCopy(vtkDataObject* src) override; - /** * Returns the total number of points of all blocks. This will * iterate over all blocks and call GetNumberOfPoints() so it diff --git a/Common/DataModel/vtkDataSet.cxx b/Common/DataModel/vtkDataSet.cxx index 2a85a6fbdd3..b23a47fdd08 100644 --- a/Common/DataModel/vtkDataSet.cxx +++ b/Common/DataModel/vtkDataSet.cxx @@ -1,7 +1,5 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkDataSet.h" #include "vtkBezierCurve.h" @@ -38,7 +36,6 @@ vtkDataSet::vtkDataSet() vtkMath::UninitializeBounds(this->Bounds); // Observer for updating the cell/point ghost arrays pointers this->DataObserver = vtkCallbackCommand::New(); - this->DataObserver->SetCallback(&vtkDataSet::OnDataModified); this->DataObserver->SetClientData(this); this->PointData = vtkPointData::New(); @@ -1161,22 +1158,6 @@ vtkUnsignedCharArray* vtkDataSet::AllocateCellGhostArray() return this->GetCellGhostArray(); } -//------------------------------------------------------------------------------ -void vtkDataSet::OnDataModified(vtkObject* source, unsigned long, void* clientdata, void*) -{ - // update the point/cell pointers to ghost data arrays. - vtkDataSet* This = static_cast<vtkDataSet*>(clientdata); - if (source == This->GetPointData()) - { - This->UpdatePointGhostArrayCache(); - } - else - { - assert(source == This->GetCellData()); - This->UpdateCellGhostArrayCache(); - } -} - //------------------------------------------------------------------------------ vtkMTimeType vtkDataSet::GetGhostCellsTime() { diff --git a/Common/DataModel/vtkDataSet.h b/Common/DataModel/vtkDataSet.h index 68fec738555..439f29e575e 100644 --- a/Common/DataModel/vtkDataSet.h +++ b/Common/DataModel/vtkDataSet.h @@ -30,7 +30,6 @@ #include "vtkCommonDataModelModule.h" // For export macro #include "vtkDataObject.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkNew.h" // For vtkNew #include "vtkSmartPointer.h" // For vtkSmartPointer #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO @@ -513,12 +512,6 @@ public: */ vtkUnsignedCharArray* GetPointGhostArray(); - /** - * Updates the pointer to the point ghost array. - */ - VTK_DEPRECATED_IN_9_3_0("This function is deprecated. It has no effect.") - void UpdatePointGhostArrayCache() {} - /** * Allocate ghost array for points. */ @@ -530,12 +523,6 @@ public: */ vtkUnsignedCharArray* GetCellGhostArray(); - /** - * Updates the pointer to the cell ghost array. - */ - VTK_DEPRECATED_IN_9_3_0("This function is deprecated. It has no effect.") - void UpdateCellGhostArrayCache() {} - /** * Allocate ghost array for cells. */ @@ -584,29 +571,8 @@ protected: // Time at which scalar range is computed vtkTimeStamp ScalarRangeComputeTime; - ///@{ - /** - * These arrays pointers are caches used to avoid a string comparison (when - * getting ghost arrays using GetArray(name)) - */ - VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.") - vtkUnsignedCharArray* PointGhostArray; - VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.") - vtkUnsignedCharArray* CellGhostArray; - VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.") - bool PointGhostArrayCached; - VTK_DEPRECATED_IN_9_3_0("This member is deprecated. It's no longer used.") - bool CellGhostArrayCached; - ///@} - private: void InternalDataSetCopy(vtkDataSet* src); - /** - * Called when point/cell data is modified - * Updates caches to point/cell ghost arrays. - */ - static void OnDataModified( - vtkObject* source, unsigned long eid, void* clientdata, void* calldata); // This should only be used if a vtkDataSet subclass don't define GetPoints() vtkSmartPointer<vtkPoints> TempPoints; diff --git a/Common/DataModel/vtkPolygon.cxx b/Common/DataModel/vtkPolygon.cxx index 06109beb9fc..796e72c7f1f 100644 --- a/Common/DataModel/vtkPolygon.cxx +++ b/Common/DataModel/vtkPolygon.cxx @@ -809,15 +809,6 @@ int vtkPolygon::PointInPolygon(double x[3], int numPts, double* pts, double boun return ((wn == 0 ? VTK_POLYGON_OUTSIDE : VTK_POLYGON_INSIDE)); } -//------------------------------------------------------------------------------ -// Triangulate polygon. -// -int vtkPolygon::Triangulate(vtkIdList* outTris) -{ - this->SuccessfulTriangulation = 1; - return this->EarCutTriangulation(outTris); -} - //------------------------------------------------------------------------------ // Split into non-degenerate polygons prior to triangulation // diff --git a/Common/DataModel/vtkPolygon.h b/Common/DataModel/vtkPolygon.h index d4f7b4f201e..300677638de 100644 --- a/Common/DataModel/vtkPolygon.h +++ b/Common/DataModel/vtkPolygon.h @@ -15,7 +15,6 @@ #include "vtkCell.h" #include "vtkCommonDataModelModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 VTK_ABI_NAMESPACE_BEGIN class vtkDoubleArray; @@ -162,16 +161,6 @@ public: { return vtkCell::Triangulate(index, ptIds, pts); } - /** - * Triangulate this polygon. The user must provide the vtkIdList outTris. - * On output, the outTris list contains the ids of the points defining the - * triangulation (i.e., not the associated polygon->PointIds, rather the - * index into the polygon->Points array). The ids are ordered into groups - * of three: each three-group defines one triangle. The method returns - * non-zero if the triangulation is successful. - */ - VTK_DEPRECATED_IN_9_3_0("Replaced by its parent's implementation vtkCell::TriangulateLocalIds") - int Triangulate(vtkIdList* outTris); /** * Same as Triangulate(vtkIdList *outTris) diff --git a/Common/DataModel/vtkQuadraticPolygon.cxx b/Common/DataModel/vtkQuadraticPolygon.cxx index 3b86807418f..ca6ea3615c0 100644 --- a/Common/DataModel/vtkQuadraticPolygon.cxx +++ b/Common/DataModel/vtkQuadraticPolygon.cxx @@ -118,15 +118,6 @@ int vtkQuadraticPolygon::IntersectWithLine( return this->Polygon->IntersectWithLine(p1, p2, tol, t, x, pcoords, subId); } -//------------------------------------------------------------------------------ -int vtkQuadraticPolygon::Triangulate(vtkIdList* outTris) -{ - this->InitializePolygon(); - int result = this->Polygon->TriangulateLocalIds(0, outTris); - vtkQuadraticPolygon::ConvertFromPolygon(this->GetNumberOfPoints(), outTris); - return result; -} - //------------------------------------------------------------------------------ int vtkQuadraticPolygon::TriangulateLocalIds(int index, vtkIdList* ptIds) { diff --git a/Common/DataModel/vtkQuadraticPolygon.h b/Common/DataModel/vtkQuadraticPolygon.h index 451b8246de5..b0b467665e7 100644 --- a/Common/DataModel/vtkQuadraticPolygon.h +++ b/Common/DataModel/vtkQuadraticPolygon.h @@ -22,7 +22,6 @@ #define vtkQuadraticPolygon_h #include "vtkCommonDataModelModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkNonLinearCell.h" VTK_ABI_NAMESPACE_BEGIN @@ -79,8 +78,6 @@ public: { return vtkCell::Triangulate(index, ptIds, pts); } - VTK_DEPRECATED_IN_9_3_0("Replaced by its parent's implementation vtkCell::TriangulateLocalIds") - int Triangulate(vtkIdList* outTris); int TriangulateLocalIds(int index, vtkIdList* ptIds) override; int NonDegenerateTriangulate(vtkIdList* outTris); static double DistanceToPolygon( diff --git a/Common/DataModel/vtkRectilinearGrid.cxx b/Common/DataModel/vtkRectilinearGrid.cxx index 5e41544101b..53c74476858 100644 --- a/Common/DataModel/vtkRectilinearGrid.cxx +++ b/Common/DataModel/vtkRectilinearGrid.cxx @@ -155,13 +155,6 @@ void vtkRectilinearGrid::Initialize() this->Cleanup(); } -//------------------------------------------------------------------------------ -void vtkRectilinearGrid::GetPoints(vtkPoints* points) -{ - assert("pre: points object should not be nullptr" && (points != nullptr)); - points->ShallowCopy(this->GetPoints()); -} - //------------------------------------------------------------------------------ void vtkRectilinearGrid::GetPoint(vtkIdType ptId, double x[3]) { diff --git a/Common/DataModel/vtkRectilinearGrid.h b/Common/DataModel/vtkRectilinearGrid.h index d93939bade6..dc0d675febf 100644 --- a/Common/DataModel/vtkRectilinearGrid.h +++ b/Common/DataModel/vtkRectilinearGrid.h @@ -27,7 +27,6 @@ #include "vtkCommonDataModelModule.h" // For export macro #include "vtkDataSet.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkSmartPointer.h" // For vtkSmartPointer #include "vtkStructuredData.h" // For inline methods @@ -177,13 +176,6 @@ public: */ void GetCellDims(int cellDims[3]); - /** - * Given a user-supplied vtkPoints container object, this method fills in all - * the points of the RectilinearGrid. - */ - VTK_DEPRECATED_IN_9_3_0("Use vtkPoints* GetPoints() instead.") - void GetPoints(vtkPoints* points); - ///@{ /** * Set dimensions of rectilinear grid dataset. diff --git a/Common/DataModel/vtkStructuredGrid.cxx b/Common/DataModel/vtkStructuredGrid.cxx index 7e7c072b2dd..c70c657eefa 100644 --- a/Common/DataModel/vtkStructuredGrid.cxx +++ b/Common/DataModel/vtkStructuredGrid.cxx @@ -394,15 +394,6 @@ void vtkStructuredGrid::SetExtent(int xMin, int xMax, int yMin, int yMax, int zM this->SetExtent(extent); } -//------------------------------------------------------------------------------ -#if !defined(VTK_LEGACY_REMOVE) -int* vtkStructuredGrid::GetDimensions() -{ - this->GetDimensions(this->Dimensions); - return this->Dimensions; -} -#endif - //------------------------------------------------------------------------------ void vtkStructuredGrid::GetDimensions(int dims[3]) { diff --git a/Common/DataModel/vtkStructuredGrid.h b/Common/DataModel/vtkStructuredGrid.h index 607f20781c5..7cb5d670eb0 100644 --- a/Common/DataModel/vtkStructuredGrid.h +++ b/Common/DataModel/vtkStructuredGrid.h @@ -31,7 +31,6 @@ #define vtkStructuredGrid_h #include "vtkCommonDataModelModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkPointSet.h" #include "vtkStructuredData.h" // Needed for inline methods @@ -188,18 +187,10 @@ public: void SetDimensions(const int dims[3]); ///@} - ///@{ - /** - * Get dimensions of this structured grid. - */ - VTK_DEPRECATED_IN_9_3_0("Please use GetDimensions(int dims[3]) instead.") - virtual int* GetDimensions() VTK_SIZEHINT(3); - /** * Get dimensions of this structured grid based on its extent. */ virtual void GetDimensions(int dims[3]); - ///@} /** * Return the dimensionality of the data. diff --git a/Common/DataModel/vtkUniformGrid.h b/Common/DataModel/vtkUniformGrid.h index f07f398cdef..d9c058da23f 100644 --- a/Common/DataModel/vtkUniformGrid.h +++ b/Common/DataModel/vtkUniformGrid.h @@ -12,7 +12,6 @@ #define vtkUniformGrid_h #include "vtkCommonDataModelModule.h" // For export macro -#include "vtkDeprecation.h" // For VTK_DEPRECATED #include "vtkImageData.h" VTK_ABI_NAMESPACE_BEGIN @@ -50,12 +49,6 @@ public: void Initialize() override; ///@} - /** - * Returns the data description of this uniform grid instance. - */ - VTK_DEPRECATED_IN_9_3_0("Use GetDataDescription() instead.") - int GetGridDescription() { return this->GetDataDescription(); } - /** * Initialize with no ghost cell arrays, from the definition in * the given box. The box is expected to be 3D, if you have 2D diff --git a/Common/DataModel/vtkUniformGridAMR.cxx b/Common/DataModel/vtkUniformGridAMR.cxx index acb2f0902d0..4f41db0ea7e 100644 --- a/Common/DataModel/vtkUniformGridAMR.cxx +++ b/Common/DataModel/vtkUniformGridAMR.cxx @@ -346,13 +346,6 @@ void vtkUniformGridAMR::ShallowCopy(vtkDataObject* src) this->Modified(); } -//------------------------------------------------------------------------------ -void vtkUniformGridAMR::RecursiveShallowCopy(vtkDataObject* src) -{ - VTK_LEGACY_REPLACED_BODY(RecursiveShallowCopy, "VTK 9.3", ShallowCopy); - this->ShallowCopy(src); -} - //------------------------------------------------------------------------------ const double* vtkUniformGridAMR::GetBounds() { diff --git a/Common/DataModel/vtkUniformGridAMR.h b/Common/DataModel/vtkUniformGridAMR.h index f4114697bde..1943f9d229a 100644 --- a/Common/DataModel/vtkUniformGridAMR.h +++ b/Common/DataModel/vtkUniformGridAMR.h @@ -15,7 +15,6 @@ #include "vtkCommonDataModelModule.h" // For export macro #include "vtkCompositeDataSet.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 VTK_ABI_NAMESPACE_BEGIN class vtkCompositeDataIterator; @@ -126,12 +125,6 @@ public: void ShallowCopy(vtkDataObject* src) override; ///@} - /** - * Deprecated RecursiveShallowCopy method, uses ShallowCopy - */ - VTK_DEPRECATED_IN_9_3_0("Please use ShallowCopy instead.") - void RecursiveShallowCopy(vtkDataObject* src) override; - /** * DeepCopy. */ diff --git a/Common/DataModel/vtkUnstructuredGrid.cxx b/Common/DataModel/vtkUnstructuredGrid.cxx index 7638c44d1bc..ed24ad22bd5 100644 --- a/Common/DataModel/vtkUnstructuredGrid.cxx +++ b/Common/DataModel/vtkUnstructuredGrid.cxx @@ -1144,12 +1144,6 @@ void vtkUnstructuredGrid::BuildLinks() this->Links->BuildLinks(); } -//------------------------------------------------------------------------------ -vtkAbstractCellLinks* vtkUnstructuredGrid::GetCellLinks() -{ - return this->Links; -} - //------------------------------------------------------------------------------ void vtkUnstructuredGrid::GetPointCells(vtkIdType ptId, vtkIdType& ncells, vtkIdType*& cells) { diff --git a/Common/DataModel/vtkUnstructuredGrid.h b/Common/DataModel/vtkUnstructuredGrid.h index e7a131e2e51..7c328951d91 100644 --- a/Common/DataModel/vtkUnstructuredGrid.h +++ b/Common/DataModel/vtkUnstructuredGrid.h @@ -241,16 +241,6 @@ public: vtkGetSmartPointerMacro(Links, vtkAbstractCellLinks); ///@} - /** - * Get the cell links. The cell links will be one of nullptr=0; - * vtkCellLinks=1; vtkStaticCellLinksTemplate<VTK_UNSIGNED_SHORT>=2; - * vtkStaticCellLinksTemplate<VTK_UNSIGNED_INT>=3; - * vtkStaticCellLinksTemplate<VTK_ID_TYPE>=4. (See enum types defined in - * vtkAbstractCellLinks.) - */ - VTK_DEPRECATED_IN_9_3_0("Use GetLinks() instead.") - vtkAbstractCellLinks* GetCellLinks(); - /** * Get the face stream of a polyhedron cell in the following format: * (numCellFaces, numFace0Pts, id1, id2, id3, numFace1Pts,id1, id2, id3, ...). @@ -331,12 +321,6 @@ public: vtkIdType neighborCellId; return this->IsCellBoundary(cellId, npts, ptIds, neighborCellId); } - VTK_DEPRECATED_IN_9_3_0("Use the overload that doesn't take a vtkIdList instead.") - bool IsCellBoundary( - vtkIdType cellId, vtkIdType npts, const vtkIdType* ptIds, vtkIdList* vtkNotUsed(cellIds)) - { - return this->IsCellBoundary(cellId, npts, ptIds); - } ///@} ///@{ diff --git a/Common/ExecutionModel/vtkTemporalAlgorithm.txx b/Common/ExecutionModel/vtkTemporalAlgorithm.txx index d09795344b4..07cce2ddb7b 100644 --- a/Common/ExecutionModel/vtkTemporalAlgorithm.txx +++ b/Common/ExecutionModel/vtkTemporalAlgorithm.txx @@ -120,11 +120,7 @@ int vtkTemporalAlgorithm<AlgorithmT>::RequestUpdateExtent( { int newTerminationTimeIndex = static_cast<int>(this->IntegrateFullTimeSeries ? this->InputTimeSteps.size() - 1 - : (this->RunBackward - // VTK_DEPRECATED_IN_9_3_0 FIXME Following 2 lines can go away. - ? this->InputTimeSteps.size() - 1 - - ::FindTimeIndex(outInfo->Get(vtkSDDP::UPDATE_TIME_STEP()), this->InputTimeSteps) - : ::FindTimeIndex(outInfo->Get(vtkSDDP::UPDATE_TIME_STEP()), this->InputTimeSteps))); + : ::FindTimeIndex(outInfo->Get(vtkSDDP::UPDATE_TIME_STEP()), this->InputTimeSteps)); if (newTerminationTimeIndex < this->CurrentTimeIndex) { @@ -135,11 +131,7 @@ int vtkTemporalAlgorithm<AlgorithmT>::RequestUpdateExtent( if (vtkInformation* inInfo = inputVector[0]->GetInformationObject(0)) { - inInfo->Set(vtkSDDP::UPDATE_TIME_STEP(), - this->InputTimeSteps[this->RunBackward - // VTK_DEPRECATED_IN_9_3_0 FIXME Following line can go away. - ? this->InputTimeSteps.size() - this->CurrentTimeIndex - 1 - : this->CurrentTimeIndex]); + inInfo->Set(vtkSDDP::UPDATE_TIME_STEP(), this->InputTimeSteps[this->CurrentTimeIndex]); } return retVal; @@ -249,10 +241,7 @@ double vtkTemporalAlgorithm<AlgorithmT>::GetCurrentTimeStep() const { return this->NoPriorTimeStepAccess ? this->ProcessedTimeSteps->GetValue(this->ProcessedTimeSteps->GetNumberOfValues() - 1) - : (this->RunBackward - // VTK_DEPRECATED_IN_9_3_0 FIXME Following line can go away. - ? this->InputTimeSteps[this->InputTimeSteps.size() - this->CurrentTimeIndex] - : this->InputTimeSteps[this->CurrentTimeIndex - 1]); + : this->InputTimeSteps[this->CurrentTimeIndex - 1]; } VTK_ABI_NAMESPACE_END diff --git a/Documentation/release/dev/remove-9-3-deprecated-APIs.md b/Documentation/release/dev/remove-9-3-deprecated-APIs.md new file mode 100644 index 00000000000..33cb000ee8c --- /dev/null +++ b/Documentation/release/dev/remove-9-3-deprecated-APIs.md @@ -0,0 +1,3 @@ +## VTK 9.3 deprecated APIs removal + +All APIs that were deprecated in 9.3 are now removed. diff --git a/Examples/GUI/QML/QtQuickProperty/main.cpp b/Examples/GUI/QML/QtQuickProperty/main.cpp index 3ef0601d650..1b0e7eeaa41 100644 --- a/Examples/GUI/QML/QtQuickProperty/main.cpp +++ b/Examples/GUI/QML/QtQuickProperty/main.cpp @@ -13,8 +13,8 @@ #include <vtkActor.h> #include <vtkCamera.h> -#include <vtkCapsuleSource.h> #include <vtkConeSource.h> +#include <vtkCylinderSource.h> #include <vtkPolyDataMapper.h> #include <vtkRenderWindow.h> #include <vtkRenderWindowInteractor.h> @@ -53,7 +53,7 @@ public: vtkNew<vtkRenderer> renderer; vtkNew<vtkConeSource> cone; vtkNew<vtkSphereSource> sphere; - vtkNew<vtkCapsuleSource> capsule; + vtkNew<vtkCylinderSource> capsule; vtkNew<vtkPolyDataMapper> mapper; }; @@ -61,6 +61,9 @@ public: { vtkNew<Data> vtk; + vtk->capsule->SetCapping(true); + vtk->capsule->SetCapsuleCap(true); + vtk->actor->SetMapper(vtk->mapper); vtk->renderer->AddActor(vtk->actor); diff --git a/Filters/Core/vtkQuadricDecimation.cxx b/Filters/Core/vtkQuadricDecimation.cxx index d6d44e8fcc1..b661504084e 100644 --- a/Filters/Core/vtkQuadricDecimation.cxx +++ b/Filters/Core/vtkQuadricDecimation.cxx @@ -88,41 +88,6 @@ vtkQuadricDecimation::~vtkQuadricDecimation() this->TargetPoints->Delete(); } -void vtkQuadricDecimation::SetPointAttributeArray(vtkIdType ptId, const double* x) -{ - int i; - this->Mesh->GetPoints()->SetPoint(ptId, x); - - for (i = 0; i < this->NumberOfComponents; i++) - { - if (i < this->AttributeComponents[0]) - { - this->Mesh->GetPointData()->GetScalars()->SetComponent( - ptId, i, x[3 + i] / this->AttributeScale[0]); - } - else if (i < this->AttributeComponents[1]) - { - this->Mesh->GetPointData()->GetVectors()->SetComponent( - ptId, i - this->AttributeComponents[0], x[3 + i] / this->AttributeScale[1]); - } - else if (i < this->AttributeComponents[2]) - { - this->Mesh->GetPointData()->GetNormals()->SetComponent( - ptId, i - this->AttributeComponents[1], x[3 + i] / this->AttributeScale[2]); - } - else if (i < this->AttributeComponents[3]) - { - this->Mesh->GetPointData()->GetTCoords()->SetComponent( - ptId, i - this->AttributeComponents[2], x[3 + i] / this->AttributeScale[3]); - } - else if (i < this->AttributeComponents[4]) - { - this->Mesh->GetPointData()->GetTensors()->SetComponent( - ptId, i - this->AttributeComponents[3], x[3 + i] / this->AttributeScale[4]); - } - } -} - void vtkQuadricDecimation::SetPointAttributeArray(vtkIdType ptId[2], const double* x) { auto points = this->Mesh->GetPoints(); diff --git a/Filters/Core/vtkQuadricDecimation.h b/Filters/Core/vtkQuadricDecimation.h index 504d25e8ba0..4b2b37226ed 100644 --- a/Filters/Core/vtkQuadricDecimation.h +++ b/Filters/Core/vtkQuadricDecimation.h @@ -44,7 +44,6 @@ #ifndef vtkQuadricDecimation_h #define vtkQuadricDecimation_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkFiltersCoreModule.h" // For export macro #include "vtkPolyDataAlgorithm.h" @@ -260,9 +259,6 @@ protected: * * The setter needs the entire edge for interpolation of point data */ - VTK_DEPRECATED_IN_9_3_0("Deprecated in favor of the method taking the indexes of both points on " - "the edge to interpolate point data") - void SetPointAttributeArray(vtkIdType ptId, const double* x); void SetPointAttributeArray(vtkIdType ptId[2], const double* x); void GetPointAttributeArray(vtkIdType ptId, double* x); ///@} diff --git a/Filters/Core/vtkThreshold.cxx b/Filters/Core/vtkThreshold.cxx index 596a5e8b3d7..bd6ac61fdad 100644 --- a/Filters/Core/vtkThreshold.cxx +++ b/Filters/Core/vtkThreshold.cxx @@ -1,7 +1,5 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkThreshold.h" @@ -391,42 +389,6 @@ int vtkThreshold::EvaluateComponents(TScalarsArray& scalars, vtkIdType id) return keepCell; } -//------------------------------------------------------------------------------ -void vtkThreshold::SetAttributeModeToDefault() -{ - this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT); -} - -//------------------------------------------------------------------------------ -void vtkThreshold::SetAttributeModeToUsePointData() -{ - this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA); -} - -//------------------------------------------------------------------------------ -void vtkThreshold::SetAttributeModeToUseCellData() -{ - this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA); -} - -//------------------------------------------------------------------------------ -// Return the method for manipulating scalar data as a string. -const char* vtkThreshold::GetAttributeModeAsString() -{ - if (this->AttributeMode == VTK_ATTRIBUTE_MODE_DEFAULT) - { - return "Default"; - } - else if (this->AttributeMode == VTK_ATTRIBUTE_MODE_USE_POINT_DATA) - { - return "UsePointData"; - } - else - { - return "UseCellData"; - } -} - //------------------------------------------------------------------------------ // Return a string representation of the component mode const char* vtkThreshold::GetComponentModeAsString() @@ -445,46 +407,6 @@ const char* vtkThreshold::GetComponentModeAsString() } } -//------------------------------------------------------------------------------ -void vtkThreshold::SetPointsDataTypeToDouble() -{ - this->SetPointsDataType(VTK_DOUBLE); -} - -//------------------------------------------------------------------------------ -void vtkThreshold::SetPointsDataTypeToFloat() -{ - this->SetPointsDataType(VTK_FLOAT); -} - -//------------------------------------------------------------------------------ -void vtkThreshold::SetPointsDataType(int type) -{ - if (type == VTK_FLOAT) - { - this->SetOutputPointsPrecision(SINGLE_PRECISION); - } - else if (type == VTK_DOUBLE) - { - this->SetOutputPointsPrecision(DOUBLE_PRECISION); - } -} - -//------------------------------------------------------------------------------ -int vtkThreshold::GetPointsDataType() -{ - if (this->OutputPointsPrecision == SINGLE_PRECISION) - { - return VTK_FLOAT; - } - else if (this->OutputPointsPrecision == DOUBLE_PRECISION) - { - return VTK_DOUBLE; - } - - return 0; -} - //------------------------------------------------------------------------------ int vtkThreshold::FillInputPortInformation(int, vtkInformation* info) { diff --git a/Filters/Core/vtkThreshold.h b/Filters/Core/vtkThreshold.h index 3e4079f8587..f6af079c01f 100644 --- a/Filters/Core/vtkThreshold.h +++ b/Filters/Core/vtkThreshold.h @@ -35,7 +35,6 @@ #ifndef vtkThreshold_h #define vtkThreshold_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkFiltersCoreModule.h" // For export macro #include "vtkUnstructuredGridAlgorithm.h" @@ -92,33 +91,6 @@ public: vtkGetMacro(LowerThreshold, double); ///@} - ///@{ - /** - * Control how the filter works with scalar point data and cell attribute - * data. By default (AttributeModeToDefault), the filter will use point - * data, and if no point data is available, then cell data is - * used. Alternatively you can explicitly set the filter to use point data - * (AttributeModeToUsePointData) or cell data (AttributeModeToUseCellData). - */ - VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.") - vtkSetMacro(AttributeMode, int); - - VTK_DEPRECATED_IN_9_3_0("This method is deprecated.") - vtkGetMacro(AttributeMode, int); - - VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.") - void SetAttributeModeToDefault(); - - VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.") - void SetAttributeModeToUsePointData(); - - VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.") - void SetAttributeModeToUseCellData(); - - VTK_DEPRECATED_IN_9_3_0("This method is deprecated.") - const char* GetAttributeModeAsString(); - ///@} - ///@{ /** * Control how the decision of in / out is made with multi-component data. @@ -173,27 +145,6 @@ public: vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool); ///@} - ///@{ - /** - * Set the data type of the output points (See the data types defined in - * vtkType.h). The default data type is float. - - * These methods are deprecated. Please use the SetOutputPointsPrecision() - * and GetOutputPointsPrecision() methods instead. - */ - VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.") - void SetPointsDataTypeToDouble(); - - VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.") - void SetPointsDataTypeToFloat(); - - VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.") - void SetPointsDataType(int type); - - VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.") - int GetPointsDataType(); - ///@} - ///@{ /** * Invert the threshold results. That is, cells that would have been in the output with this diff --git a/Filters/General/Testing/Cxx/TestTemporalPathLineFilter.cxx b/Filters/General/Testing/Cxx/TestTemporalPathLineFilter.cxx index c7ff230921a..0f275e80bb3 100644 --- a/Filters/General/Testing/Cxx/TestTemporalPathLineFilter.cxx +++ b/Filters/General/Testing/Cxx/TestTemporalPathLineFilter.cxx @@ -1,7 +1,5 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkTemporalPathLineFilter.h" @@ -75,74 +73,9 @@ bool TestForwardTime() return true; } -bool TestBackwardTime() -{ - vtkNew<vtkTimeSourceExample> timeSource; - timeSource->SetXAmplitude(10); - timeSource->SetYAmplitude(0); - timeSource->UpdateInformation(); - vtkInformation* sourceInformation = timeSource->GetOutputInformation(0); - if (!sourceInformation) - { - vtkLog(ERROR, "Invalid source information."); - return false; - } - double* timeSteps = sourceInformation->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - int timeStepsNumber = sourceInformation->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); - - vtkNew<vtkTemporalPathLineFilter> temporalPathLineFilter; - temporalPathLineFilter->SetInputConnection(0, timeSource->GetOutputPort()); - temporalPathLineFilter->SetMaxTrackLength(100); - temporalPathLineFilter->SetMaxStepDistance(100, 100, 100); - temporalPathLineFilter->SetBackwardTime(true); - - for (int timeStep = timeStepsNumber - 1; timeStep >= 0; --timeStep) - { - temporalPathLineFilter->UpdateTimeStep(timeSteps[timeStep]); - } - - auto* resultPolyData = temporalPathLineFilter->GetOutput(); - if (!resultPolyData) - { - vtkLog(ERROR, "Invalid result poly data."); - return false; - } - - if (resultPolyData->GetNumberOfPoints() != 10) - { - vtkLog( - ERROR, "Wrong number of points in result poly data: " << resultPolyData->GetNumberOfPoints()); - return false; - } - - auto* lines = resultPolyData->GetLines(); - if (!lines) - { - vtkLog(ERROR, "Invalid lines in result poly data."); - return false; - } - - if (lines->GetNumberOfCells() != 1) - { - vtkLog( - ERROR, "Wrong number of cells in lines from result poly data: " << lines->GetNumberOfCells()); - return false; - } - - vtkNew<vtkIdList> pointIDs; - lines->GetCellAtId(0, pointIDs); - if (pointIDs->GetNumberOfIds() != 10) - { - vtkLog(ERROR, "Wrong number of points in result poly data."); - return false; - } - - return true; -} - int TestTemporalPathLineFilter(int, char*[]) { - if (!TestForwardTime() || !TestBackwardTime()) + if (!TestForwardTime()) { return EXIT_FAILURE; } diff --git a/Filters/General/vtkTableFFT.h b/Filters/General/vtkTableFFT.h index 7d43a8584b9..1b65cb6a807 100644 --- a/Filters/General/vtkTableFFT.h +++ b/Filters/General/vtkTableFFT.h @@ -203,43 +203,6 @@ public: vtkBooleanMacro(Detrend, bool); ///@} - ///@{ - /** - * @deprecated in v9.3. Property has been renamed ReturnOnesided. - * - * @see vtkTableFFT::SetReturnOnesided(bool) - * - * Specify if the filter should use the optimized discrete fourier transform for - * real values. This will cause output columns to have from n to ((n / 2) + 1) rows. - * If OptimizeForRealInput is On but the input contains columns with 2 components, - * these columns will be ignored. - */ - VTK_DEPRECATED_IN_9_3_0("Function has been renamed GetReturnOnesided") - virtual bool GetOptimizeForRealInput() { return this->GetReturnOnesided(); } - VTK_DEPRECATED_IN_9_3_0("Function has been renamed SetReturnOnesided") - virtual void SetOptimizeForRealInput(bool _arg) { this->SetReturnOnesided(_arg); } - VTK_DEPRECATED_IN_9_3_0("Function has been renamed ReturnOnesidedOn") - virtual void OptimizeForRealInputOn() { this->ReturnOnesidedOn(); } - VTK_DEPRECATED_IN_9_3_0("Function has been renamed ReturnOnesidedOff") - virtual void OptimizeForRealInputOff() { this->ReturnOnesidedOff(); } - ///@} - - ///@{ - /** - * @deprecated in v9.3, in favor of the more intuitive API BlockOverlap and BlockSize. - * Does not have any effect anymore. - * - * @see vtkTableFFT::SetBlockSize(int) - * @see vtkTableFFT::SetBlockOverlap(int) - */ - VTK_DEPRECATED_IN_9_3_0( - "Block behavior is not controlled using BlockSize and BlockOverlap properties.") - virtual int GetNumberOfBlock() { return 0; } - VTK_DEPRECATED_IN_9_3_0( - "Block behavior is not controlled using BlockSize and BlockOverlap properties.") - virtual void SetNumberOfBlock(int) {} - ///@} - protected: vtkTableFFT(); ~vtkTableFFT() override; diff --git a/Filters/General/vtkTemporalPathLineFilter.cxx b/Filters/General/vtkTemporalPathLineFilter.cxx index deb1c76e559..aae6a0d290c 100644 --- a/Filters/General/vtkTemporalPathLineFilter.cxx +++ b/Filters/General/vtkTemporalPathLineFilter.cxx @@ -1,8 +1,6 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-FileCopyrightText: Copyright (c) CSCS - Swiss National Supercomputing Centre // SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings -#define VTK_DEPRECATION_LEVEL 0 #include "vtkTemporalPathLineFilter.h" #include "vtkArrayDispatch.h" @@ -217,18 +215,6 @@ int vtkTemporalPathLineFilter::FillOutputPortInformation(int port, vtkInformatio return 1; } -//------------------------------------------------------------------------------ -void vtkTemporalPathLineFilter::SetBackwardTime(bool backward) -{ - if (this->BackwardTime != backward) - { - this->LatestTime = backward ? 0 : LATEST_TIME_MAX; - this->BackwardTime = backward; - this->RunBackward = backward; - this->Modified(); - } -} - //------------------------------------------------------------------------------ void vtkTemporalPathLineFilter::SetSelectionConnection(vtkAlgorithmOutput* algOutput) { diff --git a/Filters/General/vtkTemporalPathLineFilter.h b/Filters/General/vtkTemporalPathLineFilter.h index fafbcd7be0d..12a82fb8fe9 100644 --- a/Filters/General/vtkTemporalPathLineFilter.h +++ b/Filters/General/vtkTemporalPathLineFilter.h @@ -24,7 +24,6 @@ #ifndef vtkTemporalPathLineFilter_h #define vtkTemporalPathLineFilter_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkFiltersGeneralModule.h" // For export macro #include "vtkPolyDataAlgorithm.h" #include "vtkTemporalAlgorithm.h" // For temporal algorithm @@ -125,22 +124,6 @@ public: vtkGetMacro(KeepDeadTrails, bool); ///@} - ///@{ - /** - * Set / Get if the filter is configured to work in backward time going mode. - * Default is false (time should go forward). - * - * Time going forward means that for each call to RequestData, then the time - * step from vtkDataObject::DATA_TIME_STEP() is greater than the time step - * from the previous call. Time going backward means that the current time - * step is smaller than the previous one. - */ - VTK_DEPRECATED_IN_9_3_0("Running backward will not be supported anymore.") - virtual void SetBackwardTime(bool backward); - VTK_DEPRECATED_IN_9_3_0("Running backward will not be supported anymore.") - vtkGetMacro(BackwardTime, bool); - ///@} - /** * Flush will wipe any existing data so that traces can be restarted from * whatever time step is next supplied. diff --git a/Filters/Geometry/vtkDataSetSurfaceFilter.cxx b/Filters/Geometry/vtkDataSetSurfaceFilter.cxx index 5538140864e..2f21a563510 100644 --- a/Filters/Geometry/vtkDataSetSurfaceFilter.cxx +++ b/Filters/Geometry/vtkDataSetSurfaceFilter.cxx @@ -2725,14 +2725,6 @@ vtkIdType vtkDataSetSurfaceFilter::GetOutputPointId( return outPtId; } -//------------------------------------------------------------------------------ -vtkIdType vtkDataSetSurfaceFilter::GetOutputPointIdAndInterpolate(vtkIdType cellPtId, - vtkDataSet* input, vtkCell* cell, double* weights, vtkPoints* outPts, vtkPointData* outPD) -{ - double* pc = cell->GetParametricCoords(); - return this->GetOutputPointIdAndInterpolate(cellPtId, input, cell, pc, weights, outPts, outPD); -} - //------------------------------------------------------------------------------ vtkIdType vtkDataSetSurfaceFilter::GetOutputPointIdAndInterpolate(vtkIdType cellPtId, vtkDataSet* input, vtkCell* cell, double* pc, double* weights, vtkPoints* outPts, diff --git a/Filters/Geometry/vtkDataSetSurfaceFilter.h b/Filters/Geometry/vtkDataSetSurfaceFilter.h index 24c7dcba433..d0a78d991e3 100644 --- a/Filters/Geometry/vtkDataSetSurfaceFilter.h +++ b/Filters/Geometry/vtkDataSetSurfaceFilter.h @@ -76,7 +76,6 @@ #ifndef vtkDataSetSurfaceFilter_h #define vtkDataSetSurfaceFilter_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkFiltersGeometryModule.h" // For export macro #include "vtkGeometryFilter.h" // To facilitate delegation #include "vtkPolyDataAlgorithm.h" @@ -326,10 +325,6 @@ protected: vtkIdType GetOutputPointId( vtkIdType inPtId, vtkDataSet* input, vtkPoints* outPts, vtkPointData* outPD); - VTK_DEPRECATED_IN_9_3_0("This function is deprecated since reserved for private usage.") - vtkIdType GetOutputPointIdAndInterpolate(vtkIdType inPtId, vtkDataSet* input, vtkCell* cell, - double* weights, vtkPoints* outPts, vtkPointData* outPD); - class vtkEdgeInterpolationMap; vtkEdgeInterpolationMap* EdgeMap; diff --git a/Filters/Geometry/vtkGeometryFilter.cxx b/Filters/Geometry/vtkGeometryFilter.cxx index cb0b8a5f837..aab882735a1 100644 --- a/Filters/Geometry/vtkGeometryFilter.cxx +++ b/Filters/Geometry/vtkGeometryFilter.cxx @@ -3388,40 +3388,6 @@ int ExecuteStructured(vtkGeometryFilter* self, vtkDataSet* input, vtkPolyData* o } } -//------------------------------------------------------------------------------ -int vtkGeometryFilter::StructuredExecute(vtkDataSet* input, vtkPolyData* output, - vtkInformation* inInfo, vtkPolyData* exc, bool* extractFace) -{ - int wholeExtent[6] = { 0, -1, 0, -1, 0, -1 }; - if (input->GetExtentType() == VTK_3D_EXTENT) - { - const int* wholeExt32; - if (inInfo) - { - wholeExt32 = inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()); - std::copy(wholeExt32, wholeExt32 + 6, wholeExtent); - } - } - return this->StructuredExecute(input, output, wholeExtent, exc, extractFace); -} - -//------------------------------------------------------------------------------ -int vtkGeometryFilter::StructuredExecute( - vtkDataSet* input, vtkPolyData* output, vtkInformation* inInfo, bool* extractFace) -{ - int wholeExtent[6] = { 0, -1, 0, -1, 0, -1 }; - if (input->GetExtentType() == VTK_3D_EXTENT) - { - const int* wholeExt32; - if (inInfo) - { - wholeExt32 = inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT()); - std::copy(wholeExt32, wholeExt32 + 6, wholeExtent); - } - } - return this->StructuredExecute(input, output, wholeExtent, extractFace); -} - //------------------------------------------------------------------------------ int vtkGeometryFilter::StructuredExecute(vtkDataSet* input, vtkPolyData* output, int* wholeExtent, vtkPolyData* excludedFaces, bool* extractFace) diff --git a/Filters/Geometry/vtkGeometryFilter.h b/Filters/Geometry/vtkGeometryFilter.h index a000a09b171..ac3c2bdf453 100644 --- a/Filters/Geometry/vtkGeometryFilter.h +++ b/Filters/Geometry/vtkGeometryFilter.h @@ -396,14 +396,8 @@ public: vtkDataSet* input, vtkPolyData* output, vtkGeometryFilterHelper* info, vtkPolyData* exc); virtual int UnstructuredGridExecute(vtkDataSet* input, vtkPolyData* output); - VTK_DEPRECATED_IN_9_3_0("Use the new version that has int* instead of vtkInformation*") - int StructuredExecute(vtkDataSet* input, vtkPolyData* output, vtkInformation* inInfo, - vtkPolyData* exc, bool* extractFace = nullptr); int StructuredExecute(vtkDataSet* input, vtkPolyData* output, int* wholeExtent, vtkPolyData* exc, bool* extractFace = nullptr); - VTK_DEPRECATED_IN_9_3_0("Use the new version that has int* instead of vtkInformation*") - virtual int StructuredExecute( - vtkDataSet* input, vtkPolyData* output, vtkInformation* inInfo, bool* extractFace = nullptr); virtual int StructuredExecute( vtkDataSet* input, vtkPolyData* output, int* wholeExt, bool* extractFace = nullptr); diff --git a/Filters/HyperTree/vtkHyperTreeGridGradient.h b/Filters/HyperTree/vtkHyperTreeGridGradient.h index 3dd572efc5c..3109ec77151 100644 --- a/Filters/HyperTree/vtkHyperTreeGridGradient.h +++ b/Filters/HyperTree/vtkHyperTreeGridGradient.h @@ -27,7 +27,6 @@ #include "vtkFiltersHyperTreeModule.h" // For export macro -#include "vtkDeprecation.h" // for deprecatin S/GetRenderWindow #include "vtkHyperTreeGridAlgorithm.h" #include "vtkNew.h" // for internal fields #include "vtkSmartPointer.h" // for internal fields @@ -70,10 +69,6 @@ public: */ vtkSetStringMacro(GradientArrayName); vtkGetStringMacro(GradientArrayName); - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous SetGradientArrayName method instead.") - void SetResultArrayName(std::string name) { this->SetGradientArrayName(name.c_str()); } - VTK_DEPRECATED_IN_9_3_0("Please use unambiguous GetGradientArrayName method instead.") - std::string GetResultArrayName() { return std::string(this->GetGradientArrayName()); } ///@} ///@{ diff --git a/Filters/HyperTree/vtkHyperTreeGridThreshold.h b/Filters/HyperTree/vtkHyperTreeGridThreshold.h index 2d1b0d304e5..c9b51c4f22a 100644 --- a/Filters/HyperTree/vtkHyperTreeGridThreshold.h +++ b/Filters/HyperTree/vtkHyperTreeGridThreshold.h @@ -27,7 +27,6 @@ #ifndef vtkHyperTreeGridThreshold_h #define vtkHyperTreeGridThreshold_h -#include "vtkDeprecation.h" // For deprecation macros #include "vtkFiltersHyperTreeModule.h" // For export macro #include "vtkHyperTreeGridAlgorithm.h" @@ -47,19 +46,6 @@ public: vtkTypeMacro(vtkHyperTreeGridThreshold, vtkHyperTreeGridAlgorithm); void PrintSelf(ostream& os, vtkIndent indent) override; - ///@{ - /** - * Set/Get True, sets the MemoryStrategy to MaskInput ; False, does nothing now prefer - * SetMemoryStrategy. - * - * Default is technically true - */ - VTK_DEPRECATED_IN_9_3_0("JustCreateNewMask is deprecated in favor of MemoryStrategy") - virtual void SetJustCreateNewMask(bool) {} - VTK_DEPRECATED_IN_9_3_0("JustCreateNewMask is deprecated in favor of MemoryStrategy") - virtual bool GetJustCreateNewMask() { return (this->GetMemoryStrategy() == MaskInput); } - ///@} - ///@{ /** * Set/Get minimum scalar value of threshold diff --git a/Filters/Parallel/CMakeLists.txt b/Filters/Parallel/CMakeLists.txt index 4a8371510a9..5fb83c8bd6e 100644 --- a/Filters/Parallel/CMakeLists.txt +++ b/Filters/Parallel/CMakeLists.txt @@ -23,7 +23,6 @@ set(classes vtkPHyperTreeGridProbeFilter vtkIntegrateAttributes vtkPeriodicFilter - vtkPCellDataToPointData vtkPConvertToMultiBlockDataSet vtkPExtractDataArraysOverTime vtkPExtractExodusGlobalTemporalVariables @@ -44,7 +43,6 @@ set(classes vtkPReflectionFilter vtkPResampleFilter vtkPartitionBalancer - vtkProcessIdScalars vtkPSphereSource vtkPTextureMapToSphere vtkPYoungsMaterialInterface diff --git a/Filters/Parallel/vtkPCellDataToPointData.cxx b/Filters/Parallel/vtkPCellDataToPointData.cxx deleted file mode 100644 index ccc6b48ff80..00000000000 --- a/Filters/Parallel/vtkPCellDataToPointData.cxx +++ /dev/null @@ -1,13 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkPCellDataToPointData.h" -#include "vtkObjectFactory.h" - -VTK_ABI_NAMESPACE_BEGIN - -vtkStandardNewMacro(vtkPCellDataToPointData); - -VTK_ABI_NAMESPACE_END diff --git a/Filters/Parallel/vtkPCellDataToPointData.h b/Filters/Parallel/vtkPCellDataToPointData.h deleted file mode 100644 index 8808f967969..00000000000 --- a/Filters/Parallel/vtkPCellDataToPointData.h +++ /dev/null @@ -1,39 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class vtkPCellDataToPointData - * @brief Compute point arrays from cell arrays. - * - * This class is deprecated. Use `vtkCellDataToPointData` which now supports - * the `PieceInvariant` flag. - */ - -#ifndef vtkPCellDataToPointData_h -#define vtkPCellDataToPointData_h - -#include "vtkCellDataToPointData.h" -#include "vtkDeprecation.h" // For `VTK_DEPRECATED_IN_9_3_0` -#include "vtkFiltersParallelModule.h" // For export macro - -VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0( - "Please use vtkCellDataToPointData instead") VTKFILTERSPARALLEL_EXPORT vtkPCellDataToPointData - : public vtkCellDataToPointData -{ -public: - vtkTypeMacro(vtkPCellDataToPointData, vtkCellDataToPointData); - - static vtkPCellDataToPointData* New(); - -protected: - vtkPCellDataToPointData() = default; - ~vtkPCellDataToPointData() override = default; - -private: - vtkPCellDataToPointData(const vtkPCellDataToPointData&) = delete; - void operator=(const vtkPCellDataToPointData&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif -// VTK-HeaderTest-Exclude: vtkPCellDataToPointData.h diff --git a/Filters/Parallel/vtkProcessIdScalars.cxx b/Filters/Parallel/vtkProcessIdScalars.cxx deleted file mode 100644 index 8176e6ddf12..00000000000 --- a/Filters/Parallel/vtkProcessIdScalars.cxx +++ /dev/null @@ -1,158 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkProcessIdScalars.h" - -#include "vtkCellData.h" -#include "vtkDataSet.h" -#include "vtkFloatArray.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkIntArray.h" -#include "vtkMath.h" -#include "vtkMultiProcessController.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkStreamingDemandDrivenPipeline.h" - -VTK_ABI_NAMESPACE_BEGIN -vtkStandardNewMacro(vtkProcessIdScalars); - -vtkCxxSetObjectMacro(vtkProcessIdScalars, Controller, vtkMultiProcessController); - -//------------------------------------------------------------------------------ -vtkProcessIdScalars::vtkProcessIdScalars() -{ - this->CellScalarsFlag = 0; - this->RandomMode = 0; - - this->Controller = vtkMultiProcessController::GetGlobalController(); - if (this->Controller) - { - this->Controller->Register(this); - } -} - -//------------------------------------------------------------------------------ -vtkProcessIdScalars::~vtkProcessIdScalars() -{ - if (this->Controller) - { - this->Controller->Delete(); - this->Controller = nullptr; - } -} - -//------------------------------------------------------------------------------ -// Append data sets into single unstructured grid -int vtkProcessIdScalars::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** inputVector, vtkInformationVector* outputVector) -{ - // get the info objects - vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); - vtkInformation* outInfo = outputVector->GetInformationObject(0); - - // get the input and output - vtkDataSet* input = vtkDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkDataSet* output = vtkDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); - - vtkDataArray* pieceColors; - vtkIdType num; - - if (this->CellScalarsFlag) - { - num = input->GetNumberOfCells(); - } - else - { - num = input->GetNumberOfPoints(); - } - - int piece = (this->Controller ? this->Controller->GetLocalProcessId() : 0); - - if (this->RandomMode) - { - pieceColors = this->MakeRandomScalars(piece, num); - } - else - { - pieceColors = this->MakeProcessIdScalars(piece, num); - } - - output->ShallowCopy(input); - pieceColors->SetName("ProcessId"); - if (this->CellScalarsFlag) - { - output->GetCellData()->AddArray(pieceColors); - output->GetCellData()->SetActiveScalars(pieceColors->GetName()); - } - else - { - output->GetPointData()->AddArray(pieceColors); - output->GetPointData()->SetActiveScalars(pieceColors->GetName()); - } - - pieceColors->Delete(); - - return 1; -} - -//------------------------------------------------------------------------------ -vtkIntArray* vtkProcessIdScalars::MakeProcessIdScalars(int piece, vtkIdType num) -{ - vtkIntArray* pieceColors = vtkIntArray::New(); - pieceColors->SetNumberOfTuples(num); - - for (vtkIdType i = 0; i < num; ++i) - { - pieceColors->SetValue(i, piece); - } - - return pieceColors; -} - -//------------------------------------------------------------------------------ -vtkFloatArray* vtkProcessIdScalars::MakeRandomScalars(int piece, vtkIdType num) -{ - vtkMath::RandomSeed(piece); - float randomValue = vtkMath::Random(); - - vtkFloatArray* pieceColors = vtkFloatArray::New(); - pieceColors->SetNumberOfTuples(num); - - for (vtkIdType i = 0; i < num; ++i) - { - pieceColors->SetValue(i, randomValue); - } - - return pieceColors; -} - -//------------------------------------------------------------------------------ -void vtkProcessIdScalars::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - - os << indent << "RandomMode: " << this->RandomMode << endl; - if (this->CellScalarsFlag) - { - os << indent << "ScalarMode: CellData\n"; - } - else - { - os << indent << "ScalarMode: PointData\n"; - } - - os << indent << "Controller: "; - if (this->Controller) - { - this->Controller->PrintSelf(os, indent.GetNextIndent()); - } - else - { - os << "(none)" << endl; - } -} -VTK_ABI_NAMESPACE_END diff --git a/Filters/Parallel/vtkProcessIdScalars.h b/Filters/Parallel/vtkProcessIdScalars.h deleted file mode 100644 index f39f1c7f595..00000000000 --- a/Filters/Parallel/vtkProcessIdScalars.h +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class vtkProcessIdScalars - * @brief Sets cell or point scalars to the processor rank. - * - * - * vtkProcessIdScalars is meant to display which processor owns which cells - * and points. It is useful for visualizing the partitioning for - * streaming or distributed pipelines. - * - * @sa - * vtkPolyDataStreamer vtkGenerateProcessIds - */ - -#ifndef vtkProcessIdScalars_h -#define vtkProcessIdScalars_h - -#include "vtkDataSetAlgorithm.h" -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 -#include "vtkFiltersParallelModule.h" // For export macro - -VTK_ABI_NAMESPACE_BEGIN -class vtkFloatArray; -class vtkIntArray; -class vtkMultiProcessController; - -class VTK_DEPRECATED_IN_9_3_0( - "Use `vtkGenerateProcessIds` instead") VTKFILTERSPARALLEL_EXPORT vtkProcessIdScalars - : public vtkDataSetAlgorithm -{ -public: - static vtkProcessIdScalars* New(); - - vtkTypeMacro(vtkProcessIdScalars, vtkDataSetAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) override; - - ///@{ - /** - * Option to centerate cell scalars of points scalars. Default is point - * scalars (0). - */ - void SetScalarModeToCellData() { this->SetCellScalarsFlag(1); } - void SetScalarModeToPointData() { this->SetCellScalarsFlag(0); } - vtkSetMacro(CellScalarsFlag, int); - int GetScalarMode() { return this->CellScalarsFlag; } - ///@} - - ///@{ - /** - * This option uses a random mapping between pieces and scalar values. - * The scalar values are chosen between 0 and 1. By default, random - * mode is off. - */ - vtkSetMacro(RandomMode, vtkTypeBool); - vtkGetMacro(RandomMode, vtkTypeBool); - vtkBooleanMacro(RandomMode, vtkTypeBool); - ///@} - - ///@{ - /** - * By default this filter uses the global controller, - * but this method can be used to set another instead. - */ - virtual void SetController(vtkMultiProcessController*); - vtkGetObjectMacro(Controller, vtkMultiProcessController); - ///@} - -protected: - vtkProcessIdScalars(); - ~vtkProcessIdScalars() override; - - // Append the pieces. - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - - vtkIntArray* MakeProcessIdScalars(int piece, vtkIdType numScalars); - vtkFloatArray* MakeRandomScalars(int piece, vtkIdType numScalars); - - int CellScalarsFlag; - vtkTypeBool RandomMode; - - vtkMultiProcessController* Controller; - -private: - vtkProcessIdScalars(const vtkProcessIdScalars&) = delete; - void operator=(const vtkProcessIdScalars&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif diff --git a/Filters/Sources/CMakeLists.txt b/Filters/Sources/CMakeLists.txt index c2547161f9c..2095d6061e1 100644 --- a/Filters/Sources/CMakeLists.txt +++ b/Filters/Sources/CMakeLists.txt @@ -2,7 +2,6 @@ set(classes vtkArcSource vtkArrowSource vtkButtonSource - vtkCapsuleSource vtkCellTypeSource vtkConeSource vtkCubeSource diff --git a/Filters/Sources/vtkCapsuleSource.cxx b/Filters/Sources/vtkCapsuleSource.cxx deleted file mode 100644 index eafc397efe8..00000000000 --- a/Filters/Sources/vtkCapsuleSource.cxx +++ /dev/null @@ -1,339 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. -// SPDX-License-Identifier: BSD-3-Clause AND Apache-2.0 - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 -#include "vtkCapsuleSource.h" - -#include "vtkCellArray.h" -#include "vtkFloatArray.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkMath.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkPoints.h" -#include "vtkPolyData.h" -#include "vtkStreamingDemandDrivenPipeline.h" - -#include <cmath> - -VTK_ABI_NAMESPACE_BEGIN -vtkStandardNewMacro(vtkCapsuleSource); - -//------------------------------------------------------------------------------ -vtkCapsuleSource::vtkCapsuleSource(int res) -{ - res = res < 8 ? 8 : res; - this->Radius = 0.5; - this->Center[0] = 0.0; - this->Center[1] = 0.0; - this->Center[2] = 0.0; - this->ThetaResolution = res; - this->PhiResolution = res; - this->LatLongTessellation = 0; - this->CylinderLength = 1.0; - this->OutputPointsPrecision = vtkAlgorithm::DEFAULT_PRECISION; - this->SetNumberOfInputPorts(0); -} - -namespace -{ -//------------------------------------------------------------------------------ -void InsertPole( - vtkPoints* points, vtkFloatArray* normals, double center[3], double radius, double halfHeight) -{ - double x[3]; - x[0] = center[0]; - x[1] = center[1] + halfHeight; - x[2] = center[2] + radius; - points->InsertNextPoint(x); - x[0] = x[1] = 0.0; - x[2] = radius > 0 ? 1.0 : -1.0; - normals->InsertNextTuple(x); -} - -//------------------------------------------------------------------------------ -void FillHalfSphere(vtkPoints* points, vtkFloatArray* normals, double thetaResolution, - double phiResolution, double startAngle, double sign, double center[3], double radius, - double halfHeight) -{ - double n[3], x[3], norm; - const double deltaTheta = vtkMath::Pi() / (thetaResolution - 1); - const double deltaPhi = vtkMath::Pi() / (phiResolution - 1); - for (int i = 0; i < thetaResolution; ++i) - { - const double theta = startAngle + sign * i * deltaTheta; - for (int j = 1; j < phiResolution - 1; ++j) - { - const double phi = j * deltaPhi; - const double r = radius * std::sin(phi); - n[0] = r * std::cos(theta); - n[1] = r * std::sin(theta); - n[2] = radius * std::cos(phi); - x[0] = n[0] + center[0]; - x[1] = n[1] + center[1] + halfHeight; - x[2] = n[2] + center[2]; - points->InsertNextPoint(x); - if ((norm = vtkMath::Norm(n)) == 0.0) - { - norm = 1.0; - } - n[0] /= norm; - n[1] /= norm; - n[2] /= norm; - normals->InsertNextTuple(n); - } - } -} - -//------------------------------------------------------------------------------ -void ConnectCylinderSide(vtkCellArray* faces, int minusPoleId, int plusPoleId, int clockwise, - int increment, int quadrangle) -{ - vtkIdType pts[4]; - for (int i = 0; i < increment; ++i) - { - pts[0] = minusPoleId + clockwise * i; - pts[1] = plusPoleId + clockwise * i; - - if (quadrangle != 0) - { - pts[2] = pts[0] + clockwise; - faces->InsertNextCell(3, pts); - - pts[0] = pts[2]; - pts[2] = pts[1] + clockwise; - faces->InsertNextCell(3, pts); - } - else - { - pts[2] = pts[1] + clockwise; - pts[3] = pts[0] + clockwise; - faces->InsertNextCell(4, pts); - } - } -} -} - -//------------------------------------------------------------------------------ -int vtkCapsuleSource::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) -{ - vtkInformation* outInfo = outputVector->GetInformationObject(0); - vtkPolyData* output = vtkPolyData::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); - vtkPoints* newPoints; - vtkFloatArray* newNormals; - vtkCellArray* newPolys; - // Set number of points. - const int halfSphereNumPts = (this->PhiResolution - 2) * this->ThetaResolution + 2; - const int numPts = halfSphereNumPts * 2; - // Set number of faces. - const int halfSpheresNumsPolys = - (this->ThetaResolution - 1) * 2 + (this->PhiResolution - 3) * (this->ThetaResolution - 1) * 2; - const int cylinderNumPolys = (this->PhiResolution - 1) * 4; - const int numPolys = halfSpheresNumsPolys * 2 + cylinderNumPolys; - // Allocate. - newPoints = vtkPoints::New(); - if (this->OutputPointsPrecision == vtkAlgorithm::DOUBLE_PRECISION) - { - newPoints->SetDataType(VTK_DOUBLE); - } - else - { - newPoints->SetDataType(VTK_FLOAT); - } - newPoints->Allocate(numPts); - newNormals = vtkFloatArray::New(); - newNormals->SetNumberOfComponents(3); - newNormals->Allocate(numPts * 3); - newNormals->SetName("Normals"); - newPolys = vtkCellArray::New(); - newPolys->Allocate(newPolys->EstimateSize(numPolys, 3)); - // Create half sphere 1, plus side. - const double halfHeight = this->CylinderLength * 0.5; - // North pole. - InsertPole(newPoints, newNormals, this->Center, this->Radius, halfHeight); - this->UpdateProgress(0.05); - // Create intermediate points. - FillHalfSphere(newPoints, newNormals, this->ThetaResolution, this->PhiResolution, 0.0, 1.0, - this->Center, this->Radius, halfHeight); - this->UpdateProgress(0.255); - // South pole. - InsertPole(newPoints, newNormals, this->Center, -1 * this->Radius, halfHeight); - this->UpdateProgress(0.3); // First half sphere done. - // Create half sphere 2, minus side. - // North pole. - InsertPole(newPoints, newNormals, this->Center, this->Radius, -1 * halfHeight); - this->UpdateProgress(0.305); - // Create intermediate points. - FillHalfSphere(newPoints, newNormals, this->ThetaResolution, this->PhiResolution, - vtkMath::Pi() * 2.0, -1, this->Center, this->Radius, -1.0 * halfHeight); - this->UpdateProgress(0.555); - // South pole. - InsertPole(newPoints, newNormals, this->Center, -1 * this->Radius, -1 * halfHeight); - this->UpdateProgress(0.6); // Second half sphere done. - // Generate mesh connectivity. - vtkIdType pts[4]; - // Increment represent how many ids have passed every time we change by one delta theta. - const int increment = this->PhiResolution - 2; - // Ids of the poles. - const int northPoleMinusId = 0; - const int southPoleMinusId = halfSphereNumPts - 1; - const int northPolePlusId = halfSphereNumPts; - const int southPolePlusId = numPts - 1; - // First half sphere. - // Connect the minus side half sphere north pole. - for (int i = 0; i < this->ThetaResolution - 1; ++i) - { - pts[0] = northPoleMinusId; - pts[1] = (i * increment) + 1; - pts[2] = pts[1] + increment; - newPolys->InsertNextCell(3, pts); - } - this->UpdateProgress(0.605); - // South pole connectivity. - for (int i = 1; i < this->ThetaResolution; ++i) - { - pts[0] = i * increment; - pts[1] = southPoleMinusId; - pts[2] = pts[0] + increment; - newPolys->InsertNextCell(3, pts); - } - this->UpdateProgress(0.75); // First half-sphere done. - // Second half sphere. - // North pole connectivity. - for (int i = 0; i < this->ThetaResolution - 1; ++i) - { - pts[2] = northPolePlusId; - pts[1] = (i * increment) + 1 + northPolePlusId; - pts[0] = pts[1] + increment; - newPolys->InsertNextCell(3, pts); - } - this->UpdateProgress(0.755); - // South pole connectivity. - for (int i = 1; i < this->ThetaResolution; ++i) - { - pts[0] = northPolePlusId + i * increment; - pts[2] = southPolePlusId; - pts[1] = pts[0] + increment; - newPolys->InsertNextCell(3, pts); - } - this->UpdateProgress(0.9); - // Both half sphere at the same time, connectivity of the band. - vtkIdType ptsOtherSide[4]; - for (int i = 1; i < northPolePlusId - 1 - increment; i += increment) - { - for (int j = 0; j < increment - 1; ++j) - { - pts[0] = j + i; - pts[1] = j + i + 1; - pts[2] = j + i + increment + 1; - ptsOtherSide[0] = pts[0] + northPolePlusId; - ptsOtherSide[1] = pts[2] + northPolePlusId; - ptsOtherSide[2] = pts[1] + northPolePlusId; - if (!this->LatLongTessellation) - { - newPolys->InsertNextCell(3, pts); - newPolys->InsertNextCell(3, ptsOtherSide); - pts[1] = pts[2]; - pts[2] = j + i + increment; - ptsOtherSide[1] = pts[2] + northPolePlusId; - ptsOtherSide[2] = pts[1] + northPolePlusId; - newPolys->InsertNextCell(3, pts); - newPolys->InsertNextCell(3, ptsOtherSide); - } - else - { - pts[3] = j + i + increment; - ptsOtherSide[1] = pts[3] + northPolePlusId; - ptsOtherSide[3] = ptsOtherSide[2]; - ptsOtherSide[2] = pts[2] + northPolePlusId; - newPolys->InsertNextCell(4, pts); - newPolys->InsertNextCell(4, ptsOtherSide); - } - } - } - // Cylinder pole connectivity. - // First side. - ConnectCylinderSide( - newPolys, northPoleMinusId, northPolePlusId, 1, increment, this->LatLongTessellation); - // Second side. - ConnectCylinderSide( - newPolys, southPoleMinusId, southPolePlusId, -1, increment, this->LatLongTessellation); - this->UpdateProgress(0.99); - // Weird south pole minus face case. - pts[0] = northPoleMinusId + increment; - pts[1] = northPolePlusId + increment; - if (!this->LatLongTessellation) - { - pts[2] = southPoleMinusId; - newPolys->InsertNextCell(3, pts); - pts[0] = pts[1]; - pts[1] = southPolePlusId; - newPolys->InsertNextCell(3, pts); - } - else - { - pts[2] = southPolePlusId; - pts[3] = southPoleMinusId; - newPolys->InsertNextCell(4, pts); - } - // Weird north pole 2 face case. - pts[0] = southPoleMinusId - increment; - pts[1] = southPolePlusId - increment; - if (!this->LatLongTessellation) - { - pts[2] = northPoleMinusId; - newPolys->InsertNextCell(3, pts); - pts[0] = pts[1]; - pts[1] = northPolePlusId; - newPolys->InsertNextCell(3, pts); - } - else - { - pts[2] = northPolePlusId; - pts[3] = northPoleMinusId; - newPolys->InsertNextCell(4, pts); - } - // Update ourselves and release memory. - newPoints->Squeeze(); - output->SetPoints(newPoints); - newPoints->Delete(); - newNormals->Squeeze(); - output->GetPointData()->SetNormals(newNormals); - newNormals->Delete(); - newPolys->Squeeze(); - output->SetPolys(newPolys); - newPolys->Delete(); - return 1; -} - -//------------------------------------------------------------------------------ -void vtkCapsuleSource::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "Center: (" << this->Center[0] << ", " << this->Center[1] << ", " - << this->Center[2] << ")" << std::endl; - os << indent << "CylinderLength: " << this->CylinderLength << std::endl; - os << indent << "LatLongTessellation: " << this->LatLongTessellation << std::endl; - os << indent << "PhiResolution: " << this->PhiResolution << std::endl; - os << indent << "ThetaResolution: " << this->ThetaResolution << std::endl; - os << indent << "Radius: " << this->Radius << std::endl; -} - -//------------------------------------------------------------------------------ -int vtkCapsuleSource::RequestInformation(vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) -{ - vtkInformation* outInfo = outputVector->GetInformationObject(0); - outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(), -1); - const double halfLength = this->CylinderLength * 0.5; - outInfo->Set(vtkStreamingDemandDrivenPipeline::BOUNDS(), - this->Center[0] - this->Radius - halfLength, this->Center[0] + this->Radius + halfLength, - this->Center[1] - this->Radius, this->Center[1] + this->Radius, this->Center[2] - this->Radius, - this->Center[2] + this->Radius); - return 1; -} -VTK_ABI_NAMESPACE_END diff --git a/Filters/Sources/vtkCapsuleSource.h b/Filters/Sources/vtkCapsuleSource.h deleted file mode 100644 index b8f31252299..00000000000 --- a/Filters/Sources/vtkCapsuleSource.h +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-FileCopyrightText: Copyright (c) Kitware Inc. -// SPDX-License-Identifier: BSD-3-Clause AND Apache-2.0 -/** - * @class vtkCapsuleSource - * @brief Generate a capsule centered at the origin - * - * vtkCapsuleSource creates a capsule (represented by polygons) of specified - * radius centered at the origin. The resolution (polygonal discretization) in - * both the latitude (phi) and longitude (theta) directions can be specified as - * well as the length of the capsule cylinder (CylinderLength). By default, the - * surface tessellation of the sphere uses triangles; however you can set - * LatLongTessellation to produce a tessellation using quadrilaterals (except - * at the poles of the capsule). - */ - -#ifndef vtkCapsuleSource_h -#define vtkCapsuleSource_h - -#include "vtkDeprecation.h" // For deprecation macros -#include "vtkFiltersSourcesModule.h" // For export macro -#include "vtkPolyDataAlgorithm.h" - -#include "vtkSphereSource.h" // For VTK_MAX_SPHERE_RESOLUTION - -VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0( - "Use vtkCylinderSource with SetCapping(true) and SetCapsuleCap(true) instead of " - "vtkCapsuleSource.") VTKFILTERSSOURCES_EXPORT vtkCapsuleSource : public vtkPolyDataAlgorithm -{ -public: - vtkTypeMacro(vtkCapsuleSource, vtkPolyDataAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) override; - - /** - * Construct a capsule with radius 0.5 and resolution 8 in both the Phi and Theta directions and a - * cylinder of length 1.0. - */ - static vtkCapsuleSource* New(); - - ///@{ - /** - * Set/get the radius of the capsule. The initial value is 0.5. - */ - vtkSetClampMacro(Radius, double, 0.0, VTK_DOUBLE_MAX); - vtkGetMacro(Radius, double); - ///@} - - ///@{ - /** - * Set/get the center of the capsule. The initial value is (0.0, 0.0, 0.0). - */ - vtkSetVector3Macro(Center, double); - vtkGetVectorMacro(Center, double, 3); - ///@} - - ///@{ - /** - * Set/get the length of the cylinder. The initial value is 1.0. - */ - vtkSetClampMacro(CylinderLength, double, 0.0, VTK_DOUBLE_MAX); - vtkGetMacro(CylinderLength, double); - ///@} - - ///@{ - /** - * Set/get the number of points in the longitude direction for the spheres. The initial value - * is 8. - */ - vtkSetClampMacro(ThetaResolution, int, 8, VTK_INT_MAX); - vtkGetMacro(ThetaResolution, int); - ///@} - - ///@{ - /** - * Set/get the number of points in the latitude direction for the spheres. The initial value is 8. - */ - vtkSetClampMacro(PhiResolution, int, 8, VTK_INT_MAX); - vtkGetMacro(PhiResolution, int); - ///@} - - ///@{ - /** - * Cause the spheres to be tessellated with edges along the latitude and longitude lines. If off, - * triangles are generated at non-polar regions, which results in edges that are not parallel to - * latitude and longitude lines. If on, quadrilaterals are generated everywhere except at the - * poles. This can be useful for generating wireframe spheres with natural latitude and longitude - * lines. - */ - vtkSetMacro(LatLongTessellation, int); - vtkGetMacro(LatLongTessellation, int); - vtkBooleanMacro(LatLongTessellation, int); - ///@} - - ///@{ - /** - * Set/get the desired precision for the output points. - * vtkAlgorithm::SINGLE_PRECISION - Output single-precision floating point. - * vtkAlgorithm::DOUBLE_PRECISION - Output double-precision floating point. - */ - vtkSetMacro(OutputPointsPrecision, int); - vtkGetMacro(OutputPointsPrecision, int); - ///@} - -protected: - vtkCapsuleSource(int res = 8); - ~vtkCapsuleSource() override = default; - - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - int RequestInformation(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - - double Radius; - double Center[3]; - int ThetaResolution; - int PhiResolution; - int LatLongTessellation; - int FillPoles; - double CylinderLength; - int OutputPointsPrecision; - -private: - vtkCapsuleSource(const vtkCapsuleSource&) = delete; - void operator=(const vtkCapsuleSource&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif diff --git a/GUISupport/QtQuick/CMakeLists.txt b/GUISupport/QtQuick/CMakeLists.txt index dc8b352806a..d78de588471 100644 --- a/GUISupport/QtQuick/CMakeLists.txt +++ b/GUISupport/QtQuick/CMakeLists.txt @@ -1,8 +1,4 @@ set(classes - QQuickVTKInteractiveWidget - QQuickVTKInteractorAdapter - QQuickVTKRenderItem - QQuickVTKRenderWindow QQuickVTKItem ) @@ -32,13 +28,7 @@ foreach (_qt_comp IN LISTS qt_components) "Qt${vtk_qt_major_version}::${_qt_comp}") endforeach () -# silence warnings from classes with VTK_DEPRECATED_IN_9_3_0 -set_source_files_properties( - ${CMAKE_CURRENT_BINARY_DIR}/GUISupportQtQuick_autogen/mocs_compilation.cpp - PROPERTIES COMPILE_DEFINITIONS VTK_DEPRECATION_LEVEL=0) - vtk_module_definitions(VTK::GUISupportQtQuick PRIVATE QT_NO_KEYWORDS) vtk_module_link(VTK::GUISupportQtQuick PUBLIC ${qt_modules}) -add_subdirectory(qml) vtk_add_test_mangling(VTK::GUISupportQtQuick) diff --git a/GUISupport/QtQuick/QQuickVTKInteractiveWidget.cxx b/GUISupport/QtQuick/QQuickVTKInteractiveWidget.cxx deleted file mode 100644 index 39f7d7f49bc..00000000000 --- a/GUISupport/QtQuick/QQuickVTKInteractiveWidget.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// this class is deprecated, don't warn about deprecated classes it uses -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKInteractiveWidget.h" - -// vtk includes -#include "vtkAbstractWidget.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkWidgetRepresentation.h" - -//------------------------------------------------------------------------------------------------- -VTK_ABI_NAMESPACE_BEGIN -QQuickVTKInteractiveWidget::QQuickVTKInteractiveWidget(QObject* parent) - : Superclass(parent) -{ -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractiveWidget::setWidget(vtkAbstractWidget* w) -{ - this->m_widget = w; -} - -//------------------------------------------------------------------------------------------------- -vtkAbstractWidget* QQuickVTKInteractiveWidget::widget() const -{ - return this->m_widget; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractiveWidget::setEnabled(bool e) -{ - if (this->m_enabled == e) - { - return; - } - - this->m_enabled = e; - Q_EMIT this->enabledChanged(this->m_enabled); -} - -//------------------------------------------------------------------------------------------------- -bool QQuickVTKInteractiveWidget::enabled() const -{ - return this->m_enabled; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractiveWidget::sync(vtkRenderer* ren) -{ - if (!ren || !this->m_widget) - { - return; - } - - auto iren = ren->GetRenderWindow()->GetInteractor(); - this->m_widget->SetInteractor(iren); - this->m_widget->SetCurrentRenderer(ren); - this->m_widget->SetEnabled(this->m_enabled); - this->m_widget->SetProcessEvents(this->m_enabled); -} -VTK_ABI_NAMESPACE_END diff --git a/GUISupport/QtQuick/QQuickVTKInteractiveWidget.h b/GUISupport/QtQuick/QQuickVTKInteractiveWidget.h deleted file mode 100644 index beea4816d82..00000000000 --- a/GUISupport/QtQuick/QQuickVTKInteractiveWidget.h +++ /dev/null @@ -1,75 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class QQuickVTKInteractiveWidget - * @brief QObject that manages a VTK interactive widget to ensure that it behaves as per the QtQuick - * threaded render loop. - * - * QQuickVTKInteractiveWidget holds a weak reference to the vtk widget it manages. - */ - -#ifndef QQuickVTKInteractiveWidget_h -#define QQuickVTKInteractiveWidget_h - -// Qt includes -#include <QObject> - -// vtk includes -#include "vtkDeprecation.h" -#include "vtkGUISupportQtQuickModule.h" // for export macro -#include "vtkWeakPointer.h" // For vtkWeakPointer - -// Forward declarations -VTK_ABI_NAMESPACE_BEGIN -class vtkAbstractWidget; -class vtkRenderer; - -class VTK_DEPRECATED_IN_9_3_0( - "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKInteractiveWidget - : public QObject -{ - Q_OBJECT - typedef QObject Superclass; - - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged); - -public: - QQuickVTKInteractiveWidget(QObject* parent = nullptr); - ~QQuickVTKInteractiveWidget() override = default; - - ///@{ - /** - * Set/Get the widget reference - */ - void setWidget(vtkAbstractWidget* w); - vtkAbstractWidget* widget() const; - ///@} - - ///@{ - /** - * Set/Get whether the widget is enabled. - */ - void setEnabled(bool e); - bool enabled() const; - ///@} - -public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers) - virtual void sync(vtkRenderer* ren); - -Q_SIGNALS: - void enabledChanged(bool e); - -protected: - // Helper members - vtkWeakPointer<vtkAbstractWidget> m_widget; - - // Enabled/disabled - bool m_enabled = false; - -private: - QQuickVTKInteractiveWidget(const QQuickVTKInteractiveWidget&) = delete; - void operator=(const QQuickVTKInteractiveWidget) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif // QQuickVTKInteractiveWidget_h diff --git a/GUISupport/QtQuick/QQuickVTKInteractorAdapter.cxx b/GUISupport/QtQuick/QQuickVTKInteractorAdapter.cxx deleted file mode 100644 index 685bae4bf6c..00000000000 --- a/GUISupport/QtQuick/QQuickVTKInteractorAdapter.cxx +++ /dev/null @@ -1,155 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// this class is deprecated, don't warn about deprecated classes it uses -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKInteractorAdapter.h" - -// Qt includes -#include <QEvent> -#include <QQuickItem> -#include <QQuickWindow> - -// VTK includes -#include "vtkRenderWindowInteractor.h" - -//------------------------------------------------------------------------------------------------- -VTK_ABI_NAMESPACE_BEGIN -QQuickVTKInteractorAdapter::QQuickVTKInteractorAdapter(QObject* parent) - : Superclass(parent) -{ -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::setQQuickWindow(QQuickWindow* win) -{ - m_qwindow = win; -} - -//------------------------------------------------------------------------------------------------- -QPointF QQuickVTKInteractorAdapter::mapEventPosition(QQuickItem* item, const QPointF& localPos) -{ - // Account for the difference in coordinate reference systems. - // Qt uses quadrant IV and VTK uses quadrant I. So the point should be - // translated to the right position along Y axis. - return item->mapToScene(localPos); -} - -//------------------------------------------------------------------------------------------------- -QPointF QQuickVTKInteractorAdapter::mapEventPositionFlipY(QQuickItem* item, const QPointF& localPos) -{ - QPointF mappedPos = QQuickVTKInteractorAdapter::mapEventPosition(item, localPos); - mappedPos.setY(item->window()->height() - mappedPos.y() + 1); - return mappedPos; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueHoverEvent(QQuickItem* item, QHoverEvent* e) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QPointF posf = e->posF(); -#else - QPointF posf = e->position(); -#endif -#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) - QHoverEvent* newEvent = new QHoverEvent(e->type(), this->mapEventPosition(item, posf), - this->mapEventPosition(item, e->oldPosF()), e->modifiers()); -#else - QHoverEvent* newEvent = new QHoverEvent(e->type(), this->mapEventPosition(item, posf), - e->globalPosition(), this->mapEventPosition(item, e->oldPosF()), e->modifiers()); -#endif - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueKeyEvent(QQuickItem* item, QKeyEvent* e) -{ - Q_UNUSED(item); - QKeyEvent* newEvent = new QKeyEvent(e->type(), e->key(), e->modifiers(), e->nativeScanCode(), - e->nativeVirtualKey(), e->nativeModifiers(), e->text(), e->isAutoRepeat(), e->count()); - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueFocusEvent(QQuickItem* item, QFocusEvent* e) -{ - Q_UNUSED(item); - QFocusEvent* newEvent = new QFocusEvent(e->type(), e->reason()); - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueMouseEvent(QQuickItem* item, QMouseEvent* e) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QPointF localpos = e->localPos(); - QPointF windowpos = e->windowPos(); - QPointF screenpos = e->screenPos(); -#else - QPointF localpos = e->position(); - QPointF windowpos = e->scenePosition(); - QPointF screenpos = e->globalPosition(); -#endif - QMouseEvent* newEvent = new QMouseEvent(e->type(), this->mapEventPosition(item, localpos), - this->mapEventPosition(item, windowpos), this->mapEventPosition(item, screenpos), e->button(), - e->buttons(), e->modifiers()); - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueGeometryChanged( - const QRectF& newGeometry, const QRectF& oldGeometry) -{ - QResizeEvent* newEvent = - new QResizeEvent(newGeometry.size().toSize(), oldGeometry.size().toSize()); - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueWheelEvent(QQuickItem* item, QWheelEvent* e) -{ - QPointF p, gp; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - p = e->position(); - gp = e->globalPosition(); -#else - p = e->posF(); - gp = e->globalPosF(); -#endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) - QWheelEvent* newEvent = new QWheelEvent(this->mapEventPosition(item, p), - this->mapEventPosition(item, gp), e->pixelDelta(), e->angleDelta(), e->buttons(), - e->modifiers(), e->phase(), e->inverted(), e->source()); -#else - QWheelEvent* newEvent = new QWheelEvent(this->mapEventPosition(item, p), - this->mapEventPosition(item, gp), e->pixelDelta(), e->angleDelta(), // - 0, Qt::Horizontal, // Qt4 compatibility arguments - e->buttons(), e->modifiers(), e->phase(), e->source(), e->inverted()); -#endif - QueueEvent(newEvent); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::QueueEvent(QEvent* e) -{ - m_queuedEvents << e; - if (m_qwindow) - { - m_qwindow->update(); - } -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKInteractorAdapter::ProcessEvents(vtkRenderWindowInteractor* interactor) -{ - if (interactor) - { - for (QEvent* e : this->m_queuedEvents) - { - ProcessEvent(e, interactor); - } - qDeleteAll(m_queuedEvents); - m_queuedEvents.clear(); - } -} -VTK_ABI_NAMESPACE_END diff --git a/GUISupport/QtQuick/QQuickVTKInteractorAdapter.h b/GUISupport/QtQuick/QQuickVTKInteractorAdapter.h deleted file mode 100644 index 8c387ba6dfa..00000000000 --- a/GUISupport/QtQuick/QQuickVTKInteractorAdapter.h +++ /dev/null @@ -1,87 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -#ifndef QQuickVTKInteractorAdapter_h -#define QQuickVTKInteractorAdapter_h - -// VTK includes -#include "QVTKInteractorAdapter.h" -#include "vtkDeprecation.h" -#include "vtkGUISupportQtQuickModule.h" // for export macro - -// Qt includes -#include <QList> // for QList -#include <QPointer> // for QPointer - -// Qt Forward declarations -class QEnterEvent; -class QEvent; -class QFocusEvent; -class QHoverEvent; -class QKeyEvent; -class QMouseEvent; -class QQuickItem; -class QQuickWindow; -class QWheelEvent; - -VTK_ABI_NAMESPACE_BEGIN -// VTK Forward declarations -class vtkRenderWindowInteractor; -class vtkRenderer; - -/** - * @class QQuickVTKInteractorAdapter - * @brief Intermediate class that handles relaying Qt events to VTK - */ -class VTK_DEPRECATED_IN_9_3_0( - "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKInteractorAdapter - : public QVTKInteractorAdapter -{ - Q_OBJECT - typedef QVTKInteractorAdapter Superclass; - -public: - QQuickVTKInteractorAdapter(QObject* parent = nullptr); - - void setQQuickWindow(QQuickWindow* win); - - void QueueHoverEvent(QQuickItem* item, QHoverEvent* e); - void QueueKeyEvent(QQuickItem* item, QKeyEvent* e); - void QueueFocusEvent(QQuickItem* item, QFocusEvent* e); - void QueueMouseEvent(QQuickItem* item, QMouseEvent* e); - void QueueGeometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry); - void QueueWheelEvent(QQuickItem* item, QWheelEvent* e); - - void ProcessEvents(vtkRenderWindowInteractor* interactor); - - /* - * Map the event position to VTK display coordinates - * The mapping considers the following: - * - VTK widgets expect display coordinates, not viewport/local coordinates - * - vtkRenderWindowInteractor flips Y before processing the event. - * Because of the inherent flip in the superclass, the mapping does not flip Y implicitly. - * To map and flip Y, use mapEventPositionFlipY. - * - * \sa mapEventPositionFlipY - */ - static QPointF mapEventPosition(QQuickItem* item, const QPointF& localPos); - - /* - * Map the event position to VTK display coordinates and flip the Y axis to switch the point from - * the Qt coordinate reference system to VTK's. - * - * \sa mapEventPosition - */ - static QPointF mapEventPositionFlipY(QQuickItem* item, const QPointF& localPos); - -protected: - void QueueEvent(QEvent* e); - -private: - QPointer<QQuickWindow> m_qwindow; - QList<QEvent*> m_queuedEvents; - - Q_DISABLE_COPY(QQuickVTKInteractorAdapter) -}; - -VTK_ABI_NAMESPACE_END -#endif // QQuickVTKInteractorAdapter_h diff --git a/GUISupport/QtQuick/QQuickVTKRenderItem.cxx b/GUISupport/QtQuick/QQuickVTKRenderItem.cxx deleted file mode 100644 index 0b8e1f96ab4..00000000000 --- a/GUISupport/QtQuick/QQuickVTKRenderItem.cxx +++ /dev/null @@ -1,319 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// this class is deprecated, don't warn about deprecated classes it uses -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKRenderItem.h" - -// vtk includes -#include "QQuickVTKInteractiveWidget.h" -#include "QQuickVTKInteractorAdapter.h" -#include "vtkImageData.h" -#include "vtkRenderWindow.h" - -// Qt includes -#include <QQuickWindow> - -//------------------------------------------------------------------------------------------------- -VTK_ABI_NAMESPACE_BEGIN -QQuickVTKRenderItem::QQuickVTKRenderItem(QQuickItem* parent) - : Superclass(parent) -{ - // Accept mouse events - setAcceptHoverEvents(true); - setAcceptedMouseButtons(Qt::AllButtons); - setFlag(QQuickItem::ItemIsFocusScope); - setFlag(QQuickItem::ItemHasContents); - - QObject::connect( - this, &QQuickItem::windowChanged, this, &QQuickVTKRenderItem::handleWindowChanged); -} - -//------------------------------------------------------------------------------------------------- -QQuickVTKRenderWindow* QQuickVTKRenderItem::renderWindow() const -{ - return this->m_renderWindow; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::setRenderWindow(QQuickVTKRenderWindow* w) -{ - if (this->m_renderWindow == w) - { - return; - } - - if (this->m_renderWindow) - { - this->m_renderWindow->renderWindow()->RemoveRenderer(this->m_renderer); - } - - this->m_renderWindow = w; - if (this->m_renderWindow && this->m_renderWindow->renderWindow()) - { - this->m_renderWindow->renderWindow()->AddRenderer(this->m_renderer); - } - - this->m_renderWindow->render(); -} - -//------------------------------------------------------------------------------------------------- -vtkRenderer* QQuickVTKRenderItem::renderer() const -{ - return this->m_renderer; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::setViewport(const QRectF& rect) -{ - if (!this->m_renderWindow) - { - return; - } - double viewport[4]; - this->m_renderWindow->mapToViewport(rect, viewport); - m_renderer->SetViewport(viewport); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::sync() -{ - if (!this->isVisible()) - { - return; - } - - if (!this->m_renderWindow) - { - return; - } - - // Forward the synchronize call to the window - this->m_renderWindow->sync(); - - // Explicitly set the viewport for each render window - // This is done after the window sync to ensure that the window size is set up. - QRectF rect(0, 0, this->width(), this->height()); - rect = this->mapRectToScene(rect); - this->setViewport(rect); - - // Now synchronize all the widgets - for (auto it = this->m_widgets.constBegin(); it < this->m_widgets.constEnd(); ++it) - { - (*it)->sync(this->renderer()); - } -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::paint() -{ - if (!this->isVisible()) - { - return; - } - if (!this->m_renderWindow) - { - return; - } - - // Forward the paint call to the window - this->m_renderWindow->paint(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::init() -{ - if (!this->isVisible()) - { - return; - } - if (!this->m_renderWindow) - { - return; - } - - // Forward the init call to the window - this->m_renderWindow->init(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::cleanup() -{ - if (!this->isVisible()) - { - return; - } - if (!this->m_renderWindow) - { - return; - } - - this->m_renderer->ReleaseGraphicsResources(this->m_renderWindow->renderWindow()); - // Forward the cleanup call to the window - this->m_renderWindow->cleanup(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::handleWindowChanged(QQuickWindow* w) -{ - if (this->window()) - { - QObject::disconnect( - this->window(), &QQuickWindow::beforeSynchronizing, this, &QQuickVTKRenderItem::sync); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - QObject::disconnect( - window(), &QQuickWindow::beforeRendering, this, &QQuickVTKRenderItem::paint); -#else - QObject::disconnect( - window(), &QQuickWindow::beforeRenderPassRecording, this, &QQuickVTKRenderItem::paint); -#endif - QObject::disconnect( - window(), &QQuickWindow::sceneGraphInvalidated, this, &QQuickVTKRenderItem::cleanup); - } - - if (w) - { - QObject::connect(w, &QQuickWindow::beforeSynchronizing, this, &QQuickVTKRenderItem::sync, - Qt::DirectConnection); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - QObject::connect( - w, &QQuickWindow::beforeRendering, this, &QQuickVTKRenderItem::paint, Qt::DirectConnection); -#else - // Separate the steps between initialization and actual rendering - QObject::connect( - w, &QQuickWindow::beforeRendering, this, &QQuickVTKRenderItem::init, Qt::DirectConnection); - QObject::connect(w, &QQuickWindow::beforeRenderPassRecording, this, &QQuickVTKRenderItem::paint, - Qt::DirectConnection); -#endif - QObject::connect(w, &QQuickWindow::sceneGraphInvalidated, this, &QQuickVTKRenderItem::cleanup, - Qt::DirectConnection); - } -} - -//------------------------------------------------------------------------------------------------- -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -void QQuickVTKRenderItem::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) -#else -void QQuickVTKRenderItem::geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) -#endif -{ - if (!this->renderWindow()) - { - return; - } - this->renderWindow()->interactorAdapter()->QueueGeometryChanged(newGeometry, oldGeometry); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - Superclass::geometryChanged(newGeometry, oldGeometry); -#else - Superclass::geometryChange(newGeometry, oldGeometry); -#endif -} - -//------------------------------------------------------------------------------------------------- -bool QQuickVTKRenderItem::event(QEvent* ev) -{ - if (!ev) - { - return false; - } - - switch (ev->type()) - { - case QEvent::HoverEnter: - case QEvent::HoverLeave: - case QEvent::HoverMove: - { - this->renderWindow()->interactorAdapter()->QueueHoverEvent( - this, static_cast<QHoverEvent*>(ev)); - break; - } - case QEvent::KeyPress: - case QEvent::KeyRelease: - { - this->renderWindow()->interactorAdapter()->QueueKeyEvent(this, static_cast<QKeyEvent*>(ev)); - break; - } - case QEvent::FocusIn: - case QEvent::FocusOut: - { - this->renderWindow()->interactorAdapter()->QueueFocusEvent( - this, static_cast<QFocusEvent*>(ev)); - break; - } - case QEvent::MouseMove: - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - case QEvent::MouseButtonDblClick: - { - this->renderWindow()->interactorAdapter()->QueueMouseEvent( - this, static_cast<QMouseEvent*>(ev)); - break; - } -#ifndef QT_NO_WHEELEVENT - case QEvent::Wheel: - { - this->renderWindow()->interactorAdapter()->QueueWheelEvent( - this, static_cast<QWheelEvent*>(ev)); - break; - } -#endif - default: - { - return this->Superclass::event(ev); - } - } - - ev->accept(); - return true; -} - -//------------------------------------------------------------------------------------------------- -vtkSmartPointer<vtkImageData> QQuickVTKRenderItem::captureScreenshot() -{ - if (!this->renderWindow()) - { - return nullptr; - } - return this->renderWindow()->captureScreenshot(this->m_renderer->GetViewport()); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::addWidget(QQuickVTKInteractiveWidget* w) -{ - this->m_widgets.push_back(w); - this->update(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::removeWidget(QQuickVTKInteractiveWidget* w) -{ - this->m_widgets.removeOne(w); - this->update(); -} - -//------------------------------------------------------------------------------------------------- -QQuickVTKInteractiveWidget* QQuickVTKRenderItem::widgetByName(QString name) const -{ - for (auto it = this->m_widgets.constBegin(); it < this->m_widgets.constEnd(); ++it) - { - if ((*it)->objectName().compare(name) == 0) - { - return (*it); - } - } - return nullptr; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderItem::removeWidgetByName(QString name) -{ - auto w = this->widgetByName(name); - if (!w) - { - return; - } - - this->removeWidget(w); -} -VTK_ABI_NAMESPACE_END diff --git a/GUISupport/QtQuick/QQuickVTKRenderItem.h b/GUISupport/QtQuick/QQuickVTKRenderItem.h deleted file mode 100644 index 72cc8831081..00000000000 --- a/GUISupport/QtQuick/QQuickVTKRenderItem.h +++ /dev/null @@ -1,257 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class QQuickVTKRenderItem - * @brief [QQuickItem] subclass to render a VTK scene in a QtQuick/QML application. - * - * QQuickVTKRenderItem extends [QQuickItem] so that a VTK visualization pipeline can be rendered - * within the rect of the item. - * - * This item is exported to the QML layer via the QQmlVTKPlugin under the module VTK. It is - * registered as a type \b VTKRenderItem. The QQuickVTKRenderItem manages a vtkRenderer internally - * that is rendered as a viewport inside the render window provided by QQuickVTKRenderWindow. - * - * Typical usage for QQuickVTKRenderItem in a Qml application is as follows: - * - * @code - * // import related modules - * import QtQuick 2.15 - * import QtQuick.Controls 2.15 - * import QtQuick.Window 2.15 - * - * // import the VTK module - * import VTK 9.0 - * - * // window containing the application - * ApplicationWindow { - * // title of the application - * title: qsTr("VTK QtQuick App") - * width: 400 - * height: 400 - * color: palette.window - * - * SystemPalette { - * id: palette - * colorGroup: SystemPalette.Active - * } - * - * // Instantiate the vtk render window - * VTKRenderWindow { - * id: vtkwindow - * width: 400 - * height: 400 - * } - * - * // add one or more vtk render items - * VTKRenderItem { - * objectName: "ConeView" - * x: 200 - * y: 200 - * width: 200 - * height: 200 - * // Provide the handle to the render window - * renderWindow: vtkwindow - * } - * } - * @endcode - * - * The corresponding C++ code that sets up the VTK pipeline would look like the following: - * - * @code - * int main(int argc, char* argv[]) - * { - * QQuickVTKRenderWindow::setupGraphicsBackend(); - * QGuiApplication app(argc, argv); - * - * QQmlApplicaQtionEngine engine; - * engine.load(QUrl("qrc:///<qmlfile>.qml")); - * - * QObject* topLevel = engine.rootObjects().value(0); - * QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel); - * - * window->show(); - * - * // Fetch the QQuick window using the standard object name set up in the constructor - * QQuickVTKRenderItem* qquickvtkItem = topLevel->findChild<QQuickVTKRenderItem*>("ConeView"); - * - * // Create a cone pipeline and add it to the view - * vtkNew<vtkActor> actor; - * vtkNew<vtkPolyDataMapper> mapper; - * vtkNew<vtkConeSource> cone; - * mapper->SetInputConnection(cone->GetOutputPort()); - * actor->SetMapper(mapper); - * qquickvtkItem->renderer()->AddActor(actor); - * qquickvtkItem->renderer()->ResetCamera(); - * qquickvtkItem->renderer()->SetBackground(0.5, 0.5, 0.7); - * qquickvtkItem->renderer()->SetBackground2(0.7, 0.7, 0.7); - * qquickvtkItem->renderer()->SetGradientBackground(true); - * qquickvtkItem->update(); - * app.exec(); - * } - * @endcode - * - * ## QtQuick scenegraph and threaded render loop - * - * QtQuick/QML scenegraph rendering is done via private API inside the [QQuickWindow] class. For - * details on QtQuick's render loop, see [QtQuick Scenegraph Rendering]( - * https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html#scene-graph-and-rendering). - * Qt automatically decides between a threaded and basic render loop for most applications. - * QQuickVTKRenderWindow and QQuickVTKRenderItem support both these variants of the QtQuick render - * loop. - * - * When the scenegraph render loop is threaded, i.e. there is a dedicated rendering thread, vtk - * sticks to doing all rendering on this render thread. This means that all the vtk classes, - * pipelines etc. can be set up on the main thread but vtkRenderWindow::Render should only be - * invoked on the render thread. Care must be taken not to call Render on the main thread because - * the OpenGL context would not be valid on the main thread. - * - * ## Interactive vtk widgets - * - * QQuickVTKRenderItem also supports interactive vtk widgets with QtQuick's threaded render loop via - * the QQuickVTKInteractiveWidget class. - * - * [QQuickItem]: https://doc.qt.io/qt-5/qquickitem.html - * [QQuickWindow]: https://doc.qt.io/qt-5/qquickwindow.html - */ - -#ifndef QQuickVTKRenderItem_h -#define QQuickVTKRenderItem_h - -// Qt includes -#include <QOpenGLFunctions> // For QOpenGLFunctions -#include <QQuickItem> - -// vtk includes -#include "QQuickVTKRenderWindow.h" // For QQuickVTKRenderWindow -#include "vtkDeprecation.h" -#include "vtkNew.h" // For vtkNew -#include "vtkRenderer.h" // For vtkRenderer - -#include "vtkGUISupportQtQuickModule.h" // for export macro - -// Qt Forward declarations -class QHoverEvent; -class QKeyEvent; -class QMouseEvent; - -VTK_ABI_NAMESPACE_BEGIN -// VTK Forward declarations -class QQuickVTKInteractiveWidget; -class vtkImageData; - -class VTK_DEPRECATED_IN_9_3_0( - "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderItem - : public QQuickItem - , protected QOpenGLFunctions -{ - Q_OBJECT - typedef QQuickItem Superclass; - - Q_PROPERTY(QQuickVTKRenderWindow* renderWindow READ renderWindow WRITE setRenderWindow) - -public: - QQuickVTKRenderItem(QQuickItem* parent = nullptr); - ~QQuickVTKRenderItem() override = default; - - ///@{ - /** - * Set/Get the render window for the item - */ - QQuickVTKRenderWindow* renderWindow() const; - virtual void setRenderWindow(QQuickVTKRenderWindow* w); - ///@} - - /** - * Get access to the renderer - */ - vtkRenderer* renderer() const; - - /** - * Capture a screenshot of the view - * - * \returns Image data containing the view capture. - * \sa QQuickVTKRenderWindow::captureScreenshot - */ - virtual vtkSmartPointer<vtkImageData> captureScreenshot(); - - ///@{ - /** - * Add/Remove widgets to/from the view - */ - virtual void addWidget(QQuickVTKInteractiveWidget* w); - virtual void removeWidget(QQuickVTKInteractiveWidget* w); - ///@} - - ///@{ - /** - * Get/Remove widgets from the view by their object name - */ - virtual QQuickVTKInteractiveWidget* widgetByName(QString name) const; - virtual void removeWidgetByName(QString name); - ///@} - -public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers) - /** - * This is the function called on the QtQuick render thread before the scenegraph state - * is synchronized. This is where most of the pipeline updates, camera manipulations, etc. and - * other pre-render steps can be performed. - * - * \note At the time of this method execution, the GUI thread is blocked. Hence, it is safe to - * perform state synchronization between the GUI elements and the VTK classes here. - */ - virtual void sync(); - - /** - * Initialize the graphics resources required for this render item. - * - * This method is called on the QtQuick render thread at the beforeRenderPassRecording stage of - * the scenegraph render loop. - */ - virtual void init(); - - /** - * This is the function called on the QtQuick render thread right before the scenegraph is - * rendered. This is the stage where all the vtk rendering is performed. Applications would rarely - * need to override this method. - * - * \note This method is called at the beforeRendering stage of the QtQuick scenegraph. All the - * QtQuick element rendering is stacked visually above the vtk rendering. - */ - virtual void paint(); - - /** - * This is the function called on the QtQuick render thread when the scenegraph is invalidated. - * This is where all graphics resources allocated by vtk are released. - */ - virtual void cleanup(); - -protected Q_SLOTS: - virtual void handleWindowChanged(QQuickWindow* w); - -protected: // NOLINT(readability-redundant-access-specifiers) - // Helper members - QQuickVTKRenderWindow* m_renderWindow = nullptr; - vtkNew<vtkRenderer> m_renderer; - - QVector<QQuickVTKInteractiveWidget*> m_widgets; - - /** - * Set the viewport for this item - */ - virtual void setViewport(const QRectF& rect); - - // Event handlers -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override; -#else - void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override; -#endif - bool event(QEvent* ev) override; - -private: - QQuickVTKRenderItem(const QQuickVTKRenderItem&) = delete; - void operator=(const QQuickVTKRenderItem) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif // QQuickVTKRenderItem_h diff --git a/GUISupport/QtQuick/QQuickVTKRenderWindow.cxx b/GUISupport/QtQuick/QQuickVTKRenderWindow.cxx deleted file mode 100644 index 0f340b13685..00000000000 --- a/GUISupport/QtQuick/QQuickVTKRenderWindow.cxx +++ /dev/null @@ -1,414 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// this class is deprecated, don't warn about deprecated classes it uses -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKRenderWindow.h" - -// vtk includes -#include "QQuickVTKInteractorAdapter.h" -#include "QVTKInteractor.h" -#include "QVTKRenderWindowAdapter.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkImageData.h" -#include "vtkInteractorStyleTrackballCamera.h" -#include "vtkOpenGLState.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkWindowToImageFilter.h" - -// Qt includes -#include <QQuickWindow> -#include <QSGRendererInterface> -#include <QSurfaceFormat> - -//------------------------------------------------------------------------------------------------- -VTK_ABI_NAMESPACE_BEGIN -QQuickVTKRenderWindow::QQuickVTKRenderWindow(QQuickItem* parent) - : Superclass(parent) -{ - vtkNew<vtkGenericOpenGLRenderWindow> renWin; - this->setRenderWindow(renWin); - this->m_interactorAdapter = new QQuickVTKInteractorAdapter(this); - QObject::connect( - this, &QQuickItem::windowChanged, this, &QQuickVTKRenderWindow::handleWindowChanged); - - // Set a standard object name - this->setObjectName("QQuickVTKRenderWindow"); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::setupGraphicsBackend() -{ - QSurfaceFormat fmt = QVTKRenderWindowAdapter::defaultFormat(false); - // By default QtQuick sets the alpha buffer size to 0. We follow the same thing here to prevent a - // transparent background. - fmt.setAlphaBufferSize(0); - QSurfaceFormat::setDefaultFormat(fmt); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi); -#endif -} - -//------------------------------------------------------------------------------------------------- -QQuickVTKRenderWindow::~QQuickVTKRenderWindow() -{ - this->m_renderWindow = nullptr; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::sync() -{ - if (!this->isVisible()) - { - return; - } - - if (!this->m_renderWindow) - { - return; - } - - const double dpr = window()->devicePixelRatio(); - const QSize screenSize = this->window()->size(); - const QSize deviceWindowSize = screenSize * dpr; - this->m_interactorAdapter->SetDevicePixelRatio(dpr); - if (auto iren = this->m_renderWindow->GetInteractor()) - { - iren->UpdateSize(deviceWindowSize.width(), deviceWindowSize.height()); - m_interactorAdapter->ProcessEvents(iren); - } - else - { - this->m_renderWindow->SetSize(deviceWindowSize.width(), deviceWindowSize.height()); - } - this->m_renderWindow->SetScreenSize(screenSize.width(), screenSize.height()); - const double unscaledDPI = 72.0; - this->m_renderWindow->SetDPI(dpr * unscaledDPI); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::init() -{ - if (!this->isVisible()) - { - return; - } - - if (!this->m_renderWindow) - { - // no render window set, just fill with white. - QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions(); - f->glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - f->glClear(GL_COLOR_BUFFER_BIT); - return; - } - - if (!this->checkGraphicsBackend()) - { - return; - } - - auto iren = this->m_renderWindow->GetInteractor(); - if (!this->m_initialized) - { - initializeOpenGLFunctions(); - if (iren) - { - iren->Initialize(); - } - this->m_renderWindow->SetMapped(true); - this->m_renderWindow->SetIsCurrent(true); - - // Since the context is being setup, call OpenGLInitContext - this->m_renderWindow->SetForceMaximumHardwareLineWidth(1); - this->m_renderWindow->SetOwnContext(false); - this->m_renderWindow->OpenGLInitContext(); - - // Add a dummy renderer covering the whole size of the render window as a transparent viewport. - // Without this, the QtQuick rendering is stenciled out. - this->m_dummyRenderer->InteractiveOff(); - this->m_dummyRenderer->SetLayer(1); - this->m_renderWindow->AddRenderer(this->m_dummyRenderer); - this->m_renderWindow->SetNumberOfLayers(2); - - m_initialized = true; - } -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::paint() -{ - if (!this->isVisible()) - { - return; - } - - if (!this->m_renderWindow) - { - // no render window set, just fill with white. - QOpenGLFunctions* f = QOpenGLContext::currentContext()->functions(); - f->glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - f->glClear(GL_COLOR_BUFFER_BIT); - return; - } - -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - // Explicitly call init here if using an older Qt version with no - // beforeRenderPassRecording API available - this->init(); -#endif - - if (!this->checkGraphicsBackend()) - { - return; - } - -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - this->window()->beginExternalCommands(); -#endif - auto iren = this->m_renderWindow->GetInteractor(); - auto ostate = this->m_renderWindow->GetState(); - ostate->Reset(); - ostate->Push(); - // By default, Qt sets the depth function to GL_LESS but VTK expects GL_LEQUAL - ostate->vtkglDepthFunc(GL_LEQUAL); - - // auto iren = this->m_renderWindow->GetInteractor(); - this->m_renderWindow->SetReadyForRendering(true); - if (iren) - { - iren->Render(); - } - else - { - this->m_renderWindow->Render(); - } - - if (this->m_screenshotScheduled) - { - this->m_screenshotFilter->SetInput(this->m_renderWindow); - this->m_screenshotFilter->SetReadFrontBuffer(false); - this->m_screenshotFilter->SetInputBufferTypeToRGB(); - this->m_screenshotFilter->Update(); - this->m_screenshotScheduled = false; - } - this->m_renderWindow->SetReadyForRendering(false); - - ostate->Pop(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - this->window()->endExternalCommands(); -#endif -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::cleanup() -{ - if (this->m_renderWindow) - { - this->m_renderWindow->ReleaseGraphicsResources(this->m_renderWindow); - } -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::handleWindowChanged(QQuickWindow* w) -{ - this->m_interactorAdapter->setQQuickWindow(w); - if (w) - { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // Do not clear the scenegraph before the QML rendering - // to preserve the VTK render - w->setClearBeforeRendering(false); -#endif - // This allows the cleanup method to be called on the render thread - w->setPersistentSceneGraph(false); - } -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::setRenderWindow(vtkRenderWindow* renWin) -{ - auto gwin = vtkGenericOpenGLRenderWindow::SafeDownCast(renWin); - if (renWin != nullptr && gwin == nullptr) - { - qDebug() << "QQuickVTKRenderWindow requires a `vtkGenericOpenGLRenderWindow`. `" - << renWin->GetClassName() << "` is not supported."; - } - this->setRenderWindow(gwin); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::setRenderWindow(vtkGenericOpenGLRenderWindow* renWin) -{ - if (this->m_renderWindow == renWin) - { - return; - } - - this->m_renderWindow = renWin; - this->m_initialized = false; - - if (this->m_renderWindow) - { - this->m_renderWindow->SetMultiSamples(0); - this->m_renderWindow->SetReadyForRendering(false); - this->m_renderWindow->SetFrameBlitModeToBlitToHardware(); - auto loadFunc = [](void*, const char* name) -> vtkOpenGLRenderWindow::VTKOpenGLAPIProc - { - if (auto context = QOpenGLContext::currentContext()) - { - if (auto* symbol = context->getProcAddress(name)) - { - return symbol; - } - } - else - { - vtkGenericWarningMacro(<< "Current opengl context is null!"); - } - return nullptr; - }; - this->m_renderWindow->SetOpenGLSymbolLoader(loadFunc, nullptr); - vtkNew<QVTKInteractor> iren; - iren->SetRenderWindow(this->m_renderWindow); - - // now set the default style - vtkNew<vtkInteractorStyleTrackballCamera> style; - iren->SetInteractorStyle(style); - - this->m_renderWindow->SetReadyForRendering(false); - } -} - -//------------------------------------------------------------------------------------------------- -vtkRenderWindow* QQuickVTKRenderWindow::renderWindow() const -{ - return this->m_renderWindow; -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::mapToViewport(const QRectF& rect, double viewport[4]) -{ - viewport[0] = rect.topLeft().x(); - viewport[1] = rect.topLeft().y(); - viewport[2] = rect.bottomRight().x(); - viewport[3] = rect.bottomRight().y(); - - if (this->m_renderWindow) - { - int* windowSize = this->m_renderWindow->GetScreenSize(); - if (windowSize && windowSize[0] != 0 && windowSize[1] != 0) - { - viewport[0] = viewport[0] / (windowSize[0] - 1.0); - viewport[1] = viewport[1] / (windowSize[1] - 1.0); - viewport[2] = viewport[2] / (windowSize[0] - 1.0); - viewport[3] = viewport[3] / (windowSize[1] - 1.0); - } - } - - // Change to quadrant I (vtk) from IV (Qt) - double tmp = 1.0 - viewport[1]; - viewport[1] = 1.0 - viewport[3]; - viewport[3] = tmp; - - for (int i = 0; i < 3; ++i) - { - viewport[i] = viewport[i] > 0.0 ? viewport[i] : 0.0; - viewport[i] = viewport[i] > 1.0 ? 1.0 : viewport[i]; - } -} - -//------------------------------------------------------------------------------------------------- -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -void QQuickVTKRenderWindow::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) -#else -void QQuickVTKRenderWindow::geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) -#endif -{ - m_interactorAdapter->QueueGeometryChanged(newGeometry, oldGeometry); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - Superclass::geometryChanged(newGeometry, oldGeometry); -#else - Superclass::geometryChange(newGeometry, oldGeometry); -#endif -} - -//------------------------------------------------------------------------------------------------- -QPointer<QQuickVTKInteractorAdapter> QQuickVTKRenderWindow::interactorAdapter() const -{ - return this->m_interactorAdapter; -} - -//------------------------------------------------------------------------------------------------- -vtkSmartPointer<vtkImageData> QQuickVTKRenderWindow::captureScreenshot() -{ - double viewport[4] = { 0, 0, 1, 1 }; - return this->captureScreenshot(viewport); -} - -//------------------------------------------------------------------------------------------------- -vtkSmartPointer<vtkImageData> QQuickVTKRenderWindow::captureScreenshot(double* viewport) -{ - if (!this->window()) - { - return nullptr; - } - this->m_screenshotScheduled = true; - this->m_screenshotFilter->SetViewport(viewport); - this->renderNow(); - return this->m_screenshotFilter->GetOutput(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::renderNow() -{ - if (!this->window()) - { - return; - } - // Schedule a scenegraph update - this->window()->update(); - // Wait for the update to complete - QEventLoop loop; - QObject::connect(this->window(), &QQuickWindow::afterRendering, &loop, &QEventLoop::quit); - loop.exec(); -} - -//------------------------------------------------------------------------------------------------- -void QQuickVTKRenderWindow::render() -{ - if (this->window()) - { - this->window()->update(); - } -} - -//------------------------------------------------------------------------------------------------- -bool QQuickVTKRenderWindow::isInitialized() const -{ - return this->m_initialized; -} - -//------------------------------------------------------------------------------------------------- -bool QQuickVTKRenderWindow::checkGraphicsBackend() -{ - // Enforce the use of OpenGL API - QSGRendererInterface* rif = this->window()->rendererInterface(); - auto gApi = rif->graphicsApi(); - if (!(gApi == QSGRendererInterface::OpenGL -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - || gApi == QSGRendererInterface::OpenGLRhi -#endif - )) - { - qCritical(R"***(Error: QtQuick scenegraph is using an unsupported graphics API: %d. -Set the QSG_INFO environment variable to get more information. -Use QQuickVTKRenderWindow::setupGraphicsBackend() to set the right backend.)***", - gApi); - return false; - } - return true; -} -VTK_ABI_NAMESPACE_END diff --git a/GUISupport/QtQuick/QQuickVTKRenderWindow.h b/GUISupport/QtQuick/QQuickVTKRenderWindow.h deleted file mode 100644 index cb8a0bfba85..00000000000 --- a/GUISupport/QtQuick/QQuickVTKRenderWindow.h +++ /dev/null @@ -1,290 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class QQuickVTKRenderWindow - * @brief [QQuickItem] subclass that manages the vtkRenderWindow and, in - * turn, the OpenGL context of the QML application - * - * QQuickVTKRenderWindow extends [QQuickItem] in a way that allows for VTK to get a handle to, and - * draw inside of the QtQuick scenegraph, using OpenGL draw calls. - * - * This item is exported to the QML layer via the QQmlVTKPlugin under the module VTK. It is - * registered as a type \b VTKRenderWindow. Since, this class is intended to manage an OpenGL - * context in the window, a single instance would be needed for most QML applications. - * - * Typical usage for QQuickVTKRenderWindow in a Qml application is as follows: - * - * @code - * // import related modules - * import QtQuick 2.15 - * import QtQuick.Controls 2.15 - * import QtQuick.Window 2.15 - * - * // import the VTK module - * import VTK 9.0 - * - * // window containing the application - * ApplicationWindow { - * // title of the application - * title: qsTr("VTK QtQuick App") - * width: 400 - * height: 400 - * color: palette.window - * - * SystemPalette { - * id: palette - * colorGroup: SystemPalette.Active - * } - * - * // Instantiate the vtk render window - * VTKRenderWindow { - * id: vtkwindow - * width: 400 - * height: 400 - * } - * - * // add one or more vtk render items - * VTKRenderItem { - * objectName: "ConeView" - * x: 200 - * y: 200 - * width: 200 - * height: 200 - * // Provide the handle to the render window - * renderWindow: vtkwindow - * } - * VTKRenderItem { - * objectName: "VolumeView" - * x: 0 - * y: 0 - * width: 200 - * height: 200 - * // Provide the handle to the render window - * renderWindow: vtkwindow - * } - * } - * @endcode - * - * To ensure that the graphics backend set up by QtQuick matches that expected by VTK, use the - * method QQuickVTKRenderWindow::setupGraphicsBackend() before a QApplication/QGuiApplication is - * instantiated in the main method of the application. - * - * @code - * int main(int argc, char* argv[]) - * { - * // Setup the graphics backend - * QQuickVTKRenderWindow::setupGraphicsBackend(); - * QGuiApplication app(argc, argv); - * ... - * return EXIT_SUCCESS; - * } - * @endcode - * - * The VTK pipeline can be then set up for each \b VTKRenderItem in the C++ code. - * - * ## QtQuick scenegraph and threaded render loop - * - * QtQuick/QML scenegraph rendering is done via private API inside the [QQuickWindow] class. For - * details on QtQuick's render loop, see [QtQuick Scenegraph Rendering]( - * https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html#scene-graph-and-rendering). - * Qt automatically decides between a threaded and basic render loop for most applications. - * QQuickVTKRenderWindow and QQuickVTKRenderItem support both these variants of the QtQuick render - * loop. - * - * When the scenegraph render loop is threaded, i.e. there is a dedicated rendering thread, vtk - * sticks to doing all rendering on this render thread. This means that all the vtk classes, - * pipelines etc. can be set up on the main thread but vtkRenderWindow::Render should only be - * invoked on the render thread. Care must be taken not to call Render on the main thread because - * the OpenGL context would not be valid on the main thread. - * - * [QQuickItem]: https://doc.qt.io/qt-5/qquickitem.html - * [QQuickWindow]: https://doc.qt.io/qt-5/qquickwindow.html - */ - -#ifndef QQuickVTKRenderWindow_h -#define QQuickVTKRenderWindow_h - -// vtk includes -#include "vtkDeprecation.h" -#include "vtkSmartPointer.h" // For vtkSmartPointer - -// Qt includes -#include <QOpenGLFunctions> // For QOpenGLFunctions -#include <QPointer> // For QPointer -#include <QQuickItem> - -#include "vtkGUISupportQtQuickModule.h" // for export macro - -// Qt Forward declarations -class QEvent; -class QQuickWindow; -class QWheelEvent; - -VTK_ABI_NAMESPACE_BEGIN - -// VTK Forward declarations -class QQuickVTKInteractorAdapter; -class vtkGenericOpenGLRenderWindow; -class vtkImageData; -class vtkRenderWindow; -class vtkRenderer; -class vtkWindowToImageFilter; - -class VTK_DEPRECATED_IN_9_3_0( - "Use QQuickVTKItem instead") VTKGUISUPPORTQTQUICK_EXPORT QQuickVTKRenderWindow - : public QQuickItem - , protected QOpenGLFunctions -{ - Q_OBJECT - typedef QQuickItem Superclass; - -public: - /** - * Constructor - * Creates a QQuickVTKRenderWindow with: - * - a vtkGenericOpenGLRenderWindow to manage the OpenGL context - * - an interactor adapter to forward Qt events to vtk's interactor - */ - QQuickVTKRenderWindow(QQuickItem* parent = nullptr); - - /** - * Destructor - */ - ~QQuickVTKRenderWindow() override; - - /** - * Set up the graphics surface format and api. - * - * This method sets the graphics API to OpenGLRhi and sets up the surface format for intermixed - * VTK and QtQuick rendering. - * Use this method before instantiating a QApplication/QGuiApplication in a QtQuick/QML app with - * a VTK render view like QQuickVTKRenderItem. - */ - static void setupGraphicsBackend(); - - ///@{ - /** - * Set/Get the vtkRenderWindow for the view. - * Note that this render window should be of type vtkGenericOpenGLRenderWindow. This is necessary - * since that would allow vtk's opengl draw calls to work seamlessly inside the QtQuick created - * scenegraph and OpenGL context. - * - * By default, a vtkGenericOpenGLRenderWindow is created and set on this item at construction - * time. - */ - virtual void setRenderWindow(vtkRenderWindow* renWin); - virtual void setRenderWindow(vtkGenericOpenGLRenderWindow* renWin); - vtkRenderWindow* renderWindow() const; - ///@} - - /** - * Map a Qt item rect to viewport coordinates - */ - virtual void mapToViewport(const QRectF& rect, double viewport[4]); - - /** - * Get access to the interactor adapter - */ - QPointer<QQuickVTKInteractorAdapter> interactorAdapter() const; - - ///@{ - /** - * Capture a screenshot of the window - * - * \param viewport area to capture. - * \returns Image data containing the window capture. - * \note This triggers a scenegraph update to capture the render window view. - */ - virtual vtkSmartPointer<vtkImageData> captureScreenshot(); - virtual vtkSmartPointer<vtkImageData> captureScreenshot(double* viewport); - ///@} - - /** - * Get whether the render window is initialized - * Used internally to determine if the OpenGL context, QQuickWindow, children items and viewports - * have been initialized. - */ - virtual bool isInitialized() const; - -public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers) - /** - * This is the function called on the QtQuick render thread before the scenegraph state - * is synchronized. This is where most of the pipeline updates, camera manipulations, etc. and - * other pre-render steps can be performed. - * - * \note At the time of this method execution, the GUI thread is blocked. Hence, it is safe to - * perform state synchronization between the GUI elements and the VTK classes here. - */ - virtual void sync(); - - /** - * Initialize the VTK render window for OpenGL based on the context created by QtQuick - * - * \note This method is called at the beforeRenderPassRecording stage of the QtQuick scenegraph. - * All the QtQuick element rendering is stacked visually above the vtk rendering. - */ - virtual void init(); - - /** - * This is the function called on the QtQuick render thread right before the scenegraph is - * rendered. This is the stage where all the vtk rendering is performed. Applications would rarely - * need to override this method. - * - * \note This method is called at the beforeRenderPassRecording stage of the QtQuick scenegraph. - * All the QtQuick element rendering is stacked visually above the vtk rendering. - */ - virtual void paint(); - - /** - * This is the function called on the QtQuick render thread when the scenegraph is invalidated. - * This is where all graphics resources allocated by vtk are released. - */ - virtual void cleanup(); - - /** - * Convenience method that schedules a scenegraph update and waits for the update. - * \sa render() - */ - virtual void renderNow(); - - /** - * Schedule a scenegraph update - * - * \note Since this schedules a scenegraph update, it does not guarantee that the scene will be - * updated after this call. - * \sa renderNow() - */ - virtual void render(); - -protected Q_SLOTS: - virtual void handleWindowChanged(QQuickWindow* w); - -protected: // NOLINT(readability-redundant-access-specifiers) - QPointer<QQuickVTKInteractorAdapter> m_interactorAdapter; - vtkSmartPointer<vtkGenericOpenGLRenderWindow> m_renderWindow; - bool m_initialized = false; - - // Screenshot stuff - bool m_screenshotScheduled = false; - vtkNew<vtkWindowToImageFilter> m_screenshotFilter; - vtkNew<vtkRenderer> m_dummyRenderer; - - // Event handlers -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - void geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) override; -#else - void geometryChange(const QRectF& newGeometry, const QRectF& oldGeometry) override; -#endif - - /** - * Check the scenegraph backend and graphics API being used. - */ - bool checkGraphicsBackend(); - -private: - QQuickVTKRenderWindow(const QQuickVTKRenderWindow&) = delete; - void operator=(const QQuickVTKRenderWindow) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif // QQuickVTKRenderWindow_h diff --git a/GUISupport/QtQuick/Testing/Cxx/CMakeLists.txt b/GUISupport/QtQuick/Testing/Cxx/CMakeLists.txt index 1d3af45f0c2..b14ee87fbe0 100644 --- a/GUISupport/QtQuick/Testing/Cxx/CMakeLists.txt +++ b/GUISupport/QtQuick/Testing/Cxx/CMakeLists.txt @@ -9,18 +9,8 @@ vtk_add_test_cxx(vtkGUISupportQtQuickCxxTests tests TestQQuickVTKItem_1.cxx TestQQuickVTKItem_2.cxx,LOOSE_VALID TestQQuickVTKItem_3.cxx - # VTK_DEPRECATED_IN_9_3_0 applies to these three tests - TestQQuickVTKRenderItem.cxx - TestQQuickVTKRenderItemWidget.cxx - TestQQuickVTKRenderWindow.cxx ) -# VTK_DEPRECATED_IN_9_3_0 applies here -set(qml_files - TestQQuickVTKRenderItem.qml - TestQQuickVTKRenderItemWidget.qml - TestQQuickVTKRenderWindow.qml) - foreach (qml_file IN LISTS qml_files) configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/${qml_file}.in" @@ -57,13 +47,3 @@ target_link_libraries(vtkGUISupportQtQuickCxxTests ) target_compile_definitions(vtkGUISupportQtQuickCxxTests PRIVATE QT_NO_KEYWORDS) - -# VTK_DEPRECATED_IN_9_3_0 applies here -set_property( - TEST - VTK::GUISupportQtQuickCxx-TestQQuickVTKRenderItem - VTK::GUISupportQtQuickCxx-TestQQuickVTKRenderItemWidget - VTK::GUISupportQtQuickCxx-TestQQuickVTKRenderWindow - APPEND - PROPERTY - ENVIRONMENT "QML2_IMPORT_PATH=${VTK_QML_DIR}") diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTK.qrc b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTK.qrc index 2d14703c0dd..de726b62fda 100644 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTK.qrc +++ b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTK.qrc @@ -3,8 +3,5 @@ <file>TestQQuickVTKItem_1.qml</file> <file>TestQQuickVTKItem_2.qml</file> <file>TestQQuickVTKItem_3.qml</file> - <file>TestQQuickVTKRenderItem.qml</file> - <file>TestQQuickVTKRenderItemWidget.qml</file> - <file>TestQQuickVTKRenderWindow.qml</file> </qresource> </RCC> diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.cxx b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.cxx deleted file mode 100644 index f695a693bc6..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.cxx +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Description -// Tests QQuickVTKRenderItem - -// VTK_DEPRECATED_IN_9_3_0 applies to the classes tested here -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKRenderItem.h" -#include "QQuickVTKRenderWindow.h" -#include "vtkActor.h" -#include "vtkConeSource.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkNew.h" -#include "vtkPNGWriter.h" -#include "vtkPolyDataMapper.h" -#include "vtkRenderer.h" -#include "vtkTestUtilities.h" -#include "vtkTesting.h" -#include "vtkWindowToImageFilter.h" - -#include <QApplication> -#include <QDebug> -#include <QQmlApplicationEngine> -#include <QQuickWindow> -#include <QTimer> -#include <QUrl> - -int TestQQuickVTKRenderItem(int argc, char* argv[]) -{ - cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl; - - QQuickVTKRenderWindow::setupGraphicsBackend(); - QApplication app(argc, argv); - - QQmlApplicationEngine engine; - qDebug() << "QML2_IMPORT_PATH:" << engine.importPathList(); - engine.load(QUrl("qrc:///TestQQuickVTKRenderItem.qml")); - - QObject* topLevel = engine.rootObjects().value(0); - QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel); - - window->show(); - - // Fetch the QQuick window using the standard object name set up in the constructor - QQuickVTKRenderItem* qquickvtkItem = topLevel->findChild<QQuickVTKRenderItem*>("ConeView"); - - // Create a cone pipeline and add it to the view - vtkNew<vtkActor> actor; - vtkNew<vtkPolyDataMapper> mapper; - vtkNew<vtkConeSource> cone; - mapper->SetInputConnection(cone->GetOutputPort()); - actor->SetMapper(mapper); - qquickvtkItem->renderer()->AddActor(actor); - qquickvtkItem->renderer()->ResetCamera(); - qquickvtkItem->renderer()->SetBackground(0.5, 0.5, 0.7); - qquickvtkItem->renderer()->SetBackground2(0.7, 0.7, 0.7); - qquickvtkItem->renderer()->SetGradientBackground(true); - qquickvtkItem->update(); - - vtkNew<vtkTesting> vtktesting; - vtktesting->AddArguments(argc, argv); - if (vtktesting->IsInteractiveModeSpecified()) - { - return QApplication::exec(); - } - - // Wait a little for the application and window to be set up properly - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - - // Capture a screenshot of the item - vtkSmartPointer<vtkImageData> im = qquickvtkItem->captureScreenshot(); - - std::string validName = std::string(vtktesting->GetValidImageFileName()); - std::string::size_type slashPos = validName.rfind('/'); - if (slashPos != std::string::npos) - { - validName = validName.substr(slashPos + 1); - } - std::string tmpDir = vtktesting->GetTempDirectory(); - std::string vImage = tmpDir + "/" + validName; - vtkNew<vtkPNGWriter> w; - w->SetInputData(im); - w->SetFileName(vImage.c_str()); - w->Write(); - - int retVal = vtktesting->RegressionTest(vImage, 0.05); - - switch (retVal) - { - case vtkTesting::FAILED: - case vtkTesting::NOT_RUN: - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.qml.in b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.qml.in deleted file mode 100644 index 33932e6c88c..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItem.qml.in +++ /dev/null @@ -1,74 +0,0 @@ -// import related modules -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Window 2.15 - -// import the VTK module -import VTK @VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@ - -// window containing the application -ApplicationWindow { - // title of the application - title: qsTr("VTK QtQuick App") - width: 400 - height: 400 - color: palette.window - - SystemPalette { - id: palette - colorGroup: SystemPalette.Active - } - - // menubar with two menus - menuBar: MenuBar { - Menu { - title: qsTr("File") - MenuItem { - text: qsTr("&Quit") - onTriggered: Qt.quit() - } - } - Menu { - title: qsTr("Edit") - } - } - - // Content area - - // a rectangle in the middle of the content area - Rectangle { - width: 100 - height: 100 - color: "blue" - border.color: "red" - border.width: 5 - radius: 10 - } - Text { - id: label - color: "white" - wrapMode: Text.WordWrap - text: "Custom QML\nrectangle &\ntext" - anchors.right: parent.right - anchors.left: parent.left - anchors.top: parent.top - anchors.margins: 10 - width: 100 - } - - VTKRenderWindow { - id: vtkwindow - width: 400 - height: 400 - } - - VTKRenderItem { - objectName: "ConeView" - x: 200 - y: 200 - width: 200 - height: 200 - renderWindow: vtkwindow - focus: true - } -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.cxx b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.cxx deleted file mode 100644 index 75309067b52..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.cxx +++ /dev/null @@ -1,208 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Description -// Tests QQuickVTKRenderItem - -// VTK_DEPRECATED_IN_9_3_0 applies to the classes tested here -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKInteractiveWidget.h" -#include "QQuickVTKRenderItem.h" -#include "QQuickVTKRenderWindow.h" -#include "vtkActor.h" -#include "vtkAppendPolyData.h" -#include "vtkCamera.h" -#include "vtkClipPolyData.h" -#include "vtkCommand.h" -#include "vtkConeSource.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkGlyph3D.h" -#include "vtkImplicitPlaneRepresentation.h" -#include "vtkImplicitPlaneWidget2.h" -#include "vtkInteractorEventRecorder.h" -#include "vtkNew.h" -#include "vtkPNGWriter.h" -#include "vtkPlane.h" -#include "vtkPolyData.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSphereSource.h" -#include "vtkTestUtilities.h" -#include "vtkTesting.h" -#include "vtkWindowToImageFilter.h" - -#include <QApplication> -#include <QDebug> -#include <QQmlApplicationEngine> -#include <QQuickWindow> -#include <QTimer> -#include <QUrl> - -class TestQQuickVTKRenderItemWidgetCallback : public vtkCommand -{ -public: - static TestQQuickVTKRenderItemWidgetCallback* New() - { - return new TestQQuickVTKRenderItemWidgetCallback; - } - void Execute(vtkObject* caller, unsigned long, void*) override - { - vtkImplicitPlaneWidget2* planeWidget = reinterpret_cast<vtkImplicitPlaneWidget2*>(caller); - vtkImplicitPlaneRepresentation* rep = - reinterpret_cast<vtkImplicitPlaneRepresentation*>(planeWidget->GetRepresentation()); - rep->GetPlane(this->Plane); - this->Actor->VisibilityOn(); - } - TestQQuickVTKRenderItemWidgetCallback() - : Plane(nullptr) - , Actor(nullptr) - { - } - vtkPlane* Plane; - vtkActor* Actor; -}; - -int TestQQuickVTKRenderItemWidget(int argc, char* argv[]) -{ - cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl; - - QQuickVTKRenderWindow::setupGraphicsBackend(); - QApplication app(argc, argv); - - QQmlApplicationEngine engine; - qDebug() << "QML2_IMPORT_PATH:" << engine.importPathList(); - engine.load(QUrl("qrc:///TestQQuickVTKRenderItemWidget.qml")); - - QObject* topLevel = engine.rootObjects().value(0); - QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel); - - window->show(); - - // Fetch the QQuick window using the standard object name set up in the constructor - QQuickVTKRenderWindow* qquickvtkWindow = - topLevel->findChild<QQuickVTKRenderWindow*>("QQuickVTKRenderWindow"); - - // Fetch the QQuick item using the object name set up in the qml file - QQuickVTKRenderItem* coneItem = topLevel->findChild<QQuickVTKRenderItem*>("ConeView"); - // Create a cone pipeline and add it to the view - vtkNew<vtkActor> actor; - vtkNew<vtkPolyDataMapper> mapper; - vtkNew<vtkConeSource> cone; - mapper->SetInputConnection(cone->GetOutputPort()); - actor->SetMapper(mapper); - coneItem->renderer()->AddActor(actor); - coneItem->renderer()->SetBackground(0.5, 0.5, 0.7); - coneItem->renderer()->SetBackground2(0.7, 0.7, 0.7); - coneItem->renderer()->SetGradientBackground(true); - coneItem->update(); - - // Fetch the QQuick item using the object name set up in the qml file - QQuickVTKRenderItem* widgetItem = topLevel->findChild<QQuickVTKRenderItem*>("WidgetView"); - // Create a mace out of filters. - // - vtkNew<vtkSphereSource> sphere; - vtkNew<vtkGlyph3D> glyph; - glyph->SetInputConnection(sphere->GetOutputPort()); - glyph->SetSourceConnection(cone->GetOutputPort()); - glyph->SetVectorModeToUseNormal(); - glyph->SetScaleModeToScaleByVector(); - glyph->SetScaleFactor(0.25); - - // The sphere and spikes are appended into a single polydata. - // This just makes things simpler to manage. - vtkNew<vtkAppendPolyData> apd; - apd->AddInputConnection(glyph->GetOutputPort()); - apd->AddInputConnection(sphere->GetOutputPort()); - - vtkNew<vtkPolyDataMapper> maceMapper; - maceMapper->SetInputConnection(apd->GetOutputPort()); - - vtkNew<vtkActor> maceActor; - maceActor->SetMapper(maceMapper); - maceActor->VisibilityOn(); - - // This portion of the code clips the mace with the vtkPlanes - // implicit function. The clipped region is colored green. - vtkNew<vtkPlane> plane; - vtkNew<vtkClipPolyData> clipper; - clipper->SetInputConnection(apd->GetOutputPort()); - clipper->SetClipFunction(plane); - clipper->InsideOutOn(); - - vtkNew<vtkPolyDataMapper> selectMapper; - selectMapper->SetInputConnection(clipper->GetOutputPort()); - - vtkNew<vtkActor> selectActor; - selectActor->SetMapper(selectMapper); - selectActor->GetProperty()->SetColor(0, 1, 0); - selectActor->VisibilityOff(); - selectActor->SetScale(1.01, 1.01, 1.01); - - // The SetInteractor method is how 3D widgets are associated with the render - // window interactor. Internally, SetInteractor sets up a bunch of callbacks - // using the Command/Observer mechanism (AddObserver()). - vtkNew<TestQQuickVTKRenderItemWidgetCallback> myCallback; - myCallback->Plane = plane; - myCallback->Actor = selectActor; - - vtkNew<vtkImplicitPlaneRepresentation> rep; - vtkNew<vtkImplicitPlaneWidget2> planeWidget; - planeWidget->SetRepresentation(rep); - planeWidget->AddObserver(vtkCommand::InteractionEvent, myCallback); - - QQuickVTKInteractiveWidget* qquickVTKWidget = new QQuickVTKInteractiveWidget(window); - qquickVTKWidget->setWidget(planeWidget); - qquickVTKWidget->setEnabled(true); - - widgetItem->renderer()->AddActor(maceActor); - widgetItem->renderer()->AddActor(selectActor); - widgetItem->addWidget(qquickVTKWidget); - widgetItem->update(); - - // Wait a little for the application and window to be set up properly - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - - // Once the application is up, adjust the camera, widget reps, etc. - widgetItem->renderer()->ResetCamera(); - rep->SetPlaceFactor(1.25); - rep->PlaceWidget(glyph->GetOutput()->GetBounds()); - widgetItem->renderer()->GetActiveCamera()->Azimuth(20); - - vtkNew<vtkTesting> vtktesting; - vtktesting->AddArguments(argc, argv); - if (vtktesting->IsInteractiveModeSpecified()) - { - return QApplication::exec(); - } - - // Capture a screenshot of the item - vtkSmartPointer<vtkImageData> im = qquickvtkWindow->captureScreenshot(); - - std::string validName = std::string(vtktesting->GetValidImageFileName()); - std::string::size_type slashPos = validName.rfind('/'); - if (slashPos != std::string::npos) - { - validName = validName.substr(slashPos + 1); - } - std::string tmpDir = vtktesting->GetTempDirectory(); - std::string vImage = tmpDir + "/" + validName; - vtkNew<vtkPNGWriter> w; - w->SetInputData(im); - w->SetFileName(vImage.c_str()); - w->Write(); - - int retVal = vtktesting->RegressionTest(vImage, 0.05); - - switch (retVal) - { - case vtkTesting::FAILED: - case vtkTesting::NOT_RUN: - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.qml.in b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.qml.in deleted file mode 100644 index d483251452b..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderItemWidget.qml.in +++ /dev/null @@ -1,89 +0,0 @@ -// import related modules -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import QtQuick.Window 2.15 - -// import the VTK module -import VTK @VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@ - -// window containing the application -ApplicationWindow { - // title of the application - title: qsTr("VTK QtQuick App") - width: 800 - height: 800 - color: palette.window - - SystemPalette { - id: palette - colorGroup: SystemPalette.Active - } - - // menubar with two menus - menuBar: MenuBar { - Menu { - title: qsTr("File") - MenuItem { - text: qsTr("&Quit") - onTriggered: Qt.quit() - } - } - Menu { - title: qsTr("Edit") - } - } - - // Content area - - // a rectangle in the middle of the content area - Rectangle { - width: 100 - height: 100 - color: "blue" - border.color: "red" - border.width: 5 - radius: 10 - } - Text { - id: label - color: "white" - wrapMode: Text.WordWrap - text: "Custom QML\nrectangle &\ntext" - anchors.right: parent.right - anchors.left: parent.left - anchors.top: parent.top - anchors.margins: 10 - width: 100 - } - - VTKRenderWindow { - id: vtkwindow - anchors.fill: parent - } - - RowLayout { - anchors.fill: parent - - VTKRenderItem { - objectName: "ConeView" - Layout.column: 0 - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 200 - renderWindow: vtkwindow - focus: true - } - VTKRenderItem { - objectName: "WidgetView" - Layout.column: 1 - Layout.fillWidth: true - Layout.fillHeight: true - Layout.minimumWidth: 100 - Layout.preferredWidth: 400 - renderWindow: vtkwindow - focus: true - } - } -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.cxx b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.cxx deleted file mode 100644 index 2ded253a690..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.cxx +++ /dev/null @@ -1,166 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Description -// Tests QQuickVTKRenderWindow/QQuickVTKRenderItem - -// VTK_DEPRECATED_IN_9_3_0 applies to the classes tested here -#define VTK_DEPRECATION_LEVEL 0 - -#include "QQuickVTKRenderItem.h" -#include "QQuickVTKRenderWindow.h" -#include "vtkActor.h" -#include "vtkColorTransferFunction.h" -#include "vtkConeSource.h" -#include "vtkGenericOpenGLRenderWindow.h" -#include "vtkGlyph3DMapper.h" -#include "vtkNew.h" -#include "vtkPNGWriter.h" -#include "vtkPiecewiseFunction.h" -#include "vtkPolyDataMapper.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartVolumeMapper.h" -#include "vtkSphereSource.h" -#include "vtkTestUtilities.h" -#include "vtkTesting.h" -#include "vtkVolume.h" -#include "vtkVolumeProperty.h" -#include "vtkWindowToImageFilter.h" -#include "vtkXMLImageDataReader.h" - -#include <QApplication> -#include <QDebug> -#include <QQmlApplicationEngine> -#include <QQuickWindow> -#include <QTimer> -#include <QUrl> - -int TestQQuickVTKRenderWindow(int argc, char* argv[]) -{ - cout << "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)" << endl; - - QQuickVTKRenderWindow::setupGraphicsBackend(); - QApplication app(argc, argv); - - QQmlApplicationEngine engine; - qDebug() << "QML2_IMPORT_PATH:" << engine.importPathList(); - engine.load(QUrl("qrc:///TestQQuickVTKRenderWindow.qml")); - - QObject* topLevel = engine.rootObjects().value(0); - QQuickWindow* window = qobject_cast<QQuickWindow*>(topLevel); - - window->show(); - - // Fetch the QQuick window using the standard object name set up in the constructor - QQuickVTKRenderItem* geomItem = topLevel->findChild<QQuickVTKRenderItem*>("GeomView"); - - // Create a cone pipeline and add it to the view - vtkNew<vtkActor> actor; - vtkNew<vtkPolyDataMapper> mapper; - vtkNew<vtkConeSource> cone; - mapper->SetInputConnection(cone->GetOutputPort()); - actor->SetMapper(mapper); - geomItem->renderer()->AddActor(actor); - geomItem->renderer()->ResetCamera(); - // geomItem->renderer()->SetBackground(0.5, 0.5, 0.7); - geomItem->renderer()->SetBackground2(0.7, 0.7, 0.7); - // geomItem->renderer()->SetGradientBackground(true); - geomItem->update(); - - // Now the volume view - QQuickVTKRenderItem* volumeItem = topLevel->findChild<QQuickVTKRenderItem*>("VolumeView"); - - // Create a volume pipeline and add it to the view - vtkNew<vtkSmartVolumeMapper> volumeMapper; - vtkNew<vtkXMLImageDataReader> reader; - const char* volumeFile = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/vase_1comp.vti"); - reader->SetFileName(volumeFile); - volumeMapper->SetInputConnection(reader->GetOutputPort()); - delete[] volumeFile; - double scalarRange[2]; - volumeMapper->GetInput()->GetScalarRange(scalarRange); - volumeMapper->SetAutoAdjustSampleDistances(1); - volumeMapper->SetBlendModeToComposite(); - vtkNew<vtkPiecewiseFunction> scalarOpacity; - scalarOpacity->AddPoint(scalarRange[0], 0.0); - scalarOpacity->AddPoint(scalarRange[1], 0.09); - vtkNew<vtkVolumeProperty> volumeProperty; - volumeProperty->ShadeOff(); - volumeProperty->SetInterpolationType(VTK_LINEAR_INTERPOLATION); - volumeProperty->SetScalarOpacity(scalarOpacity); - vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction = - volumeProperty->GetRGBTransferFunction(0); - colorTransferFunction->RemoveAllPoints(); - colorTransferFunction->AddRGBPoint(scalarRange[0], 0.6, 0.4, 0.1); - // colorTransferFunction->AddRGBPoint(scalarRange[1], 0.2, 0.1, 0.3); - vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New(); - volume->SetMapper(volumeMapper); - volume->SetProperty(volumeProperty); - volumeItem->renderer()->AddVolume(volume); - volumeItem->renderer()->ResetCamera(); - // volumeItem->renderer()->SetBackground(0.5, 0.5, 0.7); - volumeItem->renderer()->SetBackground(0, 0, 1); - // volumeItem->renderer()->SetBackground2(0.7, 0.7, 0.7); - volumeItem->update(); - - // Now the glyph view - QQuickVTKRenderItem* glyphItem = topLevel->findChild<QQuickVTKRenderItem*>("GlyphView"); - - // Create the glyph pipeline - vtkNew<vtkSphereSource> sphere; - vtkNew<vtkGlyph3DMapper> glyphMapper; - vtkNew<vtkConeSource> squad; - glyphMapper->SetInputConnection(sphere->GetOutputPort()); - glyphMapper->SetSourceConnection(squad->GetOutputPort()); - glyphMapper->SetOrientationArray("Normals"); - vtkNew<vtkActor> glyphActor; - glyphActor->SetMapper(glyphMapper); - glyphActor->GetProperty()->SetDiffuseColor(0.5, 1.0, 0.8); - glyphItem->renderer()->AddActor(glyphActor); - glyphItem->renderer()->SetBackground(0.5, 0.5, 0.7); - glyphItem->renderer()->ResetCamera(); - glyphItem->update(); - - // Now the testing - vtkNew<vtkTesting> vtktesting; - vtktesting->AddArguments(argc, argv); - if (vtktesting->IsInteractiveModeSpecified()) - { - return QApplication::exec(); - } - - // Wait a little for the application and window to be set up properly - QEventLoop loop; - QTimer::singleShot(100, &loop, SLOT(quit())); - loop.exec(); - - // Capture a screenshot of the window - // Fetch the QQuick window using the standard object name set up in the constructor - QQuickVTKRenderWindow* qquickvtkWindow = - topLevel->findChild<QQuickVTKRenderWindow*>("QQuickVTKRenderWindow"); - vtkSmartPointer<vtkImageData> im = qquickvtkWindow->captureScreenshot(); - - std::string validName = std::string(vtktesting->GetValidImageFileName()); - std::string::size_type slashPos = validName.rfind('/'); - if (slashPos != std::string::npos) - { - validName = validName.substr(slashPos + 1); - } - std::string tmpDir = vtktesting->GetTempDirectory(); - std::string vImage = tmpDir + "/" + validName; - vtkNew<vtkPNGWriter> w; - w->SetInputData(im); - w->SetFileName(vImage.c_str()); - w->Write(); - - int retVal = vtktesting->RegressionTest(vImage, 0.05); - - switch (retVal) - { - case vtkTesting::FAILED: - case vtkTesting::NOT_RUN: - return EXIT_FAILURE; - } - return EXIT_SUCCESS; -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml deleted file mode 100644 index 57b4a8852f1..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml +++ /dev/null @@ -1,79 +0,0 @@ -// import related modules -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import QtQuick.Window 2.15 - -// import the VTK module -import VTK @VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@ - -// window containing the application -ApplicationWindow { - // title of the application - title: qsTr("VTK QtQuick App") - width: 800 - height: 600 - color: palette.window - - SystemPalette { - id: palette - colorGroup: SystemPalette.Active - } - - // menubar with two menus - menuBar: MenuBar { - Menu { - title: qsTr("File") - MenuItem { - text: qsTr("&Quit") - onTriggered: Qt.quit() - } - } - Menu { - title: qsTr("Edit") - } - } - - // Content area - // Create a VTK render window to represent the opengl context for all vtk items in this app - VTKRenderWindow { - id: vtkwindow - anchors.fill: parent - } - - SplitView { - anchors.fill: parent - orientation: Qt.Horizontal - - VTKRenderItem { - objectName: "VolumeView" - SplitView.fillHeight: true - SplitView.fillWidth: true - SplitView.minimumHeight: 100 - SplitView.minimumWidth: 100 - SplitView.preferredHeight: 200 - SplitView.preferredWidth: 200 - renderWindow: vtkwindow - } - - ColumnLayout { - SplitView.fillHeight: true - SplitView.fillWidth: true - SplitView.minimumWidth: 200 - SplitView.preferredWidth: 200 - VTKRenderItem { - objectName: "GlyphView" - renderWindow: vtkwindow - focus: true - Layout.fillHeight: true - Layout.fillWidth: true - } - VTKRenderItem { - objectName: "GeomView" - renderWindow: vtkwindow - Layout.fillHeight: true - Layout.fillWidth: true - } - } - } -} diff --git a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml.in b/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml.in deleted file mode 100644 index 57b4a8852f1..00000000000 --- a/GUISupport/QtQuick/Testing/Cxx/TestQQuickVTKRenderWindow.qml.in +++ /dev/null @@ -1,79 +0,0 @@ -// import related modules -import QtQuick 2.15 -import QtQuick.Controls 2.15 -import QtQuick.Layouts 1.15 -import QtQuick.Window 2.15 - -// import the VTK module -import VTK @VTK_MAJOR_VERSION@.@VTK_MINOR_VERSION@ - -// window containing the application -ApplicationWindow { - // title of the application - title: qsTr("VTK QtQuick App") - width: 800 - height: 600 - color: palette.window - - SystemPalette { - id: palette - colorGroup: SystemPalette.Active - } - - // menubar with two menus - menuBar: MenuBar { - Menu { - title: qsTr("File") - MenuItem { - text: qsTr("&Quit") - onTriggered: Qt.quit() - } - } - Menu { - title: qsTr("Edit") - } - } - - // Content area - // Create a VTK render window to represent the opengl context for all vtk items in this app - VTKRenderWindow { - id: vtkwindow - anchors.fill: parent - } - - SplitView { - anchors.fill: parent - orientation: Qt.Horizontal - - VTKRenderItem { - objectName: "VolumeView" - SplitView.fillHeight: true - SplitView.fillWidth: true - SplitView.minimumHeight: 100 - SplitView.minimumWidth: 100 - SplitView.preferredHeight: 200 - SplitView.preferredWidth: 200 - renderWindow: vtkwindow - } - - ColumnLayout { - SplitView.fillHeight: true - SplitView.fillWidth: true - SplitView.minimumWidth: 200 - SplitView.preferredWidth: 200 - VTKRenderItem { - objectName: "GlyphView" - renderWindow: vtkwindow - focus: true - Layout.fillHeight: true - Layout.fillWidth: true - } - VTKRenderItem { - objectName: "GeomView" - renderWindow: vtkwindow - Layout.fillHeight: true - Layout.fillWidth: true - } - } - } -} diff --git a/GUISupport/QtQuick/qml/CMakeLists.txt b/GUISupport/QtQuick/qml/CMakeLists.txt deleted file mode 100644 index 23b5db4b6d3..00000000000 --- a/GUISupport/QtQuick/qml/CMakeLists.txt +++ /dev/null @@ -1,153 +0,0 @@ -set(config_subdir "") -get_property(multiconfig GLOBAL - PROPERTY GENERATOR_IS_MULTI_CONFIG) -if (multiconfig) - set(config_subdir "/$<CONFIG>") -endif () - -set(qml_module_dir - "${_vtk_build_PACKAGE}.${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}") -set(qml_build_output_dir - "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_QMLDIR}${config_subdir}") -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY - "${qml_build_output_dir}/${qml_module_dir}") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY - "${qml_build_output_dir}/${qml_module_dir}") - -# Set the VTK_QML_DIR for use in the test suite during the build. Other -# consumers will get it from `vtk-config.cmake`. -set(VTK_QML_DIR "${qml_build_output_dir}" - CACHE INTERNAL "QML output directory") - -if (multiconfig) - foreach (config IN LISTS CMAKE_CONFIGURATION_TYPES) - string(TOUPPER "${config}" upper_config) - set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${upper_config}" - "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_QMLDIR}/${config}/${qml_module_dir}") - set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${upper_config}" - "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_QMLDIR}/${config}/${qml_module_dir}") - endforeach () -endif () - -add_library(qmlvtkplugin MODULE - QQmlVTKPlugin.cxx - QQmlVTKPlugin.h) -add_library(VTK::qmlvtkplugin ALIAS qmlvtkplugin) -target_link_libraries(qmlvtkplugin - PRIVATE - VTK::GUISupportQtQuick - "Qt${vtk_qt_major_version}::Qml") - -install( - TARGETS qmlvtkplugin - EXPORT "${_vtk_build_INSTALL_EXPORT}" - RUNTIME - DESTINATION "${CMAKE_INSTALL_QMLDIR}${config_subdir}/${qml_module_dir}" - COMPONENT "${_vtk_build_TARGETS_COMPONENT}" - LIBRARY - DESTINATION "${CMAKE_INSTALL_QMLDIR}${config_subdir}/${qml_module_dir}" - COMPONENT "${_vtk_build_TARGETS_COMPONENT}") - -# Prepare the `qmldir` file. -configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/qmldir.in" - "${CMAKE_CURRENT_BINARY_DIR}/qmldir" - @ONLY) -file(GENERATE - OUTPUT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qmldir" - INPUT "${CMAKE_CURRENT_BINARY_DIR}/qmldir") - -# Generate the qmltypes file for the VTK QML plugin - -# First, find the qmlplugindump executable -get_target_property(qt_qmake_location "Qt${vtk_qt_major_version}::qmake" LOCATION) -get_filename_component(qt_bin_dir "${qt_qmake_location}" PATH) -if (APPLE) - get_filename_component(qt_bin_dir "${qt_bin_dir}" PATH) -endif () -find_program(QMLPLUGINDUMP_EXECUTABLE - NAMES "qmlplugindump-qt${vtk_qt_major_version}" qmlplugindump - HINTS "${qt_bin_dir}" - DOC "QmlPlugindump executable location") -mark_as_advanced(QMLPLUGINDUMP_EXECUTABLE) -if (NOT QMLPLUGINDUMP_EXECUTABLE) - message(FATAL_ERROR - "qmlplugindump executable not found.\nIt is required to generate the " - "qmltypes file for VTK Qml plugin.") -endif () - -set(qmltypes_file_template - "${CMAKE_CURRENT_SOURCE_DIR}/plugins.qmltypes") -set(qmltypes_file_output - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/plugins.qmltypes") - -set(byproducts - BYPRODUCTS "${qmltypes_file_output}") -# Generator expressions are not supported in CMake < 3.20 for byproducts -if (config_subdir AND CMAKE_VERSION VERSION_LESS "3.20") - set(byproducts) -endif () - -get_target_property(qt_config "Qt${vtk_qt_major_version}::Core" IMPORTED_CONFIGURATIONS) - -set(copy_qmlplugintypes FALSE) -if (vtk_qt_major_version VERSION_GREATER 5) - set(copy_qmlplugintypes TRUE) -endif () - -if (NOT copy_qmlplugintypes) - if (WIN32 AND ("DEBUG" IN_LIST qt_config) AND ("RELEASE" IN_LIST qt_config)) - if (NOT VTK_DISABLE_QT_MULTICONFIG_WINDOWS_WARNING) - message(AUTHOR_WARNING - "Qt5 is configured in both Debug and Release modes. Due to Qt issue " - "47774 (https://bugreports.qt.io/browse/QTBUG-47774), skipping " - "generation of qmltypes file. Using the one provided with the source " - "tree instead.") - endif () - set(copy_qmlplugintypes TRUE) - else () - # Must be `POST_BUILD` so that it is always up-to-date when building the - # QML plugin instead of also needing to run a separate custom target as - # well. - add_custom_command( - TARGET qmlvtkplugin - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E env - "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib" - "${QMLPLUGINDUMP_EXECUTABLE}" - -output "${qmltypes_file_output}" - "${_vtk_build_PACKAGE}" - "${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}" - "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_QMLDIR}${config_subdir}" - WORKING_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}" - ${byproducts} - COMMENT "Generating qmltypes file using qmlplugindump" - VERBATIM) - endif () -endif() -if (copy_qmlplugintypes) - # Must be `POST_BUILD` so that it is always up-to-date when building the - # QML plugin instead of also needing to run a separate custom target as - # well. - add_custom_command( - TARGET qmlvtkplugin - POST_BUILD - COMMAND - "${CMAKE_COMMAND}" -E copy_if_different - "${qmltypes_file_template}" - "${qmltypes_file_output}" - WORKING_DIRECTORY - "${CMAKE_CURRENT_BINARY_DIR}" - ${byproducts} - COMMENT "Copying qmltypes file from the source tree to ${qmltypes_file_output}") -endif () - -# Install the QML plugin module -install( - FILES - "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/qmldir" - "${qmltypes_file_output}" - DESTINATION "${CMAKE_INSTALL_QMLDIR}${config_subdir}/${qml_module_dir}" - COMPONENT "${_vtk_build_TARGETS_COMPONENT}") diff --git a/GUISupport/QtQuick/qml/QQmlVTKPlugin.cxx b/GUISupport/QtQuick/qml/QQmlVTKPlugin.cxx deleted file mode 100644 index 38a3f38c7f9..00000000000 --- a/GUISupport/QtQuick/qml/QQmlVTKPlugin.cxx +++ /dev/null @@ -1,42 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -// this class is deprecated, don't warn about deprecated classes it uses -#define VTK_DEPRECATION_LEVEL 0 -// vtk includes -#include "QQmlVTKPlugin.h" - -#include "QQuickVTKInteractiveWidget.h" -#include "QQuickVTKRenderItem.h" -#include "QQuickVTKRenderWindow.h" -#include "vtkVersion.h" - -// Qt includes -#include <QQmlEngine> - -//------------------------------------------------------------------------------------------------- -VTK_ABI_NAMESPACE_BEGIN -void QQmlVTKPlugin::registerTypes(const char* uri) -{ - Q_ASSERT(QString::compare(uri, "VTK") == 0); - - int major = vtkVersion::GetVTKMajorVersion(); - int minor = vtkVersion::GetVTKMinorVersion(); - - // Register QML metatypes - qmlRegisterType<QQuickVTKRenderWindow>(uri, major, minor, "VTKRenderWindow"); - qmlRegisterType<QQuickVTKRenderItem>(uri, major, minor, "VTKRenderItem"); - qmlRegisterType<QQuickVTKInteractiveWidget>(uri, major, minor, "VTKWidget"); -} - -//------------------------------------------------------------------------------------------------- -void QQmlVTKPlugin::initializeEngine(QQmlEngine* engine, const char* uri) -{ - Q_ASSERT(QString::compare(uri, "VTK") == 0); - - QObject::connect( - engine, &QQmlEngine::destroyed, this, &QQmlVTKPlugin::cleanup, Qt::DirectConnection); -} - -//------------------------------------------------------------------------------------------------- -void QQmlVTKPlugin::cleanup() {} -VTK_ABI_NAMESPACE_END diff --git a/GUISupport/QtQuick/qml/QQmlVTKPlugin.h b/GUISupport/QtQuick/qml/QQmlVTKPlugin.h deleted file mode 100644 index 574babed099..00000000000 --- a/GUISupport/QtQuick/qml/QQmlVTKPlugin.h +++ /dev/null @@ -1,96 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -#ifndef QQmlVTKPlugin_h -#define QQmlVTKPlugin_h - -#include "vtkABINamespace.h" -#include "vtkDeprecation.h" - -// Qt includes -#include <QQmlExtensionPlugin> - -/** - * \class QQmlVTKPlugin - * \brief Plugin class to expose a VTK C++ module to QML applications - * - * QQmlVTKPlugin registers various VTK C++ classes as QML types so that QtQuick applications can - * directly import and use these types from QML. - * - * ## Importing the VTK module in QML - * As part of VTK's compilation process, it would compile and install a \em \b qmldir file that - * provides the module definition and relevant plugin information required by QML to load VTK. To - * load the plugin, set the environment variable - * [QML2_IMPORT_PATH](https://doc.qt.io/qt-5/qtqml-syntax-imports.html#qml-import-path) to the path - * of the directory containing the \em qmldir file. - * - * \code - * # /projects/Import has a sub-directory VTK.9.0/qmldir - * $ export QML2_IMPORT_PATH=/projects/Import - * \endcode - * - * Once the import path is set correctly, the module can be imported in the \em .qml file as - * follows: - * - * \code - * import VTK 9.0 - * \endcode - * - * ## Registered types - * The C++ classes exposed to QML and their associated typenames are as follows: - * - * | VTK C++ class | QML type | - * | :--------------: | :--------------: | - * | QQuickVTKRenderWindow | VTKRenderWindow | - * | QQuickVTKRenderItem | VTKRenderItem | - * | QQuickVTKInteractiveWidget | VTKWidget | - * - * ## Versioning - * The VTK QML module follows the version number of the VTK source tree. For example, if compiled - * against VTK 9.0.x, the VTK module version will be 9.0 - */ -VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0("Use QQuickVTKItem instead") QQmlVTKPlugin - : public QQmlExtensionPlugin -{ - Q_OBJECT - typedef QQmlExtensionPlugin Superclass; - - Q_PLUGIN_METADATA(IID "org.kitware.VTK") - -public: - /** - * Constructor - */ - QQmlVTKPlugin() = default; - - /** - * Destructor - */ - ~QQmlVTKPlugin() override = default; - - /** - * Register QML types provided by VTK - */ - void registerTypes(const char* uri) override; - - /** - * Initialize the extension using the QQmlEngine - * - * \sa cleanup - */ - void initializeEngine(QQmlEngine* engine, const char* uri) override; - -protected Q_SLOTS: - /** - * Destroy any singleton instances that were created during initializeEngine - * - * \sa initializeEngine - */ - void cleanup(); - -private: - Q_DISABLE_COPY(QQmlVTKPlugin); -}; - -VTK_ABI_NAMESPACE_END -#endif // QQmlVTKPlugin_h diff --git a/GUISupport/QtQuick/qml/plugins.qmltypes b/GUISupport/QtQuick/qml/plugins.qmltypes deleted file mode 100644 index 23bcd014708..00000000000 --- a/GUISupport/QtQuick/qml/plugins.qmltypes +++ /dev/null @@ -1,51 +0,0 @@ -import QtQuick.tooling 1.2 - -// This file describes the plugin-supplied types contained in the library. -// It is used for QML tooling purposes only. -// -// This file was auto-generated by: -// 'qmlplugindump -output $qmldir/VTK.9.1/plugins.qmltypes VTK 9.1 $qmldir' - -Module { - dependencies: ["QtQuick 2.0"] - Component { - name: "QQuickVTKInteractiveWidget" - prototype: "QObject" - exports: ["VTKWidget 9.1"] - exportMetaObjectRevisions: [0] - Property { name: "enabled"; type: "bool" } - Signal { - name: "enabledChanged" - Parameter { name: "e"; type: "bool" } - } - Method { - name: "sync" - Parameter { name: "ren"; type: "vtkRenderer"; isPointer: true } - } - } - Component { - name: "QQuickVTKRenderItem" - defaultProperty: "data" - prototype: "QQuickItem" - exports: ["VTKRenderItem 9.1"] - exportMetaObjectRevisions: [0] - Property { name: "renderWindow"; type: "QQuickVTKRenderWindow"; isPointer: true } - Method { name: "sync" } - Method { name: "init" } - Method { name: "paint" } - Method { name: "cleanup" } - } - Component { - name: "QQuickVTKRenderWindow" - defaultProperty: "data" - prototype: "QQuickItem" - exports: ["VTKRenderWindow 9.1"] - exportMetaObjectRevisions: [0] - Method { name: "sync" } - Method { name: "init" } - Method { name: "paint" } - Method { name: "cleanup" } - Method { name: "renderNow" } - Method { name: "render" } - } -} diff --git a/GUISupport/QtQuick/qml/qmldir.in b/GUISupport/QtQuick/qml/qmldir.in deleted file mode 100644 index c9d94e11ee4..00000000000 --- a/GUISupport/QtQuick/qml/qmldir.in +++ /dev/null @@ -1,4 +0,0 @@ -module VTK -plugin qmlvtkplugin -classname QQmlVTKPlugin -typeinfo plugins.qmltypes diff --git a/IO/IOSS/vtkIOSSWriter.h b/IO/IOSS/vtkIOSSWriter.h index 1a2560701af..18f8f139468 100644 --- a/IO/IOSS/vtkIOSSWriter.h +++ b/IO/IOSS/vtkIOSSWriter.h @@ -81,7 +81,6 @@ #ifndef vtkIOSSWriter_h #define vtkIOSSWriter_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED #include "vtkIOIOSSModule.h" // For export macros #include "vtkIOSSReader.h" // For vtkIOSSReader::EntityType #include "vtkNew.h" // For vtkNew @@ -524,24 +523,6 @@ public: vtkBooleanMacro(OffsetGlobalIds, bool); ///@} - ///@{ - /** - * If input is untransformed IOSS dataset, then the writer can preserve entity - * group classifications, such as element blocks, side sets etc. The same is - * not true if the input has been transformed e.g. through a clip filter. Thus - * flag is used to indicate whether the input has valid element - * classifications. - */ - VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.") - void SetPreserveInputEntityGroups(bool) {} - VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.") - bool GetPreserveInputEntityGroups() { return true; } - VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.") - void PreserveInputEntityGroupsOn() {} - VTK_DEPRECATED_IN_9_3_0("PreserveInputEntityGroups is no longer needed.") - void PreserveInputEntityGroupsOff() {} - ///@} - ///@{ /** * If input is transformed, e.g. through clipping, new element blocks may be created. @@ -583,25 +564,6 @@ public: vtkGetMacro(DisplacementMagnitude, double); ///@} - ///@{ - /** - * A debugging variable, set this to non-zero positive number to save at most - * the specified number of timesteps in a single file before starting a new - * one. The writer may start new files (aka restarts) automatically if it - * determines that the mesh has changed. - * - * Defaults to 0 i.e. unlimited timesteps per file. - */ - VTK_DEPRECATED_IN_9_3_0("Use TimeStepRange/TimeStepStride instead.") - void SetMaximumTimeStepsPerFile(int val) - { - this->SetTimeStepStride(1); - this->SetTimeStepRange(0, val - 1); - } - VTK_DEPRECATED_IN_9_3_0("Use TimeStepRange/TimeStepStride instead.") - int GetMaximumTimeStepsPerFile() { return this->TimeStepRange[1] + 1; } - ///@} - ///@{ /** * `TimeStepRange` and `TimeStepStride` can be used to limit which timesteps will be written. diff --git a/IO/OCCT/vtkOCCTReader.h b/IO/OCCT/vtkOCCTReader.h index 36a02f5be33..9bfee8897d4 100644 --- a/IO/OCCT/vtkOCCTReader.h +++ b/IO/OCCT/vtkOCCTReader.h @@ -20,7 +20,6 @@ #include <vtkMultiBlockDataSetAlgorithm.h> -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkIOOCCTModule.h" // For export macro #include <memory> // For std::unique_ptr @@ -48,8 +47,6 @@ public: * It can be either STEP or IGES. * Default is FILE_FORMAT::STEP */ - VTK_DEPRECATED_IN_9_3_0("Use SetFormat with unsigned int instead.") - vtkSetEnumMacro(FileFormat, Format); vtkSetClampMacro(FileFormat, unsigned int, Format::STEP, Format::IGES); ///@} diff --git a/Infovis/Core/CMakeLists.txt b/Infovis/Core/CMakeLists.txt index 5147cbf7b11..95bfad015fe 100644 --- a/Infovis/Core/CMakeLists.txt +++ b/Infovis/Core/CMakeLists.txt @@ -6,7 +6,6 @@ set(classes vtkCollapseGraph vtkCollapseVerticesByArray vtkContinuousScatterplot - vtkDataObjectToTable vtkDotProductSimilarity vtkEdgeCenters vtkExpandSelectedGraph diff --git a/Infovis/Core/vtkDataObjectToTable.cxx b/Infovis/Core/vtkDataObjectToTable.cxx deleted file mode 100644 index a162a5e8eb7..00000000000 --- a/Infovis/Core/vtkDataObjectToTable.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation -// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov -// VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkDataObjectToTable.h" - -#include "vtkCellData.h" -#include "vtkDataObject.h" -#include "vtkDataSet.h" -#include "vtkDataSetAttributes.h" -#include "vtkGraph.h" -#include "vtkInformation.h" -#include "vtkInformationVector.h" -#include "vtkObjectFactory.h" -#include "vtkPointData.h" -#include "vtkTable.h" - -VTK_ABI_NAMESPACE_BEGIN -vtkStandardNewMacro(vtkDataObjectToTable); -//------------------------------------------------------------------------------ -vtkDataObjectToTable::vtkDataObjectToTable() -{ - this->FieldType = POINT_DATA; -} - -//------------------------------------------------------------------------------ -vtkDataObjectToTable::~vtkDataObjectToTable() = default; - -//------------------------------------------------------------------------------ -int vtkDataObjectToTable::FillInputPortInformation(int vtkNotUsed(port), vtkInformation* info) -{ - info->Remove(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE()); - info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); - info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkGraph"); - info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkTable"); - return 1; -} - -//------------------------------------------------------------------------------ -int vtkDataObjectToTable::RequestData( - vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector) -{ - // Get input data - vtkInformation* inputInfo = inputVector[0]->GetInformationObject(0); - vtkDataObject* input = inputInfo->Get(vtkDataObject::DATA_OBJECT()); - - // Get output table - vtkInformation* outputInfo = outputVector->GetInformationObject(0); - vtkTable* output = vtkTable::SafeDownCast(outputInfo->Get(vtkDataObject::DATA_OBJECT())); - - // If the input is a table, just copy it into the output. - if (vtkTable::SafeDownCast(input)) - { - output->ShallowCopy(input); - return 1; - } - - vtkDataSetAttributes* data = vtkDataSetAttributes::New(); - - switch (this->FieldType) - { - case FIELD_DATA: - if (input->GetFieldData()) - { - data->ShallowCopy(input->GetFieldData()); - } - break; - case POINT_DATA: - if (vtkDataSet* const dataset = vtkDataSet::SafeDownCast(input)) - { - if (dataset->GetPointData()) - { - data->ShallowCopy(dataset->GetPointData()); - } - } - break; - case CELL_DATA: - if (vtkDataSet* const dataset = vtkDataSet::SafeDownCast(input)) - { - if (dataset->GetCellData()) - { - data->ShallowCopy(dataset->GetCellData()); - } - } - break; - case VERTEX_DATA: - if (vtkGraph* const graph = vtkGraph::SafeDownCast(input)) - { - if (graph->GetVertexData()) - { - data->ShallowCopy(graph->GetVertexData()); - } - } - break; - case EDGE_DATA: - if (vtkGraph* const graph = vtkGraph::SafeDownCast(input)) - { - if (graph->GetEdgeData()) - { - data->ShallowCopy(graph->GetEdgeData()); - } - } - break; - } - - output->SetRowData(data); - data->Delete(); - return 1; -} - -//------------------------------------------------------------------------------ -void vtkDataObjectToTable::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "FieldType: " << this->FieldType << endl; -} -VTK_ABI_NAMESPACE_END diff --git a/Infovis/Core/vtkDataObjectToTable.h b/Infovis/Core/vtkDataObjectToTable.h deleted file mode 100644 index 10cf8ea7ac1..00000000000 --- a/Infovis/Core/vtkDataObjectToTable.h +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-FileCopyrightText: Copyright 2008 Sandia Corporation -// SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov -/** - * @class vtkDataObjectToTable - * @brief extract field data as a table - * - * - * This filter is used to extract either the field, cell or point data of - * any data object as a table. - */ - -#ifndef vtkDataObjectToTable_h -#define vtkDataObjectToTable_h - -#include "vtkDeprecation.h" // For deprecation macros -#include "vtkInfovisCoreModule.h" // For export macro -#include "vtkTableAlgorithm.h" - -VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0("Use vtkAttributeDataToTableFilter instead of vtkDataObjectToTable.") - VTKINFOVISCORE_EXPORT vtkDataObjectToTable : public vtkTableAlgorithm -{ -public: - static vtkDataObjectToTable* New(); - vtkTypeMacro(vtkDataObjectToTable, vtkTableAlgorithm); - void PrintSelf(ostream& os, vtkIndent indent) override; - - enum - { - FIELD_DATA = 0, - POINT_DATA = 1, - CELL_DATA = 2, - VERTEX_DATA = 3, - EDGE_DATA = 4 - }; - - ///@{ - /** - * The field type to copy into the output table. - * Should be one of FIELD_DATA, POINT_DATA, CELL_DATA, VERTEX_DATA, EDGE_DATA. - */ - vtkGetMacro(FieldType, int); - vtkSetClampMacro(FieldType, int, 0, 4); - ///@} - -protected: - vtkDataObjectToTable(); - ~vtkDataObjectToTable() override; - - int FillInputPortInformation(int port, vtkInformation* info) override; - - int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override; - - int FieldType; - -private: - vtkDataObjectToTable(const vtkDataObjectToTable&) = delete; - void operator=(const vtkDataObjectToTable&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif diff --git a/Interaction/Widgets/vtk3DCursorRepresentation.cxx b/Interaction/Widgets/vtk3DCursorRepresentation.cxx index acdc10f520c..3a7865240d0 100644 --- a/Interaction/Widgets/vtk3DCursorRepresentation.cxx +++ b/Interaction/Widgets/vtk3DCursorRepresentation.cxx @@ -304,21 +304,6 @@ void vtk3DCursorRepresentation::SetCustomCursor(vtkActor* customCursor) } } -//------------------------------------------------------------------------------ -// VTK_DEPRECATED_IN_9_3_0 -void vtk3DCursorRepresentation::SetCursor(vtkActor* cursor) -{ - this->SetCursorShape(CUSTOM_SHAPE); - this->SetCustomCursor(cursor); -} - -//------------------------------------------------------------------------------ -// VTK_DEPRECATED_IN_9_3_0 -vtkActor* vtk3DCursorRepresentation::GetCursor() -{ - return this->GetCustomCursor(); -} - //------------------------------------------------------------------------------ void vtk3DCursorRepresentation::PrintSelf(ostream& os, vtkIndent indent) { diff --git a/Interaction/Widgets/vtk3DCursorRepresentation.h b/Interaction/Widgets/vtk3DCursorRepresentation.h index 5fdce4d7ca8..986482aaba7 100644 --- a/Interaction/Widgets/vtk3DCursorRepresentation.h +++ b/Interaction/Widgets/vtk3DCursorRepresentation.h @@ -24,7 +24,6 @@ #define vtk3DCursorRepresentation_h #include "vtkActor.h" // For vtkActor -#include "vtkDeprecation.h" // For deprecation macros #include "vtkHardwarePicker.h" // For vtkHardwarePicker #include "vtkInteractionWidgetsModule.h" // For export macro #include "vtkNew.h" // For vtkNew @@ -92,17 +91,6 @@ public: vtkGetSmartPointerMacro(CustomCursor, vtkActor); ///@} - ///@{ - /** - * Set / Get the actor currently used as the 3D cursor. - * By default, the cursor is a 3D cross (vtkCursor3D). - */ - VTK_DEPRECATED_IN_9_3_0("Please use SetCursorShape and SetCustomCursor instead.") - virtual void SetCursor(vtkActor* cursor); - VTK_DEPRECATED_IN_9_3_0("Please use GetCustomCursor instead.") - virtual vtkActor* GetCursor(); - ///@} - protected: vtk3DCursorRepresentation(); ~vtk3DCursorRepresentation() override; diff --git a/Interaction/Widgets/vtkDisplaySizedImplicitPlaneRepresentation.h b/Interaction/Widgets/vtkDisplaySizedImplicitPlaneRepresentation.h index 01c7dbf0e26..1ddea659b80 100644 --- a/Interaction/Widgets/vtkDisplaySizedImplicitPlaneRepresentation.h +++ b/Interaction/Widgets/vtkDisplaySizedImplicitPlaneRepresentation.h @@ -345,15 +345,6 @@ public: void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); } ///@} - VTK_DEPRECATED_IN_9_3_0("Please use SetInteractionColor instead.") - void SetSelectedWidgetColor(double a, double b, double c) { this->SetInteractionColor(a, b, c); } - VTK_DEPRECATED_IN_9_3_0("Please use SetInteractionColor instead.") - void SetSelectedWidgetColor(double c[3]) { this->SetInteractionColor(c); } - VTK_DEPRECATED_IN_9_3_0("Please use SetHandleColor instead.") - void SetUnselectedWidgetColor(double a, double b, double c) { this->SetHandleColor(a, b, c); } - VTK_DEPRECATED_IN_9_3_0("Please use SetHandleColor instead.") - void SetUnselectedWidgetColor(double c[3]) { this->SetHandleColor(c); } - ///@{ /** * Specify a translation distance used by the BumpPlane() method. Note that the diff --git a/Interaction/Widgets/vtkImplicitCylinderRepresentation.h b/Interaction/Widgets/vtkImplicitCylinderRepresentation.h index a0a948aa21b..b8657597630 100644 --- a/Interaction/Widgets/vtkImplicitCylinderRepresentation.h +++ b/Interaction/Widgets/vtkImplicitCylinderRepresentation.h @@ -288,18 +288,6 @@ public: void SetForegroundColor(double c[3]) { this->SetForegroundColor(c[0], c[1], c[2]); } ///@} - ///@{ - /** - * Set color to the edge - */ - VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.") - void SetEdgeColor(vtkLookupTable*) {} - VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.") - void SetEdgeColor(double, double, double) {} - VTK_DEPRECATED_IN_9_3_0("Please use GetEdgesProperty or SetHandleColor instead.") - void SetEdgeColor(double[3]) {} - ///@} - ///@{ /** * Methods to interface with the vtkImplicitCylinderWidget. diff --git a/Rendering/ANARI/vtkAnariViewNodeFactory.cxx b/Rendering/ANARI/vtkAnariViewNodeFactory.cxx index 1c43de570b2..11ee08085c6 100644 --- a/Rendering/ANARI/vtkAnariViewNodeFactory.cxx +++ b/Rendering/ANARI/vtkAnariViewNodeFactory.cxx @@ -84,8 +84,6 @@ vtkAnariViewNodeFactory::vtkAnariViewNodeFactory() this->RegisterOverride("vtkPVLight", light_maker); this->RegisterOverride("vtkPainterPolyDataMapper", pd_maker); this->RegisterOverride("vtkOpenGLPolyDataMapper", pd_maker); - // VTK_DEPRECATED_IN_9_3_0: Remove CPDM2 override after vtkCompositePolyDataMapper2 is removed - this->RegisterOverride("vtkCompositePolyDataMapper2", cpd_maker); this->RegisterOverride("vtkCompositePolyDataMapper", cpd_maker); this->RegisterOverride("vtkVolume", vol_maker); this->RegisterOverride("vtkPVLODVolume", vol_maker); diff --git a/Rendering/Annotation/vtkAxisActor.cxx b/Rendering/Annotation/vtkAxisActor.cxx index 0d83984d4be..f7d466ea917 100644 --- a/Rendering/Annotation/vtkAxisActor.cxx +++ b/Rendering/Annotation/vtkAxisActor.cxx @@ -2179,25 +2179,6 @@ void vtkAxisActor::SetMajorStart(int axis, double value) } } -//------------------------------------------------------------------------------ -void vtkAxisActor::SetTitleOffset(double titleOffsetY) -{ - this->SetTitleOffset(this->TitleOffset[0], titleOffsetY); -} - -//------------------------------------------------------------------------------ -double vtkAxisActor::GetTitleOffset() -{ - return this->TitleOffset[1]; -} - -//------------------------------------------------------------------------------ -void vtkAxisActor::GetTitleOffset(double& titleOffsetX, double& titleOffsetY) -{ - titleOffsetX = this->TitleOffset[0]; - titleOffsetY = this->TitleOffset[1]; -} - //------------------------------------------------------------------------------ bool vtkAxisActor::BoundsDisplayCoordinateChanged(vtkViewport* viewport) { diff --git a/Rendering/Annotation/vtkAxisActor.h b/Rendering/Annotation/vtkAxisActor.h index a72ca616b01..2ef3cb5b1ee 100644 --- a/Rendering/Annotation/vtkAxisActor.h +++ b/Rendering/Annotation/vtkAxisActor.h @@ -42,7 +42,6 @@ #define vtkAxisActor_h #include "vtkActor.h" -#include "vtkDeprecation.h" // For deprecation macro #include "vtkNew.h" // For vtkNew #include "vtkRenderingAnnotationModule.h" // For export macro #include "vtkSmartPointer.h" // For vtkSmartPointer @@ -728,13 +727,8 @@ public: * Y-component is the same than other offsets. * Default: (20.0, 20.0). */ - VTK_DEPRECATED_IN_9_3_0("Use SetTitleOffset(double, double) as it's now a 2d vector") - void SetTitleOffset(double titleOffsetY); - VTK_DEPRECATED_IN_9_3_0("Use GetTitleOffset(double&, double&) as it's now a 2d vector") - double GetTitleOffset(); vtkSetVector2Macro(TitleOffset, double); - // TODO: Replace getter with macro once deprecated one is removed - void GetTitleOffset(double& titleOffsetX, double& titleOffsetY); + vtkGetVector2Macro(TitleOffset, double); ///@} protected: diff --git a/Rendering/Annotation/vtkCubeAxesActor.cxx b/Rendering/Annotation/vtkCubeAxesActor.cxx index 8fa7ab75499..18b66efe03b 100644 --- a/Rendering/Annotation/vtkCubeAxesActor.cxx +++ b/Rendering/Annotation/vtkCubeAxesActor.cxx @@ -445,23 +445,6 @@ void vtkCubeAxesActor::SetLabelOffset(double offset) this->Modified(); } -//------------------------------------------------------------------------------ -void vtkCubeAxesActor::SetTitleOffset(double titleOffsetY) -{ - if (this->TitleOffset[1] != titleOffsetY) - { - this->TitleOffset[1] = titleOffsetY; - this->Modified(); - - for (int i = 0; i < NUMBER_OF_ALIGNED_AXIS; i++) - { - this->XAxes[i]->SetTitleOffset(this->TitleOffset[0], titleOffsetY); - this->YAxes[i]->SetTitleOffset(this->TitleOffset[0], titleOffsetY); - this->ZAxes[i]->SetTitleOffset(this->TitleOffset[0], titleOffsetY); - } - } -} - //------------------------------------------------------------------------------ void vtkCubeAxesActor::SetTitleOffset(double titleOffset[2]) { @@ -480,19 +463,6 @@ void vtkCubeAxesActor::SetTitleOffset(double titleOffset[2]) } } -//------------------------------------------------------------------------------ -double vtkCubeAxesActor::GetTitleOffset() -{ - return this->TitleOffset[1]; -} - -//------------------------------------------------------------------------------ -void vtkCubeAxesActor::GetTitleOffset(double& titleOffsetX, double& titleOffsetY) -{ - titleOffsetX = this->TitleOffset[0]; - titleOffsetY = this->TitleOffset[1]; -} - //------------------------------------------------------------------------------ vtkCamera* vtkCubeAxesActor::GetCamera() { diff --git a/Rendering/Annotation/vtkCubeAxesActor.h b/Rendering/Annotation/vtkCubeAxesActor.h index 251020cb56c..ce2961d26e9 100644 --- a/Rendering/Annotation/vtkCubeAxesActor.h +++ b/Rendering/Annotation/vtkCubeAxesActor.h @@ -45,7 +45,6 @@ #define vtkCubeAxesActor_h #include "vtkActor.h" -#include "vtkDeprecation.h" // For deprecation macro #include "vtkNew.h" // For vtkNew #include "vtkRenderingAnnotationModule.h" // For export macro #include "vtkSmartPointer.h" // For vtkSmartPointer @@ -161,13 +160,8 @@ public: * Explicitly specify the offset between title and labels. * Default: (20.0, 20.0). */ - VTK_DEPRECATED_IN_9_3_0("Use the new setters as it's now a 2d vector") - void SetTitleOffset(double titleOffsetY); - VTK_DEPRECATED_IN_9_3_0("Use the new getter as it's now a 2d vector") - double GetTitleOffset(); void SetTitleOffset(double titleOffset[2]); - // TODO: Replace getter with macro once deprecated one is removed - void GetTitleOffset(double& titleOffsetX, double& titleOffsetY); + vtkGetVector2Macro(TitleOffset, double); ///@} ///@{ diff --git a/Rendering/Annotation/vtkPolarAxesActor.cxx b/Rendering/Annotation/vtkPolarAxesActor.cxx index 2a2c555db9e..37886030f12 100644 --- a/Rendering/Annotation/vtkPolarAxesActor.cxx +++ b/Rendering/Annotation/vtkPolarAxesActor.cxx @@ -1,7 +1,5 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkPolarAxesActor.h" @@ -853,43 +851,6 @@ void vtkPolarAxesActor::BuildAxes(vtkViewport* viewport) this->BuildTime.Modified(); } -//------------------------------------------------------------------------------ -void vtkPolarAxesActor::AutoSubdividePolarAxisOn() -{ - this->SetAutoSubdividePolarAxis(true); -} - -//------------------------------------------------------------------------------ -void vtkPolarAxesActor::AutoSubdividePolarAxisOff() -{ - this->SetAutoSubdividePolarAxis(false); -} - -//------------------------------------------------------------------------------ -void vtkPolarAxesActor::AutoComputeTicksProperties() -{ - // set DeltaRangeMajor according to Range[1] magnitude - double rangeLength = fabs(this->PolarAxis->GetRange()[1] - this->PolarAxis->GetRange()[0]); - - // we would like no more than 15 ticks - double threshold = log10(1.5); - double log10RangeLength = log10(rangeLength); - - double stepPow10 = (log10RangeLength - std::floor(log10RangeLength) < threshold) - ? std::floor(log10RangeLength) - 1.0 - : std::floor(log10RangeLength); - - double deltaRangeMajor = std::pow(10.0, stepPow10); - double deltaRangeMinor = deltaRangeMajor / 2.0; - - if (this->DeltaRangeMajor != deltaRangeMajor || this->DeltaRangeMinor != deltaRangeMinor) - { - this->DeltaRangeMajor = deltaRangeMajor; - this->DeltaRangeMinor = deltaRangeMinor; - this->Modified(); - } -} - //------------------------------------------------------------------------------ void vtkPolarAxesActor::SetCommonAxisAttributes(vtkAxisActor* axis) { @@ -958,12 +919,6 @@ void vtkPolarAxesActor::SetPolarAxisAttributes(vtkAxisActor* axis) axis->SetExponentVisibility(false); } - // Compute delta Range values (if log == 1, deltaRange properties will be overwritten) - if (this->AutoSubdividePolarAxis) - { - this->AutoComputeTicksProperties(); - } - // Set polar axis labels axis->SetLabelVisibility(this->PolarLabelVisibility); axis->SetLabelTextProperty(this->PolarAxisLabelTextProperty); @@ -2244,24 +2199,6 @@ vtkProperty* vtkPolarAxesActor::GetSecondaryPolarArcsProperty() return this->SecondaryPolarArcsActor->GetProperty(); } -//------------------------------------------------------------------------------ -void vtkPolarAxesActor::SetNumberOfPolarAxisTicks(int tickCountRequired) -{ - if (tickCountRequired <= 1) - { - return; - } - double rangeLength = fabs(this->Range[1] - this->Range[0]); - double tmpRangeMajor = rangeLength / (tickCountRequired - 1); - double tmpRangeMinor = tmpRangeMajor / 2.0; - if (tmpRangeMajor != this->DeltaRangeMajor || tmpRangeMinor != this->DeltaRangeMinor) - { - this->DeltaRangeMajor = tmpRangeMajor; - this->DeltaRangeMinor = tmpRangeMinor; - this->Modified(); - } -} - //------------------------------------------------------------------------------ void vtkPolarAxesActor::ComputeDeltaRangePolarAxes(vtkIdType n) { @@ -2394,13 +2331,6 @@ double vtkPolarAxesActor::ComputeIdealStep(int subDivsRequired, double rangeLeng return idealStep; } -//------------------------------------------------------------------------------ -int vtkPolarAxesActor::GetNumberOfPolarAxisTicks() -{ - double rangeLength = fabs(this->Range[1] - this->Range[0]); - return static_cast<int>(std::ceil(rangeLength / this->DeltaRangeMajor) + 1); -} - double vtkPolarAxesActor::ComputeEllipseAngle(double angleInDegrees, double ratio) { double miniAngleEllipse; diff --git a/Rendering/Annotation/vtkPolarAxesActor.h b/Rendering/Annotation/vtkPolarAxesActor.h index 4ba4f1b21b2..16b55747742 100644 --- a/Rendering/Annotation/vtkPolarAxesActor.h +++ b/Rendering/Annotation/vtkPolarAxesActor.h @@ -23,7 +23,6 @@ #include "vtkActor.h" #include "vtkAxisActor.h" // access to enum values -#include "vtkDeprecation.h" // For deprecation macro #include "vtkNew.h" // used for vtkNew #include "vtkRenderingAnnotationModule.h" // For export macro #include "vtkSmartPointer.h" // used for vtkSmartPointer @@ -97,29 +96,6 @@ public: vtkGetMacro(RequestedNumberOfPolarAxes, vtkIdType); ///@} - ///@{ - /** - * Set/Get whether the number of polar axis ticks and arcs should be automatically calculated. - * Default: false. - */ - VTK_DEPRECATED_IN_9_3_0("Use SetDeltaRangeMajor instead or enable AxisTickMatchesPolarAxes") - vtkSetMacro(AutoSubdividePolarAxis, bool); - VTK_DEPRECATED_IN_9_3_0("Use SetDeltaRangeMajor instead or enable AxisTickMatchesPolarAxes") - vtkGetMacro(AutoSubdividePolarAxis, bool); - void AutoSubdividePolarAxisOn(); - void AutoSubdividePolarAxisOff(); - ///@} - - ///@{ - /** - * Set/Get a number of ticks that one would like to display along polar axis. - * NB: it modifies DeltaRangeMajor to correspond to this number. - */ - VTK_DEPRECATED_IN_9_3_0("Use SetDeltaRangeMajor instead or enable AxisTickMatchesPolarAxes") - virtual void SetNumberOfPolarAxisTicks(int); - int GetNumberOfPolarAxisTicks(); - ///@} - ///@{ /** * Define the range values displayed on the polar Axis. @@ -871,15 +847,6 @@ protected: */ void BuildRadialAxes(vtkViewport* viewport = nullptr); - /** - * Set Range and PolarAxis members value to build axis ticks - * this function doesn't actually build PolarAxis ticks, it set the DeltaRangeMajor and DeltaMajor - * attributes - * then PolarAxis itself is in charge of ticks drawing - */ - VTK_DEPRECATED_IN_9_3_0("Use SetDeltaRangeMajor instead or enable AxisTickMatchesPolarAxes") - void AutoComputeTicksProperties(); - /** * return a step attempting to be as rounded as possible according to input parameters */ @@ -1005,11 +972,6 @@ protected: */ double DeltaRangeMajor = 1.0; - /** - * DEPRECATED: Automatically subdivide polar axis. - */ - bool AutoSubdividePolarAxis = false; - /** * Range between 2 polar axes. */ diff --git a/Rendering/Core/vtkCompositePolyDataMapper.cxx b/Rendering/Core/vtkCompositePolyDataMapper.cxx index bd5ba285576..33a9f27006e 100644 --- a/Rendering/Core/vtkCompositePolyDataMapper.cxx +++ b/Rendering/Core/vtkCompositePolyDataMapper.cxx @@ -1,10 +1,8 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#include "vtkSetGet.h" -#define VTK_DEPRECATION_LEVEL 0 #include "vtkLegacy.h" +#include "vtkSetGet.h" #include "vtkCompositePolyDataMapper.h" @@ -1064,31 +1062,6 @@ void vtkCompositePolyDataMapper::GetBlockColor(unsigned int index, double color[ } } -//------------------------------------------------------------------------------ -double* vtkCompositePolyDataMapper::GetBlockColor(unsigned int index) -{ - VTK_LEGACY_REPLACED_BODY(double* vtkCompositePolyDataMapper::GetBlockColor(unsigned int index), - "VTK 9.3", void vtkCompositePolyDataMapper::GetBlockColor(unsigned int index, double color[3])); - static double white[3] = { 1.0, 1.0, 1.0 }; - - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - this->CompositeAttributes->GetBlockColor(dataObj, this->ColorResult.data()); - } - - return this->ColorResult.data(); - } - else - { - return white; - } -} - //------------------------------------------------------------------------------ void vtkCompositePolyDataMapper::RemoveBlockColor(unsigned int index) { diff --git a/Rendering/Core/vtkCompositePolyDataMapper.h b/Rendering/Core/vtkCompositePolyDataMapper.h index 8c3ad39a05e..03eaf54c927 100644 --- a/Rendering/Core/vtkCompositePolyDataMapper.h +++ b/Rendering/Core/vtkCompositePolyDataMapper.h @@ -18,7 +18,6 @@ #include "vtkPolyDataMapper.h" -#include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_3_0 #include "vtkRenderingCoreModule.h" // for export macro #include "vtkStateStorage.h" // for ivar #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO @@ -106,8 +105,6 @@ public: double color[3] = { r, g, b }; this->SetBlockColor(index, color); } - VTK_DEPRECATED_IN_9_3_0("Use void GetBlockColor(unsigned int index, double color[3])") - double* GetBlockColor(unsigned int index); void GetBlockColor(unsigned int index, double color[3]); void RemoveBlockColor(unsigned int index); void RemoveBlockColors(); @@ -335,8 +332,6 @@ private: vtkCompositePolyDataMapper(const vtkCompositePolyDataMapper&) = delete; void operator=(const vtkCompositePolyDataMapper&) = delete; - std::array<double, 3> ColorResult = {}; - class vtkInternals; std::unique_ptr<vtkInternals> Internals; }; diff --git a/Rendering/Core/vtkPointGaussianMapper.h b/Rendering/Core/vtkPointGaussianMapper.h index bd116de37c9..533c625c81a 100644 --- a/Rendering/Core/vtkPointGaussianMapper.h +++ b/Rendering/Core/vtkPointGaussianMapper.h @@ -15,7 +15,6 @@ #ifndef vtkPointGaussianMapper_h #define vtkPointGaussianMapper_h -#include "vtkDeprecation.h" // For deprecation macro #include "vtkPolyDataMapper.h" #include "vtkRenderingCoreModule.h" // For export macro @@ -170,10 +169,6 @@ public: * to avoid sending many fragments to the shader that will just get * discarded. */ - VTK_DEPRECATED_IN_9_3_0("Use SetBoundScale function instead") - void SetTriangleScale(float value) { this->SetBoundScale(value); } - VTK_DEPRECATED_IN_9_3_0("Use GetBoundScale function instead") - float GetTriangleScale() { return this->GetBoundScale(); } vtkSetMacro(BoundScale, float); vtkGetMacro(BoundScale, float); ///@} diff --git a/Rendering/OpenGL2/CMakeLists.txt b/Rendering/OpenGL2/CMakeLists.txt index c950478a857..e89534ab95e 100644 --- a/Rendering/OpenGL2/CMakeLists.txt +++ b/Rendering/OpenGL2/CMakeLists.txt @@ -3,7 +3,6 @@ set(classes vtkCameraPass vtkClearRGBPass vtkClearZPass - vtkCompositePolyDataMapper2 vtkDataTransferHelper vtkDefaultPass vtkDepthImageProcessingPass @@ -116,8 +115,7 @@ set(headers "${CMAKE_CURRENT_BINARY_DIR}/vtkRenderingOpenGLConfigure.h") set(nowrap_headers - vtkCompositeMapperHelper2.h - vtkOpenGLPointGaussianMapperHelper.h + vtkOpenGLPointGaussianMapperHelper.h vtkOpenGLShaderDeclaration.h ) diff --git a/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt b/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt index e29081552ab..a6196f99e5f 100644 --- a/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt +++ b/Rendering/OpenGL2/Testing/Cxx/CMakeLists.txt @@ -26,22 +26,6 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests TestCompositeDataOverlappingCells.cxx, TestCompositeDataPointGaussian.cxx,NO_DATA TestCompositeDataPointGaussianSelection.cxx,NO_DATA - TestCompositePolyDataMapper2.cxx,NO_DATA - TestCompositePolyDataMapper2CameraShiftScale.cxx,NO_DATA - TestCompositePolyDataMapper2CellScalars.cxx,NO_DATA - TestCompositePolyDataMapper2CustomShader.cxx,NO_DATA - TestCompositePolyDataMapper2MixedGeometryCellScalars.cxx,NO_DATA - TestCompositePolyDataMapper2MixedGeometryEdges.cxx,NO_DATA - TestCompositePolyDataMapper2NaNPartial.cxx,NO_DATA - TestCompositePolyDataMapper2PartialFieldData.cxx,NO_DATA - TestCompositePolyDataMapper2PartialPointData.cxx,NO_DATA - TestCompositePolyDataMapper2Pickability.cxx,NO_DATA - TestCompositePolyDataMapper2Picking.cxx,NO_DATA - TestCompositePolyDataMapper2Scalars.cxx,NO_DATA -# TestCompositePolyDataMapper2ScalarsSurfaceOpacity.cxx,NO_DATA #19221 - TestCompositePolyDataMapper2SharedArray.cxx,NO_DATA - TestCompositePolyDataMapper2Spheres.cxx,NO_DATA - TestCompositePolyDataMapper2Vertices.cxx,NO_DATA TestComputeShader.cxx,NO_DATA,NO_VALID,NO_OUTPUT TestCubeMap.cxx TestCubeMap2.cxx diff --git a/Rendering/OpenGL2/Testing/Cxx/TestBlockVisibility.cxx b/Rendering/OpenGL2/Testing/Cxx/TestBlockVisibility.cxx index c92d1ab6b67..4c08a4fa28a 100644 --- a/Rendering/OpenGL2/Testing/Cxx/TestBlockVisibility.cxx +++ b/Rendering/OpenGL2/Testing/Cxx/TestBlockVisibility.cxx @@ -1,11 +1,9 @@ // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen // SPDX-License-Identifier: BSD-3-Clause -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 #include "vtkActor.h" #include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositePolyDataMapper2.h" +#include "vtkCompositePolyDataMapper.h" #include "vtkCubeSource.h" #include "vtkDataArray.h" #include "vtkLookupTable.h" @@ -68,8 +66,8 @@ int TestBlockVisibility(int argc, char* argv[]) auto mbds = vtkCreateData(); - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); + vtkSmartPointer<vtkCompositePolyDataMapper> mapper = + vtkSmartPointer<vtkCompositePolyDataMapper>::New(); mapper->SetInputDataObject(mbds); // mapper->SetColorModeToMapScalars(); // mapper->SetScalarModeToUsePointData(); diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2.cxx deleted file mode 100644 index d5d320d9fd3..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2.cxx +++ /dev/null @@ -1,191 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#define syntheticData -#ifdef syntheticData -#include "vtkCylinderSource.h" -#else -#include "vtkXMLMultiBlockDataReader.h" -#endif - -int TestCompositePolyDataMapper2(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - -#ifdef syntheticData - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetResolution(resolution); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 32, 64 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - cyl->Update(); - child->DeepCopy(cyl->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - double rgb[3]; - vtkMath::HSVToRGB(0.8 * block / nblocks, 0.2 + 0.8 * ((parent - levelStart) % 8) / 7.0, - 1.0, rgb + 0, rgb + 1, rgb + 2); - mapper->SetBlockColor(parent + numLeaves + 1, rgb); - // mapper->SetBlockOpacity(parent+numLeaves, (block + 3) % 7 == 0 ? 0.3 - // : 1.0); - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - -#else - - vtkNew<vtkXMLMultiBlockDataReader> reader; - reader->SetFileName("C:/Users/ken.martin/Documents/vtk/data/stargate.vtm"); - mapper->SetInputConnection(reader->GetOutputPort(0)); - - // stargate seems to have cell scalars but all white cell scalars - // are slow slow slow so do not use the unless they add value - mapper->ScalarVisibilityOff(); - - // comment the following in/out for worst/best case - // for (int i = 0; i < 20000; ++i) - // { - // double r, g, b; - // vtkMath::HSVToRGB(0.8*(i%100)/100.0, 1.0, 1.0, &r, &g, &b); - // mapper->SetBlockColor(i, r, g, b); - // } - -#endif - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 0, 0); - // actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - -#ifdef syntheticData - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(1011, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(1011, 1.0); - mapper->SetBlockVisibility(1011, 1.0); -#endif - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(40.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(2.0, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CameraShiftScale.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CameraShiftScale.cxx deleted file mode 100644 index fb693e60eac..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CameraShiftScale.cxx +++ /dev/null @@ -1,161 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCallbackCommand.h" -#include "vtkCamera.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkDataSetSurfaceFilter.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLVertexBufferObject.h" -#include "vtkPointData.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" - -#include "vtkRegressionTestImage.h" -#include "vtkTestUtilities.h" - -#include "vtkRenderWindowInteractor.h" - -namespace -{ -void createData(vtkMultiBlockDataSet* data) -{ - data->SetNumberOfBlocks(2); - for (int block = 0; block < 2; ++block) - { - vtkNew<vtkPolyData> poly; - data->SetBlock(block, poly); - - // create data - vtkNew<vtkPoints> pts; - vtkNew<vtkCellArray> cells; - - int xres = 200; - int yres = 10; - pts->SetDataType(VTK_DOUBLE); - for (int y = 0; y < yres; y++) - { - double angle = 2.0 * (block * 10 + y) / yres; - for (int x = 0; x < xres; x++) - { - // every ten steps in x double in size - int step = x / 10; - double size = pow(2.0, step); - double radius = 0.001 * (1.0 + 10.0 * (size - 1.0) + (x % 10) * size); - pts->InsertNextPoint(40000.0 + radius * cos(angle), radius * sin(angle), 0.0); - } - } - poly->SetPoints(pts); - - for (int y = 0; y < yres - 1; y++) - { - for (int x = 0; x < xres - 1; x++) - { - vtkIdType cellids[3]; - cellids[0] = y * xres + x; - cellids[1] = y * xres + x + 1; - cellids[2] = (y + 1) * xres + x + 1; - cells->InsertNextCell(3, cellids); - cellids[0] = y * xres + x; - cellids[1] = (y + 1) * xres + x + 1; - cellids[2] = (y + 1) * xres + x; - cells->InsertNextCell(3, cellids); - } - } - poly->SetPolys(cells); - } -} - -// Press 'm' to change mapper shift scale method between none, auto, and focal point -void keypressFunc(vtkObject* caller, unsigned long vtkNotUsed(eventId), void* clientData, - void* vtkNotUsed(callData)) -{ - const auto iren = static_cast<vtkRenderWindowInteractor*>(caller); - auto mapper = static_cast<vtkCompositePolyDataMapper2*>(clientData); - if (iren->GetKeyCode() == ' ') - { - auto currMethod = mapper->GetVBOShiftScaleMethod(); - if (currMethod == vtkPolyDataMapper::ShiftScaleMethodType::DISABLE_SHIFT_SCALE) - { - mapper->SetVBOShiftScaleMethod( - vtkPolyDataMapper::ShiftScaleMethodType::ALWAYS_AUTO_SHIFT_SCALE); - } - else if (currMethod == vtkPolyDataMapper::ShiftScaleMethodType::ALWAYS_AUTO_SHIFT_SCALE) - { - mapper->SetVBOShiftScaleMethod(vtkPolyDataMapper::ShiftScaleMethodType::AUTO_SHIFT); - } - else if (currMethod == vtkPolyDataMapper::ShiftScaleMethodType::AUTO_SHIFT) - { - mapper->SetVBOShiftScaleMethod( - vtkPolyDataMapper::ShiftScaleMethodType::FOCAL_POINT_SHIFT_SCALE); - } - else if (currMethod == vtkPolyDataMapper::ShiftScaleMethodType::FOCAL_POINT_SHIFT_SCALE) - { - mapper->SetVBOShiftScaleMethod(vtkPolyDataMapper::ShiftScaleMethodType::DISABLE_SHIFT_SCALE); - } - - vtkMultiBlockDataSet* input = - vtkMultiBlockDataSet::SafeDownCast(mapper->GetInputDataObject(0, 0)); - createData(input); - static_cast<vtkRenderWindowInteractor*>(caller)->Render(); - } -} - -} // end anon - -//------------------------------------------------------------------------------ -int TestCompositePolyDataMapper2CameraShiftScale(int argc, char* argv[]) -{ - vtkNew<vtkActor> actor; - vtkNew<vtkRenderer> renderer; - vtkNew<vtkCompositePolyDataMapper2> mapper; - renderer->SetBackground(0.0, 0.0, 0.0); - vtkNew<vtkRenderWindow> renderWindow; - renderWindow->SetSize(400, 400); - renderWindow->AddRenderer(renderer); - renderer->AddActor(actor); - vtkNew<vtkRenderWindowInteractor> iren; - iren->SetRenderWindow(renderWindow); - - vtkNew<vtkMultiBlockDataSet> data; - createData(data); - mapper->SetInputDataObject(data); - - mapper->SetVBOShiftScaleMethod(vtkPolyDataMapper::ShiftScaleMethodType::FOCAL_POINT_SHIFT_SCALE); - - actor->SetMapper(mapper); - actor->GetProperty()->SetDiffuse(0.0); - actor->GetProperty()->SetAmbient(1.0); - actor->GetProperty()->SetRepresentationToWireframe(); - actor->SetPosition(-40000, 0, 0); - - renderer->SetBackground(0.1, 0.2, 0.4); - - renderer->GetActiveCamera()->SetPosition(0.001, 0.0015, 0.01); - renderer->GetActiveCamera()->SetFocalPoint(0.001, 0.0015, 0); - - renderer->ResetCameraClippingRange(); - renderWindow->Render(); - vtkRegressionTestPassForMesaLessThan(renderWindow, 21, 2, 0); - renderWindow->Render(); - - vtkNew<vtkCallbackCommand> keypressCallback; - keypressCallback->SetCallback(keypressFunc); - keypressCallback->SetClientData(mapper); - - iren->AddObserver(vtkCommand::KeyPressEvent, keypressCallback); - - int retVal = vtkRegressionTestImage(renderWindow); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CellScalars.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CellScalars.cxx deleted file mode 100644 index 33d08dcac3d..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CellScalars.cxx +++ /dev/null @@ -1,174 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointDataToCellData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" - -int TestCompositePolyDataMapper2CellScalars(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - win->SetMultiSamples(0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetResolution(resolution); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(cyl->GetOutputPort()); - - vtkNew<vtkPointDataToCellData> p2c; - p2c->SetInputConnection(elev->GetOutputPort()); - p2c->PassPointDataOff(); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 32, 64 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - elev->SetLowPoint(block * 0.25 - 0.2 + 0.2 * block / nblocks, -0.02, 0.0); - elev->SetHighPoint(block * 0.25 + 0.1 + 0.2 * block / nblocks, 0.02, 0.0); - p2c->Update(); - child->DeepCopy(p2c->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - mapper->SetScalarModeToUseCellData(); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 0, 0); - // actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(911, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(911, 1.0); - mapper->SetBlockVisibility(911, 1.0); - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 30 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(10.0 / numFrames); - ren->GetActiveCamera()->Azimuth(-50.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(2.5, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CustomShader.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CustomShader.cxx deleted file mode 100644 index e1d1d00a3fc..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2CustomShader.cxx +++ /dev/null @@ -1,157 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkCompositePolyDataMapper2.h" - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkFloatArray.h" -#include "vtkLookupTable.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkShaderProperty.h" -#include "vtkSmartPointer.h" -#include "vtkSphereSource.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -void FillShaderProperty(vtkActor* actor) -{ - // Modify the shader to color based on model normal - // To do this we have to modify the vertex shader - // to pass the normal in model coordinates - // through to the fragment shader. By default the normal - // is converted to View coordinates and then passed on. - // We keep that, but add a varying for the original normal. - // Then we modify the fragment shader to set the diffuse color - // based on that normal. First lets modify the vertex - // shader - vtkShaderProperty* sp = actor->GetShaderProperty(); - sp->AddVertexShaderReplacement("//VTK::Normal::Dec", // replace the normal block - true, // before the standard replacements - "//VTK::Normal::Dec\n" // we still want the default - " out vec3 myNormalMCVSOutput;\n", // but we add this - false // only do it once - ); - sp->AddVertexShaderReplacement("//VTK::Normal::Impl", // replace the normal block - true, // before the standard replacements - "//VTK::Normal::Impl\n" // we still want the default - " myNormalMCVSOutput = normalMC;\n", // but we add this - false // only do it once - ); - sp->AddVertexShaderReplacement("//VTK::Color::Impl", // dummy replacement for testing clear method - true, "VTK::Color::Impl\n", false); - sp->ClearVertexShaderReplacement("//VTK::Color::Impl", true); - - // now modify the fragment shader - sp->AddFragmentShaderReplacement("//VTK::Normal::Dec", // replace the normal block - true, // before the standard replacements - "//VTK::Normal::Dec\n" // we still want the default - " in vec3 myNormalMCVSOutput;\n", // but we add this - false // only do it once - ); - sp->AddFragmentShaderReplacement("//VTK::Normal::Impl", // replace the normal block - true, // before the standard replacements - "//VTK::Normal::Impl\n" // we still want the default calc - " diffuseColor = abs(myNormalMCVSOutput);\n", // but we add this - false // only do it once - ); -} - -int TestCompositePolyDataMapper2CustomShader(int argc, char* argv[]) -{ - vtkNew<vtkRenderer> renderer; - - // Generate two copies of a vtkPolyData containing the same sphere - vtkNew<vtkSphereSource> sphereSource; - sphereSource->Update(); - vtkPolyData* sphere = vtkPolyData::SafeDownCast(sphereSource->GetOutputDataObject(0)); - - vtkSmartPointer<vtkPolyData> sphere1 = vtkSmartPointer<vtkPolyData>::Take(sphere->NewInstance()); - sphere1->DeepCopy(sphere); - - sphereSource->SetCenter(1., 0., 0.); - sphereSource->Update(); - sphere = vtkPolyData::SafeDownCast(sphereSource->GetOutputDataObject(0)); - - vtkNew<vtkPolyData> sphere2; - sphere2->DeepCopy(sphere); - - // Generate scalars with indices for all points on the sphere - vtkNew<vtkFloatArray> scalars; - scalars->SetName("Scalars"); - scalars->SetNumberOfComponents(1); - scalars->SetNumberOfTuples(sphere1->GetNumberOfPoints()); - for (vtkIdType i = 0; i < scalars->GetNumberOfTuples(); ++i) - { - scalars->SetTypedComponent(i, 0, static_cast<float>(i)); - } - - // Only add scalars to sphere 1. - sphere1->GetPointData()->SetScalars(scalars); - - vtkNew<vtkMultiBlockDataSet> mbds; - mbds->SetNumberOfBlocks(2); - mbds->SetBlock(0, sphere1); - mbds->SetBlock(1, sphere2); - - vtkNew<vtkLookupTable> lut; - lut->SetValueRange(scalars->GetRange()); - lut->SetNanColor(1., 1., 0., 1.); - lut->Build(); - - vtkNew<vtkCompositePolyDataMapper2> mapper; - mapper->SetInputDataObject(mbds); - mapper->SetLookupTable(lut); - mapper->SetScalarVisibility(1); - mapper->SetScalarRange(scalars->GetRange()); - mapper->SetColorMissingArraysWithNanColor(true); - mapper->SetInputArrayToProcess( - 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS); - - vtkNew<vtkActor> actor; - actor->SetMapper(mapper); - actor->GetProperty()->SetColor(0., 0., 1.); - actor->GetProperty()->SetAmbientColor(0.2, 0.2, 1.0); - actor->GetProperty()->SetDiffuseColor(1.0, 0.65, 0.7); - actor->GetProperty()->SetSpecularColor(1.0, 1.0, 1.0); - actor->GetProperty()->SetSpecular(0.5); - actor->GetProperty()->SetDiffuse(0.7); - actor->GetProperty()->SetAmbient(0.5); - actor->GetProperty()->SetSpecularPower(20.0); - actor->GetProperty()->SetOpacity(1.0); - FillShaderProperty(actor.GetPointer()); - renderer->AddActor(actor); - - vtkNew<vtkRenderWindowInteractor> iren; - vtkNew<vtkRenderWindow> renWin; - renWin->SetMultiSamples(0); - iren->SetRenderWindow(renWin); - renWin->AddRenderer(renderer); - - renWin->SetSize(500, 500); - renderer->GetActiveCamera()->SetPosition(0, 0, 1); - renderer->GetActiveCamera()->SetFocalPoint(0, 0, 0); - renderer->GetActiveCamera()->SetViewUp(0, 1, 0); - renderer->ResetCamera(); - - renWin->Render(); - - int retVal = vtkRegressionTestImageThreshold(renWin, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryCellScalars.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryCellScalars.cxx deleted file mode 100644 index 6caf4e28926..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryCellScalars.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointDataToCellData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkAppendPolyData.h" -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" -#include "vtkExtractEdges.h" -#include "vtkPlaneSource.h" - -int TestCompositePolyDataMapper2MixedGeometryCellScalars(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - win->SetMultiSamples(0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetHeight(0.8); - cyl->SetResolution(resolution); - - vtkNew<vtkPlaneSource> plane; - plane->SetResolution(resolution, resolution); - plane->SetOrigin(-0.2, -0.2, 0.0); - plane->SetPoint1(0.2, -0.2, 0.0); - plane->SetPoint2(-0.2, 0.2, 0.0); - - vtkNew<vtkExtractEdges> extract; - extract->SetInputConnection(plane->GetOutputPort()); - - vtkNew<vtkAppendPolyData> append; - append->SetUserManagedInputs(1); - append->SetNumberOfInputs(2); - append->SetInputConnectionByNumber(0, cyl->GetOutputPort()); - append->SetInputConnectionByNumber(1, extract->GetOutputPort()); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(append->GetOutputPort()); - - vtkNew<vtkPointDataToCellData> p2c; - p2c->SetInputConnection(elev->GetOutputPort()); - p2c->PassPointDataOff(); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 8, 16 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, -0.3, parent * 0.5); - plane->SetCenter(block * 0.25, 0.5, parent * 0.5); - elev->SetLowPoint(block * 0.25 - 0.2 + 0.2 * block / nblocks, -0.02, 0.0); - elev->SetHighPoint(block * 0.25 + 0.1 + 0.2 * block / nblocks, 0.02, 0.0); - p2c->Update(); - child->DeepCopy(p2c->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - mapper->SetScalarModeToUseCellData(); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 0, 0); - // actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(54, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(54, 1.0); - mapper->SetBlockVisibility(54, 1.0); - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(15.0 / numFrames); - ren->GetActiveCamera()->Azimuth(-190.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(1.5, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(5.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryEdges.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryEdges.cxx deleted file mode 100644 index 9318e754258..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2MixedGeometryEdges.cxx +++ /dev/null @@ -1,194 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointDataToCellData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkAppendPolyData.h" -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" -#include "vtkExtractEdges.h" -#include "vtkPlaneSource.h" - -int TestCompositePolyDataMapper2MixedGeometryEdges(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - win->SetMultiSamples(0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetHeight(0.8); - cyl->SetResolution(resolution); - - vtkNew<vtkPlaneSource> plane; - plane->SetResolution(resolution, resolution); - plane->SetOrigin(-0.2, -0.2, 0.0); - plane->SetPoint1(0.2, -0.2, 0.0); - plane->SetPoint2(-0.2, 0.2, 0.0); - - vtkNew<vtkExtractEdges> extract; - extract->SetInputConnection(plane->GetOutputPort()); - - vtkNew<vtkAppendPolyData> append; - append->SetUserManagedInputs(1); - append->SetNumberOfInputs(2); - append->SetInputConnectionByNumber(0, cyl->GetOutputPort()); - append->SetInputConnectionByNumber(1, extract->GetOutputPort()); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(append->GetOutputPort()); - - vtkNew<vtkPointDataToCellData> p2c; - p2c->SetInputConnection(elev->GetOutputPort()); - p2c->PassPointDataOff(); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 8, 16 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, -0.3, parent * 0.5); - plane->SetCenter(block * 0.25, 0.5, parent * 0.5); - elev->SetLowPoint(block * 0.25 - 0.2 + 0.2 * block / nblocks, -0.02, 0.0); - elev->SetHighPoint(block * 0.25 + 0.1 + 0.2 * block / nblocks, 0.02, 0.0); - p2c->Update(); - child->DeepCopy(p2c->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - mapper->SetScalarModeToUseCellData(); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 1, 1); - actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(54, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(54, 1.0); - mapper->SetBlockVisibility(54, 1.0); - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(15.0 / numFrames); - ren->GetActiveCamera()->Azimuth(-190.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(1.5, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(5.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2NaNPartial.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2NaNPartial.cxx deleted file mode 100644 index 20a5e95535a..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2NaNPartial.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkCompositePolyDataMapper2.h" - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkFloatArray.h" -#include "vtkLookupTable.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" -#include "vtkSphereSource.h" -#include "vtkTrivialProducer.h" - -int TestCompositePolyDataMapper2NaNPartial(int, char*[]) -{ - vtkNew<vtkRenderer> renderer; - - vtkNew<vtkSphereSource> sphereSource; - sphereSource->Update(); - vtkPolyData* sphere = vtkPolyData::SafeDownCast(sphereSource->GetOutputDataObject(0)); - - vtkSmartPointer<vtkPolyData> sphere1 = vtkSmartPointer<vtkPolyData>::Take(sphere->NewInstance()); - sphere1->DeepCopy(sphere); - - sphereSource->SetCenter(1., 0., 0.); - sphereSource->Update(); - sphere = vtkPolyData::SafeDownCast(sphereSource->GetOutputDataObject(0)); - - vtkSmartPointer<vtkPolyData> sphere2 = vtkSmartPointer<vtkPolyData>::Take(sphere->NewInstance()); - sphere2->DeepCopy(sphere); - - vtkNew<vtkFloatArray> scalars; - scalars->SetName("Scalars"); - scalars->SetNumberOfComponents(1); - scalars->SetNumberOfTuples(sphere1->GetNumberOfPoints()); - for (vtkIdType i = 0; i < scalars->GetNumberOfTuples(); ++i) - { - scalars->SetTypedComponent(i, 0, static_cast<float>(i)); - } - - // Only add scalars to sphere 1. - sphere1->GetPointData()->SetScalars(scalars); - - vtkNew<vtkMultiBlockDataSet> mbds; - mbds->SetNumberOfBlocks(2); - mbds->SetBlock(0, sphere1); - mbds->SetBlock(1, sphere2); - - vtkNew<vtkTrivialProducer> source; - source->SetOutput(mbds); - - vtkNew<vtkLookupTable> lut; - lut->SetValueRange(scalars->GetRange()); - lut->SetNanColor(1., 1., 0., 1.); - lut->Build(); - - vtkNew<vtkCompositePolyDataMapper2> mapper; - mapper->SetInputConnection(source->GetOutputPort()); - mapper->SetLookupTable(lut); - mapper->SetScalarVisibility(1); - mapper->SetScalarRange(scalars->GetRange()); - mapper->SetColorMissingArraysWithNanColor(true); - mapper->SetInputArrayToProcess( - 0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS); - - vtkNew<vtkActor> actor; - actor->SetMapper(mapper); - actor->GetProperty()->SetColor(0., 0., 1.); - renderer->AddActor(actor); - - vtkNew<vtkRenderWindowInteractor> iren; - vtkNew<vtkRenderWindow> renWin; - renWin->SetMultiSamples(0); - iren->SetRenderWindow(renWin); - renWin->AddRenderer(renderer); - - renWin->SetSize(500, 500); - renderer->GetActiveCamera()->SetPosition(0, 0, 1); - renderer->GetActiveCamera()->SetFocalPoint(0, 0, 0); - renderer->GetActiveCamera()->SetViewUp(0, 1, 0); - renderer->ResetCamera(); - - renWin->Render(); - iren->Start(); - - return EXIT_SUCCESS; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialFieldData.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialFieldData.cxx deleted file mode 100644 index b839bf15fd7..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialFieldData.cxx +++ /dev/null @@ -1,119 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkColorTransferFunction.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCylinderSource.h" -#include "vtkDoubleArray.h" -#include "vtkFieldData.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRegressionTestImage.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// Test for multiblock data sets with field data arrays defined on -// only a subset of the blocks. The expected behavior is to have -// coloring by scalars on the blocks with the data array and coloring -// as though scalar mapping is turned off in the blocks without the -// data array. -int TestCompositePolyDataMapper2PartialFieldData(int argc, char* argv[]) -{ - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - // Components of the multiblock data set - vtkNew<vtkCylinderSource> cylinderSource; - cylinderSource->SetRadius(1.5); - cylinderSource->SetHeight(2.0); - cylinderSource->SetResolution(32); - - // Set up the multiblock data set consisting of a ring of blocks - vtkSmartPointer<vtkMultiBlockDataSet> data = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - - int numBlocks = 15; - data->SetNumberOfBlocks(numBlocks); - - double radius = 10.0; - double deltaTheta = 2.0 * vtkMath::Pi() / numBlocks; - for (int i = 0; i < numBlocks; ++i) - { - double theta = i * deltaTheta; - double x = radius * cos(theta); - double y = radius * sin(theta); - - vtkPolyData* pd = vtkPolyData::New(); - - // Every third block does not have the color array - if (i % 3 == 0) - { - cylinderSource->SetCenter(x, y, 0.0); - cylinderSource->Update(); - pd->DeepCopy(cylinderSource->GetOutput()); - } - else - { - cylinderSource->SetCenter(x, y, 0.0); - cylinderSource->Update(); - pd->DeepCopy(cylinderSource->GetOutput()); - - // Add a field data array - vtkSmartPointer<vtkDoubleArray> dataArray = vtkSmartPointer<vtkDoubleArray>::New(); - dataArray->SetName("mydata"); - dataArray->SetNumberOfComponents(1); - dataArray->SetNumberOfTuples(1); - dataArray->InsertValue(0, static_cast<double>(i)); - - pd->GetFieldData()->AddArray(dataArray); - } - data->SetBlock(i, pd); - pd->Delete(); - } - - vtkNew<vtkColorTransferFunction> lookupTable; - lookupTable->AddRGBPoint(0.0, 1.0, 1.0, 1.0); - lookupTable->AddRGBPoint(static_cast<double>(numBlocks - 1), 0.0, 1.0, 0.0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - mapper->SetInputDataObject(data); - - // Tell mapper to use field data for rendering - mapper->SetLookupTable(lookupTable); - mapper->SetFieldDataTupleId(0); - mapper->SelectColorArray("mydata"); - mapper->SetScalarModeToUseFieldData(); - mapper->UseLookupTableScalarRangeOn(); - mapper->ScalarVisibilityOn(); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetColor(1.0, 0.67, 1.0); - - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->ResetCamera(); - - win->Render(); - - int retVal = vtkRegressionTestImageThreshold(win, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialPointData.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialPointData.cxx deleted file mode 100644 index 120699f5c27..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2PartialPointData.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRegressionTestImage.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -// Test for multiblock data sets with point data arrays defined on -// only a subset of the blocks. The expected behavior is to have -// coloring by scalars on the blocks with the data array and coloring -// as though scalar mapping is turned off in the blocks without the -// data array. -int TestCompositePolyDataMapper2PartialPointData(int argc, char* argv[]) -{ - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - // Components of the multiblock data set - vtkNew<vtkCylinderSource> cylinderSource; - cylinderSource->SetRadius(1.5); - cylinderSource->SetHeight(2.0); - cylinderSource->SetResolution(32); - - vtkNew<vtkElevationFilter> elevationFilter; - elevationFilter->SetLowPoint(-10.0, 0.0, 0.0); - elevationFilter->SetHighPoint(10.0, 0.0, 0.0); - elevationFilter->SetInputConnection(cylinderSource->GetOutputPort()); - - // Set up the multiblock data set consisting of a ring of blocks - vtkSmartPointer<vtkMultiBlockDataSet> data = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - - int numBlocks = 15; - data->SetNumberOfBlocks(numBlocks); - - double radius = 10.0; - double deltaTheta = 2.0 * vtkMath::Pi() / numBlocks; - for (int i = 0; i < numBlocks; ++i) - { - double theta = i * deltaTheta; - double x = radius * cos(theta); - double y = radius * sin(theta); - - vtkPolyData* pd = vtkPolyData::New(); - - // Every third block does not have the color array - if (i % 3 == 0) - { - cylinderSource->SetCenter(x, y, 0.0); - cylinderSource->Update(); - pd->DeepCopy(cylinderSource->GetOutput()); - data->SetBlock(i, pd); - } - else - { - cylinderSource->SetCenter(x, y, 0.0); - elevationFilter->Update(); - pd->DeepCopy(elevationFilter->GetOutput()); - data->SetBlock(i, pd); - } - pd->Delete(); - } - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - mapper->SetInputDataObject(data); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetColor(1.0, 0.67, 1.0); - - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->ResetCamera(); - - win->Render(); - - int retVal = vtkRegressionTestImageThreshold(win, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Pickability.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Pickability.cxx deleted file mode 100644 index c5e528bb7f1..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Pickability.cxx +++ /dev/null @@ -1,242 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCellData.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkDataObjectTreeIterator.h" -#include "vtkHardwareSelector.h" -#include "vtkInformation.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPlaneSource.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSelection.h" -#include "vtkSelectionNode.h" -#include "vtkSmartPointer.h" -#include "vtkUnsignedIntArray.h" - -#include "vtkRegressionTestImage.h" -#include "vtkTestUtilities.h" - -#include <functional> -#include <set> - -template <typename T, typename U, typename V> -void prepareDisplayAttribute( - T& expected, U attr, V mbds, std::function<std::pair<bool, bool>(int)> config) -{ - expected.clear(); - auto bit = mbds->NewTreeIterator(); - for (bit->InitTraversal(); !bit->IsDoneWithTraversal(); bit->GoToNextItem()) - { - int ii = bit->GetCurrentFlatIndex(); - auto cfg = config(ii); - bool visible = cfg.first; - bool pickable = cfg.second; - auto dataObj = bit->GetCurrentDataObject(); - if (visible && pickable) - { - auto pd = vtkPolyData::SafeDownCast(dataObj); - if (pd) - { - auto cid = pd->GetCellData()->GetArray("vtkCompositeIndex"); - int idx = cid ? cid->GetTuple1(0) : ii; - expected.insert(idx); - } - } - attr->SetBlockVisibility(dataObj, visible); - attr->SetBlockPickability(dataObj, pickable); - } - bit->Delete(); -} - -template <typename T> -void addCompositeIndex(T mbds, int& nextIndex) -{ - int nblk = static_cast<int>(mbds->GetNumberOfBlocks()); - for (int i = 0; i < nblk; ++i) - { - auto blk = mbds->GetBlock(i); - if (blk->IsA("vtkCompositeDataSet")) - { - addCompositeIndex(vtkMultiBlockDataSet::SafeDownCast(blk), nextIndex); - } - else if (blk->IsA("vtkPolyData")) - { - auto pdata = vtkPolyData::SafeDownCast(blk); - vtkIdType nc = pdata->GetNumberOfCells(); - auto cid = vtkSmartPointer<vtkUnsignedIntArray>::New(); - cid->SetName("vtkCompositeIndex"); - cid->SetNumberOfTuples(nc); - cid->FillComponent(0, nextIndex); - pdata->GetCellData()->AddArray(cid); - ++nextIndex; - } - } -} - -template <typename T, typename U> -int checkSelection(T seln, const U& expected, int& tt) -{ - std::cout << "Test " << tt << "\n"; - ++tt; - int numNodes = seln->GetNumberOfNodes(); - U actual; - for (int nn = 0; nn < numNodes; ++nn) - { - auto sn = seln->GetNode(nn); - auto actor = vtkActor::SafeDownCast(sn->GetProperties()->Get(vtkSelectionNode::PROP())); - if (actor) - { - auto ci = sn->GetProperties()->Get(vtkSelectionNode::COMPOSITE_INDEX()); - actual.insert(ci); - } - } - - std::cout << " Expected:"; - for (auto ee : expected) - { - std::cout << " " << ee; - } - std::cout << "\n Actual:"; - for (auto aa : actual) - { - std::cout << " " << aa; - } - std::cout << "\n"; - int result = (expected == actual ? 1 : 0); - if (!result) - { - vtkGenericWarningMacro("Mismatch between expected selection and actual selection."); - } - return result; -} - -int TestCompositePolyDataMapper2Pickability(int argc, char* argv[]) -{ - auto rw = vtkSmartPointer<vtkRenderWindow>::New(); - auto ri = vtkSmartPointer<vtkRenderWindowInteractor>::New(); - auto rr = vtkSmartPointer<vtkRenderer>::New(); - auto mp = vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - auto ac = vtkSmartPointer<vtkActor>::New(); - auto mb = vtkSmartPointer<vtkMultiBlockDataSet>::New(); - auto da = vtkSmartPointer<vtkCompositeDataDisplayAttributes>::New(); - rw->AddRenderer(rr); - rw->SetInteractor(ri); - mp->SetCompositeDataDisplayAttributes(da); - - vtkNew<vtkPlaneSource> plane; - mb->SetNumberOfBlocks(4); - for (int ii = 0; ii < static_cast<int>(mb->GetNumberOfBlocks()); ++ii) - { - double ll[2]; - ll[0] = -0.5 + 1.0 * (ii % 2); - ll[1] = -0.5 + 1.0 * (ii / 2); - plane->SetOrigin(ll[0], ll[1], ii); - plane->SetPoint1(ll[0] + 1.0, ll[1], ii); - plane->SetPoint2(ll[0], ll[1] + 1.0, ii); - plane->Update(); - vtkNew<vtkPolyData> pblk; - pblk->DeepCopy(plane->GetOutputDataObject(0)); - mb->SetBlock(ii, pblk.GetPointer()); - } - - // Note this also tests that the mapper accepts a composite ID array name: - int nextId = 7; - addCompositeIndex(mb, nextId); - - mp->SetInputDataObject(0, mb.GetPointer()); - ac->SetMapper(mp); - rr->AddActor(ac); - rw->SetSize(400, 400); - rr->RemoveCuller(rr->GetCullers()->GetLastItem()); - rr->ResetCamera(); - rw->Render(); // get the window up - - double rgb[4][3] = { { .5, .5, .5 }, { 0., 1., 1. }, { 1., 1., 0. }, { 1., 0., 1. } }; - - auto it = mb->NewIterator(); - int ii = 0; - for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextItem()) - { - auto dataObj = it->GetCurrentDataObject(); - da->SetBlockColor(dataObj, rgb[ii++]); - } - it->Delete(); - - mp->SetCompositeIdArrayName("vtkCompositeIndex"); - - vtkNew<vtkHardwareSelector> hw; - hw->SetArea(130, 130, 270, 270); - hw->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_CELLS); - hw->SetRenderer(rr); - hw->SetProcessID(0); - - int testNum = 0; - std::set<int> expected; - - // Nothing visible, but everything pickable. - prepareDisplayAttribute(expected, da, mb, [](int) { return std::pair<bool, bool>(false, true); }); - mp->Modified(); - auto sel = hw->Select(); - int retVal = checkSelection(sel, expected, testNum); - sel->Delete(); - - // Everything visible, but nothing pickable. - prepareDisplayAttribute(expected, da, mb, [](int) { return std::pair<bool, bool>(true, false); }); - mp->Modified(); - sel = hw->Select(); - retVal &= checkSelection(sel, expected, testNum); - sel->Delete(); - - // One block in every possible state. - prepareDisplayAttribute(expected, da, mb, - [](int nn) - { - --nn; - return std::pair<bool, bool>(!!(nn / 2), !!(nn % 2)); - }); - mp->Modified(); - sel = hw->Select(); - retVal &= checkSelection(sel, expected, testNum); - sel->Delete(); - - // One block in every possible state (but different). - prepareDisplayAttribute(expected, da, mb, - [](int nn) - { - --nn; - return std::pair<bool, bool>(!(nn / 2), !(nn % 2)); - }); - mp->Modified(); - sel = hw->Select(); - retVal &= checkSelection(sel, expected, testNum); - sel->Delete(); - - // Everything visible and pickable.. - prepareDisplayAttribute(expected, da, mb, [](int) { return std::pair<bool, bool>(true, true); }); - mp->Modified(); - sel = hw->Select(); - retVal &= checkSelection(sel, expected, testNum); - sel->Delete(); - - int retTestImage = vtkRegressionTestImage(rw); - retVal &= retTestImage; - if (retTestImage == vtkRegressionTester::DO_INTERACTOR) - { - ri->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Picking.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Picking.cxx deleted file mode 100644 index fe7e718df88..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Picking.cxx +++ /dev/null @@ -1,312 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include <algorithm> - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkIdTypeArray.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPointDataToCellData.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkAppendPolyData.h" -#include "vtkAreaPicker.h" -#include "vtkCommand.h" -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" -#include "vtkExtractEdges.h" -#include "vtkHardwareSelector.h" -#include "vtkInteractorStyleRubberBandPick.h" -#include "vtkPlaneSource.h" -#include "vtkProp3DCollection.h" -#include "vtkRenderedAreaPicker.h" -#include "vtkSelection.h" -#include "vtkSelectionNode.h" - -namespace -{ - -class PointPickCommand : public vtkCommand -{ -protected: - vtkRenderer* Renderer; - vtkAreaPicker* Picker; - vtkPolyDataMapper* Mapper; - std::map<int, std::vector<int>> BlockPrims; - -public: - static PointPickCommand* New() { return new PointPickCommand; } - - PointPickCommand() = default; - - ~PointPickCommand() override = default; - - void SetPointIds(vtkSelection* selection) - { - // Find selection node that we're interested in: - const vtkIdType numNodes = selection->GetNumberOfNodes(); - for (vtkIdType nodeId = 0; nodeId < numNodes; ++nodeId) - { - vtkSelectionNode* node = selection->GetNode(nodeId); - - // Check if the mapper is this instance of MoleculeMapper - vtkActor* selActor = - vtkActor::SafeDownCast(node->GetProperties()->Get(vtkSelectionNode::PROP())); - if (selActor && (selActor->GetMapper() == this->Mapper)) - { - int blockIndex = node->GetProperties()->Get(vtkSelectionNode::COMPOSITE_INDEX()); - cerr << "Block ID " << blockIndex << " with prim ids of: "; - - vtkIdTypeArray* selIds = vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()); - if (selIds) - { - vtkIdType numIds = selIds->GetNumberOfTuples(); - for (vtkIdType i = 0; i < numIds; ++i) - { - vtkIdType curId = selIds->GetValue(i); - this->BlockPrims[blockIndex].push_back(curId); - cerr << " " << curId; - } - } - cerr << "\n"; - } - } - } - - std::map<int, std::vector<int>>& GetBlockPrims() { return this->BlockPrims; } - - void SetMapper(vtkPolyDataMapper* m) { this->Mapper = m; } - - void SetRenderer(vtkRenderer* r) { this->Renderer = r; } - - void SetPicker(vtkAreaPicker* p) { this->Picker = p; } - - void Execute(vtkObject*, unsigned long, void*) override - { - vtkProp3DCollection* props = this->Picker->GetProp3Ds(); - if (props->GetNumberOfItems() != 0) - { - // If anything was picked during the fast area pick, do a more detailed - // pick. - vtkNew<vtkHardwareSelector> selector; - selector->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_POINTS); - selector->SetRenderer(this->Renderer); - selector->SetArea(static_cast<unsigned int>(this->Renderer->GetPickX1()), - static_cast<unsigned int>(this->Renderer->GetPickY1()), - static_cast<unsigned int>(this->Renderer->GetPickX2()), - static_cast<unsigned int>(this->Renderer->GetPickY2())); - // Make the actual pick and pass the result to the convenience function - // defined earlier - vtkSelection* result = selector->Select(); - this->SetPointIds(result); - // this->DumpPointSelection(); - result->Delete(); - } - } -}; - -} - -int TestCompositePolyDataMapper2Picking(int argc, char* argv[]) -{ - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - win->SetMultiSamples(0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkPlaneSource> plane; - plane->SetResolution(resolution, resolution); - plane->SetOrigin(-0.2, -0.2, 0.0); - plane->SetPoint1(0.2, -0.2, 0.0); - plane->SetPoint2(-0.2, 0.2, 0.0); - - vtkNew<vtkExtractEdges> extract; - extract->SetInputConnection(plane->GetOutputPort()); - - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetResolution(resolution); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(cyl->GetOutputPort()); - - vtkNew<vtkPointDataToCellData> p2c; - p2c->SetInputConnection(elev->GetOutputPort()); - p2c->PassPointDataOff(); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 8, 16 }; - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - if ((block / 6) % 2) - { - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - plane->SetCenter(block * 0.25, 0.5, parent * 0.5); - elev->SetLowPoint(block * 0.25 - 0.2 + 0.2 * block / nblocks, -0.02, 0.0); - elev->SetHighPoint(block * 0.25 + 0.1 + 0.2 * block / nblocks, 0.02, 0.0); - elev->Update(); - - vtkPolyData* poly = vtkPolyData::SafeDownCast(elev->GetOutput(0)); - vtkNew<vtkCellArray> lines; - lines->InsertNextCell(2); - lines->InsertCellPoint(16); - lines->InsertCellPoint(17); - lines->InsertNextCell(2); - lines->InsertCellPoint(18); - lines->InsertCellPoint(19); - poly->SetLines(lines); - // note this strip is coincident with the cylinder and - // with cell colors will resultin in some rendering - // artifacts/flickering - vtkNew<vtkCellArray> strips; - strips->InsertNextCell(5); - strips->InsertCellPoint(20); - strips->InsertCellPoint(21); - strips->InsertCellPoint(22); - strips->InsertCellPoint(23); - strips->InsertCellPoint(24); - poly->SetStrips(strips); - - p2c->Update(); - child->DeepCopy(p2c->GetOutput(0)); - } - else - { - plane->SetCenter(block * 0.25, 0.5, parent * 0.5); - extract->Update(); - child->DeepCopy(extract->GetOutput(0)); - } - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - mapper->SetScalarModeToUseCellData(); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 0, 0); - // actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(80, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(80, 1.0); - mapper->SetBlockVisibility(80, 1.0); - - // Setup picker - vtkNew<vtkInteractorStyleRubberBandPick> pickerInt; - iren->SetInteractorStyle(pickerInt.GetPointer()); - vtkNew<vtkRenderedAreaPicker> picker; - iren->SetPicker(picker.GetPointer()); - - ren->GetActiveCamera()->Elevation(30.0); - ren->GetActiveCamera()->Azimuth(-40.0); - ren->GetActiveCamera()->Zoom(3.0); - ren->GetActiveCamera()->Roll(10.0); - win->Render(); - - // We'll follow up the cheap RenderedAreaPick with a detailed selection - vtkNew<PointPickCommand> com; - com->SetRenderer(ren.GetPointer()); - com->SetPicker(picker.GetPointer()); - com->SetMapper(mapper.GetPointer()); - picker->AddObserver(vtkCommand::EndPickEvent, com.GetPointer()); - - // Make pick - win->Render(); - picker->AreaPick(250, 300, 380, 380, ren.GetPointer()); - win->Render(); - - // Interact if desired - int retVal = vtkRegressionTestImage(win.GetPointer()); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - // Verify pick - std::map<int, std::vector<int>>& bPrims = com->GetBlockPrims(); - if (bPrims.find(48) == bPrims.end() || - std::find(bPrims[48].begin(), bPrims[48].end(), 14) == bPrims[48].end() || - bPrims.find(82) == bPrims.end() || - std::find(bPrims[82].begin(), bPrims[82].end(), 114) == bPrims[82].end()) - { - cerr << "Incorrect pick results (if any picks were performed inter" - "actively this could be ignored).\n"; - return EXIT_FAILURE; - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Scalars.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Scalars.cxx deleted file mode 100644 index 1a28c52ed31..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Scalars.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" - -int TestCompositePolyDataMapper2Scalars(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetResolution(resolution); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(cyl->GetOutputPort()); - // geometry range is -0.5 to 0.5 but these colors are - // pretty - elev->SetLowPoint(0, -1.0, 0); - elev->SetHighPoint(0.0, 1.0, 0.0); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 32, 64 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - elev->Update(); - child->DeepCopy(elev->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - // mapper->SetBlockOpacity(parent+numLeaves, (block + 3) % 7 == 0 ? 0.3 - // : 1.0); - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - // actor->GetProperty()->SetEdgeColor(1,0,0); - // actor->GetProperty()->EdgeVisibilityOn(); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(911, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(911, 1.0); - mapper->SetBlockVisibility(911, 1.0); - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(40.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(2.0, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2ScalarsSurfaceOpacity.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2ScalarsSurfaceOpacity.cxx deleted file mode 100644 index df65d9284b9..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2ScalarsSurfaceOpacity.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkDiscretizableColorTransferFunction.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkPiecewiseFunction.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkRenderingOpenGLConfigure.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -#include "vtkCylinderSource.h" -#include "vtkElevationFilter.h" - -// This test exercises the vtkCompositePolyDataMapper2's ability to -// render scalars with surface opacity mapping enabled. In particular, -// it checks for correct rendering behavior when root blocks are -// set to invisible but sub-blocks are set to visible. -int TestCompositePolyDataMapper2ScalarsSurfaceOpacity(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - ren->SetBackground(1.0, 1.0, 1.0); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa.GetPointer()); - - int resolution = 18; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetResolution(resolution); - - vtkNew<vtkElevationFilter> elev; - elev->SetInputConnection(cyl->GetOutputPort()); - // geometry range is -0.5 to 0.5 but these colors are - // pretty - elev->SetLowPoint(0, -1.0, 0); - elev->SetHighPoint(0.0, 1.0, 0.0); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 32, 64 }; - if (timeit) - { - blocksPerLevel[1] = 64; - blocksPerLevel[2] = 256; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - elev->Update(); - child->DeepCopy(elev->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - - // make children explicitly visible except every 11th - mapper->SetBlockVisibility(parent + numLeaves, numLeaves % 11 != 0); - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child.GetPointer()); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - double range[2]; - elev->GetOutput(0)->GetScalarRange(range); - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - ren->AddActor(actor); - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // Set up discretizable color transfer function with opacity enable - const double controlPoints[] = { range[0], 1.0, 0.0, 0.0, range[1], 0.0, 0.0, 1.0 }; - - vtkSmartPointer<vtkDiscretizableColorTransferFunction> dctf = - vtkSmartPointer<vtkDiscretizableColorTransferFunction>::New(); - for (int i = 0; i < 2; ++i) - { - const double* xrgb = controlPoints + (i * 4); - dctf->AddRGBPoint(xrgb[0], xrgb[1], xrgb[2], xrgb[3]); - } - - // Scalar opacity transfer function - const double opacityControlPoints[] = { range[0], 0.1, range[1], 1.0 }; - - vtkSmartPointer<vtkPiecewiseFunction> pf = vtkSmartPointer<vtkPiecewiseFunction>::New(); - for (int i = 0; i < 2; ++i) - { - const double* xalpha = opacityControlPoints + (i * 2); - pf->AddPoint(xalpha[0], xalpha[1]); - } - - // Enable opacity mapping - dctf->SetScalarOpacityFunction(pf); - dctf->EnableOpacityMappingOn(); - dctf->Build(); - - mapper->SetLookupTable(dctf); - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(911, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(911, 1.0); - - // set intermediate block invisible - mapper->SetBlockVisibility(911, false); - - // set root block visibility to false. Since visibility of children are - // explicitly set, this should make no difference in rendering. - mapper->SetBlockVisibility(0, false); - - // set a block not visible - mapper->SetBlockVisibility(912, false); - - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(40.0 / numFrames); - ren->GetActiveCamera()->Zoom(pow(2.0, 1.0 / numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - - int retVal = vtkRegressionTestImageThreshold(win.GetPointer(), 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2SharedArray.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2SharedArray.cxx deleted file mode 100644 index 38180d1da66..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2SharedArray.cxx +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include <vtkAppendFilter.h> -#include <vtkCellArray.h> -#include <vtkCellArrayIterator.h> -#include <vtkCompositeDataIterator.h> -#include <vtkCompositePolyDataMapper2.h> -#include <vtkCubeSource.h> -#include <vtkDataObjectTreeIterator.h> -#include <vtkInformation.h> -#include <vtkInformationVector.h> -#include <vtkMultiBlockDataGroupFilter.h> -#include <vtkMultiBlockDataSet.h> -#include <vtkMultiBlockDataSetAlgorithm.h> -#include <vtkNew.h> -#include <vtkObjectFactory.h> -#include <vtkPointData.h> -#include <vtkPolyData.h> -#include <vtkProperty.h> -#include <vtkRandomAttributeGenerator.h> -#include <vtkRegressionTestImage.h> -#include <vtkRenderWindow.h> -#include <vtkRenderWindowInteractor.h> -#include <vtkRenderer.h> -#include <vtkUnstructuredGrid.h> - -class vtkDualCubeSource : public vtkMultiBlockDataSetAlgorithm -{ -public: - static vtkDualCubeSource* New(); - vtkTypeMacro(vtkDualCubeSource, vtkMultiBlockDataSetAlgorithm); - -protected: - vtkDualCubeSource() { this->SetNumberOfInputPorts(0); } - - ~vtkDualCubeSource() override = default; - - int RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** vtkNotUsed(inputVector), vtkInformationVector* outputVector) override - { - vtkInformation* outInfo = outputVector->GetInformationObject(0); - // get the output - vtkMultiBlockDataSet* output = - vtkMultiBlockDataSet::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); - - vtkNew<vtkCubeSource> cube1; - vtkNew<vtkRandomAttributeGenerator> id1; - id1->SetDataTypeToFloat(); - id1->GeneratePointScalarsOn(); - id1->GenerateCellScalarsOn(); - id1->SetInputConnection(cube1->GetOutputPort()); - - vtkNew<vtkCubeSource> cube2; - cube2->SetCenter(1.5, 0., 0.); - vtkNew<vtkRandomAttributeGenerator> id2; - id2->SetInputConnection(cube2->GetOutputPort()); - id2->SetDataTypeToFloat(); - id2->GeneratePointScalarsOn(); - id2->GenerateCellScalarsOn(); - - vtkNew<vtkCubeSource> cube3; - cube3->SetCenter(0.75, -1.5, 0.); - vtkNew<vtkRandomAttributeGenerator> id3; - id3->SetInputConnection(cube3->GetOutputPort()); - id3->SetDataTypeToFloat(); - id3->GeneratePointScalarsOn(); - id3->GenerateCellScalarsOn(); - id3->Update(); - - // Append geometry of the two first meshes - vtkNew<vtkAppendFilter> append; - append->AddInputConnection(id1->GetOutputPort()); - append->AddInputConnection(id2->GetOutputPort()); - append->Update(); - vtkUnstructuredGrid* aug = append->GetOutput(); - - // Transfer appended geometry (not topology) to first and second meshes - vtkPolyData* pd1 = vtkPolyData::SafeDownCast(id1->GetOutput()); - vtkIdType cube1npts = pd1->GetNumberOfPoints(); - pd1->SetPoints(aug->GetPoints()); - pd1->GetPointData()->ShallowCopy(aug->GetPointData()); - - vtkPolyData* pd2 = vtkPolyData::SafeDownCast(id2->GetOutput()); - pd2->SetPoints(aug->GetPoints()); - pd2->GetPointData()->ShallowCopy(aug->GetPointData()); - - { // Update connectivity of second mesh by shifting point ids - vtkCellArray* polys = pd2->GetPolys(); - auto cellIter = vtk::TakeSmartPointer(polys->NewIterator()); - vtkNew<vtkIdList> cell; - for (cellIter->GoToFirstCell(); !cellIter->IsDoneWithTraversal(); cellIter->GoToNextCell()) - { - cellIter->GetCurrentCell(cell); - for (vtkIdType i = 0; i < cell->GetNumberOfIds(); i++) - { - cell->SetId(i, cell->GetId(i) + cube1npts); - } - cellIter->ReplaceCurrentCell(cell); - } - } - - // Create the multiblock dataset with the different meshes - vtkNew<vtkMultiBlockDataGroupFilter> group; - group->AddInputData(pd1); - group->AddInputData(id3->GetOutput()); // This mesh has different arrays than the other two - group->AddInputData(pd2); - group->Update(); - - output->CompositeShallowCopy(group->GetOutput()); - return 1; - } - -private: - vtkDualCubeSource(const vtkDualCubeSource&) = delete; - void operator=(const vtkDualCubeSource&) = delete; -}; -vtkStandardNewMacro(vtkDualCubeSource); - -int TestCompositePolyDataMapper2SharedArray(int argc, char* argv[]) -{ - vtkNew<vtkDualCubeSource> source; - - vtkNew<vtkRenderer> renderer; - - vtkNew<vtkRenderWindow> renderWindow; - renderWindow->AddRenderer(renderer); - - vtkNew<vtkRenderWindowInteractor> interactor; - interactor->SetRenderWindow(renderWindow); - - vtkNew<vtkCompositePolyDataMapper2> mapper; - mapper->SetInputConnection(source->GetOutputPort()); - mapper->SetScalarModeToUsePointData(); - - vtkNew<vtkActor> actor; - actor->SetMapper(mapper); - - renderer->AddActor(actor); - renderer->SetBackground(.3, .4, .5); - - renderer->ResetCamera(); - - int retVal = vtkRegressionTestImageThreshold(renderWindow, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - interactor->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Spheres.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Spheres.cxx deleted file mode 100644 index d866e22983a..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Spheres.cxx +++ /dev/null @@ -1,182 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include "vtkCylinderSource.h" -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -int TestCompositePolyDataMapper2Spheres(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa); - - vtkNew<vtkCompositeDataDisplayAttributes> cdsa2; - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper2 = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - mapper2->SetCompositeDataDisplayAttributes(cdsa2); - - int resolution = 10; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetHeight(0.6); - cyl->SetResolution(resolution); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 4, 8 }; - if (timeit) - { - blocksPerLevel[1] = 32; - blocksPerLevel[2] = 64; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - mapper2->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - cyl->Update(); - child->DeepCopy(cyl->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 7) - { - double r, g, b; - vtkMath::HSVToRGB(0.8 * block / nblocks, 0.2 + 0.8 * ((parent - levelStart) % 4) / 3.0, - 1.0, &r, &g, &b); - mapper->SetBlockColor(parent + numLeaves + 1, r, g, b); - mapper->SetBlockVisibility(parent + numLeaves, (block % 3) != 0); - vtkMath::HSVToRGB(0.2 + 0.8 * block / nblocks, - 0.7 + 0.3 * ((parent - levelStart) % 4) / 3.0, 1.0, &r, &g, &b); - mapper2->SetBlockColor(parent + numLeaves + 1, r, g, b); - mapper2->SetBlockVisibility(parent + numLeaves, (block % 3) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->SetEdgeColor(1, 0, 0); - actor->GetProperty()->RenderLinesAsTubesOn(); - actor->GetProperty()->EdgeVisibilityOn(); - actor->GetProperty()->SetLineWidth(7.0); - // actor->GetProperty()->SetRepresentationToWireframe(); - ren->AddActor(actor); - - vtkSmartPointer<vtkActor> actor2 = vtkSmartPointer<vtkActor>::New(); - actor2->SetMapper(mapper2); - actor2->GetProperty()->SetEdgeColor(1, 1, 0.3); - actor2->GetProperty()->RenderPointsAsSpheresOn(); - actor2->GetProperty()->SetRepresentationToPoints(); - actor2->GetProperty()->SetPointSize(14.0); - ren->AddActor(actor2); - - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(1011, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(1011, 1.0); - mapper->SetBlockVisibility(1011, 1.0); - - win->SetMultiSamples(0); - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(20.0 / numFrames); - // ren->GetActiveCamera()->Zoom(pow(2.0,1.0/numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - int retVal = vtkRegressionTestImageThreshold(win, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Vertices.cxx b/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Vertices.cxx deleted file mode 100644 index 8b3f829631a..00000000000 --- a/Rendering/OpenGL2/Testing/Cxx/TestCompositePolyDataMapper2Vertices.cxx +++ /dev/null @@ -1,167 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include "vtkActor.h" -#include "vtkCamera.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataSet.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkCullerCollection.h" -#include "vtkInformation.h" -#include "vtkMath.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkNew.h" -#include "vtkProperty.h" -#include "vtkRenderWindow.h" -#include "vtkRenderWindowInteractor.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" -#include "vtkTimerLog.h" -#include "vtkTrivialProducer.h" - -#include "vtkCylinderSource.h" -#include <vtkRegressionTestImage.h> -#include <vtkTestUtilities.h> - -int TestCompositePolyDataMapper2Vertices(int argc, char* argv[]) -{ - bool timeit = false; - if (argc > 1 && argv[1] && !strcmp(argv[1], "-timeit")) - { - timeit = true; - } - vtkSmartPointer<vtkRenderWindow> win = vtkSmartPointer<vtkRenderWindow>::New(); - vtkSmartPointer<vtkRenderWindowInteractor> iren = - vtkSmartPointer<vtkRenderWindowInteractor>::New(); - vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New(); - win->AddRenderer(ren); - win->SetInteractor(iren); - - vtkSmartPointer<vtkCompositePolyDataMapper2> mapper = - vtkSmartPointer<vtkCompositePolyDataMapper2>::New(); - vtkNew<vtkCompositeDataDisplayAttributes> cdsa; - mapper->SetCompositeDataDisplayAttributes(cdsa); - - int resolution = 10; - vtkNew<vtkCylinderSource> cyl; - cyl->CappingOn(); - cyl->SetRadius(0.2); - cyl->SetHeight(0.6); - cyl->SetResolution(resolution); - - // build a composite dataset - vtkNew<vtkMultiBlockDataSet> data; - int blocksPerLevel[3] = { 1, 4, 8 }; - if (timeit) - { - blocksPerLevel[1] = 32; - blocksPerLevel[2] = 64; - } - std::vector<vtkSmartPointer<vtkMultiBlockDataSet>> blocks; - blocks.emplace_back(data.GetPointer()); - unsigned levelStart = 0; - unsigned levelEnd = 1; - int numLevels = sizeof(blocksPerLevel) / sizeof(blocksPerLevel[0]); - int numLeaves = 0; - int numNodes = 0; - std::string blockName("Rolf"); - mapper->SetInputDataObject(data.GetPointer()); - for (int level = 1; level < numLevels; ++level) - { - int nblocks = blocksPerLevel[level]; - for (unsigned parent = levelStart; parent < levelEnd; ++parent) - { - blocks[parent]->SetNumberOfBlocks(nblocks); - for (int block = 0; block < nblocks; ++block, ++numNodes) - { - if (level == numLevels - 1) - { - vtkNew<vtkPolyData> child; - cyl->SetCenter(block * 0.25, 0.0, parent * 0.5); - cyl->Update(); - child->DeepCopy(cyl->GetOutput(0)); - blocks[parent]->SetBlock(block, (block % 2) ? nullptr : child.GetPointer()); - blocks[parent]->GetMetaData(block)->Set(vtkCompositeDataSet::NAME(), blockName.c_str()); - // test not setting it on some - if (block % 11) - { - double r, g, b; - vtkMath::HSVToRGB(0.8 * block / nblocks, 0.2 + 0.8 * ((parent - levelStart) % 8) / 7.0, - 1.0, &r, &g, &b); - mapper->SetBlockColor(parent + numLeaves + 1, r, g, b); - mapper->SetBlockVisibility(parent + numLeaves, (block % 7) != 0); - } - ++numLeaves; - } - else - { - vtkNew<vtkMultiBlockDataSet> child; - blocks[parent]->SetBlock(block, child); - blocks.emplace_back(child.GetPointer()); - } - } - } - levelStart = levelEnd; - levelEnd = static_cast<unsigned>(blocks.size()); - } - - vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New(); - actor->SetMapper(mapper); - actor->GetProperty()->RenderLinesAsTubesOn(); - actor->GetProperty()->EdgeVisibilityOn(); - actor->GetProperty()->SetEdgeColor(0.7, 0.7, 0.7); - actor->GetProperty()->SetLineWidth(7.0); - actor->GetProperty()->RenderPointsAsSpheresOn(); - actor->GetProperty()->VertexVisibilityOn(); - actor->GetProperty()->SetVertexColor(1.0, 0.5, 0.5); - actor->GetProperty()->SetPointSize(14.0); - ren->AddActor(actor); - - win->SetSize(400, 400); - - ren->RemoveCuller(ren->GetCullers()->GetLastItem()); - ren->ResetCamera(); - - vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New(); - win->Render(); // get the window up - - // modify the data to force a rebuild of OpenGL structs - // after rendering set one cylinder to white - mapper->SetBlockColor(1011, 1.0, 1.0, 1.0); - mapper->SetBlockOpacity(1011, 1.0); - mapper->SetBlockVisibility(1011, 1.0); - - win->SetMultiSamples(0); - timer->StartTimer(); - win->Render(); - timer->StopTimer(); - cout << "First frame time: " << timer->GetElapsedTime() << "\n"; - - timer->StartTimer(); - - int numFrames = (timeit ? 300 : 2); - for (int i = 0; i <= numFrames; i++) - { - ren->GetActiveCamera()->Elevation(20.0 / numFrames); - // ren->GetActiveCamera()->Zoom(pow(2.0,1.0/numFrames)); - ren->GetActiveCamera()->Roll(20.0 / numFrames); - win->Render(); - } - - timer->StopTimer(); - if (timeit) - { - double t = timer->GetElapsedTime(); - cout << "Avg Frame time: " << t / numFrames << " Frame Rate: " << numFrames / t << "\n"; - } - int retVal = vtkRegressionTestImageThreshold(win, 0.05); - if (retVal == vtkRegressionTester::DO_INTERACTOR) - { - iren->Start(); - } - - return !retVal; -} diff --git a/Rendering/OpenGL2/vtkCompositeMapperHelper2.h b/Rendering/OpenGL2/vtkCompositeMapperHelper2.h deleted file mode 100644 index 8e2c2dfa035..00000000000 --- a/Rendering/OpenGL2/vtkCompositeMapperHelper2.h +++ /dev/null @@ -1,172 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef vtkCompositeMapperHelper2_h -#define vtkCompositeMapperHelper2_h - -#include "vtkOpenGLPolyDataMapper.h" - -#include "vtkColor.h" // class uses vtkColor -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 -#include "vtkRenderingOpenGL2Module.h" // for export macro -#include "vtk_glad.h" // for OpenGL enums -VTK_ABI_NAMESPACE_BEGIN -class vtkPolyData; -class vtkCompositePolyDataMapper2; - -// this class encapsulates values tied to a -// polydata - -class VTK_DEPRECATED_IN_9_3_0( - "Please use vtkCompositePolyDataMapper instead") vtkCompositeMapperHelperData -{ -public: - vtkPolyData* Data; - unsigned int FlatIndex; - double Opacity; - bool IsOpaque; - bool Visibility; - bool Pickability; - bool OverridesColor; - vtkColor3d AmbientColor; - vtkColor3d DiffuseColor; - vtkColor3d SelectionColor; - double SelectionOpacity; - - bool Marked; - - unsigned int StartVertex; - unsigned int NextVertex; - - // point line poly strip edge stripedge - unsigned int StartIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd]; - unsigned int NextIndex[vtkOpenGLPolyDataMapper::PrimitiveEnd]; - - // stores the mapping from vtk cells to gl_PrimitiveId - vtkNew<vtkOpenGLCellToVTKCellMap> CellCellMap; -}; - -//=================================================================== -/// Helper class for vtkCompositePolyDataMapper2 that is a subclass of vtkOpenGLPolyDataMapper -class VTK_DEPRECATED_IN_9_3_0("Please use vtkCompositePolyDataMapper instead") - VTKRENDERINGOPENGL2_EXPORT vtkCompositeMapperHelper2 : public vtkOpenGLPolyDataMapper -{ -public: - static vtkCompositeMapperHelper2* New(); - vtkTypeMacro(vtkCompositeMapperHelper2, vtkOpenGLPolyDataMapper); - void PrintSelf(ostream& os, vtkIndent indent) override; - - void SetParent(vtkCompositePolyDataMapper2* p) { this->Parent = p; } - - vtkCompositeMapperHelperData* AddData(vtkPolyData* pd, unsigned int flatIndex); - - /** - * Implemented by sub classes. Actual rendering is done here. - */ - void RenderPiece(vtkRenderer* ren, vtkActor* act) override; - - ///@{ - /// keep track of what data is being used as the multiblock - /// can change - void ClearMark(); - void RemoveUnused(); - bool GetMarked() { return this->Marked; } - void SetMarked(bool v) { this->Marked = v; } - ///@} - - /** - * Accessor to the ordered list of PolyData that we last drew. - */ - std::vector<vtkPolyData*> GetRenderedList() const; - - /** - * allows a mapper to update a selections color buffers - * Called from a prop which in turn is called from the selector - */ - void ProcessSelectorPixelBuffers( - vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override; - - virtual void ProcessCompositePixelBuffers(vtkHardwareSelector* sel, vtkProp* prop, - vtkCompositeMapperHelperData* hdata, std::vector<unsigned int>& mypixels); - -protected: - vtkCompositePolyDataMapper2* Parent; - std::map<vtkPolyData*, vtkCompositeMapperHelperData*> Data; - - bool Marked; - - /// handle updating shift scale based on pose changes - void UpdateCameraShiftScale(vtkRenderer* ren, vtkActor* actor) override; - - vtkCompositeMapperHelper2() { this->Parent = nullptr; } - ~vtkCompositeMapperHelper2() override; - - void DrawIBO(vtkRenderer* ren, vtkActor* actor, int primType, vtkOpenGLHelper& CellBO, - GLenum mode, int pointSize); - - virtual void SetShaderValues( - vtkShaderProgram* prog, vtkCompositeMapperHelperData* hdata, size_t primOffset); - - /** - * Make sure appropriate shaders are defined, compiled and bound. This method - * orchistrates the process, much of the work is done in other methods - */ - void UpdateShaders(vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* act) override; - - /** - * Perform string replacements on the shader templates, called from - * ReplaceShaderValues - */ - void ReplaceShaderColor( - std::map<vtkShader::Type, vtkShader*> shaders, vtkRenderer* ren, vtkActor* act) override; - - /** - * Does the VBO/IBO need to be rebuilt - */ - bool GetNeedToRebuildBufferObjects(vtkRenderer* ren, vtkActor* act) override; - - /** - * Build the VBO/IBO, called by UpdateBufferObjects - */ - void BuildBufferObjects(vtkRenderer* ren, vtkActor* act) override; - virtual void AppendOneBufferObject(vtkRenderer* ren, vtkActor* act, - vtkCompositeMapperHelperData* hdata, vtkIdType& flat_index, std::vector<unsigned char>& colors, - std::vector<float>& norms); - - /** - * Build the selection IBOs, called by UpdateBufferObjects - */ - void BuildSelectionIBO( - vtkPolyData* poly, std::vector<unsigned int> (&indices)[4], vtkIdType offset) override; - - /** - * Returns if we can use texture maps for scalar coloring. Note this doesn't - * say we "will" use scalar coloring. It says, if we do use scalar coloring, - * we will use a texture. Always off for this mapper. - */ - int CanUseTextureMapForColoring(vtkDataObject*) override; - - std::vector<unsigned int> VertexOffsets; - - // vert line poly strip edge stripedge - std::vector<unsigned int> IndexArray[PrimitiveEnd]; - - void RenderPieceDraw(vtkRenderer* ren, vtkActor* act) override; - - bool PrimIDUsed; - bool OverideColorUsed; - - vtkHardwareSelector* CurrentSelector; - - /// used by the hardware selector - std::vector<std::vector<unsigned int>> PickPixels; - - std::map<vtkAbstractArray*, vtkDataArray*> ColorArrayMap; - -private: - vtkCompositeMapperHelper2(const vtkCompositeMapperHelper2&) = delete; - void operator=(const vtkCompositeMapperHelper2&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif diff --git a/Rendering/OpenGL2/vtkCompositePolyDataMapper2.cxx b/Rendering/OpenGL2/vtkCompositePolyDataMapper2.cxx deleted file mode 100644 index 609cd489823..00000000000 --- a/Rendering/OpenGL2/vtkCompositePolyDataMapper2.cxx +++ /dev/null @@ -1,2202 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 -#include "vtkCompositePolyDataMapper2.h" - -#include "vtk_glad.h" - -#include "vtkArrayDispatch.h" -#include "vtkBoundingBox.h" -#include "vtkCellData.h" -#include "vtkColorTransferFunction.h" -#include "vtkCommand.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositeDataPipeline.h" -#include "vtkConstantArray.h" -#include "vtkDataObjectTree.h" -#include "vtkDataObjectTreeRange.h" -#include "vtkDataSetAttributes.h" -#include "vtkFloatArray.h" -#include "vtkHardwareSelector.h" -#include "vtkIdTypeArray.h" -#include "vtkImageData.h" -#include "vtkInformation.h" -#include "vtkLogger.h" -#include "vtkLookupTable.h" -#include "vtkObjectFactory.h" -#include "vtkOpenGLCellToVTKCellMap.h" -#include "vtkOpenGLIndexBufferObject.h" -#include "vtkOpenGLRenderWindow.h" -#include "vtkOpenGLRenderer.h" -#include "vtkOpenGLShaderProperty.h" -#include "vtkOpenGLState.h" -#include "vtkOpenGLTexture.h" -#include "vtkOpenGLVertexBufferObject.h" -#include "vtkOpenGLVertexBufferObjectGroup.h" -#include "vtkPointData.h" -#include "vtkPolyData.h" -#include "vtkProperty.h" -#include "vtkScalarsToColors.h" -#include "vtkSelection.h" -#include "vtkSelectionNode.h" -#include "vtkShaderProgram.h" -#include "vtkTextureObject.h" -#include "vtkTransform.h" -#include "vtkUnsignedCharArray.h" -#include "vtkUnsignedIntArray.h" - -#include <algorithm> -#include <sstream> - -#include "vtkCompositeMapperHelper2.h" - -//------------------------------------------------------------------------------ -VTK_ABI_NAMESPACE_BEGIN -vtkStandardNewMacro(vtkCompositeMapperHelper2); - -namespace -{ -template <typename T> -class ScopedValueRollback -{ -public: - ScopedValueRollback(T& value, T newValue) - { - Value = value; - Pointer = &value; - *Pointer = newValue; - } - ~ScopedValueRollback() { *Pointer = Value; } - -private: - T* Pointer = nullptr; - T Value; -}; -} // end anonymous namespace - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "Marked: " << this->Marked << endl; - os << indent << "Primary ID Used: " << this->PrimIDUsed << endl; - os << indent << "Override Color Used: " << this->OverideColorUsed << endl; -} - -//------------------------------------------------------------------------------ -vtkCompositeMapperHelper2::~vtkCompositeMapperHelper2() -{ - for (auto& data : this->Data) - { - delete data.second; - } - this->Data.clear(); -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::SetShaderValues( - vtkShaderProgram* prog, vtkCompositeMapperHelperData* hdata, size_t primOffset) -{ - if (this->PrimIDUsed) - { - prog->SetUniformi("PrimitiveIDOffset", static_cast<int>(primOffset)); - } - - if (this->CurrentSelector) - { - if (this->CurrentSelector->GetCurrentPass() == vtkHardwareSelector::COMPOSITE_INDEX_PASS && - prog->IsUniformUsed("mapperIndex")) - { - this->CurrentSelector->RenderCompositeIndex(hdata->FlatIndex); - prog->SetUniform3f("mapperIndex", this->CurrentSelector->GetPropColorValue()); - } - return; - } - - // If requested, color partial / missing arrays with NaN color. - bool useNanColor = false; - double nanColor[4] = { -1., -1., -1., -1 }; - if (this->Parent->GetColorMissingArraysWithNanColor() && this->GetScalarVisibility()) - { - int cellFlag = 0; - vtkAbstractArray* scalars = vtkAbstractMapper::GetAbstractScalars(hdata->Data, this->ScalarMode, - this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag); - if (scalars == nullptr) - { - vtkLookupTable* lut = vtkLookupTable::SafeDownCast(this->GetLookupTable()); - vtkColorTransferFunction* ctf = - lut ? nullptr : vtkColorTransferFunction::SafeDownCast(this->GetLookupTable()); - if (lut) - { - lut->GetNanColor(nanColor); - useNanColor = true; - } - else if (ctf) - { - ctf->GetNanColor(nanColor); - useNanColor = true; - } - } - } - - // override the opacity and color - prog->SetUniformf("opacityUniform", hdata->Opacity); - - if (useNanColor) - { - float fnancolor[3] = { static_cast<float>(nanColor[0]), static_cast<float>(nanColor[1]), - static_cast<float>(nanColor[2]) }; - prog->SetUniform3f("ambientColorUniform", fnancolor); - prog->SetUniform3f("diffuseColorUniform", fnancolor); - } - else - { - if (this->DrawingSelection) - { - vtkColor3d& sColor = hdata->SelectionColor; - float selectionColor[3] = { static_cast<float>(sColor[0]), static_cast<float>(sColor[1]), - static_cast<float>(sColor[2]) }; - prog->SetUniform3f("ambientColorUniform", selectionColor); - prog->SetUniform3f("diffuseColorUniform", selectionColor); - prog->SetUniformf("opacityUniform", hdata->SelectionOpacity); - } - else - { - vtkColor3d& aColor = hdata->AmbientColor; - float ambientColor[3] = { static_cast<float>(aColor[0]), static_cast<float>(aColor[1]), - static_cast<float>(aColor[2]) }; - vtkColor3d& dColor = hdata->DiffuseColor; - float diffuseColor[3] = { static_cast<float>(dColor[0]), static_cast<float>(dColor[1]), - static_cast<float>(dColor[2]) }; - prog->SetUniform3f("ambientColorUniform", ambientColor); - prog->SetUniform3f("diffuseColorUniform", diffuseColor); - } - if (this->OverideColorUsed) - { - prog->SetUniformi("OverridesColor", hdata->OverridesColor); - } - } -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::UpdateShaders( - vtkOpenGLHelper& cellBO, vtkRenderer* ren, vtkActor* act) -{ - Superclass::UpdateShaders(cellBO, ren, act); - if (cellBO.Program && this->Parent) - { - // allow the program to set what it wants - this->Parent->InvokeEvent(vtkCommand::UpdateShaderEvent, cellBO.Program); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::ReplaceShaderColor( - std::map<vtkShader::Type, vtkShader*> shaders, vtkRenderer* ren, vtkActor* actor) -{ - if (!this->CurrentSelector) - { - std::string FSSource = shaders[vtkShader::Fragment]->GetSource(); - - vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Dec", - "uniform bool OverridesColor;\n" - "//VTK::Color::Dec", - false); - - vtkShaderProgram::Substitute(FSSource, "//VTK::Color::Impl", - "//VTK::Color::Impl\n" - " if (OverridesColor) {\n" - " ambientColor = ambientColorUniform * ambientIntensity;\n" - " diffuseColor = diffuseColorUniform * diffuseIntensity; }\n", - false); - - shaders[vtkShader::Fragment]->SetSource(FSSource); - } - - this->Superclass::ReplaceShaderColor(shaders, ren, actor); -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::ClearMark() -{ - for (auto& data : this->Data) - { - data.second->Marked = false; - } - this->Marked = false; -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::RemoveUnused() -{ - for (auto it = this->Data.begin(); it != this->Data.end();) - { - if (!it->second->Marked) - { - delete it->second; - this->Data.erase(it++); - this->Modified(); - } - else - { - ++it; - } - } -} - -//------------------------------------------------------------------------------ -std::vector<vtkPolyData*> vtkCompositeMapperHelper2::GetRenderedList() const -{ - std::vector<vtkPolyData*> result; - result.reserve(this->Data.size()); - for (const auto& pair : this->Data) - { - result.push_back(pair.first); - } - return result; -} - -//------------------------------------------------------------------------------ -// Returns if we can use texture maps for scalar coloring. Note this doesn't say -// we "will" use scalar coloring. It says, if we do use scalar coloring, we will -// use a texture. -// When rendering multiblock datasets, if any 2 blocks provide different -// lookup tables for the scalars, then also we cannot use textures. This case can -// be handled if required. -int vtkCompositeMapperHelper2::CanUseTextureMapForColoring(vtkDataObject*) -{ - if (!this->InterpolateScalarsBeforeMapping) - { - return 0; // user doesn't want us to use texture maps at all. - } - - int cellFlag = 0; - vtkScalarsToColors* scalarsLookupTable = nullptr; - for (auto& data : this->Data) - { - vtkPolyData* pd = data.second->Data; - vtkDataArray* scalars = vtkAbstractMapper::GetScalars( - pd, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag); - - if (scalars) - { - if (cellFlag) - { - return 0; - } - if ((this->ColorMode == VTK_COLOR_MODE_DEFAULT && - vtkArrayDownCast<vtkUnsignedCharArray>(scalars)) || - this->ColorMode == VTK_COLOR_MODE_DIRECT_SCALARS) - { - // Don't use texture if direct coloring using RGB unsigned chars is - // requested. - return 0; - } - - if (scalarsLookupTable && scalars->GetLookupTable() && - (scalarsLookupTable != scalars->GetLookupTable())) - { - // Two datasets are requesting different lookup tables to color with. - // We don't handle this case right now for composite datasets. - return 0; - } - if (scalars->GetLookupTable()) - { - scalarsLookupTable = scalars->GetLookupTable(); - } - } - } - - if ((scalarsLookupTable && scalarsLookupTable->GetIndexedLookup()) || - (!scalarsLookupTable && this->LookupTable && this->LookupTable->GetIndexedLookup())) - { - return 0; - } - - return 1; -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::RenderPiece(vtkRenderer* ren, vtkActor* actor) -{ - // Make sure that we have been properly initialized. - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - if (ren->GetSelector()) - { - for (auto& it : this->Data) - { - this->CurrentInput = it.first; - this->UpdateMaximumPointCellIds(ren, actor); - } - } - this->CurrentInput = this->Data.begin()->first; - - this->UpdateCameraShiftScale(ren, actor); - this->RenderPieceStart(ren, actor); - this->RenderPieceDraw(ren, actor); - this->RenderPieceFinish(ren, actor); -} - -void vtkCompositeMapperHelper2::UpdateCameraShiftScale(vtkRenderer* ren, vtkActor* actor) -{ - if (this->PauseShiftScale) - { - return; - } - - // handle camera shift scale - if (this->ShiftScaleMethod == ShiftScaleMethodType::NEAR_PLANE_SHIFT_SCALE || - this->ShiftScaleMethod == ShiftScaleMethodType::FOCAL_POINT_SHIFT_SCALE) - { - // get ideal shift scale from camera - auto posVBO = this->VBOs->GetVBO("vertexMC"); - if (posVBO) - { - posVBO->SetCamera(ren->GetActiveCamera()); - posVBO->SetProp3D(actor); - posVBO->UpdateShiftScale(this->CurrentInput->GetPoints()->GetData()); - // force a rebuild if needed - if (posVBO->GetMTime() > posVBO->GetUploadTime()) - { - this->Modified(); - } - } - } -} - -void vtkCompositeMapperHelper2::DrawIBO(vtkRenderer* ren, vtkActor* actor, int primType, - vtkOpenGLHelper& CellBO, GLenum mode, int pointSize) -{ - if (CellBO.IBO->IndexCount) - { - vtkOpenGLRenderWindow* renWin = static_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow()); - vtkOpenGLState* ostate = renWin->GetState(); - - if (pointSize > 0) - { - ostate->vtkglPointSize(pointSize); // need to use shader value - } - // First we do the triangles, update the shader, set uniforms, etc. - this->UpdateShaders(CellBO, ren, actor); - vtkShaderProgram* prog = CellBO.Program; - if (!prog) - { - return; - } - this->PrimIDUsed = prog->IsUniformUsed("PrimitiveIDOffset"); - this->OverideColorUsed = prog->IsUniformUsed("OverridesColor"); - CellBO.IBO->Bind(); - - if (!this->HaveWideLines(ren, actor) && mode == GL_LINES) - { - ostate->vtkglLineWidth(actor->GetProperty()->GetLineWidth()); - } - - // if (this->DrawingEdgesOrVetices && !this->DrawingTubes(CellBO, actor)) - // { - // vtkProperty *ppty = actor->GetProperty(); - // float diffuseColor[3] = {0.0, 0.0, 0.0}; - // float ambientColor[3]; - // double *acol = ppty->GetEdgeColor(); - // ambientColor[0] = acol[0]; - // ambientColor[1] = acol[1]; - // ambientColor[2] = acol[2]; - // prog->SetUniform3f("diffuseColorUniform", diffuseColor); - // prog->SetUniform3f("ambientColorUniform", ambientColor); - // } - - bool selecting = this->CurrentSelector != nullptr; - bool tpass = actor->IsRenderingTranslucentPolygonalGeometry(); - - for (auto& data : this->Data) - { - vtkCompositeMapperHelperData* starthdata = data.second; - bool shouldDraw = starthdata->Visibility // must be visible - && (!selecting || starthdata->Pickability) // and pickable when selecting - && (((selecting || starthdata->IsOpaque || actor->GetForceOpaque()) && - !tpass) // opaque during opaque or when selecting - || ((!starthdata->IsOpaque || actor->GetForceTranslucent()) && tpass && - !selecting)); // translucent during translucent and never selecting - if (shouldDraw && starthdata->NextIndex[primType] > starthdata->StartIndex[primType]) - { - // compilers think this can exceed the bounds so we also - // test against primType even though we should not need to - if (primType <= vtkOpenGLPolyDataMapper::PrimitiveTriStrips) - { - this->SetShaderValues( - prog, starthdata, starthdata->CellCellMap->GetPrimitiveOffsets()[primType]); - } - - unsigned int count = this->DrawingSelection - ? static_cast<unsigned int>(CellBO.IBO->IndexCount) - : starthdata->NextIndex[primType] - starthdata->StartIndex[primType]; - - glDrawRangeElements(mode, static_cast<GLuint>(starthdata->StartVertex), - static_cast<GLuint>(starthdata->NextVertex > 0 ? starthdata->NextVertex - 1 : 0), count, - GL_UNSIGNED_INT, - reinterpret_cast<const GLvoid*>(starthdata->StartIndex[primType] * sizeof(GLuint))); - } - } - CellBO.IBO->Release(); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::RenderPieceDraw(vtkRenderer* ren, vtkActor* actor) -{ - int representation = actor->GetProperty()->GetRepresentation(); - - // render points for point picking in a special way - // all cell types should be rendered as points - this->CurrentSelector = ren->GetSelector(); - bool pointPicking = false; - if (this->CurrentSelector && this->PopulateSelectionSettings && - this->CurrentSelector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS) - { - representation = VTK_POINTS; - pointPicking = true; - } - - this->PrimitiveIDOffset = 0; - - // draw IBOs - for (int i = vtkOpenGLPolyDataMapper::PrimitiveStart; - i < (this->CurrentSelector ? vtkOpenGLPolyDataMapper::PrimitiveTriStrips + 1 - : vtkOpenGLPolyDataMapper::PrimitiveEnd); - i++) - { - this->DrawingVertices = i > vtkOpenGLPolyDataMapper::PrimitiveTriStrips; - this->DrawingSelection = false; - GLenum mode = this->GetOpenGLMode(representation, i); - this->DrawIBO(ren, actor, i, this->Primitives[i], mode, - pointPicking ? this->GetPointPickingPrimitiveSize(i) : 0); - } - - if (!this->CurrentSelector) - { - vtkSelection* sel = this->Parent->GetSelection(); - - if (sel && sel->GetNumberOfNodes() > 0) - { - // draw selection IBOs - for (int i = vtkOpenGLPolyDataMapper::PrimitiveStart; - i <= vtkOpenGLPolyDataMapper::PrimitiveTriStrips; i++) - { - this->DrawingSelection = true; - GLenum mode = this->GetOpenGLMode(this->SelectionType, i); - this->DrawIBO(ren, actor, i, this->SelectionPrimitives[i], mode, 5); - } - } - } - - if (this->CurrentSelector && - (this->CurrentSelector->GetCurrentPass() == vtkHardwareSelector::CELL_ID_LOW24 || - this->CurrentSelector->GetCurrentPass() == vtkHardwareSelector::CELL_ID_HIGH24)) - { - this->CurrentSelector->SetPropColorValue(this->PrimitiveIDOffset); - } -} - -//------------------------------------------------------------------------------ -vtkCompositeMapperHelperData* vtkCompositeMapperHelper2::AddData( - vtkPolyData* pd, unsigned int flatIndex) -{ - auto found = this->Data.find(pd); - if (found == this->Data.end()) - { - vtkCompositeMapperHelperData* hdata = new vtkCompositeMapperHelperData(); - hdata->FlatIndex = flatIndex; - hdata->Data = pd; - hdata->Marked = true; - this->Data.insert(std::make_pair(pd, hdata)); - this->Modified(); - return hdata; - } - found->second->FlatIndex = flatIndex; - found->second->Marked = true; - return found->second; -} - -//------------------------------------------------------------------------------ -bool vtkCompositeMapperHelper2::GetNeedToRebuildBufferObjects( - vtkRenderer* vtkNotUsed(ren), vtkActor* act) -{ - // Same as vtkOpenGLPolyDataMapper::GetNeedToRebuildBufferObjects(), but - // we need to check all inputs, not just this->CurrentInput - this->TempState.Clear(); - this->TempState.Append(act->GetProperty()->GetMTime(), "actor mtime"); - for (auto data : this->Data) - { - this->TempState.Append(data.first ? data.first->GetMTime() : 0, "input mtime"); - } - this->TempState.Append(act->GetTexture() ? act->GetTexture()->GetMTime() : 0, "texture mtime"); - - if (this->VBOBuildState != this->TempState || this->VBOBuildTime < this->GetMTime()) - { - this->VBOBuildState = this->TempState; - return true; - } - - return false; -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::BuildBufferObjects(vtkRenderer* ren, vtkActor* act) -{ - // render using the composite data attributes - - // create the cell scalar array adjusted for ogl Cells - std::vector<unsigned char> newColors; - std::vector<float> newNorms; - - this->VBOs->ClearAllVBOs(); - - if (this->Data.begin() == this->Data.end()) - { - this->VBOBuildTime.Modified(); - return; - } - - this->EdgeValues.clear(); - - vtkBoundingBox bbox; - double bounds[6]; - this->Data.begin()->second->Data->GetPoints()->GetBounds(bounds); - bbox.SetBounds(bounds); - vtkCompositeMapperHelperData* prevhdata = nullptr; - for (auto& data : this->Data) - { - vtkCompositeMapperHelperData* hdata = data.second; - - hdata->Data->GetPoints()->GetBounds(bounds); - bbox.AddBounds(bounds); - - for (int i = 0; i < vtkOpenGLPolyDataMapper::PrimitiveEnd; i++) - { - hdata->StartIndex[i] = static_cast<unsigned int>(this->IndexArray[i].size()); - } - - vtkIdType voffset = 0; - // vert cell offset starts at the end of the last block - hdata->CellCellMap->SetStartOffset(prevhdata ? prevhdata->CellCellMap->GetFinalOffset() : 0); - this->AppendOneBufferObject(ren, act, hdata, voffset, newColors, newNorms); - hdata->StartVertex = static_cast<unsigned int>(voffset); - hdata->NextVertex = hdata->StartVertex + hdata->Data->GetPoints()->GetNumberOfPoints(); - for (int i = 0; i < vtkOpenGLPolyDataMapper::PrimitiveEnd; i++) - { - hdata->NextIndex[i] = static_cast<unsigned int>(this->IndexArray[i].size()); - } - prevhdata = hdata; - } - - // clear color cache - for (auto& c : this->ColorArrayMap) - { - c.second->Delete(); - } - this->ColorArrayMap.clear(); - - vtkOpenGLVertexBufferObject* posVBO = this->VBOs->GetVBO("vertexMC"); - if (posVBO) - { - if (this->ShiftScaleMethod == ShiftScaleMethodType::AUTO_SHIFT_SCALE) - { - posVBO->SetCoordShiftAndScaleMethod(ShiftScaleMethodType::MANUAL_SHIFT_SCALE); - bbox.GetBounds(bounds); - std::vector<double> shift; - std::vector<double> scale; - for (int i = 0; i < 3; i++) - { - shift.push_back(0.5 * (bounds[i * 2] + bounds[i * 2 + 1])); - scale.push_back( - (bounds[i * 2 + 1] - bounds[i * 2]) ? 1.0 / (bounds[i * 2 + 1] - bounds[i * 2]) : 1.0); - } - posVBO->SetShift(shift); - posVBO->SetScale(scale); - } - else - { - posVBO->SetCoordShiftAndScaleMethod( - static_cast<vtkOpenGLVertexBufferObject::ShiftScaleMethod>(this->ShiftScaleMethod)); - posVBO->SetProp3D(act); - posVBO->SetCamera(ren->GetActiveCamera()); - } - } - - this->VBOs->BuildAllVBOs(ren); - - // refetch as it may have been deleted - posVBO = this->VBOs->GetVBO("vertexMC"); - if (posVBO) - { - // If the VBO coordinates were shifted and scaled, prepare the inverse transform - // for application to the model->view matrix: - if (posVBO->GetCoordShiftAndScaleEnabled()) - { - std::vector<double> const& shift = posVBO->GetShift(); - std::vector<double> const& scale = posVBO->GetScale(); - this->VBOInverseTransform->Identity(); - this->VBOInverseTransform->Translate(shift[0], shift[1], shift[2]); - this->VBOInverseTransform->Scale(1.0 / scale[0], 1.0 / scale[1], 1.0 / scale[2]); - this->VBOInverseTransform->GetTranspose(this->VBOShiftScale); - } - } - - for (int i = vtkOpenGLPolyDataMapper::PrimitiveStart; i < vtkOpenGLPolyDataMapper::PrimitiveEnd; - i++) - { - this->Primitives[i].IBO->IndexCount = this->IndexArray[i].size(); - if (this->Primitives[i].IBO->IndexCount) - { - this->Primitives[i].IBO->Upload( - this->IndexArray[i], vtkOpenGLBufferObject::ElementArrayBuffer); - this->IndexArray[i].resize(0); - } - } - - if (!this->EdgeValues.empty()) - { - if (!this->EdgeTexture) - { - this->EdgeTexture = vtkTextureObject::New(); - this->EdgeBuffer = vtkOpenGLBufferObject::New(); - this->EdgeBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer); - } - this->EdgeTexture->SetContext(static_cast<vtkOpenGLRenderWindow*>(ren->GetVTKWindow())); - this->EdgeBuffer->Upload(this->EdgeValues, vtkOpenGLBufferObject::TextureBuffer); - this->EdgeTexture->CreateTextureBuffer( - static_cast<unsigned int>(this->EdgeValues.size()), 1, VTK_UNSIGNED_CHAR, this->EdgeBuffer); - } - - // allocate as needed - if (this->HaveCellScalars) - { - if (!this->CellScalarTexture) - { - this->CellScalarTexture = vtkTextureObject::New(); - this->CellScalarBuffer = vtkOpenGLBufferObject::New(); - } - this->CellScalarTexture->SetContext(static_cast<vtkOpenGLRenderWindow*>(ren->GetVTKWindow())); - this->CellScalarBuffer->Upload(newColors, vtkOpenGLBufferObject::TextureBuffer); - this->CellScalarTexture->CreateTextureBuffer(static_cast<unsigned int>(newColors.size() / 4), 4, - VTK_UNSIGNED_CHAR, this->CellScalarBuffer); - } - - if (this->HaveCellNormals) - { - if (!this->CellNormalTexture) - { - this->CellNormalTexture = vtkTextureObject::New(); - this->CellNormalBuffer = vtkOpenGLBufferObject::New(); - this->CellNormalBuffer->SetType(vtkOpenGLBufferObject::TextureBuffer); - } - this->CellNormalTexture->SetContext(static_cast<vtkOpenGLRenderWindow*>(ren->GetVTKWindow())); - - // do we have float texture support ? - int ftex = static_cast<vtkOpenGLRenderWindow*>(ren->GetRenderWindow()) - ->GetDefaultTextureInternalFormat(VTK_FLOAT, 4, false, true, false); - - if (ftex) - { - this->CellNormalBuffer->Upload(newNorms, vtkOpenGLBufferObject::TextureBuffer); - this->CellNormalTexture->CreateTextureBuffer( - static_cast<unsigned int>(newNorms.size() / 4), 4, VTK_FLOAT, this->CellNormalBuffer); - } - else - { - // have to convert to unsigned char if no float support - std::vector<unsigned char> ucNewNorms; - ucNewNorms.resize(newNorms.size()); - for (size_t i = 0; i < newNorms.size(); i++) - { - ucNewNorms[i] = 127.0 * (newNorms[i] + 1.0); - } - this->CellNormalBuffer->Upload(ucNewNorms, vtkOpenGLBufferObject::TextureBuffer); - this->CellNormalTexture->CreateTextureBuffer(static_cast<unsigned int>(newNorms.size() / 4), - 4, VTK_UNSIGNED_CHAR, this->CellNormalBuffer); - } - } - - this->VBOBuildTime.Modified(); -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::BuildSelectionIBO(vtkPolyData* vtkNotUsed(poly), - std::vector<unsigned int> (&indices)[4], vtkIdType vtkNotUsed(offset)) -{ - for (auto& helper : this->Data) - { - this->Superclass::BuildSelectionIBO(helper.second->Data, indices, helper.second->StartVertex); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::AppendOneBufferObject(vtkRenderer* ren, vtkActor* act, - vtkCompositeMapperHelperData* hdata, vtkIdType& voffset, std::vector<unsigned char>& newColors, - std::vector<float>& newNorms) -{ - vtkPolyData* poly = hdata->Data; - - // if there are no points then skip this piece - if (!poly->GetPoints() || poly->GetPoints()->GetNumberOfPoints() == 0) - { - return; - } - - // Get rid of old texture color coordinates if any - if (this->ColorCoordinates) - { - this->ColorCoordinates->UnRegister(this); - this->ColorCoordinates = nullptr; - } - // Get rid of old texture color coordinates if any - if (this->Colors) - { - this->Colors->UnRegister(this); - this->Colors = nullptr; - } - - // For vertex coloring, this sets this->Colors as side effect. - // For texture map coloring, this sets ColorCoordinates - // and ColorTextureMap as a side effect. - // I moved this out of the conditional because it is fast. - // Color arrays are cached. If nothing has changed, - // then the scalars do not have to be regenerted. - this->MapScalars(poly, 1.0); - - // If we are coloring by texture, then load the texture map. - if (this->ColorTextureMap) - { - if (this->InternalColorTexture == nullptr) - { - this->InternalColorTexture = vtkOpenGLTexture::New(); - this->InternalColorTexture->RepeatOff(); - } - this->InternalColorTexture->SetInputData(this->ColorTextureMap); - } - - this->HaveCellScalars = false; - vtkDataArray* c = this->Colors; - if (this->ScalarVisibility) - { - // We must figure out how the scalars should be mapped to the polydata. - if ((this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_DATA || - this->ScalarMode == VTK_SCALAR_MODE_USE_CELL_FIELD_DATA || - this->ScalarMode == VTK_SCALAR_MODE_USE_FIELD_DATA || - !poly->GetPointData()->GetScalars()) && - this->ScalarMode != VTK_SCALAR_MODE_USE_POINT_FIELD_DATA && this->Colors) - { - this->HaveCellScalars = true; - c = nullptr; - } - } - - this->HaveCellNormals = false; - // Do we have cell normals? - vtkDataArray* n = (act->GetProperty()->GetInterpolation() != VTK_FLAT) - ? poly->GetPointData()->GetNormals() - : nullptr; - if (n == nullptr && poly->GetCellData()->GetNormals()) - { - this->HaveCellNormals = true; - n = nullptr; - } - - int representation = act->GetProperty()->GetRepresentation(); - vtkHardwareSelector* selector = ren->GetSelector(); - - if (selector && this->PopulateSelectionSettings && - selector->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS) - { - representation = VTK_POINTS; - } - - // if we have cell scalars then we have to - // explode the data - vtkCellArray* prims[4]; - prims[0] = poly->GetVerts(); - prims[1] = poly->GetLines(); - prims[2] = poly->GetPolys(); - prims[3] = poly->GetStrips(); - - // needs to get a cell call map passed in - this->AppendCellTextures( - ren, act, prims, representation, newColors, newNorms, poly, hdata->CellCellMap); - - hdata->CellCellMap->BuildPrimitiveOffsetsIfNeeded(prims, representation, poly->GetPoints()); - - // do we have texture maps? - bool haveTextures = - (this->ColorTextureMap || act->GetTexture() || act->GetProperty()->GetNumberOfTextures()); - - // Set the texture if we are going to use texture - // for coloring with a point attribute. - // fixme ... make the existence of the coordinate array the signal. - vtkDataArray* tcoords = nullptr; - if (haveTextures) - { - if (this->InterpolateScalarsBeforeMapping && this->ColorCoordinates) - { - tcoords = this->ColorCoordinates; - } - else - { - tcoords = poly->GetPointData()->GetTCoords(); - } - } - - // Check if color array is already computed for the current array. - // This step is mandatory otherwise the test ArrayExists will fail for "scalarColor" even if - // the array used to map the color has already been added. - if (c) - { - int cellFlag = 0; // not used - vtkAbstractArray* abstractArray = vtkCompositeMapperHelper2::GetAbstractScalars( - poly, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag); - - auto iter = this->ColorArrayMap.find(abstractArray); - if (iter != this->ColorArrayMap.end()) - { - c = iter->second; - } - else - { - this->ColorArrayMap[abstractArray] = c; - c->Register(this); - } - } - - vtkFloatArray* tangents = vtkFloatArray::SafeDownCast(poly->GetPointData()->GetTangents()); - - // Build the VBO - vtkIdType offsetPos = 0; - vtkIdType offsetNorm = 0; - vtkIdType offsetColor = 0; - vtkIdType offsetTex = 0; - vtkIdType offsetTangents = 0; - vtkIdType totalOffset = 0; - vtkIdType dummy = 0; - bool exists = - this->VBOs->ArrayExists("vertexMC", poly->GetPoints()->GetData(), offsetPos, totalOffset) && - this->VBOs->ArrayExists("normalMC", n, offsetNorm, dummy) && - this->VBOs->ArrayExists("scalarColor", c, offsetColor, dummy) && - this->VBOs->ArrayExists("tcoord", tcoords, offsetTex, dummy) && - this->VBOs->ArrayExists("tangentMC", tangents, offsetTangents, dummy); - - // if all used arrays have the same offset and have already been added, - // we can reuse them and save memory - if (exists && (offsetNorm == 0 || offsetPos == offsetNorm) && - (offsetColor == 0 || offsetPos == offsetColor) && (offsetTex == 0 || offsetPos == offsetTex) && - (offsetTangents == 0 || offsetPos == offsetTangents)) - { - voffset = offsetPos; - } - else - { - this->VBOs->AppendDataArray("vertexMC", poly->GetPoints()->GetData(), VTK_FLOAT); - this->VBOs->AppendDataArray("normalMC", n, VTK_FLOAT); - this->VBOs->AppendDataArray("scalarColor", c, VTK_UNSIGNED_CHAR); - this->VBOs->AppendDataArray("tcoord", tcoords, VTK_FLOAT); - this->VBOs->AppendDataArray("tangentMC", tangents, VTK_FLOAT); - - voffset = totalOffset; - } - - // now create the IBOs - vtkOpenGLIndexBufferObject::AppendPointIndexBuffer(this->IndexArray[0], prims[0], voffset); - - vtkDataArray* ef = poly->GetPointData()->GetAttribute(vtkDataSetAttributes::EDGEFLAG); - if (ef) - { - if (ef->GetNumberOfComponents() != 1) - { - vtkDebugMacro(<< "Currently only 1d edge flags are supported."); - ef = nullptr; - } - if (ef && !ef->IsA("vtkUnsignedCharArray")) - { - vtkDebugMacro(<< "Currently only unsigned char edge flags are supported."); - ef = nullptr; - } - } - - vtkProperty* prop = act->GetProperty(); - bool draw_surface_with_edges = - (prop->GetEdgeVisibility() && prop->GetRepresentation() == VTK_SURFACE); - - if (representation == VTK_POINTS) - { - vtkOpenGLIndexBufferObject::AppendPointIndexBuffer(this->IndexArray[1], prims[1], voffset); - - vtkOpenGLIndexBufferObject::AppendPointIndexBuffer(this->IndexArray[2], prims[2], voffset); - - vtkOpenGLIndexBufferObject::AppendPointIndexBuffer(this->IndexArray[3], prims[3], voffset); - } - else // WIREFRAME OR SURFACE - { - vtkOpenGLIndexBufferObject::AppendLineIndexBuffer(this->IndexArray[1], prims[1], voffset); - - if (representation == VTK_WIREFRAME) - { - if (ef) - { - vtkOpenGLIndexBufferObject::AppendEdgeFlagIndexBuffer( - this->IndexArray[2], prims[2], voffset, ef); - } - else - { - vtkOpenGLIndexBufferObject::AppendTriangleLineIndexBuffer( - this->IndexArray[2], prims[2], voffset); - } - vtkOpenGLIndexBufferObject::AppendStripIndexBuffer( - this->IndexArray[3], prims[3], voffset, true); - } - else // SURFACE - { - if (draw_surface_with_edges) - { - // have to insert dummy values for points and lines - vtkIdType* offsets = hdata->CellCellMap->GetPrimitiveOffsets(); - this->EdgeValues.resize(offsets[2], 0); - vtkOpenGLIndexBufferObject::AppendTriangleIndexBuffer( - this->IndexArray[2], prims[2], poly->GetPoints(), voffset, &this->EdgeValues, ef); - } - else - { - vtkOpenGLIndexBufferObject::AppendTriangleIndexBuffer( - this->IndexArray[2], prims[2], poly->GetPoints(), voffset, nullptr, nullptr); - } - vtkOpenGLIndexBufferObject::AppendStripIndexBuffer( - this->IndexArray[3], prims[3], voffset, false); - } - } - - if (prop->GetVertexVisibility()) - { - vtkOpenGLIndexBufferObject::AppendVertexIndexBuffer( - this->IndexArray[vtkOpenGLPolyDataMapper::PrimitiveVertices], prims, voffset); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::ProcessSelectorPixelBuffers( - vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) -{ - if (!this->PopulateSelectionSettings) - { - return; - } - - if (sel->GetCurrentPass() == vtkHardwareSelector::ACTOR_PASS) - { - this->PickPixels.clear(); - return; - } - - if (PickPixels.empty() && !pixeloffsets.empty()) - { - // preprocess the image to find matching pixels and - // store them in a map of vectors based on flat index - // this makes the block processing far faster as we just - // loop over the pixels for our block - unsigned char* compositedata = - sel->GetRawPixelBuffer(vtkHardwareSelector::COMPOSITE_INDEX_PASS); - - if (!compositedata) - { - return; - } - - size_t maxFlatIndex = 0; - for (auto& data : this->Data) - { - maxFlatIndex = - (data.second->FlatIndex > maxFlatIndex) ? data.second->FlatIndex : maxFlatIndex; - } - - this->PickPixels.resize(maxFlatIndex + 1); - - for (auto pos : pixeloffsets) - { - unsigned int compval = compositedata[pos + 2]; - compval = compval << 8; - compval |= compositedata[pos + 1]; - compval = compval << 8; - compval |= compositedata[pos]; - if (compval <= maxFlatIndex) - { - this->PickPixels[compval].push_back(pos); - } - } - } - - // for each block update the image - for (auto& data : this->Data) - { - if (!this->PickPixels[data.second->FlatIndex].empty()) - { - this->ProcessCompositePixelBuffers( - sel, prop, data.second, this->PickPixels[data.second->FlatIndex]); - } - } -} - -namespace -{ -struct ProcessFunctor -{ - template <typename TArray> - void operator()(TArray* array, unsigned char* rawplowdata, unsigned char* rawphighdata, - unsigned char* processdata, vtkCompositeMapperHelperData* hdata, - std::vector<unsigned int>& pixeloffsets) - { - auto arrayRange = vtk::DataArrayValueRange<1>(array); - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - if (rawphighdata) - { - inval = rawphighdata[pos]; - inval = inval << 8; - } - inval |= rawplowdata[pos + 2]; - inval = inval << 8; - inval |= rawplowdata[pos + 1]; - inval = inval << 8; - inval |= rawplowdata[pos]; - // as this pass happens after both low and high point passes - // the computed value should be higher than StartVertex - inval -= hdata->StartVertex; - const auto outval = static_cast<unsigned int>(arrayRange[inval]) + 1; - processdata[pos] = outval & 0xff; - processdata[pos + 1] = (outval & 0xff00) >> 8; - processdata[pos + 2] = (outval & 0xff0000) >> 16; - } - } -}; - -struct CompositeFunctor -{ - template <typename TArray> - void operator()(TArray* array, unsigned char* rawclowdata, unsigned char* rawchighdata, - unsigned char* compositedata, vtkCompositeMapperHelperData* hdata, - std::vector<unsigned int>& pixeloffsets, bool pointPicking) - { - auto arrayRange = vtk::DataArrayValueRange<1>(array); - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - if (rawchighdata) - { - inval = rawchighdata[pos]; - inval = inval << 8; - } - inval |= rawclowdata[pos + 2]; - inval = inval << 8; - inval |= rawclowdata[pos + 1]; - inval = inval << 8; - inval |= rawclowdata[pos]; - - // always gets called after the cell high and low are available - // so it is safe - vtkIdType vtkCellId = hdata->CellCellMap->ConvertOpenGLCellIdToVTKCellId(pointPicking, inval); - const auto outval = static_cast<unsigned int>(arrayRange[vtkCellId]); - compositedata[pos] = outval & 0xff; - compositedata[pos + 1] = (outval & 0xff00) >> 8; - compositedata[pos + 2] = (outval & 0xff0000) >> 16; - } - } -}; -} - -//------------------------------------------------------------------------------ -void vtkCompositeMapperHelper2::ProcessCompositePixelBuffers(vtkHardwareSelector* sel, - vtkProp* prop, vtkCompositeMapperHelperData* hdata, std::vector<unsigned int>& pixeloffsets) -{ - vtkPolyData* poly = hdata->Data; - - if (!poly) - { - return; - } - - // which pass are we processing ? - int currPass = sel->GetCurrentPass(); - - // get some common useful values - bool pointPicking = sel->GetFieldAssociation() == vtkDataObject::FIELD_ASSOCIATION_POINTS; - vtkPointData* pd = poly->GetPointData(); - vtkCellData* cd = poly->GetCellData(); - - // get some values - unsigned char* rawplowdata = sel->GetRawPixelBuffer(vtkHardwareSelector::POINT_ID_LOW24); - unsigned char* rawphighdata = sel->GetRawPixelBuffer(vtkHardwareSelector::POINT_ID_HIGH24); - - // do we need to do anything to the process pass data? - if (currPass == vtkHardwareSelector::PROCESS_PASS) - { - unsigned char* processdata = sel->GetPixelBuffer(vtkHardwareSelector::PROCESS_PASS); - vtkDataArray* processArray = nullptr; - - if (sel->GetUseProcessIdFromData()) - { - processArray = this->ProcessIdArrayName ? pd->GetArray(this->ProcessIdArrayName) : nullptr; - } - - if (processdata && (processArray && processArray->GetDataType() == VTK_UNSIGNED_INT) && - rawplowdata) - { - using UIntArrays = - vtkTypeList::Create<vtkAOSDataArrayTemplate<unsigned int>, vtkConstantArray<unsigned int>>; - using Dispatcher = vtkArrayDispatch::DispatchByArray<UIntArrays>; - ProcessFunctor functor; - if (!Dispatcher::Execute( - processArray, functor, rawplowdata, rawphighdata, processdata, hdata, pixeloffsets)) - { - functor(processArray, rawplowdata, rawphighdata, processdata, hdata, pixeloffsets); - } - } - } - - // do we need to do anything to the point id data? - if (currPass == vtkHardwareSelector::POINT_ID_LOW24) - { - vtkIdTypeArray* pointArrayId = this->PointIdArrayName - ? vtkArrayDownCast<vtkIdTypeArray>(pd->GetArray(this->PointIdArrayName)) - : nullptr; - - // do we need to do anything to the point id data? - if (rawplowdata) - { - unsigned char* plowdata = sel->GetPixelBuffer(vtkHardwareSelector::POINT_ID_LOW24); - bool hasHighPointIds = sel->HasHighPointIds(); - - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - if (rawphighdata) - { - inval = rawphighdata[pos]; - inval = inval << 8; - } - inval |= rawplowdata[pos + 2]; - inval = inval << 8; - inval |= rawplowdata[pos + 1]; - inval = inval << 8; - inval |= rawplowdata[pos]; - // this pass happens before the high pass which means the value - // could underflow etc when the high data is not around yet and high - // data is needed. - if (rawphighdata || !hasHighPointIds) - { - inval -= hdata->StartVertex; - vtkIdType outval = inval; - if (pointArrayId && static_cast<vtkIdType>(inval) <= pointArrayId->GetMaxId()) - { - outval = pointArrayId->GetValue(inval); - } - plowdata[pos] = outval & 0xff; - plowdata[pos + 1] = (outval & 0xff00) >> 8; - plowdata[pos + 2] = (outval & 0xff0000) >> 16; - } - } - } - } - - if (currPass == vtkHardwareSelector::POINT_ID_HIGH24) - { - vtkIdTypeArray* pointArrayId = this->PointIdArrayName - ? vtkArrayDownCast<vtkIdTypeArray>(pd->GetArray(this->PointIdArrayName)) - : nullptr; - - // do we need to do anything to the point id data? - if (rawphighdata) - { - unsigned char* phighdata = sel->GetPixelBuffer(vtkHardwareSelector::POINT_ID_HIGH24); - - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - inval = rawphighdata[pos]; - inval = inval << 8; - inval |= rawplowdata[pos + 2]; - inval = inval << 8; - inval |= rawplowdata[pos + 1]; - inval = inval << 8; - inval |= rawplowdata[pos]; - // always happens after the low pass so we should be safe - inval -= hdata->StartVertex; - vtkIdType outval = inval; - if (pointArrayId) - { - outval = pointArrayId->GetValue(inval); - } - phighdata[pos] = (outval & 0xff000000) >> 24; - phighdata[pos + 1] = (outval & 0xff00000000) >> 32; - phighdata[pos + 2] = (outval & 0xff0000000000) >> 40; - } - } - } - - // vars for cell based indexing - vtkCellArray* prims[4]; - prims[0] = poly->GetVerts(); - prims[1] = poly->GetLines(); - prims[2] = poly->GetPolys(); - prims[3] = poly->GetStrips(); - - int representation = static_cast<vtkActor*>(prop)->GetProperty()->GetRepresentation(); - - unsigned char* rawclowdata = sel->GetRawPixelBuffer(vtkHardwareSelector::CELL_ID_LOW24); - unsigned char* rawchighdata = sel->GetRawPixelBuffer(vtkHardwareSelector::CELL_ID_HIGH24); - - // do we need to do anything to the composite pass data? - if (currPass == vtkHardwareSelector::COMPOSITE_INDEX_PASS) - { - unsigned char* compositedata = sel->GetPixelBuffer(vtkHardwareSelector::COMPOSITE_INDEX_PASS); - - vtkDataArray* compositeArray = - this->CompositeIdArrayName ? cd->GetArray(this->CompositeIdArrayName) : nullptr; - - if (compositedata && (compositeArray && compositeArray->GetDataType() == VTK_UNSIGNED_INT) && - rawclowdata) - { - hdata->CellCellMap->Update(prims, representation, poly->GetPoints()); - - using UIntArrays = - vtkTypeList::Create<vtkAOSDataArrayTemplate<unsigned int>, vtkConstantArray<unsigned int>>; - using Dispatcher = vtkArrayDispatch::DispatchByArray<UIntArrays>; - CompositeFunctor functor; - if (!Dispatcher::Execute(compositeArray, functor, rawclowdata, rawchighdata, compositedata, - hdata, pixeloffsets, pointPicking)) - { - functor(compositeArray, rawclowdata, rawchighdata, compositedata, hdata, pixeloffsets, - pointPicking); - } - } - } - - if (currPass == vtkHardwareSelector::CELL_ID_LOW24) - { - vtkIdTypeArray* cellArrayId = this->CellIdArrayName - ? vtkArrayDownCast<vtkIdTypeArray>(cd->GetArray(this->CellIdArrayName)) - : nullptr; - unsigned char* clowdata = sel->GetPixelBuffer(vtkHardwareSelector::CELL_ID_LOW24); - bool hasHighCellIds = sel->HasHighCellIds(); - - if (rawclowdata) - { - hdata->CellCellMap->Update(prims, representation, poly->GetPoints()); - - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - if (rawchighdata) - { - inval = rawchighdata[pos]; - inval = inval << 8; - } - inval |= rawclowdata[pos + 2]; - inval = inval << 8; - inval |= rawclowdata[pos + 1]; - inval = inval << 8; - inval |= rawclowdata[pos]; - // this pass happens before the high pass which means the value - // could underflow etc when the high data is not around yet and high - // data is needed. This underflow would happen in the ConvertToOpenGLCellId - // code when passed too low a number - if (rawchighdata || !hasHighCellIds) - { - vtkIdType outval = - hdata->CellCellMap->ConvertOpenGLCellIdToVTKCellId(pointPicking, inval); - if (cellArrayId && outval <= cellArrayId->GetMaxId()) - { - outval = cellArrayId->GetValue(outval); - } - clowdata[pos] = outval & 0xff; - clowdata[pos + 1] = (outval & 0xff00) >> 8; - clowdata[pos + 2] = (outval & 0xff0000) >> 16; - } - } - } - } - - if (currPass == vtkHardwareSelector::CELL_ID_HIGH24) - { - vtkIdTypeArray* cellArrayId = this->CellIdArrayName - ? vtkArrayDownCast<vtkIdTypeArray>(cd->GetArray(this->CellIdArrayName)) - : nullptr; - unsigned char* chighdata = sel->GetPixelBuffer(vtkHardwareSelector::CELL_ID_HIGH24); - - if (rawchighdata) - { - hdata->CellCellMap->Update(prims, representation, poly->GetPoints()); - - for (auto pos : pixeloffsets) - { - unsigned int inval = 0; - inval = rawchighdata[pos]; - inval = inval << 8; - inval |= rawclowdata[pos + 2]; - inval = inval << 8; - inval |= rawclowdata[pos + 1]; - inval = inval << 8; - inval |= rawclowdata[pos]; - // always called after low24 so safe - vtkIdType outval = hdata->CellCellMap->ConvertOpenGLCellIdToVTKCellId(pointPicking, inval); - if (cellArrayId) - { - outval = cellArrayId->GetValue(outval); - } - chighdata[pos] = (outval & 0xff000000) >> 24; - chighdata[pos + 1] = (outval & 0xff00000000) >> 32; - chighdata[pos + 2] = (outval & 0xff0000000000) >> 40; - } - } - } -} - -//------------------------------------------------------------------------------ -// Now the main class methods -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -vtkStandardNewMacro(vtkCompositePolyDataMapper2); - -//------------------------------------------------------------------------------ -vtkCompositePolyDataMapper2::vtkCompositePolyDataMapper2() -{ - this->CurrentFlatIndex = 0; - this->ColorMissingArraysWithNanColor = false; -} - -//------------------------------------------------------------------------------ -vtkCompositePolyDataMapper2::~vtkCompositePolyDataMapper2() -{ - for (auto& helper : this->Helpers) - { - helper.second->Delete(); - } - this->Helpers.clear(); -} - -//------------------------------------------------------------------------------ -int vtkCompositePolyDataMapper2::FillInputPortInformation( - int vtkNotUsed(port), vtkInformation* info) -{ - info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData"); - info->Append(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObjectTree"); - return 1; -} - -//------------------------------------------------------------------------------ -vtkExecutive* vtkCompositePolyDataMapper2::CreateDefaultExecutive() -{ - return vtkCompositeDataPipeline::New(); -} - -//------------------------------------------------------------------------------ -// Looks at each DataSet and finds the union of all the bounds -void vtkCompositePolyDataMapper2::ComputeBounds() -{ - vtkDataObjectTree* input = vtkDataObjectTree::SafeDownCast(this->GetInputDataObject(0, 0)); - - // If we don't have hierarchical data, test to see if we have - // plain old polydata. In this case, the bounds are simply - // the bounds of the input polydata. - if (!input) - { - this->Superclass::ComputeBounds(); - return; - } - - if (input->GetMTime() < this->BoundsMTime && this->GetMTime() < this->BoundsMTime) - { - return; - } - - // computing bounds with only visible blocks - vtkCompositeDataDisplayAttributes::ComputeVisibleBounds( - this->CompositeAttributes, input, this->Bounds); - this->BoundsMTime.Modified(); -} - -//------------------------------------------------------------------------------ -// simple tests, the mapper is tolerant of being -// called both on opaque and translucent -bool vtkCompositePolyDataMapper2::HasOpaqueGeometry() -{ - return true; -} - -//------------------------------------------------------------------------------ -bool vtkCompositePolyDataMapper2::RecursiveHasTranslucentGeometry( - vtkDataObject* dobj, unsigned int& flat_index) -{ - vtkCompositeDataDisplayAttributes* cda = this->GetCompositeDataDisplayAttributes(); - bool overrides_opacity = (cda && cda->HasBlockOpacity(dobj)); - if (overrides_opacity) - { - if (cda->GetBlockOpacity(dobj) < 1.0) - { - return true; - } - } - - // Advance flat-index. After this point, flat_index no longer points to this - // block. - flat_index++; - - if (auto dObjTree = vtkDataObjectTree::SafeDownCast(dobj)) - { - using Opts = vtk::DataObjectTreeOptions; - for (vtkDataObject* child : vtk::Range(dObjTree, Opts::None)) - { - if (!child) - { - ++flat_index; - } - else - { - if (this->RecursiveHasTranslucentGeometry(child, flat_index)) - { - return true; - } - } - } - return false; - } - else - { - bool overrides_visibility = (cda && cda->HasBlockVisibility(dobj)); - if (overrides_visibility) - { - if (!cda->GetBlockVisibility(dobj)) - { - return false; - } - } - - vtkPolyData* pd = vtkPolyData::SafeDownCast(dobj); - - // if we think it is opaque check the scalars - if (this->ScalarVisibility) - { - vtkScalarsToColors* lut = this->GetLookupTable(); - int cellFlag; - vtkDataArray* scalars = vtkCompositePolyDataMapper2::GetScalars( - pd, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag); - - unsigned char ghostsToSkip; - vtkUnsignedCharArray* ghosts = - vtkAbstractMapper::GetGhostArray(pd, this->ScalarMode, ghostsToSkip); - - if (lut->IsOpaque(scalars, this->ColorMode, this->ArrayComponent, ghosts, ghostsToSkip) == 0) - { - return true; - } - } - } - - return false; -} - -//------------------------------------------------------------------------------ -// simple tests, the mapper is tolerant of being -// called both on opaque and translucent -bool vtkCompositePolyDataMapper2::HasTranslucentPolygonalGeometry() -{ - // Make sure that we have been properly initialized. - if (this->GetInputAlgorithm() == nullptr) - { - return false; - } - - if (!this->Static) - { - this->InvokeEvent(vtkCommand::StartEvent, nullptr); - this->GetInputAlgorithm()->Update(); - this->InvokeEvent(vtkCommand::EndEvent, nullptr); - } - - if (this->GetInputDataObject(0, 0) == nullptr) - { - return false; - } - - // rebuild the render values if needed - vtkCompositeDataDisplayAttributes* cda = this->GetCompositeDataDisplayAttributes(); - vtkScalarsToColors* lut = this->ScalarVisibility ? this->GetLookupTable() : nullptr; - - this->TempState.Clear(); - this->TempState.Append(cda ? cda->GetMTime() : 0, "cda mtime"); - this->TempState.Append(lut ? lut->GetMTime() : 0, "lut mtime"); - this->TempState.Append(this->GetInputDataObject(0, 0)->GetMTime(), "input mtime"); - if (this->TranslucentState != this->TempState) - { - this->TranslucentState = this->TempState; - if (lut) - { - // Ensure that the lookup table is built - lut->Build(); - } - - // Push base-values on the state stack. - unsigned int flat_index = 0; - this->HasTranslucentGeometry = - this->RecursiveHasTranslucentGeometry(this->GetInputDataObject(0, 0), flat_index); - } - - return this->HasTranslucentGeometry; -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetBlockVisibility(unsigned int index, bool visible) -{ - if (this->CompositeAttributes) - { - auto dataObj = - vtkCompositeDataDisplayAttributes::DataObjectFromIndex(index, this->GetInputDataObject(0, 0)); - if (dataObj) - { - this->CompositeAttributes->SetBlockVisibility(dataObj, visible); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -bool vtkCompositePolyDataMapper2::GetBlockVisibility(unsigned int index) -{ - if (this->CompositeAttributes) - { - auto dataObj = - vtkCompositeDataDisplayAttributes::DataObjectFromIndex(index, this->GetInputDataObject(0, 0)); - if (dataObj) - { - return this->CompositeAttributes->GetBlockVisibility(dataObj); - } - } - - return true; -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockVisibility(unsigned int index) -{ - if (this->CompositeAttributes) - { - auto dataObj = - vtkCompositeDataDisplayAttributes::DataObjectFromIndex(index, this->GetInputDataObject(0, 0)); - if (dataObj) - { - this->CompositeAttributes->RemoveBlockVisibility(dataObj); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockVisibilities() -{ - if (this->CompositeAttributes) - { - this->CompositeAttributes->RemoveBlockVisibilities(); - this->Modified(); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetBlockColor(unsigned int index, const double color[3]) -{ - if (this->CompositeAttributes) - { - auto dataObj = - vtkCompositeDataDisplayAttributes::DataObjectFromIndex(index, this->GetInputDataObject(0, 0)); - - if (dataObj) - { - this->CompositeAttributes->SetBlockColor(dataObj, color); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -double* vtkCompositePolyDataMapper2::GetBlockColor(unsigned int index) -{ - static double white[3] = { 1.0, 1.0, 1.0 }; - - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - this->CompositeAttributes->GetBlockColor(dataObj, this->ColorResult); - } - - return this->ColorResult; - } - else - { - return white; - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockColor(unsigned int index) -{ - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - this->CompositeAttributes->RemoveBlockColor(dataObj); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockColors() -{ - if (this->CompositeAttributes) - { - this->CompositeAttributes->RemoveBlockColors(); - this->Modified(); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetBlockOpacity(unsigned int index, double opacity) -{ - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - this->CompositeAttributes->SetBlockOpacity(dataObj, opacity); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -double vtkCompositePolyDataMapper2::GetBlockOpacity(unsigned int index) -{ - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - return this->CompositeAttributes->GetBlockOpacity(dataObj); - } - } - return 1.; -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockOpacity(unsigned int index) -{ - if (this->CompositeAttributes) - { - unsigned int start_index = 0; - auto dataObj = vtkCompositeDataDisplayAttributes::DataObjectFromIndex( - index, this->GetInputDataObject(0, 0), start_index); - if (dataObj) - { - this->CompositeAttributes->RemoveBlockOpacity(dataObj); - this->Modified(); - } - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::RemoveBlockOpacities() -{ - if (this->CompositeAttributes) - { - this->CompositeAttributes->RemoveBlockOpacities(); - this->Modified(); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetCompositeDataDisplayAttributes( - vtkCompositeDataDisplayAttributes* attributes) -{ - if (this->CompositeAttributes != attributes) - { - this->CompositeAttributes = attributes; - this->Modified(); - } -} - -//------------------------------------------------------------------------------ -vtkCompositeDataDisplayAttributes* vtkCompositePolyDataMapper2::GetCompositeDataDisplayAttributes() -{ - return this->CompositeAttributes; -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::CopyMapperValuesToHelper(vtkCompositeMapperHelper2* helper) -{ - // We avoid PolyDataMapper::ShallowCopy because it copies the input - helper->vtkMapper::ShallowCopy(this); - helper->SetPointIdArrayName(this->GetPointIdArrayName()); - helper->SetCompositeIdArrayName(this->GetCompositeIdArrayName()); - helper->SetProcessIdArrayName(this->GetProcessIdArrayName()); - helper->SetCellIdArrayName(this->GetCellIdArrayName()); - helper->SetSeamlessU(this->SeamlessU); - helper->SetSeamlessV(this->SeamlessV); - helper->SetStatic(1); - helper->SetSelection(this->GetSelection()); - helper->SetVBOShiftScaleMethod(this->GetVBOShiftScaleMethod()); -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetVBOShiftScaleMethod(int m) -{ - if (this->ShiftScaleMethod == m) - { - return; - } - - this->Superclass::SetVBOShiftScaleMethod(m); - - for (auto& helper : this->Helpers) - { - helper.second->SetVBOShiftScaleMethod(m); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetPauseShiftScale(bool pauseShiftScale) -{ - if (pauseShiftScale == this->PauseShiftScale) - { - return; - } - - this->Superclass::SetPauseShiftScale(pauseShiftScale); - for (auto& helper : this->Helpers) - { - helper.second->SetPauseShiftScale(pauseShiftScale); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::ReleaseGraphicsResources(vtkWindow* win) -{ - for (auto& helper : this->Helpers) - { - helper.second->ReleaseGraphicsResources(win); - helper.second->Delete(); - } - this->Helpers.clear(); - this->Modified(); - this->Superclass::ReleaseGraphicsResources(win); -} - -//------------------------------------------------------------------------------ -// Description: -// Method initiates the mapping process. Generally sent by the actor -// as each frame is rendered. -void vtkCompositePolyDataMapper2::Render(vtkRenderer* ren, vtkActor* actor) -{ - this->RenderedList.clear(); - - // Make sure that we have been properly initialized. - if (ren->GetRenderWindow()->CheckAbortStatus()) - { - return; - } - - if (this->GetInputAlgorithm() == nullptr) - { - return; - } - - if (!this->Static) - { - this->InvokeEvent(vtkCommand::StartEvent, nullptr); - this->GetInputAlgorithm()->Update(); - this->InvokeEvent(vtkCommand::EndEvent, nullptr); - } - - if (this->GetInputDataObject(0, 0) == nullptr) - { - vtkErrorMacro(<< "No input!"); - return; - } - - // the first step is to gather up the polydata based on their - // signatures (aka have normals, have scalars etc) - if (this->HelperMTime < this->GetInputDataObject(0, 0)->GetMTime() || - this->HelperMTime < this->GetMTime()) - { - // clear old helpers - for (auto& helper : this->Helpers) - { - helper.second->ClearMark(); - } - this->HelperDataMap.clear(); - - if (auto dObjTree = vtkDataObjectTree::SafeDownCast(this->GetInputDataObject(0, 0))) - { - vtkNew<vtkDataObjectTreeIterator> iter; - iter->SetDataSet(dObjTree); - iter->SkipEmptyNodesOn(); - iter->VisitOnlyLeavesOn(); - for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem()) - { - unsigned int flatIndex = iter->GetCurrentFlatIndex(); - vtkPolyData* pd = vtkPolyData::SafeDownCast(iter->GetCurrentDataObject()); - - if (!pd || !pd->GetPoints()) - { - continue; - } - int cellFlag = 0; - bool hasScalars = this->ScalarVisibility && - (vtkAbstractMapper::GetAbstractScalars(pd, this->ScalarMode, this->ArrayAccessMode, - this->ArrayId, this->ArrayName, cellFlag) != nullptr); - - bool hasNormals = (pd->GetPointData()->GetNormals() || pd->GetCellData()->GetNormals()); - - bool hasTCoords = (pd->GetPointData()->GetTCoords() != nullptr); - - std::ostringstream toString; - toString.str(""); - toString.clear(); - toString << 'A' << (hasScalars ? 1 : 0) << 'B' << (hasNormals ? 1 : 0) << 'C' - << (hasTCoords ? 1 : 0); - - vtkCompositeMapperHelper2* helper = nullptr; - auto found = this->Helpers.find(toString.str()); - if (found == this->Helpers.end()) - { - helper = this->CreateHelper(); - helper->SetParent(this); - this->Helpers.insert(std::make_pair(toString.str(), helper)); - } - else - { - helper = found->second; - } - this->CopyMapperValuesToHelper(helper); - helper->SetMarked(true); - this->HelperDataMap[pd] = helper->AddData(pd, flatIndex); - } - } - else - { - vtkPolyData* pd = vtkPolyData::SafeDownCast(this->GetInputDataObject(0, 0)); - if (pd && pd->GetPoints()) - { - int cellFlag = 0; - bool hasScalars = this->ScalarVisibility && - (vtkAbstractMapper::GetAbstractScalars(pd, this->ScalarMode, this->ArrayAccessMode, - this->ArrayId, this->ArrayName, cellFlag) != nullptr); - - bool hasNormals = (pd->GetPointData()->GetNormals() || pd->GetCellData()->GetNormals()); - - bool hasTCoords = (pd->GetPointData()->GetTCoords() != nullptr); - - std::ostringstream toString; - toString.str(""); - toString.clear(); - toString << 'A' << (hasScalars ? 1 : 0) << 'B' << (hasNormals ? 1 : 0) << 'C' - << (hasTCoords ? 1 : 0); - - vtkCompositeMapperHelper2* helper = nullptr; - auto found = this->Helpers.find(toString.str()); - if (found == this->Helpers.end()) - { - helper = this->CreateHelper(); - helper->SetParent(this); - this->Helpers.insert(std::make_pair(toString.str(), helper)); - } - else - { - helper = found->second; - } - this->CopyMapperValuesToHelper(helper); - helper->SetMarked(true); - this->HelperDataMap[pd] = helper->AddData(pd, 0); - } - } - - // delete unused old helpers/data - for (auto hiter = this->Helpers.begin(); hiter != this->Helpers.end();) - { - hiter->second->RemoveUnused(); - if (!hiter->second->GetMarked()) - { - hiter->second->ReleaseGraphicsResources(ren->GetVTKWindow()); - hiter->second->Delete(); - this->Helpers.erase(hiter++); - } - else - { - ++hiter; - } - } - this->HelperMTime.Modified(); - } - - // rebuild the render values if needed - this->TempState.Clear(); - this->TempState.Append(actor->GetProperty()->GetMTime(), "actor mtime"); - this->TempState.Append(this->GetMTime(), "this mtime"); - this->TempState.Append(this->HelperMTime, "helper mtime"); - this->TempState.Append( - actor->GetTexture() ? actor->GetTexture()->GetMTime() : 0, "texture mtime"); - if (this->RenderValuesState != this->TempState) - { - this->RenderValuesState = this->TempState; - vtkProperty* prop = actor->GetProperty(); - vtkScalarsToColors* lut = this->GetLookupTable(); - if (lut) - { - // Ensure that the lookup table is built - lut->Build(); - } - - double* selColor = prop->GetSelectionColor(); - - // Push base-values on the state stack. - this->BlockState.Visibility.push(true); - this->BlockState.Pickability.push(true); - this->BlockState.Opacity.push(prop->GetOpacity()); - this->BlockState.AmbientColor.emplace(prop->GetAmbientColor()); - this->BlockState.DiffuseColor.emplace(prop->GetDiffuseColor()); - this->BlockState.SpecularColor.emplace(prop->GetSpecularColor()); - this->BlockState.SelectionColor.emplace(selColor); - this->BlockState.SelectionOpacity.push(selColor[3]); - - unsigned int flat_index = 0; - this->BuildRenderValues(ren, actor, this->GetInputDataObject(0, 0), flat_index); - - this->BlockState.Visibility.pop(); - this->BlockState.Pickability.pop(); - this->BlockState.Opacity.pop(); - this->BlockState.AmbientColor.pop(); - this->BlockState.DiffuseColor.pop(); - this->BlockState.SpecularColor.pop(); - this->BlockState.SelectionColor.pop(); - this->BlockState.SelectionOpacity.pop(); - } - - this->InitializeHelpersBeforeRendering(ren, actor); - - for (auto& helper : this->Helpers) - { - vtkCompositeMapperHelper2* helper2 = helper.second; - helper2->RenderPiece(ren, actor); - - // update the list of rendered polydata that vtkValuePass relies on - std::vector<vtkPolyData*> pdl = helper2->GetRenderedList(); - for (unsigned int i = 0; i < pdl.size(); ++i) - { - this->RenderedList.push_back(pdl[i]); - } - } -} - -vtkCompositeMapperHelper2* vtkCompositePolyDataMapper2::CreateHelper() -{ - return vtkCompositeMapperHelper2::New(); -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::BuildRenderValues( - vtkRenderer* renderer, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index) -{ - vtkCompositeDataDisplayAttributes* cda = this->GetCompositeDataDisplayAttributes(); - bool overrides_visibility = (cda && cda->HasBlockVisibility(dobj)); - if (overrides_visibility) - { - this->BlockState.Visibility.push(cda->GetBlockVisibility(dobj)); - } - bool overrides_pickability = (cda && cda->HasBlockPickability(dobj)); - if (overrides_pickability) - { - this->BlockState.Pickability.push(cda->GetBlockPickability(dobj)); - } - - bool overrides_opacity = (cda && cda->HasBlockOpacity(dobj)); - if (overrides_opacity) - { - this->BlockState.Opacity.push(cda->GetBlockOpacity(dobj)); - } - - bool overrides_color = (cda && cda->HasBlockColor(dobj)); - if (overrides_color) - { - vtkColor3d color = cda->GetBlockColor(dobj); - this->BlockState.AmbientColor.push(color); - this->BlockState.DiffuseColor.push(color); - this->BlockState.SpecularColor.push(color); - } - - // Advance flat-index. After this point, flat_index no longer points to this - // block. - flat_index++; - - bool textureOpaque = true; - if (actor->GetTexture() != nullptr && actor->GetTexture()->IsTranslucent()) - { - textureOpaque = false; - } - - if (auto dObjTree = vtkDataObjectTree::SafeDownCast(dobj)) - { - using Opts = vtk::DataObjectTreeOptions; - for (vtkDataObject* child : vtk::Range(dObjTree, Opts::None)) - { - if (!child) - { - ++flat_index; - } - else - { - this->BuildRenderValues(renderer, actor, child, flat_index); - } - } - } - else - { - vtkPolyData* pd = vtkPolyData::SafeDownCast(dobj); - auto dit = this->HelperDataMap.find(pd); - if (dit != this->HelperDataMap.end()) - { - vtkCompositeMapperHelperData* helperData = dit->second; - helperData->Opacity = this->BlockState.Opacity.top(); - helperData->Visibility = this->BlockState.Visibility.top(); - helperData->Pickability = this->BlockState.Pickability.top(); - helperData->AmbientColor = this->BlockState.AmbientColor.top(); - helperData->DiffuseColor = this->BlockState.DiffuseColor.top(); - helperData->SelectionColor = this->BlockState.SelectionColor.top(); - helperData->SelectionOpacity = this->BlockState.SelectionOpacity.top(); - helperData->OverridesColor = (this->BlockState.AmbientColor.size() > 1); - helperData->IsOpaque = (helperData->Opacity >= 1.0) ? textureOpaque : false; - // if we think it is opaque check the scalars - if (helperData->IsOpaque && this->ScalarVisibility) - { - vtkScalarsToColors* lut = this->GetLookupTable(); - int cellFlag; - vtkDataArray* scalars = vtkCompositePolyDataMapper2::GetScalars( - pd, this->ScalarMode, this->ArrayAccessMode, this->ArrayId, this->ArrayName, cellFlag); - - unsigned char ghostsToSkip; - vtkUnsignedCharArray* ghosts = - vtkAbstractMapper::GetGhostArray(pd, this->ScalarMode, ghostsToSkip); - - if (lut->IsOpaque(scalars, this->ColorMode, this->ArrayComponent, ghosts, ghostsToSkip) == - 0) - { - helperData->IsOpaque = false; - } - } - } - } - if (overrides_color) - { - this->BlockState.AmbientColor.pop(); - this->BlockState.DiffuseColor.pop(); - this->BlockState.SpecularColor.pop(); - } - if (overrides_opacity) - { - this->BlockState.Opacity.pop(); - } - if (overrides_pickability) - { - this->BlockState.Pickability.pop(); - } - if (overrides_visibility) - { - this->BlockState.Visibility.pop(); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetInputArrayToProcess(int idx, vtkInformation* inInfo) -{ - this->Superclass::SetInputArrayToProcess(idx, inInfo); - - // set inputs to helpers - for (auto& helper : this->Helpers) - { - helper.second->SetInputArrayToProcess(idx, inInfo); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetInputArrayToProcess( - int idx, int port, int connection, int fieldAssociation, int attributeType) -{ - this->Superclass::SetInputArrayToProcess(idx, port, connection, fieldAssociation, attributeType); - - // set inputs to helpers - for (auto& helper : this->Helpers) - { - helper.second->SetInputArrayToProcess(idx, port, connection, fieldAssociation, attributeType); - } -} - -//------------------------------------------------------------------------------ -void vtkCompositePolyDataMapper2::SetInputArrayToProcess( - int idx, int port, int connection, int fieldAssociation, const char* name) -{ - this->Superclass::SetInputArrayToProcess(idx, port, connection, fieldAssociation, name); - - // set inputs to helpers - for (auto& helper : this->Helpers) - { - helper.second->SetInputArrayToProcess(idx, port, connection, fieldAssociation, name); - } -} - -//----------------------------------------------------------------------------- -void vtkCompositePolyDataMapper2::ProcessSelectorPixelBuffers( - vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) -{ - // forward to helper - for (auto& helper : this->Helpers) - { - helper.second->ProcessSelectorPixelBuffers(sel, pixeloffsets, prop); - } -} - -//----------------------------------------------------------------------------- -vtkMTimeType vtkCompositePolyDataMapper2::GetMTime() -{ - if (this->CompositeAttributes) - { - return std::max(this->Superclass::GetMTime(), this->CompositeAttributes->GetMTime()); - } - return this->Superclass::GetMTime(); -} -VTK_ABI_NAMESPACE_END diff --git a/Rendering/OpenGL2/vtkCompositePolyDataMapper2.h b/Rendering/OpenGL2/vtkCompositePolyDataMapper2.h deleted file mode 100644 index 4df3f81df25..00000000000 --- a/Rendering/OpenGL2/vtkCompositePolyDataMapper2.h +++ /dev/null @@ -1,251 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class vtkCompositePolyDataMapper2 - * @brief mapper for composite dataset consisting - * of polygonal data. - * - * vtkCompositePolyDataMapper2 is similar to vtkCompositePolyDataMapper except - * that instead of creating individual mapper for each block in the composite - * dataset, it iterates over the blocks internally. - */ - -#ifndef vtkCompositePolyDataMapper2_h -#define vtkCompositePolyDataMapper2_h - -#include "vtkOpenGLPolyDataMapper.h" - -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 -#include "vtkRenderingOpenGL2Module.h" // For export macro -#include "vtkSmartPointer.h" // for vtkSmartPointer -#include "vtk_glad.h" // for OpenGL enums - -#include "vtkColor.h" // used for ivars -#include <map> // use for ivars -#include <stack> // used for ivars -#include <vector> // used for ivars - -VTK_ABI_NAMESPACE_BEGIN -class vtkCompositeDataDisplayAttributes; -class vtkCompositeMapperHelper2; -class vtkCompositeMapperHelperData; - -class VTK_DEPRECATED_IN_9_3_0("Please use vtkCompositePolyDataMapper instead") - VTKRENDERINGOPENGL2_EXPORT vtkCompositePolyDataMapper2 : public vtkOpenGLPolyDataMapper -{ -public: - static vtkCompositePolyDataMapper2* New(); - vtkTypeMacro(vtkCompositePolyDataMapper2, vtkOpenGLPolyDataMapper); - void PrintSelf(ostream& os, vtkIndent indent) override; - - ///@{ - /** - * Some introspection on the type of data the mapper will render - * used by props to determine if they should invoke the mapper - * on a specific rendering pass. - */ - bool HasOpaqueGeometry() override; - bool HasTranslucentPolygonalGeometry() override; - ///@} - - ///@{ - /** - * Set/get the composite data set attributes. - */ - void SetCompositeDataDisplayAttributes(vtkCompositeDataDisplayAttributes* attributes); - vtkCompositeDataDisplayAttributes* GetCompositeDataDisplayAttributes(); - ///@} - - ///@{ - /** - * Set/get the visibility for a block given its flat index. - */ - void SetBlockVisibility(unsigned int index, bool visible); - bool GetBlockVisibility(unsigned int index); - void RemoveBlockVisibility(unsigned int index); - void RemoveBlockVisibilities(); - ///@} - - ///@{ - /** - * Set/get the color for a block given its flat index. - */ - void SetBlockColor(unsigned int index, const double color[3]); - void SetBlockColor(unsigned int index, double r, double g, double b) - { - double color[3] = { r, g, b }; - this->SetBlockColor(index, color); - } - double* GetBlockColor(unsigned int index); - void RemoveBlockColor(unsigned int index); - void RemoveBlockColors(); - ///@} - - ///@{ - /** - * Set/get the opacity for a block given its flat index. - */ - void SetBlockOpacity(unsigned int index, double opacity); - double GetBlockOpacity(unsigned int index); - void RemoveBlockOpacity(unsigned int index); - void RemoveBlockOpacities(); - ///@} - - /** - * If the current 'color by' array is missing on some datasets, color these - * dataset by the LookupTable's NaN color, if the lookup table supports it. - * Default is false. - * @{ - */ - vtkSetMacro(ColorMissingArraysWithNanColor, bool); - vtkGetMacro(ColorMissingArraysWithNanColor, bool); - vtkBooleanMacro(ColorMissingArraysWithNanColor, bool); - /**@}*/ - - /** - * Release any graphics resources that are being consumed by this mapper. - * The parameter window could be used to determine which graphic - * resources to release. - */ - void ReleaseGraphicsResources(vtkWindow*) override; - - /** - * This calls RenderPiece (in a for loop if streaming is necessary). - */ - void Render(vtkRenderer* ren, vtkActor* act) override; - - /**\brief A convenience method for enabling/disabling - * the VBO's shift+scale transform. - */ - void SetVBOShiftScaleMethod(int m) override; - - /**\brief Pause updates of shift-scale parameters based on camera position. - * - * This override passes the information to all instances in \a Helpers . - */ - void SetPauseShiftScale(bool pauseShiftScale) override; - - ///@{ - /** - * Call SetInputArrayToProcess on helpers. - */ - using vtkAlgorithm::SetInputArrayToProcess; - void SetInputArrayToProcess( - int idx, int port, int connection, int fieldAssociation, const char* name) override; - void SetInputArrayToProcess( - int idx, int port, int connection, int fieldAssociation, int fieldAttributeType) override; - void SetInputArrayToProcess(int idx, vtkInformation* info) override; - ///@} - - /** - * Accessor to the ordered list of PolyData that we end last drew. - */ - std::vector<vtkPolyData*> GetRenderedList() { return this->RenderedList; } - - /** - * allows a mapper to update a selections color buffers - * Called from a prop which in turn is called from the selector - */ - void ProcessSelectorPixelBuffers( - vtkHardwareSelector* sel, std::vector<unsigned int>& pixeloffsets, vtkProp* prop) override; - - /** - * Overridden to include vtkCompositeDataDisplayAttributes' mtime. - */ - vtkMTimeType GetMTime() override; - -protected: - vtkCompositePolyDataMapper2(); - ~vtkCompositePolyDataMapper2() override; - - /** - * We need to override this method because the standard streaming - * demand driven pipeline is not what we want - we are expecting - * hierarchical data as input - */ - vtkExecutive* CreateDefaultExecutive() override; - - /** - * Need to define the type of data handled by this mapper. - */ - int FillInputPortInformation(int port, vtkInformation* info) override; - - /** - * Need to loop over the hierarchy to compute bounds - */ - void ComputeBounds() override; - - /** - * This method is called before RenderPiece is called on helpers. - * One can override it to initialize the helpers. - */ - virtual void InitializeHelpersBeforeRendering( - vtkRenderer* vtkNotUsed(ren), vtkActor* vtkNotUsed(act)) - { - } - - /** - * Time stamp for computation of bounds. - */ - vtkTimeStamp BoundsMTime; - - // what "index" are we currently rendering, -1 means none - int CurrentFlatIndex; - std::map<const std::string, vtkCompositeMapperHelper2*> Helpers; - std::map<vtkPolyData*, vtkCompositeMapperHelperData*> HelperDataMap; - vtkTimeStamp HelperMTime; - - virtual vtkCompositeMapperHelper2* CreateHelper(); - - // copy values to the helpers - virtual void CopyMapperValuesToHelper(vtkCompositeMapperHelper2* helper); - - class RenderBlockState - { - public: - std::stack<bool> Visibility; - std::stack<bool> Pickability; - std::stack<double> Opacity; - std::stack<vtkColor3d> AmbientColor; - std::stack<vtkColor3d> DiffuseColor; - std::stack<vtkColor3d> SpecularColor; - std::stack<vtkColor3d> SelectionColor; - std::stack<float> SelectionOpacity; - }; - - bool RecursiveHasTranslucentGeometry(vtkDataObject* dobj, unsigned int& flat_index); - vtkStateStorage TranslucentState; - bool HasTranslucentGeometry; - - void BuildRenderValues( - vtkRenderer* renderer, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index); - vtkStateStorage RenderValuesState; - - RenderBlockState BlockState; - void RenderBlock( - vtkRenderer* renderer, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index); - - /** - * Composite data set attributes. - */ - vtkSmartPointer<vtkCompositeDataDisplayAttributes> CompositeAttributes; - - friend class vtkCompositeMapperHelper2; - - /** - * If the current 'color by' array is missing on some datasets, color these - * dataset by the LookupTable's NaN color, if the lookup table supports it. - */ - bool ColorMissingArraysWithNanColor; - - std::vector<vtkPolyData*> RenderedList; - -private: - double ColorResult[3]; - - vtkCompositePolyDataMapper2(const vtkCompositePolyDataMapper2&) = delete; - void operator=(const vtkCompositePolyDataMapper2&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif diff --git a/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx b/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx index d298bd09e2a..6ca18a3642d 100644 --- a/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx +++ b/Rendering/OpenGL2/vtkXOpenGLRenderWindow.cxx @@ -1073,15 +1073,6 @@ void vtkXOpenGLRenderWindow::SetSize(int width, int height) } } -void vtkXOpenGLRenderWindow::SetSizeNoXResize(int width, int height) -{ - if ((this->Size[0] != width) || (this->Size[1] != height)) - { - this->Superclass::SetSize(width, height); - this->Modified(); - } -} - bool vtkXOpenGLRenderWindow::SetSwapControl(int i) { glXSwapIntervalEXTProc glXSwapIntervalEXT = diff --git a/Rendering/OpenGL2/vtkXOpenGLRenderWindow.h b/Rendering/OpenGL2/vtkXOpenGLRenderWindow.h index c07e862db51..68d1b467497 100644 --- a/Rendering/OpenGL2/vtkXOpenGLRenderWindow.h +++ b/Rendering/OpenGL2/vtkXOpenGLRenderWindow.h @@ -13,7 +13,6 @@ #ifndef vtkXOpenGLRenderWindow_h #define vtkXOpenGLRenderWindow_h -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 #include "vtkOpenGLRenderWindow.h" #include "vtkRenderingOpenGL2Module.h" // For export macro #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO @@ -96,13 +95,6 @@ public: void SetSize(int width, int height) override; void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); } - /** - * Specify the size of the rendering window in pixels but do not resize - * the XWindow. Useful when resizing is done interactively. - */ - VTK_DEPRECATED_IN_9_3_0("Use vtkRenderWindow::SetSize(w,h) instead") - void SetSizeNoXResize(int, int); - ///@{ /** * Get the X properties of an ideal rendering window. diff --git a/Rendering/RayTracing/CMakeLists.txt b/Rendering/RayTracing/CMakeLists.txt index 98b212229f3..c236c5d6e62 100644 --- a/Rendering/RayTracing/CMakeLists.txt +++ b/Rendering/RayTracing/CMakeLists.txt @@ -3,7 +3,6 @@ set(classes vtkOSPRayAMRVolumeMapperNode vtkOSPRayCameraNode vtkOSPRayCompositePolyDataMapperNode - vtkOSPRayCompositePolyDataMapper2Node vtkOSPRayLightNode vtkOSPRayMaterialHelpers vtkOSPRayMaterialLibrary diff --git a/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.cxx b/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.cxx deleted file mode 100644 index 01edd926b60..00000000000 --- a/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.cxx +++ /dev/null @@ -1,212 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 -#include "vtkOSPRayCompositePolyDataMapper2Node.h" - -#include "vtkActor.h" -#include "vtkCompositeDataDisplayAttributes.h" -#include "vtkCompositePolyDataMapper2.h" -#include "vtkMultiBlockDataSet.h" -#include "vtkMultiPieceDataSet.h" -#include "vtkOSPRayActorNode.h" -#include "vtkOSPRayRendererNode.h" -#include "vtkPolyData.h" -#include "vtkProperty.h" -#include "vtkRenderer.h" -#include "vtkSmartPointer.h" - -//============================================================================ -VTK_ABI_NAMESPACE_BEGIN -vtkStandardNewMacro(vtkOSPRayCompositePolyDataMapper2Node); - -//------------------------------------------------------------------------------ -vtkOSPRayCompositePolyDataMapper2Node::vtkOSPRayCompositePolyDataMapper2Node() = default; - -//------------------------------------------------------------------------------ -vtkOSPRayCompositePolyDataMapper2Node::~vtkOSPRayCompositePolyDataMapper2Node() = default; - -//------------------------------------------------------------------------------ -void vtkOSPRayCompositePolyDataMapper2Node::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); -} - -//------------------------------------------------------------------------------ -void vtkOSPRayCompositePolyDataMapper2Node::Invalidate(bool prepass) -{ - if (prepass) - { - this->RenderTime = 0; - } -} - -//------------------------------------------------------------------------------ -void vtkOSPRayCompositePolyDataMapper2Node::Render(bool prepass) -{ - if (prepass) - { - // we use a lot of params from our parent - vtkOSPRayActorNode* aNode = vtkOSPRayActorNode::SafeDownCast(this->Parent); - vtkActor* act = vtkActor::SafeDownCast(aNode->GetRenderable()); - - if (act->GetVisibility() == false) - { - return; - } - - vtkOSPRayRendererNode* orn = - static_cast<vtkOSPRayRendererNode*>(this->GetFirstAncestorOfType("vtkOSPRayRendererNode")); - - // if there are no changes, just reuse last result - vtkMTimeType inTime = aNode->GetMTime(); - if (this->RenderTime >= inTime) - { - this->RenderGeometricModels(); - return; - } - this->RenderTime = inTime; - this->ClearGeometricModels(); - - vtkProperty* prop = act->GetProperty(); - - // Push base-values on the state stack. - this->BlockState.Visibility.push(true); - this->BlockState.Opacity.push(prop->GetOpacity()); - this->BlockState.AmbientColor.push(vtkColor3d(prop->GetAmbientColor())); - this->BlockState.DiffuseColor.push(vtkColor3d(prop->GetDiffuseColor())); - this->BlockState.SpecularColor.push(vtkColor3d(prop->GetSpecularColor())); - const char* mname = prop->GetMaterialName(); - if (mname != nullptr) - { - this->BlockState.Material.push(std::string(mname)); - } - else - { - this->BlockState.Material.push(std::string("")); - } - - // render using the composite data attributes - unsigned int flat_index = 0; - vtkCompositePolyDataMapper2* cpdm = vtkCompositePolyDataMapper2::SafeDownCast(act->GetMapper()); - vtkDataObject* dobj = nullptr; - if (cpdm) - { - dobj = cpdm->GetInputDataObject(0, 0); - if (dobj) - { - this->RenderBlock(orn, cpdm, act, dobj, flat_index); - } - } - - this->BlockState.Visibility.pop(); - this->BlockState.Opacity.pop(); - this->BlockState.AmbientColor.pop(); - this->BlockState.DiffuseColor.pop(); - this->BlockState.SpecularColor.pop(); - this->BlockState.Material.pop(); - - this->RenderGeometricModels(); - } -} - -//------------------------------------------------------------------------------ -void vtkOSPRayCompositePolyDataMapper2Node::RenderBlock(vtkOSPRayRendererNode* orn, - vtkCompositePolyDataMapper2* cpdm, vtkActor* actor, vtkDataObject* dobj, unsigned int& flat_index) -{ - vtkCompositeDataDisplayAttributes* cda = cpdm->GetCompositeDataDisplayAttributes(); - - vtkProperty* prop = actor->GetProperty(); - // bool draw_surface_with_edges = - // (prop->GetEdgeVisibility() && prop->GetRepresentation() == VTK_SURFACE); - vtkColor3d ecolor(prop->GetEdgeColor()); - - bool overrides_visibility = (cda && cda->HasBlockVisibility(dobj)); - if (overrides_visibility) - { - this->BlockState.Visibility.push(cda->GetBlockVisibility(dobj)); - } - - bool overrides_opacity = (cda && cda->HasBlockOpacity(dobj)); - if (overrides_opacity) - { - this->BlockState.Opacity.push(cda->GetBlockOpacity(dobj)); - } - - bool overrides_color = (cda && cda->HasBlockColor(dobj)); - if (overrides_color) - { - vtkColor3d color = cda->GetBlockColor(dobj); - this->BlockState.AmbientColor.push(color); - this->BlockState.DiffuseColor.push(color); - this->BlockState.SpecularColor.push(color); - } - - bool overrides_material = (cda && cda->HasBlockMaterial(dobj)); - if (overrides_material) - { - std::string material = cda->GetBlockMaterial(dobj); - this->BlockState.Material.push(material); - } - - // Advance flat-index. After this point, flat_index no longer points to this - // block. - flat_index++; - - vtkMultiBlockDataSet* mbds = vtkMultiBlockDataSet::SafeDownCast(dobj); - vtkMultiPieceDataSet* mpds = vtkMultiPieceDataSet::SafeDownCast(dobj); - if (mbds || mpds) - { - unsigned int numChildren = mbds ? mbds->GetNumberOfBlocks() : mpds->GetNumberOfPieces(); - for (unsigned int cc = 0; cc < numChildren; cc++) - { - vtkDataObject* child = mbds ? mbds->GetBlock(cc) : mpds->GetPiece(cc); - if (child == nullptr) - { - // speeds things up when dealing with nullptr blocks (which is common with - // AMRs). - flat_index++; - continue; - } - this->RenderBlock(orn, cpdm, actor, child, flat_index); - } - } - else if (dobj && this->BlockState.Visibility.top() == true && - this->BlockState.Opacity.top() > 0.0) - { - // do we have a entry for this dataset? - // make sure we have an entry for this dataset - vtkPolyData* ds = vtkPolyData::SafeDownCast(dobj); - if (ds) - { - vtkOSPRayActorNode* aNode = vtkOSPRayActorNode::SafeDownCast(this->Parent); - vtkColor3d& aColor = this->BlockState.AmbientColor.top(); - vtkColor3d& dColor = this->BlockState.DiffuseColor.top(); - std::string& material = this->BlockState.Material.top(); - cpdm->ClearColorArrays(); // prevents reuse of stale color arrays - this->ORenderPoly(orn->GetORenderer(), aNode, ds, aColor.GetData(), dColor.GetData(), - this->BlockState.Opacity.top(), material); - } - } - - if (overrides_color) - { - this->BlockState.AmbientColor.pop(); - this->BlockState.DiffuseColor.pop(); - this->BlockState.SpecularColor.pop(); - } - if (overrides_opacity) - { - this->BlockState.Opacity.pop(); - } - if (overrides_visibility) - { - this->BlockState.Visibility.pop(); - } - if (overrides_material) - { - this->BlockState.Material.pop(); - } -} -VTK_ABI_NAMESPACE_END diff --git a/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.h b/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.h deleted file mode 100644 index ea4c09d11fd..00000000000 --- a/Rendering/RayTracing/vtkOSPRayCompositePolyDataMapper2Node.h +++ /dev/null @@ -1,67 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class vtkOSPRayCompositePolyDataMapper2Node - * @brief links vtkActor and vtkMapper to OSPRay - * - * Translates vtkActor/Mapper state into OSPRay rendering calls - */ - -#ifndef vtkOSPRayCompositePolyDataMapper2Node_h -#define vtkOSPRayCompositePolyDataMapper2Node_h - -#include "vtkColor.h" // used for ivars -#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0 -#include "vtkOSPRayPolyDataMapperNode.h" -#include "vtkRenderingRayTracingModule.h" // For export macro -#include <stack> // used for ivars - -VTK_ABI_NAMESPACE_BEGIN -class vtkDataObject; -class vtkCompositePolyDataMapper2; -class vtkOSPRayRendererNode; - -class VTK_DEPRECATED_IN_9_3_0("Use vtkOSPRayCompositePolyDataMapperNode instead") - VTKRENDERINGRAYTRACING_EXPORT vtkOSPRayCompositePolyDataMapper2Node - : public vtkOSPRayPolyDataMapperNode -{ -public: - static vtkOSPRayCompositePolyDataMapper2Node* New(); - vtkTypeMacro(vtkOSPRayCompositePolyDataMapper2Node, vtkOSPRayPolyDataMapperNode); - void PrintSelf(ostream& os, vtkIndent indent) override; - - /** - * Make ospray calls to render me. - */ - void Render(bool prepass) override; - - /** - * Invalidates cached rendering data. - */ - void Invalidate(bool prepass) override; - -protected: - vtkOSPRayCompositePolyDataMapper2Node(); - ~vtkOSPRayCompositePolyDataMapper2Node() override; - - class RenderBlockState - { - public: - std::stack<bool> Visibility; - std::stack<double> Opacity; - std::stack<vtkColor3d> AmbientColor; - std::stack<vtkColor3d> DiffuseColor; - std::stack<vtkColor3d> SpecularColor; - std::stack<std::string> Material; - }; - - RenderBlockState BlockState; - void RenderBlock(vtkOSPRayRendererNode* orn, vtkCompositePolyDataMapper2* cpdm, vtkActor* actor, - vtkDataObject* dobj, unsigned int& flat_index); - -private: - vtkOSPRayCompositePolyDataMapper2Node(const vtkOSPRayCompositePolyDataMapper2Node&) = delete; - void operator=(const vtkOSPRayCompositePolyDataMapper2Node&) = delete; -}; -VTK_ABI_NAMESPACE_END -#endif diff --git a/Rendering/RayTracing/vtkOSPRayViewNodeFactory.cxx b/Rendering/RayTracing/vtkOSPRayViewNodeFactory.cxx index b8309c6a8ca..e30924c814a 100644 --- a/Rendering/RayTracing/vtkOSPRayViewNodeFactory.cxx +++ b/Rendering/RayTracing/vtkOSPRayViewNodeFactory.cxx @@ -110,8 +110,6 @@ vtkOSPRayViewNodeFactory::vtkOSPRayViewNodeFactory() this->RegisterOverride("vtkOSPRayVolumeMapper", vm_maker); this->RegisterOverride("vtkOpenGLGPUVolumeRayCastMapper", vm_maker); this->RegisterOverride("vtkMultiBlockVolumeMapper", vm_maker); - // VTK_DEPRECATED_IN_9_3_0: Remove CPDM2 override after vtkCompositePolyDataMapper2 is removed - this->RegisterOverride("vtkCompositePolyDataMapper2", cpd_maker); this->RegisterOverride("vtkCompositePolyDataMapper", cpd_maker); this->RegisterOverride("vtkOpenGLProjectedTetrahedraMapper", tetm_maker); this->RegisterOverride("vtkUnstructuredGridVolumeZSweepMapper", tetm_maker); diff --git a/Rendering/UI/CMakeLists.txt b/Rendering/UI/CMakeLists.txt index 3257557c3cd..743964db26e 100644 --- a/Rendering/UI/CMakeLists.txt +++ b/Rendering/UI/CMakeLists.txt @@ -68,18 +68,10 @@ elseif (APPLE_IOS) endif () elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") # Add some custom overrides - # VTK_DEPRECATED_IN_9_3_0() Remove when vtkSDL2RenderWindowInteractor is removed. - if (VTK_USE_SDL2) - vtk_object_factory_declare( - BASE vtkRenderWindowInteractor - OVERRIDE vtkSDL2RenderWindowInteractor) - list(APPEND classes vtkSDL2RenderWindowInteractor) - else () - vtk_object_factory_declare( - BASE vtkRenderWindowInteractor - OVERRIDE vtkWebAssemblyRenderWindowInteractor) - list(APPEND classes vtkWebAssemblyRenderWindowInteractor) - endif () + vtk_object_factory_declare( + BASE vtkRenderWindowInteractor + OVERRIDE vtkWebAssemblyRenderWindowInteractor) + list(APPEND classes vtkWebAssemblyRenderWindowInteractor) else () # use generic vtk_object_factory_declare( BASE vtkRenderWindowInteractor @@ -102,23 +94,12 @@ vtk_module_add_module(VTK::RenderingUI ) if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten") - # VTK_DEPRECATED_IN_9_3_0() Remove when vtkSDL2RenderWindowInteractor is removed. - if (VTK_USE_SDL2) - # The -sUSE_SDL=2 flag will inform emcc driver to add include paths. - vtk_module_compile_options(VTK::RenderingUI - PRIVATE - "-sUSE_SDL=2") - vtk_module_LINK_options(VTK::RenderingUI - PRIVATE - "-sUSE_SDL=2") - else () - vtk_module_link_options(VTK::RenderingUI - INTERFACE - "$<BUILD_INTERFACE:--js-library=${CMAKE_CURRENT_SOURCE_DIR}/vtkWebAssemblyRenderWindowInteractor.js>" - "$<INSTALL_INTERFACE:--js-library=$<INSTALL_PREFIX>/${_vtk_build_LIBRARY_DESTINATION}/vtkWebAssemblyRenderWindowInteractor.js>") - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/vtkWebAssemblyRenderWindowInteractor.js" - DESTINATION ${_vtk_build_LIBRARY_DESTINATION}) - endif () + vtk_module_link_options(VTK::RenderingUI + INTERFACE + "$<BUILD_INTERFACE:--js-library=${CMAKE_CURRENT_SOURCE_DIR}/vtkWebAssemblyRenderWindowInteractor.js>" + "$<INSTALL_INTERFACE:--js-library=$<INSTALL_PREFIX>/${_vtk_build_LIBRARY_DESTINATION}/vtkWebAssemblyRenderWindowInteractor.js>") + install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/vtkWebAssemblyRenderWindowInteractor.js" + DESTINATION ${_vtk_build_LIBRARY_DESTINATION}) endif () if (VTK_USE_X) diff --git a/Rendering/UI/vtkSDL2RenderWindowInteractor.cxx b/Rendering/UI/vtkSDL2RenderWindowInteractor.cxx deleted file mode 100644 index 6f2e5854b88..00000000000 --- a/Rendering/UI/vtkSDL2RenderWindowInteractor.cxx +++ /dev/null @@ -1,393 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause - -// Hide VTK_DEPRECATED_IN_9_3_0() warnings for this class. -#define VTK_DEPRECATION_LEVEL 0 - -#include <cmath> -#include <cstdio> -#include <cstdlib> -#include <cstring> - -#include "vtkHardwareWindow.h" -#include "vtkRenderWindow.h" -#include "vtkSDL2RenderWindowInteractor.h" -// Ignore reserved-identifier warnings from -// 1. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_mul_overflow_builtin' -// 2. SDL2/SDL_stdinc.h: warning: identifier '_SDL_size_add_overflow_builtin' -// 3. SDL2/SDL_audio.h: warning: identifier '_SDL_AudioStream' -// 4. SDL2/SDL_joystick.h: warning: identifier '_SDL_Joystick' -// 5. SDL2/SDL_sensor.h: warning: identifier '_SDL_Sensor' -// 6. SDL2/SDL_gamecontroller.h: warning: identifier '_SDL_GameController' -// 7. SDL2/SDL_haptic.h: warning: identifier '_SDL_Haptic' -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wreserved-identifier" -#endif -#include "SDL.h" -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#ifdef __EMSCRIPTEN__ -#include "emscripten.h" -#include "emscripten/html5.h" -#endif - -#include "vtkStringArray.h" - -#include "vtkActor.h" -#include "vtkCommand.h" -#include "vtkObjectFactory.h" - -VTK_ABI_NAMESPACE_BEGIN - -#ifdef __EMSCRIPTEN__ -namespace -{ -EM_BOOL ResizeCallback(int vtkNotUsed(eventType), const EmscriptenUiEvent* e, void* userData) -{ - auto interactor = reinterpret_cast<vtkRenderWindowInteractor*>(userData); - interactor->UpdateSize(e->windowInnerWidth, e->windowInnerHeight); - return 0; -} -} -#endif - -vtkStandardNewMacro(vtkSDL2RenderWindowInteractor); - -//------------------------------------------------------------------------------ -// Construct object so that light follows camera motion. -vtkSDL2RenderWindowInteractor::vtkSDL2RenderWindowInteractor() - : StartedMessageLoop(false) -{ -} - -//------------------------------------------------------------------------------ -vtkSDL2RenderWindowInteractor::~vtkSDL2RenderWindowInteractor() {} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::ProcessEvents() -{ - // No need to do anything if this is a 'mapped' interactor - if (!this->Enabled) - { - return; - } - - SDL_Event event; - std::vector<SDL_Event> events; - - // SDL generates continuous sequences of mouse motion events per frame, - // let use only last event of each sequence - - while (SDL_PollEvent(&event)) - { - if (event.type == SDL_MOUSEMOTION && !events.empty() && events.back().type == event.type) - { - events.back() = event; - } - else - { - events.push_back(event); - } - } - - for (SDL_Event ev : events) - { - if (this->ProcessEvent(&ev)) - { - break; - } - } -} - -bool vtkSDL2RenderWindowInteractor::ProcessEvent(void* arg) -{ - SDL_Event* event = reinterpret_cast<SDL_Event*>(arg); - SDL_Keymod modstates = SDL_GetModState(); - - int alt = modstates & (KMOD_LALT | KMOD_RALT) ? 1 : 0; - int shift = modstates & (KMOD_LSHIFT | KMOD_RSHIFT) ? 1 : 0; - int ctrl = modstates & (KMOD_LCTRL | KMOD_RCTRL) ? 1 : 0; - - switch (event->type) - { - case SDL_QUIT: - { - return true; - } - - case SDL_USEREVENT: - { - if (event->user.data1 == reinterpret_cast<void*>(vtkCommand::TimerEvent)) - { - int tid = static_cast<int>(reinterpret_cast<int64_t>(event->user.data2)); - auto iter = this->VTKToPlatformTimerMap.find(tid); - if (iter != this->VTKToPlatformTimerMap.end()) - { - this->InvokeEvent(vtkCommand::TimerEvent, (void*)&tid); - int ptid = (*iter).second; - // Here we deal with one-shot versus repeating timers - if (this->IsOneShotTimer(tid)) - { - SDL_RemoveTimer(ptid); - } - } - } - } - break; - - case SDL_KEYDOWN: - case SDL_KEYUP: - { - std::string keyname = SDL_GetKeyName(event->key.keysym.sym); - { - this->SetKeyEventInformation( - ctrl, shift, event->key.keysym.sym, event->key.repeat, keyname.c_str()); - this->SetAltKey(alt); - this->InvokeEvent( - (event->type == SDL_KEYDOWN) ? vtkCommand::KeyPressEvent : vtkCommand::KeyReleaseEvent, - nullptr); - } - } - break; - - case SDL_TEXTINPUT: - { - this->SetKeyEventInformation( - ctrl, shift, event->text.text[0], event->key.repeat, event->text.text); - this->SetAltKey(alt); - this->InvokeEvent(vtkCommand::CharEvent); - } - break; - - case SDL_MOUSEMOTION: - { - this->SetEventInformationFlipY(event->motion.x, event->motion.y, ctrl, shift); - this->SetAltKey(alt); - this->InvokeEvent(vtkCommand::MouseMoveEvent, nullptr); - } - break; - - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEBUTTONUP: - { - this->SetEventInformationFlipY(event->button.x, event->button.y, ctrl, shift); - this->SetAltKey(alt); - - int ev = -1; - - switch (event->button.button) - { - case SDL_BUTTON_LEFT: - ev = event->button.state == SDL_PRESSED ? vtkCommand::LeftButtonPressEvent - : vtkCommand::LeftButtonReleaseEvent; - break; - case SDL_BUTTON_MIDDLE: - ev = event->button.state == SDL_PRESSED ? vtkCommand::MiddleButtonPressEvent - : vtkCommand::MiddleButtonReleaseEvent; - break; - case SDL_BUTTON_RIGHT: - ev = event->button.state == SDL_PRESSED ? vtkCommand::RightButtonPressEvent - : vtkCommand::RightButtonReleaseEvent; - break; - } - if (ev >= 0) - { - this->InvokeEvent(ev, nullptr); - } - } - break; - - case SDL_MOUSEWHEEL: - { - this->SetControlKey(ctrl); - this->SetShiftKey(shift); - this->SetAltKey(alt); - // The precise y value is more robust because browsers set a value b/w 0 and 1. - // Otherwise, the value is often rounded to an integer =zero which causes a stutter - // in dolly motion. -#ifdef __EMSCRIPTEN__ - int ev = event->wheel.preciseY > 0 ? vtkCommand::MouseWheelForwardEvent - : vtkCommand::MouseWheelBackwardEvent; -#else - int ev = event->wheel.y > 0 ? vtkCommand::MouseWheelForwardEvent - : vtkCommand::MouseWheelBackwardEvent; -#endif - this->InvokeEvent(ev, nullptr); - } - break; - - case SDL_WINDOWEVENT: - { - switch (event->window.event) - { - case SDL_WINDOWEVENT_SIZE_CHANGED: - { - this->UpdateSize(event->window.data1, event->window.data2); - this->Render(); - } - break; - case SDL_WINDOWEVENT_CLOSE: - { - this->TerminateApp(); - } - break; - } - } - break; - } - return false; -} - -namespace -{ - -void mainLoopCallback(void* arg) -{ - vtkSDL2RenderWindowInteractor* iren = static_cast<vtkSDL2RenderWindowInteractor*>(arg); - iren->ProcessEvents(); -} -} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::StartEventLoop() -{ - // No need to do anything if this is a 'mapped' interactor - if (!this->Enabled) - { - return; - } - - this->StartedMessageLoop = 1; -#ifdef __EMSCRIPTEN__ - emscripten_set_resize_callback( - EMSCRIPTEN_EVENT_TARGET_WINDOW, reinterpret_cast<void*>(this), 1, ::ResizeCallback); - emscripten_set_main_loop_arg(&mainLoopCallback, (void*)this, 0, 1); -#else - while (!this->Done) - { - this->ProcessEvents(); - } -#endif -} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::AddEventHandler() -{ - // No need to do anything if this is a 'mapped' interactor - if (!this->Enabled) - { - return; - } - - this->StartedMessageLoop = 1; - this->Done = false; -#ifdef __EMSCRIPTEN__ - emscripten_set_resize_callback( - EMSCRIPTEN_EVENT_TARGET_WINDOW, reinterpret_cast<void*>(this), 1, ::ResizeCallback); - emscripten_set_main_loop_arg(&mainLoopCallback, (void*)this, 0, 0); -#endif -} - -//------------------------------------------------------------------------------ -// Begin processing keyboard strokes. -void vtkSDL2RenderWindowInteractor::Initialize() -{ - vtkRenderWindow* ren; - int* size; - - // make sure we have a RenderWindow and camera - if (!this->RenderWindow) - { - vtkErrorMacro(<< "No renderer defined!"); - return; - } - if (this->Initialized) - { - return; - } - this->Initialized = 1; - // get the info we need from the RenderingWindow - ren = this->RenderWindow; - ren->Start(); - ren->End(); - size = ren->GetSize(); - ren->GetPosition(); - - this->Enable(); - this->Size[0] = size[0]; - this->Size[1] = size[1]; -} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::TerminateApp(void) -{ - this->Done = true; - -#ifdef __EMSCRIPTEN__ - // Only post a quit message if Start was called... - if (this->StartedMessageLoop) - { - emscripten_cancel_main_loop(); - } -#endif -} - -namespace -{ -Uint32 timerCallback(Uint32 interval, void* param) -{ - SDL_Event event; - SDL_UserEvent userevent; - - userevent.type = SDL_USEREVENT; - userevent.code = 0; - userevent.data1 = reinterpret_cast<void*>(vtkCommand::TimerEvent); - userevent.data2 = param; - - event.type = SDL_USEREVENT; - event.user = userevent; - - SDL_PushEvent(&event); - return (interval); -} -} - -//------------------------------------------------------------------------------ -int vtkSDL2RenderWindowInteractor::InternalCreateTimer( - int timerId, int vtkNotUsed(timerType), unsigned long duration) -{ - auto result = SDL_AddTimer(duration, timerCallback, reinterpret_cast<void*>(timerId)); - this->VTKToPlatformTimerMap[timerId] = result; - return result; -} - -//------------------------------------------------------------------------------ -int vtkSDL2RenderWindowInteractor::InternalDestroyTimer(int platformTimerId) -{ - int tid = this->GetVTKTimerId(platformTimerId); - auto i = this->VTKToPlatformTimerMap.find(tid); - this->VTKToPlatformTimerMap.erase(i); - return SDL_RemoveTimer(platformTimerId); -} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::PrintSelf(ostream& os, vtkIndent indent) -{ - this->Superclass::PrintSelf(os, indent); - os << indent << "StartedMessageLoop: " << this->StartedMessageLoop << endl; -} - -//------------------------------------------------------------------------------ -void vtkSDL2RenderWindowInteractor::ExitCallback() -{ - if (this->HasObserver(vtkCommand::ExitEvent)) - { - this->InvokeEvent(vtkCommand::ExitEvent, nullptr); - } - - this->TerminateApp(); -} -VTK_ABI_NAMESPACE_END diff --git a/Rendering/UI/vtkSDL2RenderWindowInteractor.h b/Rendering/UI/vtkSDL2RenderWindowInteractor.h deleted file mode 100644 index 71cc4049d9a..00000000000 --- a/Rendering/UI/vtkSDL2RenderWindowInteractor.h +++ /dev/null @@ -1,95 +0,0 @@ -// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen -// SPDX-License-Identifier: BSD-3-Clause -/** - * @class vtkSDL2RenderWindowInteractor - * @brief implements SDL2 specific functions - * required by vtkRenderWindowInteractor. - * - */ - -#ifndef vtkSDL2RenderWindowInteractor_h -#define vtkSDL2RenderWindowInteractor_h - -#include "vtkRenderWindowInteractor.h" - -#include "vtkDeprecation.h" // for VTK_DEPRECATED_IN_9_3_0 -#include "vtkRenderingUIModule.h" // For export macro -#include <map> // for ivar - -VTK_ABI_NAMESPACE_BEGIN -class VTK_DEPRECATED_IN_9_3_0( - "Please use one of the dedicated platform render window interactors or " - "vtkWebAssemblyRenderWindowInteractor if your application targets WebAssembly.") - VTKRENDERINGUI_EXPORT vtkSDL2RenderWindowInteractor : public vtkRenderWindowInteractor -{ -public: - /** - * Construct object so that light follows camera motion. - */ - static vtkSDL2RenderWindowInteractor* New(); - - vtkTypeMacro(vtkSDL2RenderWindowInteractor, vtkRenderWindowInteractor); - void PrintSelf(ostream& os, vtkIndent indent) override; - - /** - * Initialize the event handler - */ - void Initialize() override; - - /** - * Process all user-interaction, timer events and return. - * If there are no events, this method returns immediately. - */ - void ProcessEvents() override; - - /** - * SDL2 specific application terminate, calls ClassExitMethod then - * calls PostQuitMessage(0) to terminate the application. An application can Specify - * ExitMethod for alternative behavior (i.e. suppression of keyboard exit) - */ - void TerminateApp() override; - - /** - * These methods correspond to the Exit, User and Pick - * callbacks. They allow for the Style to invoke them. - */ - void ExitCallback() override; - - // When using emscripten this adds the event handler - // and then returns without blocking or aborting. - // TerminateApp will remove the event hanbdler. - void AddEventHandler(); - -protected: - vtkSDL2RenderWindowInteractor(); - ~vtkSDL2RenderWindowInteractor() override; - - bool ProcessEvent(void* event); - - ///@{ - /** - * SDL2-specific internal timer methods. See the superclass for detailed - * documentation. - */ - int InternalCreateTimer(int timerId, int timerType, unsigned long duration) override; - int InternalDestroyTimer(int platformTimerId) override; - ///@} - - std::map<int, int> VTKToPlatformTimerMap; - - /** - * This will start up the event loop and never return. If you - * call this method it will loop processing events until the - * application is exited. - */ - void StartEventLoop() override; - - bool StartedMessageLoop; - -private: - vtkSDL2RenderWindowInteractor(const vtkSDL2RenderWindowInteractor&) = delete; - void operator=(const vtkSDL2RenderWindowInteractor&) = delete; -}; - -VTK_ABI_NAMESPACE_END -#endif -- GitLab