Compilation errors building vtk_examples

I have downloaded VTK 9.2.0.rc1 and built it using Visual Studio 2022 without errors. I also downloaded vtk_examples (as of July 8) from github.

In trying to build vtk_examples using VS 2022, the projects in the GeometricObjects and Rendering Cxx directories fail to build because they cannot find any of the vtk include files… This seems to be an error of some sort in the CMakeLists files used to generate these projects, because all other projects seem to be able to find the header files without problems. I have compared CMakeLists files for the failed and for successful builds and can’t see what could be wrong.

Also, there was a recent commit comment about replacing SetColor with SetColorF. This has broken the build of projects where this is used.

Some advice on how to fix the CMake errors in GeometricObjects and Rendering would be appreciated.

Thanks, David

The removed function had been deprecated since 9.1. Consumers should have been getting warnings about its deprecation; was this not happening (without explicit suppression of the warnings)?

As for the examples, they are tested regularly. @lassoan?

Example error output: re: SetColorF

86>ChartsOn3DScene.cxx
86>G:\VTK\vtk-examples\src\Cxx\Plotting\ChartsOn3DScene.cxx(103,11): error C2039: ‘SetColorF’: is not a member of ‘vtkPlot’
86>G:\VTK\Charts\Core\vtkPlot.h(47): message : see declaration of ‘vtkPlot’
86>G:\VTK\vtk-examples\src\Cxx\Plotting\ChartsOn3DScene.cxx(108,11): error C2039: ‘SetColorF’: is not a member of ‘vtkPlot’
86>G:\VTK\Charts\Core\vtkPlot.h(47): message : see declaration of ‘vtkPlot’
86>G:\VTK\vtk-examples\src\Cxx\Plotting\ChartsOn3DScene.cxx(113,11): error C2039: ‘SetColorF’: is not a member of ‘vtkPlot’
86>G:\VTK\Charts\Core\vtkPlot.h(47): message : see declaration of ‘vtkPlot’
86>Done building project “ChartsOn3DScene.vcxproj” – FAILED.

vtkPlot.h (from the 9.2.0.rc1 Charts/Core directory contains this:

///@{
/**

  • Set the plot color
    */
    virtual void SetColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
    virtual void SetColor(double r, double g, double b);
    virtual void GetColor(double rgb[3]);
    void GetColor(unsigned char rgb[3]);
    ///@}

So this seems to have escaped the regular testing, or there is some regression from 9.1 to 9.2.

@DStranz you can replace SetColorF by SetColor to fix this build error. It is a version incompatibility introduced in VTKExamples a few days ago (VTKExamples is currently only compatible with the VTK master that is not older than two weeks).

@amaclean I guess VTKExamples would need to keep using the old API for a while (optionally, use the new SetColorF API if VTK is found to be recent enough).

Thanks, Andras, that was my intention to work around this bug. What about the build problems with Rendering and GeometricObjects? I can figure out how to build them standalone as Visual Studio projects, but it would be nice to fix whatever is wrong with the CMake scripts.

I could not find a way to D/L the 9.1 version - all of the links from the web site lead to the github page for 9.2.0.rc1. Older version links are for 8.x or older.

@DStranz You should be able to build OK now. I can verify that building GeometricObjects and Rendering are now OK in both WIndows and Linux. Also I have introduced a check for the VTK version in Plotting so that SetColorF() or SetColor() can be used.

Only three files were flagging the use of the deprecated SetColor(), however I also provided a check for the deprecated version on the other files.

@ben I had only noticed this a week or so ago when building against the master. From memory, only three examples were flagging the deprecation warning: BarChart.cxx, ChartsOn3DScene.cxx and FunctionalBagPlot.cxx. The other plotting examples were already using SetColorF.

@amclean Thanks. I will D/L again in the morning. Thank you for the quick response.

Unfortunately, Rendering and GeometricObjects are still broken in the version I D/L this morning. I did a clean install after wiping out all previous vtk-examples source and build trees, reconfiguring and regenerating the VS 2022 projects.

Can’t copy the error output except as a screen shot.

See: Changes to the VTK Examples 1

I suspect that you need to enable testing or these third party libraries in your VTK build:

  • vtk::cli11
  • vtk::json
  • vtk::fmt

I’ll add a check for the existence of these third party modules this at some stage.

OK, enabling those items seemed to fix the problem. I have not rebuilt all of the examples, but building AmbientSpheres (from Rendering) and Arrow (from GeometricObjects) was successful so I presume the others will build also. Thanks for the help.

I just did a commit which should fix the problem. If a VTK third party module is not built then the example(s) needing it will not be built.

The SetColorF problem still persists when building the examples against VTK 9.2.0.rc1. The #define VTK_HAS_SETCOLORF tests TRUE for this version:

#if VTK_VERSION_NUMBER >= 90020220630ULL
#define VTK_HAS_SETCOLORF 1
#endif

but the vtkPlot.h header file for 9.2.0.rc1 does not contain the SetColorF() method, only SetColor().

OK, I’m confused. I have downloaded the VTK source distribution from here: https://vtk.org/download/ which claims to be giving me VTK 9.2.0.rc1. In this source code, vtkPlot.h does not contain the SetColorF method.If I look at the same file in git on gitlab.kitware.com, that does contain the SetColorF methods, with the deprecation warning (for version 9.3.0).

So it seems that the #if statement should be testing against a higher version of VTK than 90020220630.

Should be Ok now, I forgot to add in the minor version number