PointCloudLibrary / PointCloudLibrary/pcl

Inconsistency between addPolygonMesh and updatePolygonMesh

Open
#2,259 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

module: visualization needs: code review
Dominant language
C++
Stars
11.1k
Forks
4.7k
Avg merge
4d 10h
Merged PRs (30d)
6

Description

Your Environment

  • Operating System and version: Ubuntu 16.04
  • Compiler: gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
  • PCL Version: 1.8.1

Context

I am trying to update a polygon mesh with only one polygon in PCLVisualizer. The updatePolygonMesh function returns false here(https://github.com/PointCloudLibrary/pcl/blob/master/visualization/src/pcl_visualizer.cpp#L3235). The reason is because the addPolygonMesh functions handles mesh differently when the size of polygons are 1 and bigger than 1 (see https://github.com/PointCloudLibrary/pcl/blob/master/visualization/src/pcl_visualizer.cpp#L3149). Can I ask why we use a vtkUnstructuredGrid instead of vtkPolyData when there is only one polygon in the mesh?

Expected Behavior

I would expect the updatePolygonMesh call to be successful regardless of how many polygons are there in the mesh.

Current Behavior

However, current updatePolygonMesh has a bug if the existing PolygonMesh has only one polygon when added. Because the code(https://github.com/PointCloudLibrary/pcl/blob/master/visualization/src/pcl_visualizer.cpp#L3235) is checking if there is a vtkPolyData added but addPolygonMesh added a updatePolygonMesh, which will always fail.

Code to Reproduce

Try adding a polygon mesh with just one polygon and then update it by calling updatePolygonMesh, it will fail.

Possible Solution

I personally tried removing the special case when the polygon number is 1 and always use the existing code for cases where there more than 1 polygon, it worked fine. So my question is: why do we handle the cases differently, as when the number of polygons is equal or bigger than 1?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read visualization/src/pcl_visualizer.cpp at the addPolygonMesh and updatePolygonMesh locations linked in the issue, then reproduce the failure by adding a mesh with one polygon and calling updatePolygonMesh. Compare the vtkPolyData and vtkUnstructuredGrid handling. Done means updating a single-polygon mesh succeeds and the add and update paths use compatible handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, computer-vision
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.