VCG Library
Static Public Member Functions | List of all members
vcg::tri::SurfaceSampling< MeshType, VertexSampler > Class Template Reference

Main Class of the Sampling framework. More...

#include <point_sampling.h>

Static Public Member Functions

static int Poisson (double lambda)
 
static void VertexWeighted (MeshType &m, VertexSampler &ps, int sampleNum)
 
static void VertexAreaUniform (MeshType &m, VertexSampler &ps, int sampleNum)
 
static void VertexUniform (MeshType &m, VertexSampler &ps, int sampleNum, bool onlySelected)
 Sample the vertices in a uniform way. Each vertex has the same probabiltiy of being chosen.
 
static void EdgeMeshUniform (MeshType &m, VertexSampler &ps, float radius, bool conservative=true)
 
static void VertexBorderCorner (MeshType &m, VertexSampler &ps, ScalarType angleRad)
 Sample all the border corner vertices.
 
static void VertexBorder (MeshType &m, VertexSampler &ps)
 Sample all the border vertices.
 
static void VertexCrease (MeshType &m, VertexSampler &ps)
 
static void MontecarloPoisson (MeshType &m, VertexSampler &ps, int sampleNum)
 
static void EdgeMontecarlo (MeshType &m, VertexSampler &ps, int sampleNum, bool sampleAllEdges)
 
static void Montecarlo (MeshType &m, VertexSampler &ps, int sampleNum)
 
static void WeightedMontecarlo (MeshType &m, VertexSampler &ps, int sampleNum, float variance)
 
static void FaceSubdivision (MeshType &m, VertexSampler &ps, int sampleNum, bool randSample)
 Compute a sampling of the surface where the points are regularly scattered over the face surface using a recursive longest-edge subdivision rule.
 
static void FaceSubdivisionOld (MeshType &m, VertexSampler &ps, int sampleNum, bool randSample)
 Compute a sampling of the surface where the points are regularly scattered over the face surface using a recursive longest-edge subdivision rule.
 
static ScalarType ComputePoissonDiskRadius (MeshType &origMesh, int sampleNum)
 Estimate the radius r that you should give to get a certain number of samples in a Poissson Disk Distribution of radius r.
 
static void InitRadiusHandleFromQuality (MeshType &sampleMesh, PerVertexFloatAttribute &rH, ScalarType diskRadius, ScalarType radiusVariance, bool invert)
 
static void PoissonDiskPruning (VertexSampler &ps, MeshType &montecarloMesh, ScalarType diskRadius, PoissonDiskParam &pp)
 
static void HierarchicalPoissonDisk (MeshType &origMesh, VertexSampler &ps, MeshType &montecarloMesh, ScalarType diskRadius, const struct PoissonDiskParam pp=PoissonDiskParam())
 

Detailed Description

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
class vcg::tri::SurfaceSampling< MeshType, VertexSampler >

Main Class of the Sampling framework.

This class allows you to perform various kind of random/procedural point sampling over a triangulated surface. The class is templated over the PointSampler object that allows to customize the use of the generated samples.

Definition at line 465 of file point_sampling.h.

Member Function Documentation

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static ScalarType vcg::tri::SurfaceSampling< MeshType, VertexSampler >::ComputePoissonDiskRadius ( MeshType &  origMesh,
int  sampleNum 
)
inlinestatic

Estimate the radius r that you should give to get a certain number of samples in a Poissson Disk Distribution of radius r.

Definition at line 1739 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::EdgeMeshUniform ( MeshType &  m,
VertexSampler &  ps,
float  radius,
bool  conservative = true 
)
inlinestatic

Perform an uniform sampling over an EdgeMesh.

It assumes that the mesh is 1-manifold. each connected component is sampled in a independent way. For each component of lenght <L> we place on it floor(L/radius)+1 samples. (if conservative argument is false we place ceil(L/radius)+1 samples)

Definition at line 765 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::EdgeMontecarlo ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum,
bool  sampleAllEdges 
)
inlinestatic

This function computes a montecarlo distribution with an EXACT number of samples. it works by generating a sequence of consecutive segments proportional to the triangle areas and actually shooting sample over this line

Definition at line 1084 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::FaceSubdivision ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum,
bool  randSample 
)
inlinestatic

Compute a sampling of the surface where the points are regularly scattered over the face surface using a recursive longest-edge subdivision rule.

Definition at line 1260 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::FaceSubdivisionOld ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum,
bool  randSample 
)
inlinestatic

Compute a sampling of the surface where the points are regularly scattered over the face surface using a recursive longest-edge subdivision rule.

Definition at line 1351 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::HierarchicalPoissonDisk ( MeshType &  origMesh,
VertexSampler &  ps,
MeshType &  montecarloMesh,
ScalarType  diskRadius,
const struct PoissonDiskParam  pp = PoissonDiskParam() 
)
inlinestatic

