46 vtkInformationVector** inputVector,
47 vtkInformationVector* outputVector)
49 vtkDebugMacro(<<
"Executing VtkImageDataToSurfacePointsFilter");
51 vtkInformation* input_info = inputVector[0]->GetInformationObject(0);
52 vtkInformation* output_info = outputVector->GetInformationObject(0);
53 vtkImageData* input = vtkImageData::SafeDownCast(
54 input_info->Get(vtkDataObject::DATA_OBJECT()));
55 vtkPolyData* output = vtkPolyData::SafeDownCast(
56 output_info->Get(vtkDataObject::DATA_OBJECT()));
58 void* pixvals = input->GetScalarPointer();
59 int n_comp = input->GetNumberOfScalarComponents();
62 vtkDebugMacro(
"Error reading number of components.");
67 "RGB colours detected. Using only first channel for computation.");
70 auto const n_points =
static_cast<std::size_t
>(input->GetNumberOfPoints());
73 vtkDebugMacro(
"No data found!");
78 input->GetSpacing(spacing);
80 input->GetDimensions(dimensions);
82 input->GetOrigin(origin);
84 std::array<double, 3>{{origin[0], origin[1], origin[2]}});
86 std::vector<double> pixels;
87 pixels.reserve(n_points);
88 for (std::size_t i = 0; i < n_points; ++i)
90 if ((n_comp == 2 || n_comp == 4) &&
91 ((
static_cast<float*
>(pixvals))[(i + 1) * n_comp - 1] <
94 pixels.push_back(-9999);
98 pixels.push_back((
static_cast<float*
>(pixvals))[i * n_comp]);
102 {
static_cast<std::size_t
>(dimensions[0]),
103 static_cast<std::size_t
>(dimensions[1]), 1, ll, spacing[0], -9999},
107 vtkSmartPointer<vtkPoints> new_points = vtkSmartPointer<vtkPoints>::New();
109 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
112 double const half_cellsize(spacing[0] / 2.0);
113 std::size_t pnt_idx(0);
114 for (std::size_t i = 0; i < static_cast<std::size_t>(n_points); ++i)
117 if (n_comp == 2 || n_comp == 4)
119 if ((
static_cast<float*
>(pixvals))[(i + 1) * n_comp - 1] <
127 input->GetPoint(i, p);
129 {p[0] - half_cellsize, p[1] - half_cellsize, 0}}};
131 {p[0] + half_cellsize, p[1] + half_cellsize, 0}}};
133 new_points, cells, pnt_idx, min_pnt, max_pnt, *raster);
137 output->SetPoints(new_points);
138 output->SetVerts(cells);
141 vtkDebugMacro(<<
"Created " << new_points->GetNumberOfPoints()
147 vtkSmartPointer<vtkPoints>& points,
148 vtkSmartPointer<vtkCellArray>& cells,
154 auto const n_points(
static_cast<std::size_t
>(this->GetPointsPerPixel()));
155 for (std::size_t i = 0; i < n_points; ++i)
162 points->SetPoint(pnt_idx + i, p);
163 cells->InsertNextCell(1);
164 cells->InsertCellPoint(pnt_idx + i);
void createPointSurface(vtkSmartPointer< vtkPoints > &points, vtkSmartPointer< vtkCellArray > &cells, std::size_t pnt_idx, MathLib::Point3d const &min_pnt, MathLib::Point3d const &max_pnt, GeoLib::Raster const &raster)
Creates the point objects based on the parameters set by the user.