37 #include <vtkSmartPointer.h>
38 #include <vtkPolyData.h>
39 #include <vtkCellArray.h>
40 #include <vtkPolyDataMapper.h>
41 #include <vtkPoints.h>
43 #include <vtkProperty.h>
44 #include <vtkPointData.h>
45 #include <vtkFloatArray.h>
46 #include <vtkIdFilter.h>
47 #include <vtkDataSetSurfaceFilter.h>
100 return col1.
r == col2.
r && col1.
g == col2.
g && col1.
b == col2.
b;
133 vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
134 scalars->SetNumberOfComponents(3);
135 scalars->SetName(
"Colors");
136 scalars->SetNumberOfTuples(n);
138 #pragma omp parallel for
139 for (vtkIdType i = 0; i < n; i++)
141 int specIndex = n_channels * i;
142 unsigned char speccolor[3];
148 #if VTK_MAJOR_VERSION < 7
149 scalars->SetTupleValue(i, speccolor);
151 scalars->SetTypedTuple(i, speccolor);
210 #pragma omp parallel for reduction(max : ndviMax), reduction(min : ndviMin)
211 for (
int i = 0; i < n; i++)
214 float nearRedTotal = 0;
215 unsigned char* specPixel = spec.get() + n_channels * i;
218 for (
int channel = redStart; channel < redEnd; channel++)
220 redTotal += specPixel[channel];
222 for (
int channel = nearRedStart; channel < nearRedEnd; channel++)
224 nearRedTotal += specPixel[channel];
228 float red = redTotal / (redEnd - redStart);
229 float nearRed = nearRedTotal / (nearRedEnd - nearRedStart);
231 float val = (nearRed - red) / (nearRed + red);
236 if (val < ndviMin) ndviMin = val;
237 if (val > ndviMax) ndviMax = val;
242 vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
243 scalars->SetNumberOfComponents(3);
244 scalars->SetName(
"Colors");
245 scalars->SetNumberOfTuples(n);
248 unsigned char min = 0;
249 unsigned char max = 255;
254 #pragma omp parallel for reduction(max : max_val), reduction(min : min_val)
255 for (
int i = 0; i < n; i++)
281 #pragma omp parallel for
282 for (
int i = 0; i < n; i++)
284 int specIndex = n_channels * i;
297 unsigned char speccolor[3];
298 speccolor[0] =
color[0] * 255;
299 speccolor[1] =
color[1] * 255;
300 speccolor[2] =
color[2] * 255;
302 #if VTK_MAJOR_VERSION < 7
303 scalars->SetTupleValue(i, speccolor);
305 scalars->SetTypedTuple(i, speccolor);
367 vtkSmartPointer<vtkPolyData> vtk_polyData = vtkSmartPointer<vtkPolyData>::New();
368 vtkSmartPointer<vtkPoints> vtk_points = vtkSmartPointer<vtkPoints>::New();
377 size_t n, n_c, n_s_p;
378 size_t n_s_channels, w_color;
382 floatArr points = pc->getPointArray();
384 ucharArr spec = pc->getUCharArray(
"spectral_channels", n_s_p, n_s_channels);
385 floatArr normals = pc->getNormalArray();
389 vtkSmartPointer<vtkFloatArray> pts_data = vtkSmartPointer<vtkFloatArray>::New();
390 pts_data->SetNumberOfComponents(3);
391 pts_data->SetVoidArray(points.get(), n * 3, 1);
392 vtk_points->SetData(pts_data);
395 vtkSmartPointer<vtkCellArray> vtk_cells = vtkSmartPointer<vtkCellArray>::New();
396 vtkSmartPointer<vtkIdTypeArray> cells = vtkSmartPointer<vtkIdTypeArray>::New();
397 vtkIdType* cell_buf =
new vtkIdType[n * 2];
398 for(
size_t i = 0; i < n; i++)
401 cell_buf[i2 + 0] =
static_cast<vtkIdType
>(1);
402 cell_buf[i2 + 1] = i;
409 cells->SetVoidArray(cell_buf, n * 2, 0, vtkIdTypeArray::VTK_DATA_ARRAY_DELETE);
411 vtk_cells->SetCells(n, cells);
413 vtkSmartPointer<vtkUnsignedCharArray> scalars = vtkSmartPointer<vtkUnsignedCharArray>::New();
414 scalars->SetNumberOfComponents(3);
415 scalars->SetName(
"Colors");
435 unsigned char* spec_buf =
new unsigned char[n * 3];
436 for(
size_t i = 0; i < n; ++i)
438 size_t specIndex = n_s_channels * i;
445 scalars->SetVoidArray(spec_buf, n * 3, vtkIdTypeArray::VTK_DATA_ARRAY_DELETE);
451 scalars->SetVoidArray(
colors.get(), n * w_color, 1);
464 double* normal_buf =
new double[n * 3];
465 for(
size_t i = 0; i < n; ++i)
467 size_t index = 3 * i;
468 normal_buf[index + 0] = normals[index + 0];
469 normal_buf[index + 1] = normals[index + 1];
470 normal_buf[index + 2] = normals[index + 2];
473 m_vtk_normals->SetVoidArray(normal_buf, n * 3, vtkIdTypeArray::VTK_DATA_ARRAY_DELETE);
482 vtkSmartPointer<vtkIdFilter> pointFilter =
483 vtkSmartPointer<vtkIdFilter>::New();
487 pointFilter->SetCellIdsArrayName(
"OriginalIds");
488 pointFilter->SetPointIdsArrayName(
"OriginalIds");
490 pointFilter->SetIdsArrayName(
"OriginalIds");
492 pointFilter->Update();
509 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
544 p->SetPointSize(pointSize);
550 p->SetOpacity(opacityValue);