MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
39
40/* The same as template function */
41template <class T> T* checkObject(vtkObject* vtkObjPtr)
42{
43 if (auto result1 = T::SafeDownCast(vtkObjPtr)) {
44 return result1;
45 }
46 else if (auto algo = vtkAlgorithm::SafeDownCast(vtkObjPtr)) {
47
48 // Get number of output ports. Are there one or more outputs?
49 int numAlgoOutputs = algo->GetNumberOfOutputPorts();
50
51 // Check all outputs and take the first fitting one.
52 for (int i = 0; i < numAlgoOutputs; ++i) {
53 if (auto safeOutput = T::SafeDownCast(algo->GetOutputDataObject(i))) {
54 return safeOutput;
55 }
56 }
57 }
58 return nullptr; // nothing fits
59}
60
61
64
@ 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.