Core 1.0
DiscTile Class Reference

Poisson tiling. More...

#include <sampling.h>

Public Member Functions

 DiscTile ()
 Empty.
 
 DiscTile (const double &, const double &, const QVector< Vector2 > &)
 Create a Poisson disc sampling over a square domain.
 
 DiscTile (const double &, const double &, int, Random &=Random::R239)
 Create a poisson sampling in a square domain.
 
 DiscTile (const double &, const double &, int, const QVector< Vector2 > &, Random &=Random::R239)
 Create a poisson sampling in a square domain.
 
 ~DiscTile ()
 Empty.
 
void Relaxation (const double &=1.0/4.0)
 Perform a relaxation step over the Poisson-Disc distribution.
 
void Relaxation (int, const double &=1.0/4.0)
 Perform a relaxation step over the Poisson-Disc distribution.
 
void Scramble ()
 Scramble the points inside the generated tile.
 
void Draw (QGraphicsScene &) const
 Draw the distribution.
 
Box2 GetBox () const
 Return the box.
 
double Radius () const
 Return the radius.
 
Vector2 Vertex (int) const
 Getter on the i-th sample.
 
Vector2 Vertex (int, int, int) const
 Compute the i-th sample for a displaced tile.
 
Vector2 Vertex (const QPoint &, int) const
 Compute the i-th sample for a displaced tile.
 
const QVector< Vector2GetSet () const
 Return the vector containing the samples.
 
int Size () const
 Return the number of samples.
 
void Scale (const double &)
 Scale a disc tile.
 
QVector< Vector2Sample (const Box2 &, double(*)(const Vector2 &)) const
 Sample a domain according to an input importance function.
 
QVector< Vector2Sample (const ScalarField2 &) const
 Sample a domain according to an input importance function.
 
QVector< Vector2Sample (const Box2 &) const
 Sample a domain according to an input importance function.
 
double Packing () const
 Compute the packing density.
 

Static Public Member Functions

static bool Check (const Vector2 &, const QVector< Vector2 > &, double)
 Performs a Poisson disc check on a set of point and a candidate position.
 

Static Public Attributes

static const DiscTile UnitReference
 Reference unit disc tile with 231 discs.
 

Protected Member Functions

void Generate (int, Random &=Random::R239)
 Generate the poisson sampling of the domain.
 
bool Intersect (const Vector2 &, bool=true) const
 Check if a disc intersect existing discs inside the tile, with or without toric constraints.
 

Protected Attributes

double s = 0.0
 Size.
 
double r = 0.0
 Radius.
 
double e = 0.0
 Squared radius with small epsilon tolerance.
 
QVector< Vector2p
 Set of samples.
 

Friends

std::ostream & operator<< (std::ostream &s, const DiscTile &disctile)
 Overloaded.
 

Detailed Description

Poisson tiling.

Can be used for importance sampling from Template Poisson disk tiles, Ares Lagae, Philip Dutré. See Ares Lagae, Philip Dutré. A procedural object distribution function. ACM Transactions on Graphics. 24(4), 1442–1461.

Constructor & Destructor Documentation

◆ DiscTile() [1/4]

DiscTile::DiscTile ( )
explicit

Empty.

Initialize a poisson disc tiling.

◆ DiscTile() [2/4]

DiscTile::DiscTile ( const double & s,
const double & r,
const QVector< Vector2 > & v )
explicit

Create a Poisson disc sampling over a square domain.

Parameters
sSize of the side of the square.
rRadius of the samples.
vSet of points.

◆ DiscTile() [3/4]

DiscTile::DiscTile ( const double & s,
const double & r,
int n,
Random & ra = Random::R239 )
explicit

Create a poisson sampling in a square domain.

Parameters
sSize of the side of the square.
rRadius of the samples.
nMaximum number of samples in the dart throwing process. Note that the number of samples will be different.
raRandom number generator.

◆ DiscTile() [4/4]

DiscTile::DiscTile ( const double & s,
const double & r,
int n,
const QVector< Vector2 > & p,
Random & ra = Random::R239 )
explicit

Create a poisson sampling in a square domain.

Parameters
sSize of the side of the square.
rRadius of the samples.
nMaximum number of samples in the dart throwing process. Note that the number of samples will be different.
pSet of samples that will be in the tile.
raRandom number generator.

Member Function Documentation

◆ Check()

bool DiscTile::Check ( const Vector2 & p,
const QVector< Vector2 > & s,
double r )
static

Performs a Poisson disc check on a set of point and a candidate position.

Returns true if the candidate intersects with the distribution, false otherwise.

Parameters
pCandidate position.
sSet of point.
rPoisson disc radius.

◆ Draw()

void DiscTile::Draw ( QGraphicsScene & scene) const

Draw the distribution.

Parameters
sceneThe graphics scene.

◆ Generate()

void DiscTile::Generate ( int n,
Random & random = Random::R239 )
protected

Generate the poisson sampling of the domain.

Parameters
nNumber of darts thrown on the domain. Note that the number of generated samples will be less than n.
randomRandom number generator.

◆ Intersect()

bool DiscTile::Intersect ( const Vector2 & q,
bool t = true ) const
protected

Check if a disc intersect existing discs inside the tile, with or without toric constraints.

This complexity is O(n), thus the function is expensive should it be called many times.

Parameters
qPoint.
tToric constraint, set to true as default.

◆ Packing()

double DiscTile::Packing ( ) const

Compute the packing density.

See also
DiscTile::Packing()

◆ Relaxation() [1/2]

void DiscTile::Relaxation ( const double & c = 1.0 / 4.0)

Perform a relaxation step over the Poisson-Disc distribution.

Parameters
cRelaxation coefficient, it is the fraction of the Poisson radius.

◆ Relaxation() [2/2]

void DiscTile::Relaxation ( int n,
const double & c = 1.0 / 4.0 )

Perform a relaxation step over the Poisson-Disc distribution.

Parameters
cRelaxation coefficient, it the fraction of the radius of the Poisson distribution.
nNumber of steps.

◆ Sample() [1/3]

QVector< Vector2 > DiscTile::Sample ( const Box2 & box) const

Sample a domain according to an input importance function.

Parameters
boxThe box.

◆ Sample() [2/3]

QVector< Vector2 > DiscTile::Sample ( const Box2 & b,
double(* )(const Vector2 &) ) const

Sample a domain according to an input importance function.

Parameters
bThe box.
fImportance function.

◆ Sample() [3/3]

QVector< Vector2 > DiscTile::Sample ( const ScalarField2 & s) const

Sample a domain according to an input importance function.

Parameters
sScalar field defining the importance function.

◆ Scale()

void DiscTile::Scale ( const double & s)

Scale a disc tile.

Parameters
sScaling factor.

◆ Scramble()

void DiscTile::Scramble ( )

Scramble the points inside the generated tile.

Use a modified version of the Fisher-Yates algorithm.

See also
Shuffle::Table

◆ Vertex() [1/3]

Vector2 DiscTile::Vertex ( const QPoint & t,
int i ) const
inline

Compute the i-th sample for a displaced tile.

Parameters
tInteger coordinates of the tile.
iSample index.

◆ Vertex() [2/3]

Vector2 DiscTile::Vertex ( int i) const
inline

Getter on the i-th sample.

Parameters
iSample index.

◆ Vertex() [3/3]

Vector2 DiscTile::Vertex ( int x,
int y,
int i ) const
inline

Compute the i-th sample for a displaced tile.

Parameters
x,yInteger coordinates of the tile.
iSample index.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & s,
const DiscTile & disctile )
friend

Overloaded.

Parameters
sStream.
disctileThe disc tile.