MeVisLab Toolbox Reference
mlVTKCommonWrappers.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#pragma once
14
15// Include dll-specific settings.
17#include "mlVTKMLBaseWrapper.h"
18
19#include <vtkObject.h>
20#include <vtkDataObject.h>
21#include <vtkActor.h>
22#include <vtkMapper.h>
23#include <vtkRenderer.h>
24#include <vtkAlgorithm.h>
25
28
30
40
41/* The same as template function */
42template<class T>
44{
45 if (auto result1 = T::SafeDownCast(vtkObjPtr)) {
46 return result1;
47 }
48 else if (auto algo = vtkAlgorithm::SafeDownCast(vtkObjPtr)) {
49
50 // Get number of output ports. Are there one or more outputs?
51 int numAlgoOutputs = algo->GetNumberOfOutputPorts();
52
53 // Check all outputs and take the first fitting one.
54 for (int i = 0; i < numAlgoOutputs; ++i) {
55 if (auto safeOutput = T::SafeDownCast(algo->GetOutputDataObject(i))) {
56 return safeOutput;
57 }
58 }
59 }
60 return nullptr; // nothing fits
61}
62
63
64
67
@ T
#define MLVTK_SUPPORT_EXPORT
When included by other libraries MLVTK_SUPPORT_EXPORT is compiled as import symbol.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
vtkObject vtkObjectType
Helper typedef.
T * checkObject(vtkObject *vtkObjPtr)
MLVTK_SUPPORT_EXPORT vtkObject * checkPointer(const std::string &reqConnectType, vtkObject *vtkObjPtr)
MLVTK_SUPPORT_EXPORT int VTKCommonTypesAndWrappersInit()
Initializes the wrapper classes.