Page 1 of 2

Save/Load picked points

Posted: Thu Mar 19, 2020 7:34 am
by Viktor Peske
Hello.

I'm building a plugin. I'm going to save and load the picked points using this plugin.
The information for a picked point must be only x, y, z. And the plugin should load the x, y, z info and show the saved points on the scene.

I can get the x, y, z of the picked points when save, but I cannot get the point from the x, y, z value when load.
If I save the point index with x, y, z, I can correctly load and show the saved point, but I mustn't save point index.

Please help me!
Thanks a lot!

Re: Save/Load picked points

Posted: Thu Mar 19, 2020 4:33 pm
by daniel
but I cannot get the point from the x, y, z value when load
Do you mean that you want to find a point in a cloud knowing its 3 coordinates but not its index?

Either you make a brute-force comparison on all the points (with OpenMP in addition, it can be pretty quick). Just be sure to allow for some inaccuracies in the coordinates if you load them from a file.

Another option is to rely on the octree (with the 'closest point' determination algorithm). It may be worth the cost if you want to do that multiple times.

Re: Save/Load picked points

Posted: Thu Mar 19, 2020 11:46 pm
by Viktor Peske
Thanks for your quick reply!
daniel wrote: Thu Mar 19, 2020 4:33 pm Do you mean that you want to find a point in a cloud knowing its 3 coordinates but not its index?
Exactly! My main goal is to get point index from x,y,z.
daniel wrote: Thu Mar 19, 2020 4:33 pm Either you make a brute-force comparison on all the points (with OpenMP in addition, it can be pretty quick). Just be sure to allow for some inaccuracies in the coordinates if you load them from a file.
brute-force comparison is not a good option for my goal I think.
But seems OpenMP is a good option. I'm using 2.10.2(current stable version) source code.
How I can enable the OpenMP in it? And can you let me know the correct class or function to get the point index from x, y, z?
daniel wrote: Thu Mar 19, 2020 4:33 pm Another option is to rely on the octree (with the 'closest point' determination algorithm). It may be worth the cost if you want to do that multiple times.
Sorry but I don't know how to use the 'closest point' determination algorithm in octree. Can you let me know the correct class or function?
And I'm going to get 10~20 point indexes from those x, y, z. So will it be worth the cost? And which kind of cost do you mean?

Sorry for bothering you! Thanks again, Daniel!

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 8:28 am
by daniel
Brute force might be surprisingly fast sometimes... and OpenMP is just a simply way to make this brute force comparison faster by making the computation parallel (see "#pragma pmp" in the code).

And why are you using the 2.10 code and not the latest version? (master branch)

And the octree function you can use is 'DgmOctree::findPointNeighbourhood'. See how it's used in the Canupo or Compass plugins (their sources are on the main repository as well).

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 9:23 am
by Viktor Peske
Thanks a lot, Daniel!

I've solved this problem using the Compass plugin source.

I really appreciate for your help. Regards!

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 3:23 pm
by Viktor Peske
One more question!

Can I change the color of picked points?
That is, the color of firstly picked point is default color and the second is red, third is green....
How can I change the color per point?

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 3:45 pm
by daniel
You have to first initialize (resize) the set of RGB colors if the cloud doesn't have colors yet (ccPointCloud::resizeTheRGBTable).

Then set each point color (ccPointCloud::setPointColor).

Another option is to use a scalar field (but controlling the colors may be more tricky).

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 3:57 pm
by Viktor Peske
Sorry for my bad writing. The point I wrote was not the point of point cloud, but the mark of selected point.
Untitled.png
Untitled.png (231.18 KiB) Viewed 8292 times

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 5:26 pm
by daniel
Ah! Then currently I don't think it's possible to change it.

You would have to change the 'label' code slightly (but this contribution would probably be welcome!)

Re: Save/Load picked points

Posted: Fri Mar 20, 2020 5:31 pm
by Viktor Peske
I see. I'll try more by myself.

Thanks anyway.