forked from Slicer/SlicerGitSVNArchive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vtkMRMLSceneDefaultNodeTest.cxx
51 lines (40 loc) · 1.98 KB
/
vtkMRMLSceneDefaultNodeTest.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*=auto=========================================================================
Portions (c) Copyright 2016 Brigham and Women's Hospital (BWH)
All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Program: 3D Slicer
=========================================================================auto=*/
#include "vtkMRMLModelNode.h"
#include "vtkMRMLModelStorageNode.h"
#include "vtkMRMLScene.h"
#include "vtkMRMLCoreTestingMacros.h"
//------------------------------------------------------------------------------
int vtkMRMLSceneDefaultNodeTest(int , char * [] )
{
vtkNew<vtkMRMLScene> scene1;
// Test default node setting in scene
vtkNew<vtkMRMLModelStorageNode> defaultStorageNode;
defaultStorageNode->SetDefaultWriteFileExtension("stl");
scene1->AddDefaultNode(defaultStorageNode.GetPointer());
CHECK_POINTER(scene1->GetDefaultNodeByClass("vtkMRMLModelStorageNode"), defaultStorageNode.GetPointer());
// Test if storage node created by AddDefaultStorage node
// is overridden by default storage node set in the scene
vtkNew<vtkMRMLModelNode> modelNode;
scene1->AddNode(modelNode.GetPointer());
CHECK_BOOL(modelNode->AddDefaultStorageNode(), true);
vtkMRMLStorageNode* storageNode = modelNode->GetStorageNode();
CHECK_NOT_NULL(storageNode);
CHECK_STRING(storageNode->GetDefaultWriteFileExtension(), "stl");
// Test if default node can be modified
vtkMRMLModelStorageNode* defaultStorageNode2 = vtkMRMLModelStorageNode::SafeDownCast(scene1->GetDefaultNodeByClass("vtkMRMLModelStorageNode"));
CHECK_NOT_NULL(defaultStorageNode2);
defaultStorageNode2->SetDefaultWriteFileExtension("vtp");
vtkNew<vtkMRMLModelNode> modelNode2;
scene1->AddNode(modelNode2.GetPointer());
CHECK_BOOL(modelNode2->AddDefaultStorageNode(), true);
vtkMRMLStorageNode* storageNode2 = modelNode2->GetStorageNode();
CHECK_NOT_NULL(storageNode2);
CHECK_STRING(storageNode2->GetDefaultWriteFileExtension(), "vtp");
return EXIT_SUCCESS;
}