-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.h
77 lines (65 loc) · 2.01 KB
/
utils.h
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
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
#include <iostream>
#include <vtkSmartPointer.h>
#include <vtkObjectFactory.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkImageViewer2.h>
#include <vtkDICOMImageReader.h>
#include <vtkInteractorStyleImage.h>
#include <vtkActor.h>
#include <vtkSliderWidget.h>
#include <vtkSliderRepresentation2D.h>
#include <vtkImageData.h>
#include <vtkImageSliceMapper.h>
#include <vtkImageSlice.h>
#include <vtkCamera.h>
#include <vtkImageProperty.h>
#include <vtkImageStack.h>
#include <vtkTextProperty.h>
#include <vtkTextMapper.h>
#include <vtkTextActor.h>
#include <vtkPolyDataMapper.h>
#include <vtkOutlineFilter.h>
#include <vtkMarchingCubes.h>
#include <vtkStripper.h>
#include <vtkNamedColors.h>
#include <vtkProperty.h>
// Helper class for formating slice status message
class SlicingStatusMessage
{
public:
static std::string Format(int slice,
int maxSlice,
std::string name)
{
std::stringstream tmp;
tmp << name << " Slice " << slice + 1 << "/" << maxSlice + 1;
return tmp.str();
}
};
// Helper for Slider's User Method & Event Handling
class vtkSliderCallback : public vtkCommand
{
public:
static vtkSliderCallback *New()
{
return new vtkSliderCallback;
}
virtual void Execute(vtkObject *caller, unsigned long, void *)
{
vtkSliderWidget *sliderWidget =
reinterpret_cast<vtkSliderWidget *>(caller);
this->z = static_cast<vtkSliderRepresentation *>(sliderWidget->GetRepresentation())->GetValue();
cout << "[" << name << "] -> Slice : " << z << std::endl;
slicer->SetSliceNumber(z);
std::string msg = SlicingStatusMessage::Format(z, sliderWidget->GetSliderRepresentation()->GetMaximumValue(), name);
statMapper->SetInput(msg.c_str());
}
vtkSliderCallback() : slicer(0), statMapper(0) {}
vtkImageSliceMapper *slicer;
std::string name;
vtkTextMapper *statMapper;
int z;
};