forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkImageStencilSource.cxx
113 lines (91 loc) · 3.9 KB
/
vtkImageStencilSource.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*=========================================================================
Program: Visualization Toolkit
Module: vtkImageStencilSource.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkImageStencilSource.h"
#include "vtkGarbageCollector.h"
#include "vtkImageData.h"
#include "vtkImageStencilData.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkStreamingDemandDrivenPipeline.h"
vtkStandardNewMacro(vtkImageStencilSource);
vtkCxxSetObjectMacro(vtkImageStencilSource, InformationInput, vtkImageData);
//------------------------------------------------------------------------------
vtkImageStencilSource::vtkImageStencilSource()
{
this->InformationInput = nullptr;
this->OutputOrigin[0] = 0;
this->OutputOrigin[1] = 0;
this->OutputOrigin[2] = 0;
this->OutputSpacing[0] = 1;
this->OutputSpacing[1] = 1;
this->OutputSpacing[2] = 1;
this->OutputWholeExtent[0] = 0;
this->OutputWholeExtent[1] = -1;
this->OutputWholeExtent[2] = 0;
this->OutputWholeExtent[3] = -1;
this->OutputWholeExtent[4] = 0;
this->OutputWholeExtent[5] = -1;
}
//------------------------------------------------------------------------------
vtkImageStencilSource::~vtkImageStencilSource()
{
this->SetInformationInput(nullptr);
}
//------------------------------------------------------------------------------
void vtkImageStencilSource::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "InformationInput: " << this->InformationInput << "\n";
os << indent << "OutputSpacing: " << this->OutputSpacing[0] << " " << this->OutputSpacing[1]
<< " " << this->OutputSpacing[2] << "\n";
os << indent << "OutputOrigin: " << this->OutputOrigin[0] << " " << this->OutputOrigin[1] << " "
<< this->OutputOrigin[2] << "\n";
os << indent << "OutputWholeExtent: " << this->OutputWholeExtent[0] << " "
<< this->OutputWholeExtent[1] << " " << this->OutputWholeExtent[2] << " "
<< this->OutputWholeExtent[3] << " " << this->OutputWholeExtent[4] << " "
<< this->OutputWholeExtent[5] << "\n";
}
//------------------------------------------------------------------------------
void vtkImageStencilSource::ReportReferences(vtkGarbageCollector* collector)
{
this->Superclass::ReportReferences(collector);
vtkGarbageCollectorReport(collector, this->InformationInput, "InformationInput");
}
//------------------------------------------------------------------------------
int vtkImageStencilSource::RequestInformation(
vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)
{
int wholeExtent[6];
double spacing[3];
double origin[3];
vtkInformation* outInfo = outputVector->GetInformationObject(0);
for (int i = 0; i < 3; i++)
{
wholeExtent[2 * i] = this->OutputWholeExtent[2 * i];
wholeExtent[2 * i + 1] = this->OutputWholeExtent[2 * i + 1];
spacing[i] = this->OutputSpacing[i];
origin[i] = this->OutputOrigin[i];
}
// If InformationInput is set, then get the spacing,
// origin, and whole extent from it.
if (this->InformationInput)
{
this->InformationInput->GetExtent(wholeExtent);
this->InformationInput->GetSpacing(spacing);
this->InformationInput->GetOrigin(origin);
}
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent, 6);
outInfo->Set(vtkDataObject::SPACING(), spacing, 3);
outInfo->Set(vtkDataObject::ORIGIN(), origin, 3);
outInfo->Set(vtkStreamingDemandDrivenPipeline::UNRESTRICTED_UPDATE_EXTENT(), 1);
return 1;
}