lefer  0.1.0
A C++ library to draw evenly-spaced and non-overlapping curves in a flow field using the Jobard and Lefer (1997) algorithm.
Public Member Functions | List of all members
lefer::DensityGrid Class Reference

#include <lefer.hpp>

Public Member Functions

 DensityGrid (int flow_field_width, int flow_field_height, double d_sep, int cell_capacity)
 
int get_density_col (double x)
 
int get_density_row (double y)
 
int get_density_index (double x, double y)
 
int get_density_index (int col, int row)
 
bool off_boundaries (double x, double y)
 
void insert_coord (double x, double y)
 
void insert_curve_coords (Curve *curve)
 
bool is_valid_next_step (double x, double y)
 

Constructor & Destructor Documentation

◆ DensityGrid()

lefer::DensityGrid::DensityGrid ( int  flow_field_width,
int  flow_field_height,
double  d_sep,
int  cell_capacity 
)

The constructor for DensityGrid class

The Jobard and Lefer algortihm works around a "supporting" 2D grid, called of "density grid". Each cell (or coordinate) in this density grid is responsible for keeping tracking of curves that are already drawn into that specific area of the flow field.

In the cell_capacity argument, you can specify an amount of space you want to pre-allocate for each cell in the density grid before the algorithm starts to run. This might improve drawstically the performance of the algorithm, because you avoid the need for frequents resizing and reallocation of the std::vector objects that represents each cell.

In other words, if you pre-allocate enough space for each cell in the density grid, then, the algorithm does not have to spend time resizing the cell every time it hits the maximum capacity for that cell.

Parameters
flow_field_widththe width of the flow field.
flow_field_heightthe height of the flow field.
d_septhe "separation distance", i.e., the amount of distance that each curve must be from neighbouring curves.
cell_capacitythe capacity (or "space") you want to allocate for each cell in the density grid.

Member Function Documentation

◆ get_density_col()

int lefer::DensityGrid::get_density_col ( double  x)

◆ get_density_index() [1/2]

int lefer::DensityGrid::get_density_index ( double  x,
double  y 
)

◆ get_density_index() [2/2]

int lefer::DensityGrid::get_density_index ( int  col,
int  row 
)

◆ get_density_row()

int lefer::DensityGrid::get_density_row ( double  y)

◆ insert_coord()

void lefer::DensityGrid::insert_coord ( double  x,
double  y 
)

◆ insert_curve_coords()

void lefer::DensityGrid::insert_curve_coords ( Curve curve)

◆ is_valid_next_step()

bool lefer::DensityGrid::is_valid_next_step ( double  x,
double  y 
)

◆ off_boundaries()

bool lefer::DensityGrid::off_boundaries ( double  x,
double  y 
)

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