Visual Computing Library
Loading...
Searching...
No Matches
Point Sampling Algorithms

List of functions that compute point samplings. More...

Collaboration diagram for Point Sampling Algorithms:

Functions

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::allVerticesPointSampling (const MeshType &m, std::vector< uint > &birthVertices, bool onlySelected=false)
 Returns a Sampler object that contains all the vertices contained in the given mesh.
 
template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::allVerticesPointSampling (const MeshType &m, bool onlySelected=false)
 Returns a Sampler object that contains all the vertices contained in the given mesh.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::allFacesPointSampling (const MeshType &m, std::vector< uint > &birthFaces, bool onlySelected=false)
 Returns a SamplerType object that contains all the faces contained in the given mesh.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::allFacesPointSampling (const MeshType &m, bool onlySelected=false)
 Returns a SamplerType object that contains all the faces contained in the given mesh.
 
template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexUniformPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthVertices, bool onlySelected=false, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the vertices of the given mesh. Each vertex has the same probability of being chosen. If onlySelected is true, only the selected vertices are sampled. The indices of the sampled vertices in the mesh are stored in the birthVertices vector.
 
template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexUniformPointSampling (const MeshType &m, uint nSamples, bool onlySelected=false, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the vertices of the given mesh. Each vertex has the same probability of being chosen. If onlySelected is true, only the selected vertices are sampled.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceUniformPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthFaces, bool onlySelected=false, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled. The indices of the sampled faces in the mesh are stored in the birthFaces vector.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceUniformPointSampling (const MeshType &m, uint nSamples, bool onlySelected=false, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled.
 
template<SamplerConcept SamplerType, MeshConcept MeshType, typename ScalarType >
SamplerType vcl::vertexWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::vector< uint > &birthVertices, bool deterministic=false)
 Samples the vertices in a weighted way, using the per vertex weights given as input. Each vertex has a probability of being chosen that is proportional to its weight. If onlySelected is true, only the selected vertices are sampled. The indices of the sampled vertices in the mesh are stored in the birthVertices vector.
 
template<SamplerConcept SamplerType, MeshConcept MeshType, typename ScalarType >
SamplerType vcl::vertexWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, bool deterministic=false)
 Samples the vertices in a weighted way, using the per vertex weights given as input. Each vertex has a probability of being chosen that is proportional to its weight. If onlySelected is true, only the selected vertices are sampled.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType, typename ScalarType >
SamplerType vcl::faceWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::vector< uint > &birthFaces, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled. The indices of the sampled faces in the mesh are stored in the birthFaces vector.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType, typename ScalarType >
SamplerType vcl::faceWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, bool deterministic=false)
 Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled.
 
template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexQualityWeightedPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 Samples the vertices in a weighted way, using the per vertex Quality component. Each vertex has a probability of being chosen that is proportional to its quality value.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceQualityWeightedPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 Samples the faces in a weighted way, using the per face Quality component. Each face has a probability of being chosen that is proportional to its quality value.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::vertexAreaWeightedPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 Samples the vertices in a weighted way, using the area. Each vertex has a probability of being chosen that is proportional to the average area of its adjacent faces.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceAreaWeightedPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 Samples the faces in a weighted way, using the per face area. Each face has a probability of being chosen that is proportional to its area.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthFaces, bool deterministic=false)
 Computes a montecarlo distribution with an exact number of samples. It works by generating a sequence of consecutive segments proportional to the face areas and actually shooting sample over this line. The indices of the sampled faces in the mesh are stored in the birthFaces vector.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 Computes a montecarlo distribution with an exact number of samples. It works by generating a sequence of consecutive segments proportional to the face areas and actually shooting sample over this line.
 
template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPoissonPointSampling (const MeshType &m, uint nSamples, bool deterministic=false)
 This function compute montecarlo distribution with an approximate number of samples exploiting the poisson distribution approximation of the binomial distribution.
 

Detailed Description

List of functions that compute point samplings.

These functions compute saplings using various simple and complex methods, and return objects that satisfy the vcl::SamplerConcept. A Sampler is an object that allows to store points that can be results of some geometric function (e.g. a point sample that is computed as the barycentric coordinate of a triangle).

You can access these algorithms by including #include <vclib/algorithms/point_sampling.h>

Function Documentation

