forked from Slicer/SlicerGitSVNArchive
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vtkMRMLModelHierarchyNodeTest1.cxx
65 lines (51 loc) · 2.22 KB
/
vtkMRMLModelHierarchyNodeTest1.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*=auto=========================================================================
Portions (c) Copyright 2005 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=*/
// MRML includes
#include "vtkMRMLModelDisplayNode.h"
#include "vtkMRMLModelHierarchyNode.h"
#include "vtkMRMLModelNode.h"
#include "vtkMRMLScene.h"
#include "vtkMRMLCoreTestingMacros.h"
// VTK includes
#include <vtkCollection.h>
int vtkMRMLModelHierarchyNodeTest1(int , char * [] )
{
vtkSmartPointer< vtkMRMLModelHierarchyNode > node1 = vtkSmartPointer< vtkMRMLModelHierarchyNode >::New();
EXERCISE_BASIC_OBJECT_METHODS( node1 );
EXERCISE_BASIC_MRML_METHODS(vtkMRMLModelHierarchyNode, node1);
TEST_SET_GET_STRING(node1, ModelNodeID);
//TEST_SET_GET_STRING(node1, DisplayNodeID);
vtkSmartPointer<vtkMRMLScene> scene = vtkSmartPointer<vtkMRMLScene>::New();
vtkSmartPointer<vtkMRMLModelDisplayNode> dnode = vtkSmartPointer<vtkMRMLModelDisplayNode>::New();
scene->AddNode(node1);
scene->AddNode(dnode);
node1->SetAndObserveDisplayNodeID(dnode->GetID());
TEST_SET_GET_BOOLEAN(node1, Expanded);
vtkSmartPointer<vtkMRMLModelNode> mnode = vtkSmartPointer<vtkMRMLModelNode>::New();
scene->AddNode(mnode);
node1->SetModelNodeID(mnode->GetID());
vtkSmartPointer<vtkMRMLModelNode> mnode2 = vtkSmartPointer<vtkMRMLModelNode>::New();
mnode2 = node1->GetModelNode();
if (mnode2 != mnode)
{
std::cerr << "ERROR setting/getting model node" << std::endl;
return EXIT_FAILURE;
}
vtkSmartPointer<vtkMRMLModelHierarchyNode> hnode1 = node1->GetCollapsedParentNode();
std::cout << "Unexpanded parent node = " << (hnode1 == NULL ? "NULL" : hnode1->GetID()) << std::endl;
vtkSmartPointer<vtkCollection> col = vtkSmartPointer<vtkCollection>::New();
node1->GetChildrenModelNodes(col);
int numChildren = col->GetNumberOfItems();
std::cout << "Number of children model nodes = " << numChildren << std::endl;
if (numChildren != 1)
{
std::cerr << "Expected 1 child, got " << numChildren << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}