MCPcopy Create free account
hub / github.com/Kitware/VTK / Initialize

Method Initialize

Imaging/Core/vtkImagePointDataIterator.cxx:66–256  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

64
65//------------------------------------------------------------------------------
66void vtkImagePointDataIterator::Initialize(vtkImageData* image, const int extent[6],
67 vtkImageStencilData* stencil, vtkAlgorithm* algorithm, int threadId)
68{
69 const int* dataExtent = image->GetExtent();
70 if (extent == nullptr)
71 {
72 extent = dataExtent;
73 }
74
75 // Save the extent (will be adjusted if there is a stencil).
76 bool emptyExtent = false;
77 for (int i = 0; i < 6; i += 2)
78 {
79 this->Extent[i] = std::max(extent[i], dataExtent[i]);
80 this->Extent[i + 1] = std::min(extent[i + 1], dataExtent[i + 1]);
81 if (this->Extent[i] > this->Extent[i + 1])
82 {
83 emptyExtent = true;
84 }
85 }
86
87 // Compute the increments for marching through the data.
88 this->RowIncrement = dataExtent[1] - dataExtent[0] + 1;
89 this->SliceIncrement = this->RowIncrement * (dataExtent[3] - dataExtent[2] + 1);
90
91 int rowSpan, sliceSpan, volumeSpan;
92
93 if (!emptyExtent)
94 {
95 // Compute the span of the image region to be covered.
96 rowSpan = this->Extent[1] - this->Extent[0] + 1;
97 sliceSpan = this->Extent[3] - this->Extent[2] + 1;
98 volumeSpan = this->Extent[5] - this->Extent[4] + 1;
99 this->Id = (this->Extent[0] - dataExtent[0]) +
100 (this->Extent[2] - dataExtent[2]) * this->RowIncrement +
101 (this->Extent[4] - dataExtent[4]) * this->SliceIncrement;
102
103 // Compute the end increments (continuous increments).
104 this->RowEndIncrement = this->RowIncrement - rowSpan;
105 this->SliceEndIncrement =
106 this->RowEndIncrement + this->SliceIncrement - this->RowIncrement * sliceSpan;
107 }
108 else
109 {
110 // Extent is empty, IsAtEnd() will immediately return "true"
111 rowSpan = 0;
112 sliceSpan = 0;
113 volumeSpan = 0;
114 this->Id = 0;
115 this->RowEndIncrement = 0;
116 this->SliceEndIncrement = 0;
117 for (int i = 0; i < 6; i += 2)
118 {
119 this->Extent[i] = dataExtent[i];
120 this->Extent[i + 1] = dataExtent[i] - 1;
121 }
122 }
123

Callers

nothing calls this directly

Calls 5

SetSpanStateMethod · 0.95
GetExtentListsFunction · 0.85
maxFunction · 0.50
minFunction · 0.50
GetExtentMethod · 0.45

Tested by

no test coverage detected