Compute a Poisson-disk sampling of the surface. The radius of the disk is computed according to the estimated sampling density.

This algorithm is an adaptation of the algorithm of White et al. :

"Poisson Disk Point Set by Hierarchical Dart Throwing" K. B. White, D. Cline, P. K. Egbert, IEEE Symposium on Interactive Ray Tracing, 2007, 10-12 Sept. 2007, pp. 129-132.

Definition at line 1973 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::InitRadiusHandleFromQuality ( MeshType &  sampleMesh,
PerVertexFloatAttribute &  rH,
ScalarType  diskRadius,
ScalarType  radiusVariance,
bool  invert 
)
inlinestatic

When performing an adptive pruning for each sample we expect a varying radius to be removed. The radius is a PerVertex attribute that we compute from the current quality

the expected radius of the sample is computed so that it linearly maps the quality between diskradius and diskradius*variance in other words the radius

Definition at line 1768 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::Montecarlo ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum 
)
inlinestatic

This function computes a montecarlo distribution with an EXACT number of samples. it works by generating a sequence of consecutive segments proportional to the triangle areas and actually shooting sample over this line

Definition at line 1125 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::MontecarloPoisson ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum 
)
inlinestatic

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 = np can be used as an approximation to B(n,p) (it works if n is sufficiently large and p is sufficiently small).

Definition at line 1058 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static int vcg::tri::SurfaceSampling< MeshType, VertexSampler >::Poisson ( double  lambda)
inlinestatic

algorithm poisson random number (Knuth): init: Let L ← e^−λ, k ← 0 and p ← 1. do: k ← k + 1. Generate uniform random number u in [0,1] and let p ← p × u. while p > L. return k − 1.

Definition at line 610 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::PoissonDiskPruning ( VertexSampler &  ps,
MeshType &  montecarloMesh,
ScalarType  diskRadius,
PoissonDiskParam &  pp 
)
inlinestatic

This is the main function that is used to build a poisson distribuition starting from a dense sample cloud (the montecarloMesh) by 'pruning' it. it puts all the samples in a hashed UG and randomly choose a sample and remove all the points in the sphere centered on the chosen sample

You can impose some constraint: all the vertices in the montecarloMesh that are marked with a bool attribute called "fixed" are surely chosen (if you also set the preGenFlag option)

Definition at line 1885 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexAreaUniform ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum 
)
inlinestatic

Sample the vertices in a uniform way. Each vertex has a probability of being chosen that is proportional to the area it represent.

Definition at line 688 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexBorder ( MeshType &  m,
VertexSampler &  ps 
)
inlinestatic

Sample all the border vertices.

It assumes that the border flag have been set over the mesh. All the vertices on the border are sampled.

Definition at line 902 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexBorderCorner ( MeshType &  m,
VertexSampler &  ps,
ScalarType  angleRad 
)
inlinestatic

Sample all the border corner vertices.

It assumes that the border flag have been set over the mesh both for vertex and for faces. All the vertices on the border where the edges of the boundary of the surface forms an angle smaller than the given threshold are sampled. It assumes that the Per-Vertex border Flag has been set.

Definition at line 888 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexCrease ( MeshType &  m,
VertexSampler &  ps 
)
inlinestatic

Sample all the crease vertices. It assumes that the crease edges had been marked as non-faux edges for example by using tri::UpdateFlags<MeshType>::FaceFauxCrease(mesh,creaseAngleRad); Then it chooses all the vertices where there are at least three non faux edges.

Definition at line 913 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexUniform ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum,
bool  onlySelected 
)
inlinestatic

Sample the vertices in a uniform way. Each vertex has the same probabiltiy of being chosen.

Definition at line 730 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::VertexWeighted ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum 
)
inlinestatic

Sample the vertices in a weighted way. Each vertex has a probability of being chosen that is proportional to its quality. It assumes that you are asking a number of vertices smaller than nv; Algorithm: 1) normalize quality so that sum q == 1; 2) shuffle vertices. 3) for each vertices choose it if rand > thr;

Definition at line 650 of file point_sampling.h.

template<class MeshType, class VertexSampler = TrivialSampler< MeshType>>
static void vcg::tri::SurfaceSampling< MeshType, VertexSampler >::WeightedMontecarlo ( MeshType &  m,
VertexSampler &  ps,
int  sampleNum,
float  variance 
)
inlinestatic

Compute a sampling of the surface that is weighted by the quality and a variance

We use the quality as linear distortion of density. We consider each triangle as scaled between 1 and 1/variance linearly according quality.

In practice with variance 2 the average distance between sample will double where the quality is maxima. If you have two same area region A with q==-1 and B with q==1, if variance==2 the A will have 4 times more samples than B

Definition at line 1168 of file point_sampling.h.


The documentation for this class was generated from the following file: