MCPcopy Create free account
hub / github.com/Kitware/ParaView / Build

Method Build

Remoting/Views/vtkPVTransferFunction2D.cxx:139–220  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

137
138//------------------------------------------------------------------------------------------------
139void vtkPVTransferFunction2D::Build()
140{
141 if (this->Internals->BuildTime > this->GetMTime())
142 {
143 return;
144 }
145
146 if (!this->Internals->Function)
147 {
148 this->Internals->Function = vtkImageData::New();
149 }
150 this->Internals->Function->Initialize();
151
152 this->Internals->Function->SetDimensions(this->OutputDimensions[0], this->OutputDimensions[1], 1);
153 this->Internals->Function->SetOrigin(this->Range[0], this->Range[2], 0.0);
154 double spacing[2];
155 spacing[0] = (this->Range[1] - this->Range[0]) / this->OutputDimensions[0];
156 spacing[1] = (this->Range[3] - this->Range[2]) / this->OutputDimensions[1];
157 this->Internals->Function->SetSpacing(spacing[0], spacing[1], 1.0);
158 this->Internals->Function->AllocateScalars(VTK_FLOAT, 4);
159 auto arr = vtkFloatArray::FastDownCast(this->Internals->Function->GetPointData()->GetScalars());
160 auto arrRange = vtk::DataArrayValueRange(arr);
161 std::fill(arrRange.begin(), arrRange.end(), 0.0);
162
163 for (const auto& box : this->Internals->Boxes)
164 {
165 if (!box)
166 {
167 continue;
168 }
169 const vtkRectd bbox = box->GetBox();
170 vtkIdType width = static_cast<vtkIdType>(bbox.GetWidth() / spacing[0]);
171 vtkIdType height = static_cast<vtkIdType>(bbox.GetHeight() / spacing[1]);
172 if (width <= 0 || height <= 0)
173 {
174 continue;
175 }
176 vtkIdType x0 = static_cast<vtkIdType>((bbox.GetX() - this->Range[0]) / spacing[0]);
177 vtkIdType y0 = static_cast<vtkIdType>((bbox.GetY() - this->Range[2]) / spacing[1]);
178 x0 = bbox.GetX() <= this->Range[0] ? 0 : x0;
179 x0 = bbox.GetX() >= this->Range[1] ? this->OutputDimensions[0] : x0;
180 y0 = bbox.GetY() <= this->Range[2] ? 0 : y0;
181 y0 = bbox.GetY() >= this->Range[3] ? this->OutputDimensions[1] : y0;
182 vtkIdType x1 = static_cast<vtkIdType>((bbox.GetRight() - this->Range[0]) / spacing[0]);
183 vtkIdType y1 = static_cast<vtkIdType>((bbox.GetTop() - this->Range[2]) / spacing[1]);
184 x1 = bbox.GetRight() <= this->Range[0] ? 0 : x1;
185 x1 = bbox.GetRight() >= this->Range[1] ? this->OutputDimensions[0] : x1;
186 y1 = bbox.GetTop() <= this->Range[2] ? 0 : y1;
187 y1 = bbox.GetTop() >= this->Range[3] ? this->OutputDimensions[1] : y1;
188 vtkSmartPointer<vtkImageData> boxTexture = box->GetTexture();
189 int boxDims[3];
190 boxTexture->GetDimensions(boxDims);
191 double boxSpacing[3] = { 1, 1, 1 };
192 boxSpacing[0] = bbox.GetWidth() / boxDims[0];
193 boxSpacing[1] = bbox.GetHeight() / boxDims[1];
194 for (vtkIdType ii = x0; ii < x1; ++ii)
195 {
196 for (vtkIdType jj = y0; jj < y1; ++jj)

Callers 1

GetFunctionMethod · 0.95

Calls 13

GetWidthMethod · 0.80
NewFunction · 0.50
GetMTimeMethod · 0.45
InitializeMethod · 0.45
SetDimensionsMethod · 0.45
SetOriginMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetXMethod · 0.45
GetYMethod · 0.45
GetTextureMethod · 0.45
GetDimensionsMethod · 0.45

Tested by

no test coverage detected