◆ allFacesPointSampling() [1/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::allFacesPointSampling ( const MeshType &  m,
bool  onlySelected = false 
)

Returns a SamplerType object that contains all the faces contained in the given mesh.

This function creates a SamplerType object that contains sampled points on the faces of the given MeshType object m. If onlySelected is true, only the selected faces are sampled.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mA const reference to the Mesh object
[in]onlySelectedA bool that specifies whether to sample only selected faces
Returns
A SamplerType object that contains the sampled points on the faces

◆ allFacesPointSampling() [2/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::allFacesPointSampling ( const MeshType &  m,
std::vector< uint > &  birthFaces,
bool  onlySelected = false 
)

Returns a SamplerType object that contains all the faces contained in the given mesh.

This function creates a SamplerType object that contains sampled points on the faces of the given MeshType object m. If onlySelected is true, only the selected faces are sampled. The indices of the sampled faces in the mesh are stored in the birthFaces vector.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mA const reference to the Mesh object
[out]birthFacesA vector of uints that will contain the indices of the sampled faces in the mesh
[in]onlySelectedA bool that specifies whether to sample only selected faces
Returns
A SamplerType object that contains the sampled points on the faces

◆ allVerticesPointSampling() [1/2]

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::allVerticesPointSampling ( const MeshType &  m,
bool  onlySelected = false 
)

Returns a Sampler object that contains all the vertices contained in the given mesh.

This function creates a SamplerType object that contains all the vertices in the given MeshType object m. If onlySelected is true, only the selected vertices are sampled.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
Parameters
[in]mA const reference to the Mesh object
[in]onlySelectedA bool that specifies whether to sample only selected vertices
Returns
A SamplerType object that contains the sampled vertices

◆ allVerticesPointSampling() [2/2]

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::allVerticesPointSampling ( const MeshType &  m,
std::vector< uint > &  birthVertices,
bool  onlySelected = false 
)

Returns a Sampler object that contains all the vertices contained in the given mesh.

This function creates a SamplerType object that contains all the vertices in the given MeshType object m. If onlySelected is true, only the selected vertices are sampled. The indices of the sampled vertices in the mesh are stored in the birthVertices vector.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
Parameters
[in]mA const reference to the Mesh object
[out]birthVerticesA vector of uints that will contain the indices of the sampled vertices in the mesh
[in]onlySelectedA bool that specifies whether to sample only selected vertices
Returns
A SamplerType object that contains the sampled vertices

◆ faceAreaWeightedPointSampling()

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceAreaWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

Samples the faces in a weighted way, using the per face area. Each face has a probability of being chosen that is proportional to its area.

Parameters
m
nSamples
deterministic
Returns

◆ faceQualityWeightedPointSampling()

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceQualityWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

Samples the faces in a weighted way, using the per face Quality component. Each face has a probability of being chosen that is proportional to its quality value.

Parameters
m
nSamples
deterministic
Returns

◆ faceUniformPointSampling() [1/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceUniformPointSampling ( const MeshType &  m,
uint  nSamples,
bool  onlySelected = false,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[in]onlySelectedWhether to only sample from the selected faces.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ faceUniformPointSampling() [2/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::faceUniformPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthFaces,
bool  onlySelected = false,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled. The indices of the sampled faces in the mesh are stored in the birthFaces vector.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[out]birthFacesA vector of indices of the birth faces.
[in]onlySelectedWhether to only sample from the selected faces.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ faceWeightedPointSampling() [1/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType, typename ScalarType >
SamplerType vcl::faceWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
ScalarTypeThe scalar type used for the weights
Parameters
[in]mThe mesh to sample from.
[in]weightsA vector of scalars having the i-th entry associated to the face having index i. Note: weights.size() == m.faceContainerSize().
[in]nSamplesThe number of samples to take.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ faceWeightedPointSampling() [2/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType, typename ScalarType >
SamplerType vcl::faceWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::vector< uint > &  birthFaces,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the faces of the given mesh. Each face has the same probability of being chosen. If onlySelected is true, only the selected faces are sampled. The indices of the sampled faces in the mesh are stored in the birthFaces vector.

The specific sampling method is determined by the implementation of the SamplerType class. However, in general, the sampled point on each face is the face barycenter.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
ScalarTypeThe scalar type used for the weights
Parameters
[in]mThe mesh to sample from.
[in]weightsA vector of scalars having the i-th entry associated to the face having index i. Note: weights.size() == m.faceContainerSize().
[in]nSamplesThe number of samples to take.
[out]birthFacesA vector to store the indices of the faces that were sampled.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ montecarloPointSampling() [1/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

Computes a montecarlo distribution with an exact number of samples. It works by generating a sequence of consecutive segments proportional to the face areas and actually shooting sample over this line.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ montecarloPointSampling() [2/2]

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthFaces,
bool  deterministic = false 
)

Computes a montecarlo distribution with an exact number of samples. It works by generating a sequence of consecutive segments proportional to the face areas and actually shooting sample over this line. The indices of the sampled faces in the mesh are stored in the birthFaces vector.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[out]birthFacesA vector to store the indices of the faces that were sampled.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object that contains the sampled points on the faces.

◆ montecarloPoissonPointSampling()

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::montecarloPoissonPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

This function compute montecarlo distribution with an approximate number of samples exploiting the poisson distribution approximation of the binomial distribution.

For a given triangle t of area a_t, in a Mesh of area A, if we take n_s sample over the mesh, the number of samples that falls in t follows the poisson distribution of P(lambda) with lambda = n_s * (a_t/A).

To approximate the Binomial we use a Poisson distribution with parameter lambda = np can be used as an approximation to B(n,p) (it works if n is sufficiently large and p is sufficiently small).

Parameters
m
nSamples
deterministic
Returns

◆ vertexAreaWeightedPointSampling()

template<SamplerConcept SamplerType, FaceMeshConcept MeshType>
SamplerType vcl::vertexAreaWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

Samples the vertices in a weighted way, using the area. Each vertex has a probability of being chosen that is proportional to the average area of its adjacent faces.

Parameters
m
nSamples
deterministic
Returns

◆ vertexQualityWeightedPointSampling()

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexQualityWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
bool  deterministic = false 
)

Samples the vertices in a weighted way, using the per vertex Quality component. Each vertex has a probability of being chosen that is proportional to its quality value.

Parameters
m
nSamples
deterministic
Returns

◆ vertexUniformPointSampling() [1/2]

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexUniformPointSampling ( const MeshType &  m,
uint  nSamples,
bool  onlySelected = false,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the vertices of the given mesh. Each vertex has the same probability of being chosen. If onlySelected is true, only the selected vertices are sampled.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[in]onlySelectedWhether to only sample from the selected vertices.
[in]deterministicWhether to use a deterministic random generator.
Returns
A Sampler object containing the sampled vertices.

◆ vertexUniformPointSampling() [2/2]

template<SamplerConcept SamplerType, MeshConcept MeshType>
SamplerType vcl::vertexUniformPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthVertices,
bool  onlySelected = false,
bool  deterministic = false 
)

Returns a SamplerType object that contains the given number of samples taken from the vertices of the given mesh. Each vertex has the same probability of being chosen. If onlySelected is true, only the selected vertices are sampled. The indices of the sampled vertices in the mesh are stored in the birthVertices vector.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[out]birthVerticesA vector of indices of the birth vertices.
[in]onlySelectedWhether to only sample from the selected vertices.
[in]deterministicWhether to use a deterministic random generator.
Returns
A SamplerType object containing the sampled vertices.

◆ vertexWeightedPointSampling() [1/2]

template<SamplerConcept SamplerType, MeshConcept MeshType, typename ScalarType >
SamplerType vcl::vertexWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
bool  deterministic = false 
)

Samples the vertices in a weighted way, using the per vertex weights given as input. Each vertex has a probability of being chosen that is proportional to its weight. If onlySelected is true, only the selected vertices are sampled.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
ScalarTypeThe scalar type used for the weights
Parameters
[in]mThe input mesh to sample from.
[in]weightsA vector of scalars having the i-th entry associated to the vertex having index i. Note: weights.size() == m.vertexContainerSize().
[in]nSamplesThe number of vertices to sample.
[in]deterministicIf true, sets the random number generator to a deterministic mode.
Returns
A SamplerType object containing the samples selected from the input mesh.

◆ vertexWeightedPointSampling() [2/2]

template<SamplerConcept SamplerType, MeshConcept MeshType, typename ScalarType >
SamplerType vcl::vertexWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::vector< uint > &  birthVertices,
bool  deterministic = false 
)

Samples the vertices in a weighted way, using the per vertex weights given as input. Each vertex has a probability of being chosen that is proportional to its weight. If onlySelected is true, only the selected vertices are sampled. The indices of the sampled vertices in the mesh are stored in the birthVertices vector.

Template Parameters
SamplerTypeA type that satisfies the SamplerConcept
MeshTypeA type that satisfies the MeshConcept
ScalarTypeThe scalar type used for the weights
Parameters
[in]mThe input mesh to sample from.
[in]weightsA vector of scalars having the i-th entry associated to the vertex having index i. Note: weights.size() == m.vertexContainerSize().
[in]nSamplesThe number of vertices to sample.
[out]birthVerticesA vector to store the indices of the vertices that were sampled.
[in]deterministicIf true, sets the random number generator to a deterministic mode.
Returns
A SamplerType object containing the samples selected from the input mesh.