39 vtkImageData* output, IT* inPtr,
43 input->GetDimensions(dims);
44 if (input->GetScalarType() != output->GetScalarType())
46 vtkGenericWarningMacro(
47 <<
"Execute: input ScalarType, " << input->GetScalarType()
48 <<
", must match out ScalarType " << output->GetScalarType());
53 dims[0] * dims[1] * dims[2] * input->GetNumberOfScalarComponents();
55 for (
int i = 0; i < size; i++)
101 vtkDebugMacro(<<
"Executing VtkGeoImageSource");
102 void* inPtr = input->GetScalarPointer();
103 void* outPtr = output->GetScalarPointer();
104 switch (output->GetScalarType())
109 input, output, (VTK_TT*)(inPtr), (VTK_TT*)(outPtr)));
111 vtkGenericWarningMacro(
"Execute: Unknown input ScalarType");
126 source->GetOutput()->GetDimensions(dims);
128 source->GetOutput()->GetOrigin(origin);
130 source->GetOutput()->GetSpacing(spacing);
132 std::array<double, 3>{{origin[0] - 0.5 * spacing[0],
133 origin[1] - 0.5 * spacing[1], origin[2]}});
135 static_cast<std::size_t
>(dims[1]),
136 static_cast<std::size_t
>(dims[2]),
141 vtkSmartPointer<vtkDataArray>
const pixelData =
142 vtkSmartPointer<vtkDataArray>(
143 source->GetOutput()->GetPointData()->GetScalars());
144 int const nTuple = pixelData->GetNumberOfComponents();
145 if (nTuple < 1 || nTuple > 4)
147 ERR(
"VtkMeshConverter::convertImgToMesh(): Unsupported pixel "
152 std::vector<double> pix(header.n_cols * header.n_rows * header.n_depth, 0);
153 for (std::size_t k = 0; k < header.n_depth; k++)
155 std::size_t
const layer_idx = (k * header.n_rows * header.n_cols);
156 for (std::size_t i = 0; i < header.n_rows; i++)
158 std::size_t
const idx = i * header.n_cols + layer_idx;
159 for (std::size_t j = 0; j < header.n_cols; j++)
161 double const*
const colour = pixelData->GetTuple(idx + j);
162 bool const visible = (nTuple == 2 || nTuple == 4)
163 ? (colour[nTuple - 1] != 0)
167 pix[idx + j] = header.no_data;
171 pix[idx + j] = (nTuple < 3) ? colour[0] :
172 (0.3 * colour[0] + 0.6 * colour[1] +
179 return std::make_optional<GeoLib::Raster>(header, pix.begin(), pix.end());