Hi Experts,
I have 2 datasets. One with 3 components (RGB) and the other as 1 component (A). I want to combine these two to form a single dataset of 4 components (RGBA). I implemented this using a programmable filter in ParaView GUI using numpy and stacking them. But I want to do it in a custom application. I cannot find an efficient solution to implement in custom application. How should I approach this?
Thanks Alot
Write it in a C++ VTK filter and add it as a plugin in your custom application.
Hi, thanks for the suggestion.
I have created a custom plugin for the vtkImageAppendComponents filter.
I have structured the project as followed:
src/
├── CMakeLists.txt
├── mainWindow.cxx
├── mainWindow.h
├── mainWindow.ui
└── ImageAppendComponents/
├── CMakeLists.txt
└── Plugin/
├── CMakeLists.txt
├── ImageAppendComponents.xml
└── paraview.plugin
paraview.plugin:
NAME
ImageAppendComponents
DESCRIPTION
expose vtkImageAppendComponents
REQUIRES_MODULES
VTK::ImagingCore
This is how the XML file looks like:
<ServerManagerConfiguration>
<ProxyGroup name="filters">
<SourceProxy name="ImageAppendComponents" class="vtkImageAppendComponents" label="ImageAppendComponents">
<Documentation
long_help = ""
short_help = ""
</Documentation>
<InputProperty
name="Source"
port_index="0"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataObject"/>
</DataTypeDomain>
<Documentation>
Set the source data set.
</Documentation>
</InputProperty>
<InputProperty
name="Target"
port_index="1"
command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkDataObject"/>
</DataTypeDomain>
<Documentation>
Set the target data set.
</Documentation>
</InputProperty>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
Plugin/CMakeLists.txt:
paraview_add_plugin(ImageAppendComponents
REQUIRED_ON_CLIENT
REQUIRED_ON_SERVER
VERSION "1.0"
SERVER_MANAGER_XML ImageAppendComponents.xml)
ImageAppendComponents/CMakeLists.txt:
cmake_minimum_required(VERSION 3.8)
project(ImageAppendComponents)
include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(BUILD_SHARED_LIBS ON)
find_package(ParaView REQUIRED)
set("_paraview_plugin_default_${PROJECT_NAME}" ON)
paraview_plugin_scan(
PLUGIN_FILES "Plugin/paraview.plugin"
PROVIDES_PLUGINS plugins
ENABLE_BY_DEFAULT ON)
paraview_plugin_build(
PLUGINS ${plugins})
Top Level CMake:
cmake_minimum_required(VERSION 3.8)
project(CustomPV)
set(ParaView_DIR /home/usr/Downloads/Paraview/paraview_build)
find_package(ParaView REQUIRED)
include(GNUInstallDirs)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}")
find_package("Qt${PARAVIEW_QT_MAJOR_VERSION}" REQUIRED COMPONENTS Widgets)
find_package(VTK)
find_package(ParaView REQUIRED COMPONENTS VTKExtensionsFiltersGeneral RemotingViews)
set(CMAKE_AUTOMOC 1)
set(CMAKE_AUTOUIC 1)
set(SOURCES
mainWindow.h
mainWindow.cxx
mainWindow.ui
)
add_executable(CustomPV main.cxx ${SOURCES})
target_link_libraries(CustomPV
PRIVATE
ParaView::pqApplicationComponents
${VTK_LIBRARIES} ${ParaView_Libraries}
ParaView::RemotingSettings
ParaView::RemotingViews
ParaView::VTKExtensionsFiltersGeneral
"Qt${PARAVIEW_QT_MAJOR_VERSION}::Widgets")
# Set include directories
target_include_directories(CustomPV PRIVATE ${ParaView_INCLUDE_DIRS})
add_subdirectory(ImageAppendComponents)
When I build the project, I am getting the following error:
The ImageAppendComponents's CMakeLists.txt may not add the
ImageAppendComponents plugin.
Call Stack (most recent call first):
ImageAppendComponents/Plugin/CMakeLists.txt:1 (paraview_add_plugin)
your VTK module and your plugin cannot share the same name.