Shiokaze Framework
A research-oriented fluid solver for computer graphics
array2< T > Class Template Reference

Two dimensional array class designed to be defined as instance member in recursive_configurable class. More...

#include <array2.h>

Inheritance diagram for array2< T >:
recursive_configurable messageable configurable

Classes

class  const_iterator
 Read-only iterator. More...
 
class  iterator
 Writable iterator. More...
 
struct  type2
 Collection of properties of this grid. More...
 

Public Types

enum  { ACTIVES = true, ALL = false }
 
- Public Types inherited from configurable
using environment_map = std::map< std::string, const void * >
 Type for environment_map.
 

Public Member Functions

 array2 (recursive_configurable *parent, const shape2 &shape, T value=T(), std::string core_name="")
 Constructor for array2. More...
 
 array2 (recursive_configurable *parent, std::string core_name="")
 Constructor for array2. More...
 
 array2 (std::string core_name="")
 Constructor for array2. More...
 
 array2 (const shape2 &shape, T value=T(), std::string core_name="")
 Constructor for array2. More...
 
virtual bool send_message (std::string message, void *ptr) override
 Send a message to the core module. More...
 
virtual bool const_send_message (std::string message, void *ptr) const override
 Send a message to the core module. More...
 
 array2 (const array2 &array)
 Copy constructor for array2. More...
 
void set_touch_only_actives (bool touch_only_actives)
 Set whether to force grid manipulation only on active cells. If true, operatios such operator+=() only acts on active cells. More...
 
array2operator= (const array2 &array)
 Deep copy operation for array2. More...
 
void copy (const array2 &array)
 Deep copy function for array2. More...
 
std::vector< T > linearize () const
 Flatten this grid to a fully linearized one dimendional array, of which can be accessed like array[i+j*w]. More...
 
shape2 shape () const
 Get the shape of the array. More...
 
void initialize (const shape2 &shape, T value=T())
 Allocate grid memory with value. More...
 
void set_as_levelset (double bandwidth_half)
 Set the grid as level set. More...
 
void set_as_fillable (const T &fill_value)
 Set the grid as a grid that is fillable by flood fill. More...
 
void set_as_fillable_as (const array2 &array)
 Set the grid as fillable as same as an input array. More...
 
void set_as_levelset_as (const array2 &array)
 Set the grid as level set as same as an input array. More...
 
bool is_fillable () const
 Return if the grid is set fillable. More...
 
bool is_levelset () const
 Return if the grid is set level set. More...
 
void flood_fill ()
 Perform flood fill. Grid should be set either level set of fillable beforehand.
 
std::vector< vec2ifills () const
 Function to return the list of filled cells. More...
 
bool filled (int i, int j) const
 Function to get if a cell is filled. More...
 
bool filled (const vec2i &pi) const
 Function to get if a cell is filled. More...
 
size_t count () const
 Function to count the number of active cells. More...
 
std::vector< vec2iactives () const
 Function to return the list of active cells positions. More...
 
void activate (const std::vector< vec2i > &active_entries, const vec2i &offset=vec2i())
 Activate cells at the positons of active_entries with an offset. More...
 
template<class Y >
void activate_as (const array2< Y > &array, const vec2i &offset=vec2i())
 Activate cells at the same positons where an input array is active with an offset. More...
 
template<class Y >
void activate_as_bit (const Y &array, const vec2i &offset=vec2i())
 Activate cells at the same positons where an input array is active with an offset. More...
 
template<class Y >
void activate_inside_as (const array2< Y > &array, const vec2i &offset=vec2i())
 Activate cells at the same positons where an input array is filled with an offset. More...
 
void activate_all ()
 Activate all the cells.
 
void activate_inside ()
 Activate all the filled cells.
 
template<class Y >
void copy_active_as (const array2< Y > &array, const vec2i &offset=vec2i())
 Copy the states of active and inactive cells as same as input array with an offset. More...
 
get_background_value () const
 Get the background value (alternatively, initial value) of the grid.
 
void set_background_value (const T &value)
 Set the background value (alternatively, initial value) of the grid. More...
 
void clear ()
 Clear out the grid. More...
 
void clear (const T &v)
 Clear out the grid with the new backgroud value. More...
 
void set (int i, int j, const T &value)
 Set value on grid. More...
 
void set (const vec2i &pi, const T &value)
 Set value on grid. More...
 
bool active (int i, int j) const
 Get if a position on grid is active. More...
 
bool active (const vec2i &pi) const
 Get if a position on grid is active. More...
 
bool safe_active (int i, int j) const
 Get if a position on grid is active. (i,j) can be safely out of the domain. More...
 
bool safe_active (const vec2i &pi) const
 Get if a position on grid is active. pi can be safely out of the domain. More...
 
void set_off (int i, int j)
 Set a position on grid inactive. More...
 
void set_off (const vec2i &pi)
 Set a position on grid inactive. More...
 
void increment (int i, int j, const T &value)
 Increment value on grid. More...
 
void increment (const vec2i &pi, const T &value)
 Increment value on grid. More...
 
void subtract (int i, int j, const T &value)
 Subtract value on grid. More...
 
void subtract (const vec2i &pi, const T &value)
 Subtract value on grid. More...
 
