 |
Shiokaze Framework
A research-oriented fluid solver for computer graphics
|
|
Go to the documentation of this file.
57 m_core_name(core_name), m_shape(
shape), m_background_value(value) {
92 if( m_core_name.empty()) {
93 m_core_name = shkz_default_array_core2;
95 auto pos = m_core_name.find(
'*');
96 if( pos != std::string::npos ) {
97 m_core_name.erase(pos,1);
98 m_core_name.insert(pos,shkz_default_array_core2);
101 m_core = array_core2::quick_load_module(config,m_core_name);
105 m_core->recursive_configure(config);
108 virtual void post_initialize()
override {
148 m_core_name = array.m_core_name;
161 m_touch_only_actives = touch_only_actives;
170 if(
this != &array ) {
182 if(
this != &array ) {
186 m_core->copy(*array.
get_core(),[&](
void *target,
const void *src) {
187 new (target) T(*static_cast<const T *>(src));
199 const shape3 &s = m_shape;
200 std::vector<T> result(s.
count(),m_background_value);
202 result[i+j*s.
w] = it();
205 if( ! it.active()) result[i+j*s.
w] = it();
231 m_background_value = value;
234 m_is_initialized =
true;
245 m_background_value = bandwidth_half;
246 m_fill_value = -bandwidth_half;
257 m_fill_value = fill_value;
301 m_core->flood_fill([&](
const void *value_ptr) {
302 return *
static_cast<const T *
>(value_ptr) == m_fill_value;
304 }
else if( m_levelset ) {
305 m_core->flood_fill([&](
const void *value_ptr) {
306 return *
static_cast<const T *
>(value_ptr) < 0.0;
309 printf(
"Flood fill attempted without being set either levelset or fillable.\n");
320 std::vector<vec2i> result;
322 result.push_back(
vec2i(i,j));
350 return filled(pi[0],pi[1]);
358 size_t count ()
const {
return m_core->count(m_parallel); }
366 std::vector<vec2i> result;
368 result.push_back(
vec2i(i,j));
381 for(
const auto &e : active_entries ) {
382 const vec2i &pi = e + offset;
399 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
400 this->
set(pi,(*
this)(pi));
413 array.const_serial_actives([&](
int i,
int j) {
415 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
416 this->
set(pi,(*
this)(pi));
431 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
432 this->
set(pi,(*
this)(pi));
463 if( ! this->
shape().out_of_bounds(pi) ) {
505 m_background_value = v;
518 void set(
int i,
int j,
const T& value ) {
519 m_core->set(i,j,[&](
void *value_ptr,
bool &
active){
520 if( !
active )
new (value_ptr) T(value);
521 else *
static_cast<T *
>(value_ptr) = value;
534 set(pi[0],pi[1],value);
548 return (*m_core)(i,j,
filled) !=
nullptr;
559 return active(pi[0],pi[1]);
597 m_core->set(i,j,[&](
void *value_ptr,
bool &
active){
598 if(
active ) (
static_cast<T *
>(value_ptr))->~T();
622 m_core->set(i,j,[&](
void *value_ptr,
bool &
active){
623 if(
active ) *
static_cast<T *
>(value_ptr) += value;
625 *
static_cast<T *
>(value_ptr) = m_background_value + value;
652 m_core->set(i,j,[&](
void *value_ptr,
bool &
active){
653 if(
active ) *
static_cast<T *
>(value_ptr) -= value;
655 *
static_cast<T *
>(value_ptr) = m_background_value - value;
682 m_core->set(i,j,[&](
void *value_ptr,
bool &
active){
683 if(
active ) *
static_cast<T *
>(value_ptr) *= value;
685 *
static_cast<T *
>(value_ptr) = m_background_value * value;
711 void divide(
int i,
int j,
const T& value ) {
723 divide(pi[0],pi[1],value);
735 return const_cast<T *
>(
static_cast<const T *
>((*m_core)(i,j,
filled)));
745 const T*
ptr(
int i,
int j )
const {
755 return ptr(pi[0],pi[1]);
776 const T*
ptr =
static_cast<const T *
>((*m_core)(i,j,
filled));
778 else return filled ? m_fill_value : m_background_value;
787 return (*
const_cast<array2<T> *
>(
this))(pi[0],pi[1]);
798 return ! (*
this == array);
810 bool differnt (
false);
812 if( it() != v(i,j)) {
822 if( it() != v(i,j)) {
843 },m_touch_only_actives);
852 assert(shape()==v.
shape());
853 parallel_op([&](
int i,
int j,
iterator& it,
int tn) {
854 if( ! m_touch_only_actives || v.
active(i,j)) {
855 it.increment(v(i,j));
857 },m_touch_only_actives);
866 assert(shape()==v.
shape());
867 parallel_op([&](
int i,
int j,
iterator& it,
int tn) {
868 if( ! m_touch_only_actives || v.
active(i,j)) {
871 },m_touch_only_actives);
882 },m_touch_only_actives);
893 },m_touch_only_actives);
904 },m_touch_only_actives);
915 },m_touch_only_actives);
924 m_parallel.set_thread_num(number);
933 return m_parallel.get_thread_num();
946 void set(
const T &value ) {
947 if( ! m_active ) allocate(value);
948 else *
static_cast<T *
>(m_value_ptr) = value;
956 if( m_active && m_value_ptr ) deallocate();
967 *
static_cast<T *
>(m_value_ptr) += value;
969 allocate(m_background_value + value);
981 *
static_cast<T *
>(m_value_ptr) -= value;
983 allocate(m_background_value - value);
995 *
static_cast<T *
>(m_value_ptr) *= value;
997 allocate(m_background_value * value);
1032 return *
static_cast<const T *
>(m_value_ptr);
1034 return m_background_value;
1043 T*
ptr() {
return m_active ?
static_cast<T *
>(m_value_ptr) :
nullptr; }
1050 const T*
ptr()
const {
return m_active ?
static_cast<const T *
>(m_value_ptr) :
nullptr; }
1053 iterator(
void *value_ptr,
bool &_active,
bool _filled,
const T& m_background_value )
1054 : m_value_ptr(value_ptr), m_active(_active), m_filled(_filled), m_background_value(m_background_value) {}
1056 void allocate (
const T& value ) {
1057 new (m_value_ptr) T(value);
1060 (
static_cast<T *
>(m_value_ptr))->~T();
1065 const T& m_background_value;
1094 return *
static_cast<const T *
>(m_value_ptr);
1096 return m_background_value;
1105 const T*
ptr()
const {
return m_active ?
static_cast<const T *
>(m_value_ptr) :
nullptr; }
1107 const_iterator(
const void *value_ptr,
const bool &_active,
bool _filled,
const T& m_background_value )
1108 : m_value_ptr(value_ptr), m_active(_active), m_filled(_filled), m_background_value(m_background_value) {}
1110 const bool &m_active;
1112 const void *m_value_ptr;
1113 const T& m_background_value;
1116 enum { ACTIVES =
true, ALL =
false };
1194 if(
type == ACTIVES ) {
1195 m_core->parallel_actives([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_n ){
1197 func(i,j,it,thread_n);
1200 m_core->parallel_all([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_n ){
1202 func(i,j,it,thread_n);
1305 if(
type == ACTIVES ) {
1306 m_core->const_parallel_actives([&](
int i,
int j,
const void *value_ptr,
const bool &
filled,
int thread_n ){
1309 func(i,j,it,thread_n);
1312 m_core->const_parallel_all([&](
int i,
int j,
const void *value_ptr,
const bool &
active,
const bool &
filled,
int thread_n ){
1314 func(i,j,it,thread_n);
1325 m_core->const_parallel_inside([&](
int i,
int j,
const void *value_ptr,
const bool &
active,
int thread_n ){
1327 func(i,j,it,thread_n);
1380 if(
type == ACTIVES ) {
1381 m_core->serial_actives([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled ){
1387 m_core->serial_all([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled ){
1455 if(
type == ACTIVES ) {
1456 m_core->const_serial_actives([&](
int i,
int j,
const void *value_ptr,
const bool &
filled ){
1463 m_core->const_serial_all([&](
int i,
int j,
const void *value_ptr,
const bool &
active,
const bool &
filled ){
1477 m_core->const_serial_inside([&](
int i,
int j,
const void *value_ptr,
const bool &
active ){
1533 if(
type == ACTIVES ) {
1534 m_core->serial_actives([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled ){
1536 return func(i,j,it);
1539 m_core->serial_all([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled ){
1541 return func(i,j,it);
1606 if(
type == ACTIVES ) {
1607 m_core->const_serial_actives([&](
int i,
int j,
const void *value_ptr,
const bool &
filled ){
1610 return func(i,j,it);
1613 m_core->const_serial_all([&](
int i,
int j,
const void *value_ptr,
const bool &
active,
const bool &
filled ){
1615 return func(i,j,it);
1626 m_core->const_serial_inside([&](
int i,
int j,
const void *value_ptr,
const bool &
active ){
1628 return func(i,j,it);
1641 m_core->dilate([&](
int i,
int j,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_index) {
1643 func(i,j,it,thread_index);
1679 std::vector<std::vector<vec2i> > off_positions(
get_thread_num());
1683 bool exit_loop (
false);
1684 for(
int dim : DIMS2 ) {
1685 for(
int dir=-1; dir<=1; dir+=2 ) {
1687 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
1688 if( func(i,j,it,tn)) {
1689 off_positions[tn].push_back(
vec2i(i,j));
1695 if( exit_loop )
break;
1698 for(
const auto &bucket : off_positions )
for(
const auto &pi : bucket ) {
1713 return func(i,j,it);
1732 m_core.swap(rhs.m_core);
1733 std::swap(m_shape,rhs.m_shape);
1734 std::swap(m_background_value,rhs.m_background_value);
1735 std::swap(m_core_name,rhs.m_core_name);
1736 std::swap(m_touch_only_actives,rhs.m_touch_only_actives);
1737 std::swap(m_levelset,rhs.m_levelset);
1738 std::swap(m_fillable,rhs.m_fillable);
1739 std::swap(m_fill_value,rhs.m_fill_value);
1766 m_core_name = core_name;
1784 return m_core.
get();
1793 return m_core.
get();
1840 shape == rhs.
shape &&
1854 type2 type()
const {
return { get_core_name(),shape(),m_background_value,m_fill_value,m_fillable,m_levelset,m_touch_only_actives}; }
1863 m_shape = type.
shape;
1875 T m_background_value {T()}, m_fill_value {T()};
1876 bool m_touch_only_actives {
false}, m_fillable {
false}, m_levelset {
false}, m_is_initialized {
false};
1878 std::string m_core_name;
void set(const vec2i &pi, const T &value)
Set value on grid.
Definition: array2.h:533
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.
Definition: array2.h:1605
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.
Definition: array2.h:1589
unsigned w
Width of the shape.
Definition: shape.h:942
void operator-=(const T &v)
Subtract all the grid values with an input value.
Definition: array2.h:890
void erode(std::function< bool(int i, int j, const const_iterator &it)> func, int count=1)
Erode cells.
Definition: array2.h:1711
T fill_value
Fill value.
Definition: array2.h:1817
void parallel_actives(std::function< void(int i, int j, iterator &it)> func)
Loop over all the active cells in parallel.
Definition: array2.h:1150
bool operator==(const type2 &rhs) const
Comparison operator.
Definition: array2.h:1837
void parallel_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array2.h:1139
shape2 shape
Shape of the grid.
Definition: array2.h:1807
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.
Definition: array2.h:1567
void interruptible_serial_all(std::function< bool(int i, int j, iterator &it)> func)
Loop over all the cells in serial order.
Definition: array2.h:1523
const array_core2 * get_core() const
Get pointer to the core module.
Definition: array2.h:1783
void serial_all(std::function< void(int i, int j, iterator &it)> func)
Loop over all the cells in serial order.
Definition: array2.h:1370
void activate_all()
Activate all the cells.
Definition: array2.h:440
void parallel_all(std::function< void(int i, int j, iterator &it, int thread_index)> func)
Loop over all the cells in parallel.
Definition: array2.h:1184
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.
Definition: array2.h:1476
virtual bool send_message(std::string message, void *ptr=nullptr)
Send a message.
Definition: messageable.h:48
bool active(const vec2i &pi) const
Get if a position on grid is active.
Definition: array2.h:558
void operator/=(const T &v)
Divide all the grid values with an input value.
Definition: array2.h:912
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.
Definition: array2.h:1427
bool touch_only_actives
Are grid operations only allowed on active cells.
Definition: array2.h:1832
void increment(const T &value)
Increment value.
Definition: array2.h:965
void flood_fill()
Perform flood fill. Grid should be set either level set of fillable beforehand.
Definition: array2.h:299
void multiply(const vec2i &pi, const T &value)
Multiply value on grid.
Definition: array2.h:698
void interruptible_serial_actives(std::function< bool(int i, int j, iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array2.h:1516
void set_touch_only_actives(bool touch_only_actives)
Set whether to force grid manipulation only on active cells. If true, operatios such operator+=() onl...
Definition: array2.h:160
bool is_levelset
Is grid level set.
Definition: array2.h:1827
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
void set_as_fillable_as(const array2 &array)
Set the grid as fillable as same as an input array.
Definition: array2.h:265
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.
Definition: array2.h:1438
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.
Definition: array2.h:1295
void set_background_value(const T &value)
Set the background value (alternatively, initial value) of the grid.
Definition: array2.h:482
array2(recursive_configurable *parent, const shape2 &shape, T value=T(), std::string core_name="")
Constructor for array2.
Definition: array2.h:56
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.
Definition: array2.h:1407
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.
Definition: array2.h:1239
void interruptible_serial_all(std::function< bool(iterator &it)> func)
Loop over all the cells in serial order.
Definition: array2.h:1496
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.
Definition: array2.h:1596
array2(recursive_configurable *parent, std::string core_name="")
Constructor for array2.
Definition: array2.h:69
void set_off()
Inactivate a cell.
Definition: array2.h:955
void subtract(const vec2i &pi, const T &value)
Subtract value on grid.
Definition: array2.h:668
virtual void setup_now(configuration &config=get_global_configuration()) override
Run recursive_load - recursive_configure - recursive_initialize processes.
Definition: configurable.h:227
void set_off(int i, int j)
Set a position on grid inactive.
Definition: array2.h:596
void set(int i, int j, const T &value)
Set value on grid.
Definition: array2.h:518
size_t count() const
Function to count the number of active cells.
Definition: array2.h:358
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.
Definition: array2.h:1454
void divide(const T &value)
Divide by value.
Definition: array2.h:1007
void clear()
Clear out the grid.
Definition: array2.h:491
const T * ptr() const
Get const pointer to the value.
Definition: array2.h:1105
bool operator!=(const array2< T > &array) const
Return if the grid is different from an input array.
Definition: array2.h:797
void dilate(std::function< void(int i, int j, iterator &it)> func, int count=1)
Dilate cells.
Definition: array2.h:1655
bool active() const
Get if a cell is active.
Definition: array2.h:1014
array_core2 * get_core()
Get pointer to the core module.
Definition: array2.h:1792
array2(std::string core_name="")
Constructor for array2.
Definition: array2.h:76
void parallel_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in parallel.
Definition: array2.h:1123
Collection of properties of this grid.
Definition: array2.h:1797
void parallel_op(std::function< void(int i, int j, iterator &it, int thread_index)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array2.h:1193
size_t count() const
Count the number of cells of the grid of this shape.
Definition: shape.h:857
void serial_actives(std::function< void(int i, int j, iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array2.h:1363
bool is_levelset() const
Return if the grid is set level set.
Definition: array2.h:292
Structure that defines a three dimensional shape such as width, height and depth.
Definition: shape.h:478
void set(const T &value)
Set a value.
Definition: array2.h:946
T get_background_value() const
Get the background value (alternatively, initial value) of the grid.
Definition: array2.h:475
array2(const array2 &array)
Copy constructor for array2.
Definition: array2.h:147
T * ptr(const vec2i &pi)
Get the pointer to the value at a position on grid.
Definition: array2.h:754
void multiply(const T &value)
Multiply value.
Definition: array2.h:993
void serial_op(std::function< void(int i, int j, iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array2.h:1379
void serial_all(std::function< void(iterator &it)> func)
Loop over all the cells in serial order.
Definition: array2.h:1343
void serial_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array2.h:1352
void set_as_fillable(const T &fill_value)
Set the grid as a grid that is fillable by flood fill.
Definition: array2.h:254
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.
Definition: array2.h:1250
void set_as_levelset(double bandwidth_half)
Set the grid as level set.
Definition: array2.h:242
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: array2.h:1765
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.
Definition: array2.h:1266
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.
Definition: array2.h:1445
void increment(int i, int j, const T &value)
Increment value on grid.
Definition: array2.h:621
void subtract(const T &value)
Subtract value.
Definition: array2.h:979
void erode(int count=1)
Erode cells.
Definition: array2.h:1722
bool out_of_bounds(int i, int j) const
Get if the position is outside of the index space of this shape.
Definition: shape.h:341
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.
Definition: array2.h:1551
shape2 shape() const
Get the shape of the array.
Definition: array2.h:218
bool filled() const
Get if a cell is filled.
Definition: array2.h:1083
void interruptible_serial_op(std::function< bool(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array2.h:1505
unsigned h
Height of the shape.
Definition: shape.h:466
void multiply(int i, int j, const T &value)
Multiply value on grid.
Definition: array2.h:681
void set_thread_num(int number)
Set the number of threads for parallel processing on this grid.
Definition: array2.h:923
virtual bool const_send_message(std::string message, void *ptr=nullptr) const
Send a message.
Definition: messageable.h:59
const T & operator()() const
Get the value.
Definition: array2.h:1092
void set_as_levelset_as(const array2 &array)
Set the grid as level set as same as an input array.
Definition: array2.h:274
T background_value
Background value.
Definition: array2.h:1812
std::string get_core_name() const
Get the core name of module of this grid.
Definition: array2.h:1774
bool active(int i, int j) const
Get if a position on grid is active.
Definition: array2.h:546
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.
Definition: array2.h:396
const T * ptr(int i, int j) const
Get the const pointer to the value at a position on grid.
Definition: array2.h:745
const parallel_driver & get_parallel_driver() const
Get the const instance of parallel_driver of this grid.
Definition: array2.h:1756
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
void parallel_all(std::function< void(iterator &it)> func)
Loop over all the cells in parallel.
Definition: array2.h:1130
const T * ptr() const
Get const pointer to the value.
Definition: array2.h:1050
unsigned w
Width of the shape.
Definition: shape.h:461
void set_type(const type2 &type)
Set the type of this grid.
Definition: array2.h:1861
void activate(const std::vector< vec2i > &active_entries, const vec2i &offset=vec2i())
Activate cells at the positons of active_entries with an offset.
Definition: array2.h:380
void divide(int i, int j, const T &value)
Divide by value on grid.
Definition: array2.h:711
void operator*=(const T &v)
Multiply all the grid values with an input value.
Definition: array2.h:901
std::vector< vec2i > fills() const
Function to return the list of filled cells.
Definition: array2.h:319
void initialize(const shape2 &shape, T value=T())
Allocate grid memory with value.
Definition: array2.h:227
void interruptible_serial_actives(std::function< bool(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array2.h:1489
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.
Definition: array2.h:460
virtual void get(unsigned &nx, unsigned &ny, unsigned &element_size) const =0
Get grid information.
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: array2.h:125
void operator-=(const array2< T > &v)
Subtract all the values with the values of an input array.
Definition: array2.h:865
Core module class for two dimensional array designed to be used in array2 class.
Definition: array_core2.h:38
void swap(array2 &rhs)
Swap array.
Definition: array2.h:1731
void operator+=(const array2< T > &v)
Increment all the values with the values of an input array.
Definition: array2.h:851
void activate_inside()
Activate all the filled cells.
Definition: array2.h:449
bool filled() const
Get if a cell is filled.
Definition: array2.h:1021
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.
Definition: array2.h:1324
void set_off(const vec2i &pi)
Set a position on grid inactive.
Definition: array2.h:608
parallel_driver & get_parallel_driver()
Get the instance of parallel_driver of this grid.
Definition: array2.h:1747
bool is_fillable() const
Return if the grid is set fillable.
Definition: array2.h:283
const T & operator()(const vec2i &pi) const
Get the the value at a position on grid.
Definition: array2.h:786
void parallel_actives(std::function< void(int i, int j, iterator &it, int thread_index)> func)
Loop over all the active cells in parallel.
Definition: array2.h:1177
std::vector< T > linearize() const
Flatten this grid to a fully linearized one dimendional array, of which can be accessed like array[i+...
Definition: array2.h:198
void serial_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array2.h:1336
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.
Definition: array2.h:1625
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.
Definition: array2.h:412
void clear(const T &v)
Clear out the grid with the new backgroud value.
Definition: array2.h:504
void increment(const vec2i &pi, const T &value)
Increment value on grid.
Definition: array2.h:638
void dilate(std::function< void(int i, int j, iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: array2.h:1639
void operator+=(const T &v)
Increment all the grid values with an input value.
Definition: array2.h:879
Extended configurable class that holds multiple children of configurable.
Definition: configurable.h:126
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.
Definition: array2.h:428
bool is_fillable
Is grid fillable.
Definition: array2.h:1822
bool operator==(const array2< T > &v) const
Return if the grid is same to an input array.
Definition: array2.h:808
const T * ptr(const vec2i &pi) const
Get the const pointer to the value at a position on grid.
Definition: array2.h:763
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.
Definition: array2.h:1558
Fixed sized vector structure.
Definition: vec.h:38
void parallel_all(std::function< void(int i, int j, iterator &it)> func)
Loop over all the cells in parallel.
Definition: array2.h:1157
bool filled(const vec2i &pi) const
Function to get if a cell is filled.
Definition: array2.h:349
bool safe_active(const vec2i &pi) const
Get if a position on grid is active. pi can be safely out of the domain.
Definition: array2.h:585
Two dimensional array class designed to be defined as instance member in recursive_configurable class...
Definition: array2.h:42
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.
Definition: array2.h:1400
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.
Definition: array2.h:1277
Writable iterator.
Definition: array2.h:937
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.
Definition: array2.h:1304
Class that controls the settings of the program.
Definition: configuration.h:39
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.
Definition: array2.h:1416
Structure that defines shape such as width, height.
Definition: shape.h:42
const T & operator()(int i, int j) const
Get the the value at a position on grid.
Definition: array2.h:774
void erode(std::function< bool(int i, int j, const const_iterator &it, int thread_index)> func, int count=1)
Erode cells.
Definition: array2.h:1677
Message class.
Definition: messageable.h:36
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
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.
Definition: array2.h:1212
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: array2.h:932
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: array2.h:138
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.
Definition: array2.h:1288
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.
Definition: array2.h:1228
std::string core_name
Core name of the module.
Definition: array2.h:1802
void const_parallel_all(std::function< void(const const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: array2.h:1219
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.
Definition: array2.h:571
std::vector< vec2i > actives() const
Function to return the list of active cells positions.
Definition: array2.h:365
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.
Definition: array2.h:1578
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.
Definition: array2.h:1257
array2 & operator=(const array2 &array)
Deep copy operation for array2.
Definition: array2.h:169
T * ptr(int i, int j)
Get the pointer to the value at a position on grid.
Definition: array2.h:733
void operator=(const T &v)
Set all the grid values with an input value.
Definition: array2.h:840
void interruptible_serial_op(std::function< bool(int i, int j, iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array2.h:1532
T * ptr()
Get pointer to the value.
Definition: array2.h:1043
virtual void add_child(configurable *child)
Add a child instance.
Definition: configurable.h:191
void parallel_op(std::function< void(int i, int j, iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array2.h:1166
bool filled(int i, int j) const
Function to get if a cell is filled.
Definition: array2.h:336
const T & operator()() const
Get the value.
Definition: array2.h:1030
Read-only iterator.
Definition: array2.h:1069
void dilate(int count=1)
Dilate cells.
Definition: array2.h:1666
bool active() const
Get if a cell is active.
Definition: array2.h:1076
void copy(const array2 &array)
Deep copy function for array2.
Definition: array2.h:181
array2(const shape2 &shape, T value=T(), std::string core_name="")
Constructor for array2.
Definition: array2.h:87
type2 type() const
Get the type of this grid.
Definition: array2.h:1854
void subtract(int i, int j, const T &value)
Subtract value on grid.
Definition: array2.h:651
void divide(const vec2i &pi, const T &value)
Divide by value on grid.
Definition: array2.h:722