Skip to content

Commit

Permalink
Merge pull request #4354 from larshg/FixKinfuGetColor
Browse files Browse the repository at this point in the history
[Tools / Kinfu] Fix getColor()
  • Loading branch information
SergioRAgostinho committed Aug 26, 2020
2 parents c5fc651 + 5209ffa commit c9e8ed0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
17 changes: 8 additions & 9 deletions gpu/kinfu/tools/kinfu_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,17 @@ namespace pcl
}

/** \brief Obtain the actual color for the input dataset as vtk scalars.
* \param[out] scalars the output scalars containing the color for the dataset
* \return true if the operation was successful (the handler is capable and
* the input cloud was given as a valid pointer), false otherwise
* \return Array of scalars if the operation was successful (the handler is capable and
* the input cloud was given as a valid pointer), nullptr otherwise
*/
bool
getColor (vtkSmartPointer<vtkDataArray> &scalars) const override
vtkSmartPointer<vtkDataArray>
getColor () const override
{
if (!capable_ || !cloud_)
return (false);
return nullptr;

if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
auto scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();

scalars->SetNumberOfComponents (3);

vtkIdType nr_points = vtkIdType (cloud_->size ());
Expand All @@ -157,7 +156,7 @@ namespace pcl
colors[idx + 1] = (*rgb_)[cp].g;
colors[idx + 2] = (*rgb_)[cp].b;
}
return (true);
return scalars;
}

private:
Expand Down
11 changes: 5 additions & 6 deletions gpu/kinfu_large_scale/tools/color_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@ namespace pcl
capable_ = true;
}

bool
getColor (vtkSmartPointer<vtkDataArray> &scalars) const override
vtkSmartPointer<vtkDataArray>
getColor () const override
{
if (!capable_)
return (false);
return nullptr;

if (!scalars)
scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
auto scalars = vtkSmartPointer<vtkUnsignedCharArray>::New ();
scalars->SetNumberOfComponents (3);

vtkIdType nr_points = static_cast<vtkIdType>(cloud_->size ());
Expand All @@ -88,7 +87,7 @@ namespace pcl
colors[idx + 1] = (*rgb_)[cp].g;
colors[idx + 2] = (*rgb_)[cp].b;
}
return (true);
return scalars;
}

private:
Expand Down

0 comments on commit c9e8ed0

Please sign in to comment.