void multiply (int i, int j, const T &value)
 Multiply value on grid. More...
 
void multiply (const vec2i &pi, const T &value)
 Multiply value on grid. More...
 
void divide (int i, int j, const T &value)
 Divide by value on grid. More...
 
void divide (const vec2i &pi, const T &value)
 Divide by value on grid. More...
 
T * ptr (int i, int j)
 Get the pointer to the value at a position on grid. More...
 
const T * ptr (int i, int j) const
 Get the const pointer to the value at a position on grid. More...
 
T * ptr (const vec2i &pi)
 Get the pointer to the value at a position on grid. More...
 
const T * ptr (const vec2i &pi) const
 Get the const pointer to the value at a position on grid. More...
 
const T & operator() (int i, int j) const
 Get the the value at a position on grid. More...
 
const T & operator() (const vec2i &pi) const
 Get the the value at a position on grid. More...
 
bool operator!= (const array2< T > &array) const
 Return if the grid is different from an input array. More...
 
bool operator== (const array2< T > &v) const
 Return if the grid is same to an input array. More...
 
void operator= (const T &v)
 Set all the grid values with an input value. More...
 
void operator+= (const array2< T > &v)
 Increment all the values with the values of an input array. More...
 
void operator-= (const array2< T > &v)
 Subtract all the values with the values of an input array. More...
 
void operator+= (const T &v)
 Increment all the grid values with an input value. More...
 
void operator-= (const T &v)
 Subtract all the grid values with an input value. More...
 
void operator*= (const T &v)
 Multiply all the grid values with an input value. More...
 
void operator/= (const T &v)
 Divide all the grid values with an input value. More...
 
void set_thread_num (int number)
 Set the number of threads for parallel processing on this grid. More...
 
int get_thread_num () const
 Get the current number of threads for parallel processing on this grid. More...
 
void parallel_actives (std::function< void(iterator &it)> func)
 Loop over all the active cells in parallel. More...
 
void parallel_all (std::function< void(iterator &it)> func)
 Loop over all the cells in parallel. More...
 
void parallel_op (std::function< void(iterator &it)> func, bool type=ALL)
 Loop over cells in parallel. More...
 
void parallel_actives (std::function< void(int i, int j, iterator &it)> func)
 Loop over all the active cells in parallel. More...
 
void parallel_all (std::function< void(int i, int j, iterator &it)> func)
 Loop over all the cells in parallel. More...
 
void parallel_op (std::function< void(int i, int j, iterator &it)> func, bool type=ALL)
 Loop over cells in parallel. More...
 
void parallel_actives (std::function< void(int i, int j, iterator &it, int thread_index)> func)
 Loop over all the active cells in parallel. More...
 
void parallel_all (std::function< void(int i, int j, iterator &it, int thread_index)> func)
 Loop over all the cells in parallel. More...
 
void parallel_op (std::function< void(int i, int j, iterator &it, int thread_index)> func, bool type=ALL)
 Loop over cells in parallel. More...
 
void const_parallel_actives (std::function< void(const const_iterator &it)> func) const
 Loop over all the active cells in parallel by read-only fashion. More...
 
void const_parallel_all (std::function< void(const const_iterator &it)> func) const
 Loop over all the cells in parallel by read-only fashion. More...
 
void const_parallel_op (std::function< void(const const_iterator &it)> func, bool type=ALL) const
 Loop over cells in parallel by read-only fashion. More...
 
void const_parallel_inside (std::function< void(const const_iterator &it)> func) const
 Loop over all the filled cells in parallel by read-only fashion. More...
 
