[ As designed ] [ Bug ] Points_Structure command does not work properly

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

[ As designed ] [ Bug ] Points_Structure command does not work properly

Post by Roy_043 »

As far as I understand things the Points_Structure command should sort the points in a point cloud. The current algorithm seems flawed as only the X and Y coordinates of a point are used in the sorting process and to determine the index of the point in the new point cloud.

src\Mod\Points\Gui\Command.cpp Line 434:

Code: Select all

                if (xx < 0.01 && yy < 0.01) {
                    xi = std::round(xi);
                    yi = std::round(yi);
                    long index = long(yi * width_l + xi);
                    sortedPoints[index] = pnt;
                }
Example:
pt1: 0,0,0
pt2: 0,0,1
pt1 and pt2 will receive the same index in the structured point cloud. Which effectively means that pt1 is overwritten by pt2.

Also the structured point cloud can have 'nan' vectors which the algorithm should only use temporarily. See the attached file.

Code: Select all

App.ActiveDocument.Test13__Structured_.Points.Points
=>

Code: Select all

[Vector (0.0, 0.0, 2.0), Vector (nan, nan, nan), Vector (1.0, 0.0, 2.0), Vector (nan, nan, nan), Vector (0.5, 0.5, 2.5), Vector (nan, nan, nan), Vector (0.0, 1.0, 2.0), Vector (nan, nan, nan), Vector (1.0, 1.0, 2.0)]

Code: Select all

OS: Windows 8.1 (6.3)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22262 (Git)
Build type: Release
Branch: master
Hash: f56825c79f11b75648a7a0dcc8a9f52bb4574e61
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: Dutch/Netherlands (nl_NL)
Attachments
Test_Points_Structure.FCStd
(3.52 KiB) Downloaded 24 times
Last edited by Roy_043 on Sat Jan 30, 2021 2:19 pm, edited 2 times in total.
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Points_Structure command does not work properly

Post by Roy_043 »

Bump! Can someone confirm this please. Thanks.
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Bug ] Points_Structure command does not work properly

Post by Roy_043 »

User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: [ Ticket #4436 ] [ Bug ] Points_Structure command does not work properly

Post by Kunda1 »

wmayer wrote: pinged by pinger macro
Probably a good idea to fix this before 0.19 release.
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
wmayer
Founder
Posts: 19965
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: [ Ticket #4436 ] [ Bug ] Points_Structure command does not work properly

Post by wmayer »

This command only works for point clouds whose points are organized in a grid structure. For such points there must exist a view direction so that when looking from there the points are perfectly aligned in a regular 2D grid. For the sake of simplicity it's expected that this view direction is the Z axis.

If this view direction is not the Z axis for your data then you have to change the placement accordingly. Afterwards the command will output the expected result.

Additionally, the point cloud must be undercut-free. So, your data will never work and the only way is to split them into several parts.

Usually you have this kind of points clouds coming from structured-light 3D scanners.
A "view" describes a small undercut-free part of a bigger object. For a complex object you scan many views and align them afterwards so that they lie in a common coordinate system.

The main advantage of a structured point cloud over a scattered point cloud is that its tessellation is very easy.
User avatar
Kunda1
Veteran
Posts: 13447
Joined: Thu Jan 05, 2017 9:03 pm

Re: [ Bug ] Points_Structure command does not work properly

Post by Kunda1 »

Roy_043 wrote: Tue Sep 15, 2020 8:12 am issue #4436
@Roy_043 per wmayer's comments above it seems we should add this info to the Points Structure wiki documentation for better clarity as to what the command actually addresses.

Edit:
Thanks for you response @wmayer!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Roy_043
Veteran
Posts: 7393
Joined: Thu Dec 27, 2018 12:28 pm

Re: [ Ticket #4436 ] [ Bug ] Points_Structure command does not work properly

Post by Roy_043 »

@Kunda1: Thanks for the follow up.
@wmayer: Thanks for the explanation.

I'll fix the documentation then.
Post Reply