Slicer 5.13
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
vtkMRMLLayerDMPipelineCreateHelper.h
Go to the documentation of this file.
1/*==============================================================================
2
3 Program: 3D Slicer
4
5 Copyright (c) Kitware SAS
6
7 See COPYRIGHT.txt
8 or http://www.slicer.org/copyright/copyright.txt for details.
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 This file was originally developed by Thibault Pelletier, Kitware SAS,
17 and was partially funded by ANR grants ANR-22-CE45-0034 and ANR-18-RHUS-005.
18
19==============================================================================*/
20
21#ifndef __vtkMRMLLayerDMPipelineCreateHelper_h
22#define __vtkMRMLLayerDMPipelineCreateHelper_h
23
24// Layer DM includes
26
27// VTK includes
28#include <vtkSmartPointer.h>
29
30namespace layer_dm
31{
35template <typename TExpView, typename TExpNode, typename TPipeline, typename... Rest>
36vtkSmartPointer<vtkMRMLLayerDMPipeline> TryCreateForView(vtkMRMLAbstractViewNode* viewNode, vtkMRMLNode* node)
37{
38 if (TExpView::SafeDownCast(viewNode) && TExpNode::SafeDownCast(node))
39 {
40 auto pipeline = vtkSmartPointer<TPipeline>::New();
41 pipeline->SetViewNode(viewNode);
42 pipeline->SetDisplayNode(node);
43 return pipeline;
44 }
45 if constexpr (sizeof...(Rest) > 0)
46 {
47 return TryCreateForView<TExpView, Rest...>(viewNode, node);
48 }
49 return nullptr;
50}
51
55template <typename TExpView, typename TExpNode, typename TPipeline, typename... Rest>
56vtkSmartPointer<vtkMRMLLayerDMPipeline> TryCreate(vtkMRMLAbstractViewNode* viewNode, vtkMRMLNode* node)
57{
58 if (auto pipeline = TryCreateForView<TExpView, TExpNode, TPipeline>(viewNode, node))
59 {
60 return pipeline;
61 }
62 if constexpr (sizeof...(Rest) > 0)
63 {
64 return TryCreate<Rest...>(viewNode, node);
65 }
66 return nullptr;
67}
68}; // namespace layer_dm
69
70#endif
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D,...
Abstract Superclass for all specific types of MRML nodes.
vtkSmartPointer< vtkMRMLLayerDMPipeline > TryCreateForView(vtkMRMLAbstractViewNode *viewNode, vtkMRMLNode *node)
vtkSmartPointer< vtkMRMLLayerDMPipeline > TryCreate(vtkMRMLAbstractViewNode *viewNode, vtkMRMLNode *node)