This was undertaken to make the Online Examples of the VTK Documentation more accurate. As a side note: a maximum of 10 online examples are shown, and, if there are more than 10 examples, then a randomised set is produced which will change the next time the documentation is built. You can also run SelectExamples to get a customised list of a VTK class and links to relevant examples for a selected language.
In many of the C++ examples, there are includes for VTK classes that are unused (mostly copy/paste issues) and others that are needed but not directly implemented. The latter are required because they refer to pointers of incomplete class types.
An example of a referral to an incomplete pointer class, you often see
#include <vtkProperty.h> and statements like
actor->GetProperty()->... but no statement like
vtkNew<vtkProperty> = ... in the implementation. See vtkProperty - most of the Online Examples shown here exhibit this behaviour.
A script was written to scan the VTK C++ examples for includes with no subsequent implementation of the class. As a result, 784 examples were detected with possible unneeded includes (a total of 1918 includes). I reviewed each example one by one (build and run) and ended up with 516 examples with a total of 819 VTK classes that are needed but not implemented. A few of the examples were rewritten for various reasons. The outcome of this is that only necessary includes are now present in these C++ examples. Some examples that were unable to use OpenGL2 were moved to the Deprecated folder.
The main changes in this script are:
- The regular expressions were simplified and moved into a dataclass
- When parsing, comments within the example code are now ignored
- While Python has only inline comments (# …) I also added code to ignore docstrings (a bit tricky)
- C++ interface and implementation files are separately processed and then merged into the implementation file (.cxx) and removing the interface file (.h) of the same name
- Better documentation in the code
- More status information printed
These changes have improved the accuracy of linking VTK classes, languages and examples together.