Issue compiling custom reader plugin with accompanying VTK reader

Hey guys,

I’m currently trying to create a reader for the JSON based CityJSON format (mix of CityGML and GeoJSON (www.cityjson.org)).

As far as I understand I will need to create a new VTK reader to accompany the ParaView plugin, so I’m using the ElevationFilter as an example. Running into a few issues however, so was hoping someone could help:

When I try to compile I run into the following error:

In file included from /mnt/hdd/Repositories/Paraview-CityJSONReader/Plugin/CityJSONReaders/vtkMyCityJSONReader.cxx:1:
/mnt/hdd/Repositories/Paraview-CityJSONReader/Plugin/CityJSONReaders/vtkMyCityJSONReader.h:6:49: error: expected initializer before ‘:’ token
    6 | class CITYJSONREADER_EXPORT vtkMyCityJSONReader : public vtkPolyData
      |                                               

The code I have so far is:
vtkMyCityJSONReader.cxx

#include "vtkMyCityJSONReader.h"

#include "vtkObjectFactory.h"

vtkStandardNewMacro(vtkMyCityJSONReader);

//----------------------------------------------------------------------------
vtkMyCityJSONReader::vtkMyCityJSONReader()
{
}

//----------------------------------------------------------------------------
vtkMyCityJSONReader::~vtkMyCityJSONReader()
{
}

//----------------------------------------------------------------------------
void vtkMyCityJSONReader::PrintSelf(ostream& os, vtkIndent indent)
{
    this->Superclass::PrintSelf(os, indent);
}

vtkMyCityJSONReader.h

#ifndef vtkMyCityJSONReader_h
#define vtkMyCityJSONReader_h

#include "vtkPolyData.h"

class CITYJSONREADER_EXPORT vtkMyCityJSONReader : public vtkPolyData
{
public:
    static vtkMyCityJSONReader* New();
    vtkTypeMacro(vtkMyCityJSONReader, vtkPolyData);
    void PrintSelf(ostream& os, vtkIndent indent) override;

protected:
    vtkMyCityJSONReader();
    ~vtkMyCityJSONReader();

private:
    vtkMyCityJSONReader(const vtkMyCityJSONReader&) = delete;
    void operator=(const vtkMyCityJSONReader&) = delete;
};

#endif

CMakeLists.txt

cmake_minimum_required(VERSION 3.8)
project(CityJSONReader)

find_package(ParaView REQUIRED)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
enable_testing()

# Required for python testing
set(_vtk_build_TEST_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Testing/Temporary)

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("_paraview_plugin_default_${CMAKE_PROJECT_NAME}" ON)
paraview_plugin_scan(
        PLUGIN_FILES      "${CMAKE_CURRENT_SOURCE_DIR}/Plugin/paraview.plugin"
        PROVIDES_PLUGINS  plugins
        REQUIRES_MODULES  required_modules)

foreach (module IN LISTS required_modules)
    if (NOT TARGET "${module}")
        message(#FATAL_ERROR
                "Skipping example ${CMAKE_PROJECT_NAME}: Missing required module: "
                "${module}")
        return ()
    endif ()
endforeach ()

paraview_plugin_build(
        RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
        LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
        LIBRARY_SUBDIRECTORY "${PARAVIEW_PLUGIN_SUBDIR}"
        PLUGINS ${plugins})

I would take a look at the CityGML reader
https://blog.kitware.com/citygml-reader/
and integrate it in ParaView the same way first. When you get that working, you can make the code a ParaView plugin as a separate step.

#include "YourModuleName.h" // for export macro

is missing.

Thanks Mathieu, I was just wondering what ‘YourModuleName’ is going to end up being, because in the examples I see “vtkIOGeoJSONModule” for the module “vtkGeoJSONReader”, but am unable to actually find the header file that is being referenced. How is this include chosen?

it is coming from the vtk.module file alongside your vtkMyCityJSONReader.cxx.

Great, thanks Mathieu, I have a module that’s compiling now, so that’s awesome

Must be a few hurdles still on the way, but at least this brings me some steps closer!

1 Like