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

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

Collaboration diagram for Point Sampling Algorithms:

Functions

template<FaceMeshConcept MeshType>
auto vcl::allFacesPointSampling (const MeshType &m, bool onlySelected=false)
 Returns a PointSampler object that contains all the faces contained in the given mesh.
 
template<FaceMeshConcept MeshType>
auto vcl::allFacesPointSampling (const MeshType &m, std::vector< uint > &birthFaces, bool onlySelected=false)
 Returns a PointSampler object that contains all the faces contained in the given mesh.
 
template<MeshConcept MeshType>
auto vcl::allVerticesPointSampling (const MeshType &m, bool onlySelected=false)
 Returns a PointSampler object that contains all the vertices contained in the given mesh.
 
template<MeshConcept MeshType>
auto vcl::allVerticesPointSampling (const MeshType &m, std::vector< uint > &birthVertices, bool onlySelected=false)
 Returns a PointSampler object that contains all the vertices contained in the given mesh.
 
template<FaceMeshConcept MeshType>
auto vcl::faceAreaWeightedPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<FaceMeshConcept MeshType>
auto vcl::faceQualityWeightedPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<FaceMeshConcept MeshType>
auto vcl::faceUniformPointSampling (const MeshType &m, uint nSamples, bool onlySelected=false, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<FaceMeshConcept MeshType>
auto vcl::faceUniformPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthFaces, bool onlySelected=false, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<FaceMeshConcept MeshType, typename ScalarType >
auto vcl::faceWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<FaceMeshConcept MeshType, typename ScalarType >
auto vcl::faceWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::vector< uint > &birthFaces, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<FaceMeshConcept MeshType>
auto vcl::montecarloPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<FaceMeshConcept MeshType>
auto vcl::montecarloPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthFaces, std::optional< uint > seed=std::nullopt)
 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<FaceMeshConcept MeshType>
auto vcl::montecarloPoissonPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 This function compute montecarlo distribution with an approximate number of samples exploiting the poisson distribution approximation of the binomial distribution.
 
template<FaceMeshConcept MeshType>
auto vcl::vertexAreaWeightedPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<MeshConcept MeshType>
auto vcl::vertexQualityWeightedPointSampling (const MeshType &m, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<MeshConcept MeshType>
auto vcl::vertexUniformPointSampling (const MeshType &m, uint nSamples, bool onlySelected=false, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<MeshConcept MeshType>
auto vcl::vertexUniformPointSampling (const MeshType &m, uint nSamples, std::vector< uint > &birthVertices, bool onlySelected=false, std::optional< uint > seed=std::nullopt)
 Returns a PointSampler 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<MeshConcept MeshType, typename ScalarType >
auto vcl::vertexWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::optional< uint > seed=std::nullopt)
 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<MeshConcept MeshType, typename ScalarType >
auto vcl::vertexWeightedPointSampling (const MeshType &m, const std::vector< ScalarType > &weights, uint nSamples, std::vector< uint > &birthVertices, std::optional< uint > seed=std::nullopt)
 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.
 

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<FaceMeshConcept MeshType>
auto vcl::allFacesPointSampling ( const MeshType &  m,
bool  onlySelected = false 
)

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

This function creates a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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 PointSampler object that contains the sampled points on the faces

◆ allFacesPointSampling() [2/2]

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

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

This function creates a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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 PointSampler object that contains the sampled points on the faces

◆ allVerticesPointSampling() [1/2]

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

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

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

Template Parameters
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 PointSampler object that contains the sampled vertices

◆ allVerticesPointSampling() [2/2]

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

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

This function creates a PointSampler 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
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 PointSampler object that contains the sampled vertices

◆ faceAreaWeightedPointSampling()

template<FaceMeshConcept MeshType>
auto vcl::faceAreaWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns

◆ faceQualityWeightedPointSampling()

template<FaceMeshConcept MeshType>
auto vcl::faceQualityWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns

◆ faceUniformPointSampling() [1/2]

template<FaceMeshConcept MeshType>
auto vcl::faceUniformPointSampling ( const MeshType &  m,
uint  nSamples,
bool  onlySelected = false,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ faceUniformPointSampling() [2/2]

template<FaceMeshConcept MeshType>
auto vcl::faceUniformPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthFaces,
bool  onlySelected = false,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ faceWeightedPointSampling() [1/2]

template<FaceMeshConcept MeshType, typename ScalarType >
auto vcl::faceWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ faceWeightedPointSampling() [2/2]

template<FaceMeshConcept MeshType, typename ScalarType >
auto vcl::faceWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::vector< uint > &  birthFaces,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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 sampled point on each face is the face barycenter.

Template Parameters
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ montecarloPointSampling() [1/2]

template<FaceMeshConcept MeshType>
auto vcl::montecarloPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
MeshTypeA type that satisfies the FaceMeshConcept
Parameters
[in]mThe mesh to sample from.
[in]nSamplesThe number of samples to take.
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ montecarloPointSampling() [2/2]

template<FaceMeshConcept MeshType>
auto vcl::montecarloPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthFaces,
std::optional< uint >  seed = std::nullopt 
)

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
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object that contains the sampled points on the faces.

◆ montecarloPoissonPointSampling()

template<FaceMeshConcept MeshType>
auto vcl::montecarloPoissonPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns

◆ vertexAreaWeightedPointSampling()

template<FaceMeshConcept MeshType>
auto vcl::vertexAreaWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns

◆ vertexQualityWeightedPointSampling()

template<MeshConcept MeshType>
auto vcl::vertexQualityWeightedPointSampling ( const MeshType &  m,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
[in]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns

◆ vertexUniformPointSampling() [1/2]

template<MeshConcept MeshType>
auto vcl::vertexUniformPointSampling ( const MeshType &  m,
uint  nSamples,
bool  onlySelected = false,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object containing the sampled vertices.

◆ vertexUniformPointSampling() [2/2]

template<MeshConcept MeshType>
auto vcl::vertexUniformPointSampling ( const MeshType &  m,
uint  nSamples,
std::vector< uint > &  birthVertices,
bool  onlySelected = false,
std::optional< uint >  seed = std::nullopt 
)

Returns a PointSampler 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
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object containing the sampled vertices.

◆ vertexWeightedPointSampling() [1/2]

template<MeshConcept MeshType, typename ScalarType >
auto vcl::vertexWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::optional< uint >  seed = std::nullopt 
)

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
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object containing the samples selected from the input mesh.

◆ vertexWeightedPointSampling() [2/2]

template<MeshConcept MeshType, typename ScalarType >
auto vcl::vertexWeightedPointSampling ( const MeshType &  m,
const std::vector< ScalarType > &  weights,
uint  nSamples,
std::vector< uint > &  birthVertices,
std::optional< uint >  seed = std::nullopt 
)

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
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]seedoptional value of seed, to get deterministic results. If not provided, a random seed is used.
Returns
A PointSampler object containing the samples selected from the input mesh.