void const_parallel_actives (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over all the active cells in parallel by read-only fashion. More...
 
void const_parallel_all (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over all the cells in parallel by read-only fashion. More...
 
void const_parallel_op (std::function< void(int i, int j, const const_iterator &it)> func, bool type=ALL) const
 Loop over cells in parallel by read-only fashion. More...
 
void const_parallel_inside (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over all the filled cells in parallel by read-only fashion. More...
 
void const_parallel_actives (std::function< void(int i, int j, const const_iterator &it, int thread_index)> func) const
 Loop over all the active cells in parallel by read-only fashion. More...
 
void const_parallel_all (std::function< void(int i, int j, const const_iterator &it, int thread_index)> func) const
 Loop over all the cells in parallel by read-only fashion. More...
 
void const_parallel_op (std::function< void(int i, int j, const const_iterator &it, int thread_index)> func, bool type=ALL) const
 Loop over cells in parallel by read-only fashion. More...
 
void const_parallel_inside (std::function< void(int i, int j, const const_iterator &it, int thread_index)> func) const
 Loop over all the filled cells in parallel. More...
 
void serial_actives (std::function< void(iterator &it)> func)
 Loop over all the active cells in serial order. More...
 
void serial_all (std::function< void(iterator &it)> func)
 Loop over all the cells in serial order. More...
 
void serial_op (std::function< void(iterator &it)> func, bool type=ALL)
 Loop over cells in serial order. More...
 
void serial_actives (std::function< void(int i, int j, iterator &it)> func)
 Loop over all the active cells in serial order. More...
 
void serial_all (std::function< void(int i, int j, iterator &it)> func)
 Loop over all the cells in serial order. More...
 
void serial_op (std::function< void(int i, int j, iterator &it)> func, bool type=ALL)
 Loop over cells in serial order. More...
 
void const_serial_actives (std::function< void(const const_iterator &it)> func) const
 Loop over all the active cells in serial order by read-only fashion. More...
 
void const_serial_all (std::function< void(const const_iterator &it)> func) const
 Loop over all the cells in serial order by read-only fashion. More...
 
void const_serial_op (std::function< void(const const_iterator &it)> func, bool type=ALL) const
 Loop over the cells in serial order by read-only fashion. More...
 
void const_serial_inside (std::function< void(const const_iterator &it)> func) const
 Loop over filled the cells in serial order by read-only fashion. More...
 
void const_serial_actives (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over all the active cells in serial order by read-only fashion. More...
 
void const_serial_all (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over all the cells in serial order by read-only fashion. More...
 
void const_serial_op (std::function< void(int i, int j, const const_iterator &it)> func, bool type=ALL) const
 Loop over cells in serial order by read-only fashion. More...
 
void const_serial_inside (std::function< void(int i, int j, const const_iterator &it)> func) const
 Loop over filled the cells in serial order by read-only fashion. More...
 
void interruptible_serial_actives (std::function< bool(iterator &it)> func)
 Loop over all the active cells in serial order. More...
 
void interruptible_serial_all (std::function< bool(iterator &it)> func)
 Loop over all the cells in serial order. More...
 
void interruptible_serial_op (std::function< bool(iterator &it)> func, bool type=ALL)
 Loop over cells in serial order. More...
 
void interruptible_serial_actives (std::function< bool(int i, int j, iterator &it)> func)
 Loop over all the active cells in serial order. More...
 
void interruptible_serial_all (std::function< bool(int i, int j, iterator &it)> func)
 Loop over all the cells in serial order. More...
 
void interruptible_serial_op (std::function< bool(int i, int j, iterator &it)> func, bool type=ALL)
 Loop over cells in serial order. More...
 
void interruptible_const_serial_actives (std::function< bool(const const_iterator &it)> func) const
 Loop over all the active cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_all (std::function< bool(const const_iterator &it)> func) const
 Loop over all the cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_op (std::function< bool(const const_iterator &it)> func, bool type=ALL) const
 Loop over cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_inside (std::function< bool(const const_iterator &it)> func) const
 Loop over all the filled cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_actives (std::function< bool(int i, int j, const const_iterator &it)> func) const
 Loop over all the active cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_all (std::function< bool(int i, int j, const const_iterator &it)> func) const
 Loop over all the cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_op (std::function< bool(int i, int j, const const_iterator &it)> func, bool type=ALL) const
 Loop over cells in serial order by read-only fashion. More...
 
void interruptible_const_serial_inside (std::function< bool(int i, int j, const const_iterator &it)> func) const
 Loop over all the filled cells in serial order by read-only fashion. More...
 
void dilate (std::function< void(int i, int j, iterator &it, int thread_index)> func, int count=1)
 Dilate cells. More...
 
void dilate (std::function< void(int i, int j, iterator &it)> func, int count=1)
 Dilate cells. More...
 
void dilate (int count=1)
 Dilate cells. More...
 
void erode (std::function< bool(int i, int j, const const_iterator &it, int thread_index)> func, int count=1)
 Erode cells. More...
 
void erode (std::function< bool(int i, int j, const const_iterator &it)> func, int count=1)
 Erode cells. More...
 
void erode (int count=1)
 Erode cells. More...
 
void swap (array2 &rhs)
 Swap array. More...
 
parallel_driverget_parallel_driver ()
 Get the instance of parallel_driver of this grid. More...
 
const parallel_driverget_parallel_driver () const
 Get the const instance of parallel_driver of this grid. More...
 
void set_core_name (std::string core_name)
 Set the core name of module of this grid. More...
 
std::string get_core_name () const
 Get the core name of module of this grid. More...
 
const array_core2get_core () const
 Get pointer to the core module. More...
 
array_core2get_core ()
 Get pointer to the core module. More...
 
type2 type () const
 Get the type of this grid. More...
 
void set_type (const type2 &type)
 Set the type of this grid. More...
 
- Public Member Functions inherited from recursive_configurable
 recursive_configurable ()=default
 Default constructor.
 
virtual void recursive_load (configuration &config)
 Load the program itself and relay the same to its children. Used to load files and libraries into memory. More...
 
virtual void recursive_configure (configuration &config)
 Configure the program itself and relay the same to its children. Used to load and set parameters. More...
 
virtual void recursive_initialize (const configurable::environment_map &environment=configurable::environment_map())
 Initialize the program itself and relay the same to its children. Used to get things ready for actual use. More...
 
virtual bool is_ready () const
 Get if the instance is initialized. More...
 
virtual void add_child (configurable *child)
 Add a child instance. More...
 
virtual void add_child (recursive_configurable *child)
 Add a child instance. More...
 
virtual void remove_child (configurable *child)
 Remove a child instance. More...
 
virtual void remove_child (recursive_configurable *child)
 Remove a child instance. More...
 
virtual void setup_now (configuration &config=get_global_configuration()) override
 Run recursive_load - recursive_configure - recursive_initialize processes.
 
virtual bool not_recursive () override
 Check if this instance is not derived from recursive_configurable. More...
 
void set_environment (std::string name, const void *value)
 Set the pointer to an environmental value associated with an input name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from configurable
static configurationset_global_configuration (const configuration &config)
 Assign the global settings of the program. More...
 
static configurationget_global_configuration ()
 Get the global settings of the program. More...
 
template<class T >
static const T & get_env (const environment_map &environment, std::string key)
 Extract an specified type of pointer from the input environment. More...
 
- Protected Member Functions inherited from configurable
bool check_set (const environment_map &environment, std::vector< std::string > names)
 Check if the values for a variable keys exist. More...
 

Detailed Description

template<class T>
class array2< T >

Two dimensional array class designed to be defined as instance member in recursive_configurable class.

Constructor & Destructor Documentation

◆ array2() [1/5]

template<class T >
array2< T >::array2 ( recursive_configurable parent,
const shape2 shape,
value = T(),
std::string  core_name = "" 
)
inline

Constructor for array2.

Parameters
[in]parentPointer to a parent recursive_configurable instance. Can be nullptr.
[in]shapeShape of the grid
[in]valueBackground value (initial value).
[in]core_nameCore module name. Default value is "tiledarray2".

◆ array2() [2/5]

template<class T >
array2< T >::array2 ( recursive_configurable parent,
std::string  core_name = "" 
)
inline

Constructor for array2.

Parameters
[in]parentPointer to a parent recursive_configurable instance. Can be nullptr.
[in]core_nameCore module name. Default value is "tiledarray2".

◆ array2() [3/5]

template<class T >
array2< T >::array2 ( std::string  core_name = "")
inline

Constructor for array2.

Parameters
[in]core_nameCore module name. Default value is "tiledarray2".

◆ array2() [4/5]

template<class T >
array2< T >::array2 ( const shape2 shape,
value = T(),
std::string  core_name = "" 
)
inline

Constructor for array2.

Parameters
[in]shapeShape of the grid
[in]valueBackground value (initial value).
[in]core_nameCore module name. Default value is "tiledarray2".

◆ array2() [5/5]

template<class T >
array2< T >::array2 ( const array2< T > &  array)
inline

Copy constructor for array2.

Parameters
[in]arrayReference to an instance of array to copy from.

Member Function Documentation

◆ activate()

template<class T >
void array2< T >::activate ( const std::vector< vec2i > &  active_entries,
const vec2i offset = vec2i() 
)
inline

Activate cells at the positons of active_entries with an offset.

Parameters
[in]active_entriesThe list of target positions to activate.
[in]offsetOffset applied to the active_entries.

◆ activate_as()

template<class T >
template<class Y >
void array2< T >::activate_as ( const array2< Y > &  array,
const vec2i offset = vec2i() 
)
inline

Activate cells at the same positons where an input array is active with an offset.

Parameters
[in]arrayTarget array.
[in]offsetOffset applied to the target array.

◆ activate_as_bit()

template<class T >
template<class Y >
void array2< T >::activate_as_bit ( const Y &  array,
const vec2i offset = vec2i() 
)
inline

Activate cells at the same positons where an input array is active with an offset.

Parameters
[in]arrayTarget array.
[in]offsetOffset applied to the target array.

◆ activate_inside_as()

template<class T >
template<class Y >
void array2< T >::activate_inside_as ( const array2< Y > &  array,
const vec2i offset = vec2i() 
)
inline

Activate cells at the same positons where an input array is filled with an offset.

Parameters
[in]arrayTarget array.
[in]offsetOffset applied to the target array.

◆ active() [1/2]

template<class T >
bool array2< T >::active ( const vec2i pi) const
inline

Get if a position on grid is active.

Parameters
[in]piposition on grid.
Returns
true if active flase if inactive.

◆ active() [2/2]

template<class T >
bool array2< T >::active ( int  i,
int  j 
) const
inline

Get if a position on grid is active.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
Returns
true if active flase if inactive.

◆ actives()

template<class T >
std::vector<vec2i> array2< T >::actives ( ) const
inline

Function to return the list of active cells positions.

Returns
The list of active cells positions.

◆ clear() [1/2]

template<class T >
void array2< T >::clear ( )
inline

Clear out the grid.

Note that size, the memory allocation, background values and the information regarding level set or fillable left intact.

◆ clear() [2/2]

template<class T >
void array2< T >::clear ( const T &  v)
inline

Clear out the grid with the new backgroud value.

Background values regarding level set and the fillable will be dicarded. Size and the memory allocation left intact.

◆ const_parallel_actives() [1/3]

template<class T >
void array2< T >::const_parallel_actives ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over all the active cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_actives() [2/3]

template<class T >
void array2< T >::const_parallel_actives ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the active cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_actives() [3/3]

template<class T >
void array2< T >::const_parallel_actives ( std::function< void(int i, int j, const const_iterator &it, int thread_index)>  func) const
inline

Loop over all the active cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_all() [1/3]

template<class T >
void array2< T >::const_parallel_all ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over all the cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_all() [2/3]

template<class T >
void array2< T >::const_parallel_all ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_all() [3/3]

template<class T >
void array2< T >::const_parallel_all ( std::function< void(int i, int j, const const_iterator &it, int thread_index)>  func) const
inline

Loop over all the cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_inside() [1/3]

template<class T >
void array2< T >::const_parallel_inside ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over all the filled cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_inside() [2/3]

template<class T >
void array2< T >::const_parallel_inside ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the filled cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_inside() [3/3]

template<class T >
void array2< T >::const_parallel_inside ( std::function< void(int i, int j, const const_iterator &it, int thread_index)>  func) const
inline

Loop over all the filled cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_parallel_op() [1/3]

template<class T >
void array2< T >::const_parallel_op ( std::function< void(const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ const_parallel_op() [2/3]

template<class T >
void array2< T >::const_parallel_op ( std::function< void(int i, int j, const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ const_parallel_op() [3/3]

template<class T >
void array2< T >::const_parallel_op ( std::function< void(int i, int j, const const_iterator &it, int thread_index)>  func,
bool  type = ALL 
) const
inline

Loop over cells in parallel by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ const_send_message()

template<class T >
virtual bool array2< T >::const_send_message ( std::string  message,
void *  ptr 
) const
inlineoverridevirtual

Send a message to the core module.

Parameters
[in]messageMessage
[in]ptrPointer to some value.
Returns
true if handled false otherwise.

Reimplemented from messageable.

◆ const_serial_actives() [1/2]

template<class T >
void array2< T >::const_serial_actives ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over all the active cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_actives() [2/2]

template<class T >
void array2< T >::const_serial_actives ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the active cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_all() [1/2]

template<class T >
void array2< T >::const_serial_all ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over all the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_all() [2/2]

template<class T >
void array2< T >::const_serial_all ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_inside() [1/2]

template<class T >
void array2< T >::const_serial_inside ( std::function< void(const const_iterator &it)>  func) const
inline

Loop over filled the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_inside() [2/2]

template<class T >
void array2< T >::const_serial_inside ( std::function< void(int i, int j, const const_iterator &it)>  func) const
inline

Loop over filled the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ const_serial_op() [1/2]

template<class T >
void array2< T >::const_serial_op ( std::function< void(const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ const_serial_op() [2/2]

template<class T >
void array2< T >::const_serial_op ( std::function< void(int i, int j, const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ copy()

template<class T >
void array2< T >::copy ( const array2< T > &  array)
inline

Deep copy function for array2.

Parameters
[in]arrayReference to an instance of array to copy from.

◆ copy_active_as()

template<class T >
template<class Y >
void array2< T >::copy_active_as ( const array2< Y > &  array,
const vec2i offset = vec2i() 
)
inline

Copy the states of active and inactive cells as same as input array with an offset.

Parameters
[in]arrayTarget input array from which the states to be copied.
[in]offsetOffset

◆ count()

template<class T >
size_t array2< T >::count ( ) const
inline

Function to count the number of active cells.

Returns
Active cell count.

◆ dilate() [1/3]

template<class T >
void array2< T >::dilate ( int  count = 1)
inline

Dilate cells.

Parameters
[in]countNumber of dilation count.

◆ dilate() [2/3]

template<class T >
void array2< T >::dilate ( std::function< void(int i, int j, iterator &it)>  func,
int  count = 1 
)
inline

Dilate cells.

Parameters
[in]funcFunction that specifies what value to assign on dilated cells.
[in]countNumber of dilation count.

◆ dilate() [3/3]

template<class T >
void array2< T >::dilate ( std::function< void(int i, int j, iterator &it, int thread_index)>  func,
int  count = 1 
)
inline

Dilate cells.

Parameters
[in]funcFunction that specifies what value to assign on dilated cells.
[in]countNumber of dilation count.

◆ divide() [1/2]

template<class T >
void array2< T >::divide ( const vec2i pi,
const T &  value 
)
inline

Divide by value on grid.

Parameters
[in]piposition on grid.
[in]valueValue to divide at the position.

◆ divide() [2/2]

template<class T >
void array2< T >::divide ( int  i,
int  j,
const T &  value 
)
inline

Divide by value on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
[in]valueValue to divide at the position.

◆ erode() [1/3]

template<class T >
void array2< T >::erode ( int  count = 1)
inline

Erode cells.

Parameters
[in]countNumber of erode count.

◆ erode() [2/3]

template<class T >
void array2< T >::erode ( std::function< bool(int i, int j, const const_iterator &it)>  func,
int  count = 1 
)
inline

Erode cells.

Parameters
[in]funcFunction that specifies whether to inactivate the cell.
[in]countNumber of erode count.

◆ erode() [3/3]

template<class T >
void array2< T >::erode ( std::function< bool(int i, int j, const const_iterator &it, int thread_index)>  func,
int  count = 1 
)
inline

Erode cells.

Parameters
[in]funcFunction that specifies whether to inactivate the cell.
[in]countNumber of erode count.

◆ filled() [1/2]

template<class T >
bool array2< T >::filled ( const vec2i pi) const
inline

Function to get if a cell is filled.

Parameters
[in]piposition.
Returns
true if the cell is filled false if not.

◆ filled() [2/2]

template<class T >
bool array2< T >::filled ( int  i,
int  j 
) const
inline

Function to get if a cell is filled.

Parameters
[in]ix coordinate position.
[in]jy coordinate position.
Returns
true if the cell is filled false if not.

◆ fills()

template<class T >
std::vector<vec2i> array2< T >::fills ( ) const
inline

Function to return the list of filled cells.

Returns
The list of filled cells.

◆ get_core() [1/2]

template<class T >
array_core2* array2< T >::get_core ( )
inline

Get pointer to the core module.

Returns
Pointer to the core module.

◆ get_core() [2/2]

template<class T >
const array_core2* array2< T >::get_core ( ) const
inline

Get pointer to the core module.

Returns
Pointer to the core module.

◆ get_core_name()

template<class T >
std::string array2< T >::get_core_name ( ) const
inline

Get the core name of module of this grid.

Returns
Name of the core name.

◆ get_parallel_driver() [1/2]

template<class T >
parallel_driver& array2< T >::get_parallel_driver ( )
inline

Get the instance of parallel_driver of this grid.

Returns
Instance of parallel_driver of this grid.

◆ get_parallel_driver() [2/2]

template<class T >
const parallel_driver& array2< T >::get_parallel_driver ( ) const
inline

Get the const instance of parallel_driver of this grid.

Returns
Const instance of parallel_driver of this grid.

◆ get_thread_num()

template<class T >
int array2< T >::get_thread_num ( ) const
inline

Get the current number of threads for parallel processing on this grid.

Returns
number Number of threads.

◆ increment() [1/2]

template<class T >
void array2< T >::increment ( const vec2i pi,
const T &  value 
)
inline

Increment value on grid.

Parameters
[in]piposition on grid
[in]valueValue to increment at the position.

◆ increment() [2/2]

template<class T >
void array2< T >::increment ( int  i,
int  j,
const T &  value 
)
inline

Increment value on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
[in]valueValue to increment at the position.

◆ initialize()

template<class T >
void array2< T >::initialize ( const shape2 shape,
value = T() 
)
inline

Allocate grid memory with value.

Parameters
[in]shapeShape of the grid.
[in]valueInitial value

◆ interruptible_const_serial_actives() [1/2]

template<class T >
void array2< T >::interruptible_const_serial_actives ( std::function< bool(const const_iterator &it)>  func) const
inline

Loop over all the active cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_actives() [2/2]

template<class T >
void array2< T >::interruptible_const_serial_actives ( std::function< bool(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the active cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_all() [1/2]

template<class T >
void array2< T >::interruptible_const_serial_all ( std::function< bool(const const_iterator &it)>  func) const
inline

Loop over all the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_all() [2/2]

template<class T >
void array2< T >::interruptible_const_serial_all ( std::function< bool(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_inside() [1/2]

template<class T >
void array2< T >::interruptible_const_serial_inside ( std::function< bool(const const_iterator &it)>  func) const
inline

Loop over all the filled cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_inside() [2/2]

template<class T >
void array2< T >::interruptible_const_serial_inside ( std::function< bool(int i, int j, const const_iterator &it)>  func) const
inline

Loop over all the filled cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_const_serial_op() [1/2]

template<class T >
void array2< T >::interruptible_const_serial_op ( std::function< bool(const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.
[in]typeType of target cells. ACTIVE or ALL. Stop the loop if return true.

◆ interruptible_const_serial_op() [2/2]

template<class T >
void array2< T >::interruptible_const_serial_op ( std::function< bool(int i, int j, const const_iterator &it)>  func,
bool  type = ALL 
) const
inline

Loop over cells in serial order by read-only fashion.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.
[in]typeType of target cells. ACTIVE or ALL. Stop the loop if return true.

◆ interruptible_serial_actives() [1/2]

template<class T >
void array2< T >::interruptible_serial_actives ( std::function< bool(int i, int j, iterator &it)>  func)
inline

Loop over all the active cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_serial_actives() [2/2]

template<class T >
void array2< T >::interruptible_serial_actives ( std::function< bool(iterator &it)>  func)
inline

Loop over all the active cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_serial_all() [1/2]

template<class T >
void array2< T >::interruptible_serial_all ( std::function< bool(int i, int j, iterator &it)>  func)
inline

Loop over all the cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_serial_all() [2/2]

template<class T >
void array2< T >::interruptible_serial_all ( std::function< bool(iterator &it)>  func)
inline

Loop over all the cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.

◆ interruptible_serial_op() [1/2]

template<class T >
void array2< T >::interruptible_serial_op ( std::function< bool(int i, int j, iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL. Stop the loop if return true.

◆ interruptible_serial_op() [2/2]

template<class T >
void array2< T >::interruptible_serial_op ( std::function< bool(iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed. Stop the loop if return true.
[in]typeType of target cells. ACTIVE or ALL.

◆ is_fillable()

template<class T >
bool array2< T >::is_fillable ( ) const
inline

Return if the grid is set fillable.

Returns
Whether the grid is set fillable.

◆ is_levelset()

template<class T >
bool array2< T >::is_levelset ( ) const
inline

Return if the grid is set level set.

Returns
Whether the grid is set level set.

◆ linearize()

template<class T >
std::vector<T> array2< T >::linearize ( ) const
inline

Flatten this grid to a fully linearized one dimendional array, of which can be accessed like array[i+j*w].

Returns
Flattened linearized array.

◆ multiply() [1/2]

template<class T >
void array2< T >::multiply ( const vec2i pi,
const T &  value 
)
inline

Multiply value on grid.

Parameters
[in]piposition on grid.
[in]valueValue to multiply at the position.

◆ multiply() [2/2]

template<class T >
void array2< T >::multiply ( int  i,
int  j,
const T &  value 
)
inline

Multiply value on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
[in]valueValue to multiply at the position.

◆ operator!=()

template<class T >
bool array2< T >::operator!= ( const array2< T > &  array) const
inline

Return if the grid is different from an input array.

Parameters
[in]arrayTarget array to compare.
Returns
true if the array is different from the input array and false otherwise.

◆ operator()() [1/2]

template<class T >
const T& array2< T >::operator() ( const vec2i pi) const
inline

Get the the value at a position on grid.

Parameters
[in]piposition on grid.

◆ operator()() [2/2]

template<class T >
const T& array2< T >::operator() ( int  i,
int  j 
) const
inline

Get the the value at a position on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.

◆ operator*=()

template<class T >
void array2< T >::operator*= ( const T &  v)
inline

Multiply all the grid values with an input value.

Parameters
[in]vValue to multiply.

◆ operator+=() [1/2]

template<class T >
void array2< T >::operator+= ( const array2< T > &  v)
inline

Increment all the values with the values of an input array.

Parameters
[in]vInput array.

◆ operator+=() [2/2]

template<class T >
void array2< T >::operator+= ( const T &  v)
inline

Increment all the grid values with an input value.

Parameters
[in]vValue to increment.

◆ operator-=() [1/2]

template<class T >
void array2< T >::operator-= ( const array2< T > &  v)
inline

Subtract all the values with the values of an input array.

Parameters
[in]vInput array.

◆ operator-=() [2/2]

template<class T >
void array2< T >::operator-= ( const T &  v)
inline

Subtract all the grid values with an input value.

Parameters
[in]vValue to subtract.

◆ operator/=()

template<class T >
void array2< T >::operator/= ( const T &  v)
inline

Divide all the grid values with an input value.

Parameters
[in]vValue to divide.

◆ operator=() [1/2]

template<class T >
array2& array2< T >::operator= ( const array2< T > &  array)
inline

Deep copy operation for array2.

Parameters
[in]arrayReference to an instance of array to copy from.

◆ operator=() [2/2]

template<class T >
void array2< T >::operator= ( const T &  v)
inline

Set all the grid values with an input value.

Parameters
[in]vInput value to set.

◆ operator==()

template<class T >
bool array2< T >::operator== ( const array2< T > &  v) const
inline

Return if the grid is same to an input array.

Parameters
[in]vTarget array to compare.
Returns
true if the array is the same to the input and false otherwise.

◆ parallel_actives() [1/3]

template<class T >
void array2< T >::parallel_actives ( std::function< void(int i, int j, iterator &it)>  func)
inline

Loop over all the active cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_actives() [2/3]

template<class T >
void array2< T >::parallel_actives ( std::function< void(int i, int j, iterator &it, int thread_index)>  func)
inline

Loop over all the active cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_actives() [3/3]

template<class T >
void array2< T >::parallel_actives ( std::function< void(iterator &it)>  func)
inline

Loop over all the active cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_all() [1/3]

template<class T >
void array2< T >::parallel_all ( std::function< void(int i, int j, iterator &it)>  func)
inline

Loop over all the cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_all() [2/3]

template<class T >
void array2< T >::parallel_all ( std::function< void(int i, int j, iterator &it, int thread_index)>  func)
inline

Loop over all the cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_all() [3/3]

template<class T >
void array2< T >::parallel_all ( std::function< void(iterator &it)>  func)
inline

Loop over all the cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ parallel_op() [1/3]

template<class T >
void array2< T >::parallel_op ( std::function< void(int i, int j, iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ parallel_op() [2/3]

template<class T >
void array2< T >::parallel_op ( std::function< void(int i, int j, iterator &it, int thread_index)>  func,
bool  type = ALL 
)
inline

Loop over cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ parallel_op() [3/3]

template<class T >
void array2< T >::parallel_op ( std::function< void(iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in parallel.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ ptr() [1/4]

template<class T >
T* array2< T >::ptr ( const vec2i pi)
inline

Get the pointer to the value at a position on grid.

Parameters
[in]piposition on grid.

◆ ptr() [2/4]

template<class T >
const T* array2< T >::ptr ( const vec2i pi) const
inline

Get the const pointer to the value at a position on grid.

Parameters
[in]piposition on grid.

◆ ptr() [3/4]

template<class T >
T* array2< T >::ptr ( int  i,
int  j 
)
inline

Get the pointer to the value at a position on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.

◆ ptr() [4/4]

template<class T >
const T* array2< T >::ptr ( int  i,
int  j 
) const
inline

Get the const pointer to the value at a position on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.

◆ safe_active() [1/2]

template<class T >
bool array2< T >::safe_active ( const vec2i pi) const
inline

Get if a position on grid is active. pi can be safely out of the domain.

Parameters
[in]piposition on grid.
Returns
true if active flase if inactive.

◆ safe_active() [2/2]

template<class T >
bool array2< T >::safe_active ( int  i,
int  j 
) const
inline

Get if a position on grid is active. (i,j) can be safely out of the domain.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
Returns
true if active flase if inactive.

◆ send_message()

template<class T >
virtual bool array2< T >::send_message ( std::string  message,
void *  ptr 
)
inlineoverridevirtual

Send a message to the core module.

Parameters
[in]messageMessage
[in]ptrPointer to some value.
Returns
true if handled false otherwise.

Reimplemented from messageable.

◆ serial_actives() [1/2]

template<class T >
void array2< T >::serial_actives ( std::function< void(int i, int j, iterator &it)>  func)
inline

Loop over all the active cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ serial_actives() [2/2]

template<class T >
void array2< T >::serial_actives ( std::function< void(iterator &it)>  func)
inline

Loop over all the active cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ serial_all() [1/2]

template<class T >
void array2< T >::serial_all ( std::function< void(int i, int j, iterator &it)>  func)
inline

Loop over all the cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ serial_all() [2/2]

template<class T >
void array2< T >::serial_all ( std::function< void(iterator &it)>  func)
inline

Loop over all the cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.

◆ serial_op() [1/2]

template<class T >
void array2< T >::serial_op ( std::function< void(int i, int j, iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ serial_op() [2/2]

template<class T >
void array2< T >::serial_op ( std::function< void(iterator &it)>  func,
bool  type = ALL 
)
inline

Loop over cells in serial order.

Parameters
[in]funcFunction that defines how each grid cell is processed.
[in]typeType of target cells. ACTIVE or ALL.

◆ set() [1/2]

template<class T >
void array2< T >::set ( const vec2i pi,
const T &  value 
)
inline

Set value on grid.

Parameters
[in]piposition on grid
[in]valueValue to set at the position.

◆ set() [2/2]

template<class T >
void array2< T >::set ( int  i,
int  j,
const T &  value 
)
inline

Set value on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
[in]valueValue to set at the position.

◆ set_as_fillable()

template<class T >
void array2< T >::set_as_fillable ( const T &  fill_value)
inline

Set the grid as a grid that is fillable by flood fill.

Parameters
[in]fill_valuefill_value

◆ set_as_fillable_as()

template<class T >
void array2< T >::set_as_fillable_as ( const array2< T > &  array)
inline

Set the grid as fillable as same as an input array.

Parameters
[in]arrayInput array to mimic the fillable properties.

◆ set_as_levelset()

template<class T >
void array2< T >::set_as_levelset ( double  bandwidth_half)
inline

Set the grid as level set.

Parameters
[in]bandwidth_halfhalf bandwidth size of the level set.

◆ set_as_levelset_as()

template<class T >
void array2< T >::set_as_levelset_as ( const array2< T > &  array)
inline

Set the grid as level set as same as an input array.

Parameters
[in]arrayInput array to mimic the level set properties.

◆ set_background_value()

template<class T >
void array2< T >::set_background_value ( const T &  value)
inline

Set the background value (alternatively, initial value) of the grid.

Parameters
[in]valueNew background value

◆ set_core_name()

template<class T >
void array2< T >::set_core_name ( std::string  core_name)
inline

Set the core name of module of this grid.

Parameters
[in]Nameof the core name.

◆ set_off() [1/2]

template<class T >
void array2< T >::set_off ( const vec2i pi)
inline

Set a position on grid inactive.

Parameters
[in]piposition on grid

◆ set_off() [2/2]

template<class T >
void array2< T >::set_off ( int  i,
int  j 
)
inline

Set a position on grid inactive.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.

◆ set_thread_num()

template<class T >
void array2< T >::set_thread_num ( int  number)
inline

Set the number of threads for parallel processing on this grid.

Parameters
[in]numberNumber of threads.

◆ set_touch_only_actives()

template<class T >
void array2< T >::set_touch_only_actives ( bool  touch_only_actives)
inline

Set whether to force grid manipulation only on active cells. If true, operatios such operator+=() only acts on active cells.

Parameters
[in]touch_only_activesWhether to turn this on or off.

◆ set_type()

template<class T >
void array2< T >::set_type ( const type2 type)
inline

Set the type of this grid.

Parameters
[in]typeAn instance of type to set.

◆ shape()

template<class T >
shape2 array2< T >::shape ( ) const
inline

Get the shape of the array.

Returns
Shape of the array.

◆ subtract() [1/2]

template<class T >
void array2< T >::subtract ( const vec2i pi,
const T &  value 
)
inline

Subtract value on grid.

Parameters
[in]piposition on grid.
[in]valueValue to subtract at the position.

◆ subtract() [2/2]

template<class T >
void array2< T >::subtract ( int  i,
int  j,
const T &  value 
)
inline

Subtract value on grid.

Parameters
[in]iposition on x coordiante.
[in]jposition on y coordinate.
[in]valueValue to subtract at the position.

◆ swap()

template<class T >
void array2< T >::swap ( array2< T > &  rhs)
inline

Swap array.

Parameters
[in]rhsArray to swap.

◆ type()

template<class T >
type2 array2< T >::type ( ) const
inline

Get the type of this grid.

Returns
Type of this grid.

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