Core 1.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
DiscTile Class Reference

Poisson tiling. More...

#include <sampling.h>

Public Member Functions

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

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. More...
 

Protected Member Functions

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

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.
 

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. <BF>24</BF>(4), 1442–1461.

Constructor & Destructor Documentation

◆ DiscTile() [1/3]

DiscTile::DiscTile ( )
explicit

Empty.

Initialize a poisson disc tiling.

◆ DiscTile() [2/3]

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() [3/3]

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 function performs in O(n) and is thus quite expensive should it be called many times.

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

◆ 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 &)  f 
) 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
bThe box.
sScalar field definin the importance function.

◆ 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/2]

Vector2 DiscTile::Vertex ( int  i) const
inline

Getter on the i-th sample.

Parameters
iSample index.

◆ Vertex() [2/2]

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

Compute the i-th sample for a displaced tile.

Parameters
iSample index.
x,yInteger coordinates of the tile