Point sampling from mesh

Feel free to ask any question here
Post Reply
krips89
Posts: 3
Joined: Tue Jan 03, 2017 4:39 pm

Point sampling from mesh

Post by krips89 »

Hello,

I have two questions about the sampling functionality provided in CC.

1. What algorithm is used for sampling points on a mesh? When I see the sampling functionlities in Meshlab, I find a list of algorithms to chose from; for example Poisson disk sampling, Texel sampling etc.. I want to know what algorithm is used in CC as it performs so good.

2. I want to sample point cloud on a mesh with normal in command line mode and save it in some format. Following does not work:

Code: Select all

CloudCompare -SILENT -COMPUTE_NORMALS -o desk_0133.off -C_EXPORT_FMT ASC -SAMPLE_MESH POINTS 500000
But when I use the same mesh in the GUI and select appropriate settings for generating normals in the sampled points, it works. Is there any way of achieving this in command line?

Thanks a lot!
Kripa
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Point sampling from mesh

Post by daniel »

1. Well, I don't know :D.

The algorithm is very simple: we randomly pick a given number of point on each triangle. This number depends on the triangle area. And as the theoretical number may not be an integer, we cope with the fractional part by considering the fractional part as a probability to pick another additional point (e.g.: 7.32 points for a given triangle --> we pick 7 points -> then we draw a random number between 0 and 1 --> if it's inferior to 0.32, we pick a 8th point). This is the only 'trick' of this algorithm.

I think this algorithm was proposed by Cignoni et al. in the article describing their METRO software (but I'm not 100% sure ;).

2. The COMPUTE_NORMALS option only applies to gridded point clouds in fact... You would have to add a specific option to the command line mode to do it on meshes (it's not very hard). We could do it as well but it will probably be longer as the TODO list is huge right now.
Daniel, CloudCompare admin
krips89
Posts: 3
Joined: Tue Jan 03, 2017 4:39 pm

Re: Point sampling from mesh

Post by krips89 »

Hi, thanks for the reply.
You would have to add a specific option to the command line mode to do it on meshes (it's not very hard).


What do you mean? I want to sample points with normal. Logically (and the work-flow in GUI to achieve same) the steps to be followed are to compute normal per face, and then sample points with normal in that mesh. I don't find the option to sample points with normal in the command line mode. Are there any?
Thanks,
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Point sampling from mesh

Post by daniel »

I mean that in command line mode, normals are automatically extract (with the SAMPLE_MESH option). But of course you need normals. And some meshes don't have normals. So you have first to compute normals (but the COMPUTE_NORMALS doesn't work with meshes). So you need an option to compute normals on meshes.
Daniel, CloudCompare admin
krips89
Posts: 3
Joined: Tue Jan 03, 2017 4:39 pm

Re: Point sampling from mesh

Post by krips89 »

Aah) And what are the options for computing normals on the mesh? I didn't find any in the documentation (http://www.cloudcompare.org/doc/wiki/in ... _line_mode)

Do you have any source which explains/has details on how to perform it?

Thanks,
Kripa
daniel
Site Admin
Posts: 7710
Joined: Wed Oct 13, 2010 7:34 am
Location: Grenoble, France
Contact:

Re: Point sampling from mesh

Post by daniel »

There are two 'options' (see http://www.cloudcompare.org/doc/wiki/in ... _on_a_mesh):
- per vertex
- per triangle

Depending on the output format, you'll have to choose one or the other. And by the way I'm not sure the OFF format supports normals, does it?

And regarding the code it's very simple: simply call computeNormals(bool perVertex) on a mesh entity.
Daniel, CloudCompare admin
Post Reply