 |
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_core3;
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_core3);
101 m_core = array_core3::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 + s.
w * (j + s.
h * k)] = it();
205 if( ! it.active()) result[i + s.
w * (j + s.
h * k)] = 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<vec3i> result;
322 result.push_back(
vec3i(i,j,k));
338 bool filled(
int i,
int j,
int k )
const {
352 return filled(pi[0],pi[1],pi[2]);
360 size_t count ()
const {
return m_core->count(m_parallel); }
368 std::vector<vec3i> result;
370 result.push_back(
vec3i(i,j,k));
383 for(
const auto &e : active_entries ) {
384 const vec3i &pi = e + offset;
401 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
402 this->
set(pi,(*
this)(pi));
415 array.const_serial_actives([&](
int i,
int j,
int k) {
417 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
418 this->
set(pi,(*
this)(pi));
433 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
434 this->
set(pi,(*
this)(pi));
465 if( ! this->
shape().out_of_bounds(pi) ) {
507 m_background_value = v;
522 void set(
int i,
int j,
int k,
const T& value ) {
523 m_core->set(i,j,k,[&](
void *value_ptr,
bool &
active){
524 if( !
active )
new (value_ptr) T(value);
525 else *
static_cast<T *
>(value_ptr) = value;
538 set(pi[0],pi[1],pi[2],value);
552 bool active(
int i,
int j,
int k )
const {
554 return (*m_core)(i,j,k,
filled) !=
nullptr;
565 return active(pi[0],pi[1],pi[2]);
605 m_core->set(i,j,k,[&](
void *value_ptr,
bool &
active){
606 if(
active ) (
static_cast<T *
>(value_ptr))->~T();
632 m_core->set(i,j,k,[&](
void *value_ptr,
bool &
active){
633 if(
active ) *
static_cast<T *
>(value_ptr) += value;
635 *
static_cast<T *
>(value_ptr) = m_background_value + value;
663 void subtract(
int i,
int j,
int k,
const T& value) {
664 m_core->set(i,j,k,[&](
void *value_ptr,
bool &
active){
665 if(
active ) *
static_cast<T *
>(value_ptr) -= value;
667 *
static_cast<T *
>(value_ptr) = m_background_value - value;
695 void multiply(
int i,
int j,
int k,
const T& value ) {
696 m_core->set(i,j,k,[&](
void *value_ptr,
bool &
active){
697 if(
active ) *
static_cast<T *
>(value_ptr) *= value;
699 *
static_cast<T *
>(value_ptr) = m_background_value * value;
727 void devide(
int i,
int j,
int k,
const T& value ) {
739 devide(pi[0],pi[1],pi[2],value);
751 T*
ptr(
unsigned i,
unsigned j,
unsigned k ) {
753 return const_cast<T *
>(
static_cast<const T *
>((*m_core)(i,j,k,
filled)));
765 const T*
ptr(
unsigned i,
unsigned j,
unsigned k )
const {
775 return ptr(pi[0],pi[1],pi[2]);
798 const T*
ptr =
static_cast<const T *
>((*m_core)(i,j,k,
filled));
800 else return filled ? m_fill_value : m_background_value;
809 return (*
const_cast<array3<T> *
>(
this))(pi[0],pi[1],pi[2]);
820 return ! (*
this == array);
832 bool differnt (
false);
834 if( it() != v(i,j,k)) {
844 if( it() != v(i,j,k)) {
865 },m_touch_only_actives);
874 assert(shape()==v.
shape());
875 parallel_op([&](
int i ,
int j,
int k,
iterator& it,
int tn) {
876 if( ! m_touch_only_actives || v.
active(i,j,k)) {
877 it.increment(v(i,j,k));
879 },m_touch_only_actives);
888 assert(shape()==v.
shape());
889 parallel_op([&](
int i,
int j,
int k,
iterator& it,
int tn) {
890 if( ! m_touch_only_actives || v.
active(i,j,k)) {
891 it.subtract(v(i,j,k));
893 },m_touch_only_actives);
904 },m_touch_only_actives);
915 },m_touch_only_actives);
926 },m_touch_only_actives);
937 },m_touch_only_actives);
946 m_parallel.set_thread_num(number);
955 return m_parallel.get_thread_num();
968 void set(
const T &value ) {
969 if( ! m_active ) allocate(value);
970 else *
static_cast<T *
>(m_value_ptr) = value;
978 if( m_active && m_value_ptr ) deallocate();
989 *
static_cast<T *
>(m_value_ptr) += value;
991 allocate(m_background_value + value);
1003 *
static_cast<T *
>(m_value_ptr) -= value;
1005 allocate(m_background_value - value);
1017 *
static_cast<T *
>(m_value_ptr) *= value;
1019 allocate(m_background_value * value);
1054 return *
static_cast<const T *
>(m_value_ptr);
1056 return m_background_value;
1065 T*
ptr() {
return m_active ?
static_cast<T *
>(m_value_ptr) :
nullptr; }
1072 const T*
ptr()
const {
return m_active ?
static_cast<const T *
>(m_value_ptr) :
nullptr; }
1074 iterator(
void *value_ptr,
bool &_active,
bool _filled,
const T& m_background_value )
1075 : m_value_ptr(value_ptr), m_active(_active), m_filled(_filled), m_background_value(m_background_value) {}
1077 void allocate (
const T& value ) {
1078 new (m_value_ptr) T(value);
1081 (
static_cast<T *
>(m_value_ptr))->~T();
1086 const T& m_background_value;
1115 return *
static_cast<const T *
>(m_value_ptr);
1117 return m_background_value;
1126 const T*
ptr()
const {
return m_active ?
static_cast<const T *
>(m_value_ptr) :
nullptr; }
1128 const_iterator(
const void *value_ptr,
const bool &_active,
bool _filled,
const T& m_background_value )
1129 : m_value_ptr(value_ptr), m_active(_active), m_filled(_filled), m_background_value(m_background_value) {}
1130 const bool &m_active;
1132 const void *m_value_ptr;
1133 const T& m_background_value;
1136 enum { ACTIVES =
true, ALL =
false };
1214 if(
type == ACTIVES ) {
1215 m_core->parallel_actives([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_n ){
1217 func(i,j,k,it,thread_n);
1220 m_core->parallel_all([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_n ){
1222 func(i,j,k,it,thread_n);
1325 if(
type == ACTIVES ) {
1326 m_core->const_parallel_actives([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
filled,
int thread_n ){
1329 func(i,j,k,it,thread_n);
1332 m_core->const_parallel_all([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active,
const bool &
filled,
int thread_n ){
1334 func(i,j,k,it,thread_n);
1345 m_core->const_parallel_inside([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active,
int thread_n ){
1347 func(i,j,k,it,thread_n);
1400 if(
type == ACTIVES ) {
1401 m_core->serial_actives([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled ){
1407 m_core->serial_all([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled ){
1475 if(
type == ACTIVES ) {
1476 m_core->const_serial_actives([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
filled ){
1483 m_core->const_serial_all([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active,
const bool &
filled ){
1497 m_core->const_serial_inside([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active ){
1553 if(
type == ACTIVES ) {
1554 m_core->serial_actives([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled ){
1556 return func(i,j,k,it);
1559 m_core->serial_all([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled ){
1561 return func(i,j,k,it);
1628 if(
type == ACTIVES ) {
1629 m_core->const_serial_actives([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
filled ){
1632 return func(i,j,k,it);
1635 m_core->const_serial_all([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active,
const bool &
filled ){
1637 return func(i,j,k,it);
1648 m_core->const_serial_inside([&](
int i,
int j,
int k,
const void *value_ptr,
const bool &
active ){
1650 return func(i,j,k,it);
1663 m_core->dilate([&](
int i,
int j,
int k,
void *value_ptr,
bool &
active,
const bool &
filled,
int thread_index) {
1665 func(i,j,k,it,thread_index);
1678 dilate([&](
int i,
int j,
int k,
iterator& it,
int thread_index) {
1701 std::vector<std::vector<vec3i> > off_positions(
get_thread_num());
1705 bool exit_loop (
false);
1706 for(
int dim : DIMS3 ) {
1707 for(
int dir=-1; dir<=1; dir+=2 ) {
1709 if( ! this->
shape().out_of_bounds(pi) && ! this->
active(pi)) {
1710 if( func(i,j,k,it,tn)) {
1711 off_positions[tn].push_back(
vec3i(i,j,k));
1717 if( exit_loop )
break;
1720 for(
const auto &bucket : off_positions )
for(
const auto &pi : bucket ) {
1735 return func(i,j,it);
1756 m_core.swap(rhs.m_core);
1757 std::swap(m_shape,rhs.m_shape);
1758 std::swap(m_background_value,rhs.m_background_value);
1759 std::swap(m_core_name,rhs.m_core_name);
1760 std::swap(m_touch_only_actives,rhs.m_touch_only_actives);
1761 std::swap(m_levelset,rhs.m_levelset);
1762 std::swap(m_fillable,rhs.m_fillable);
1763 std::swap(m_fill_value,rhs.m_fill_value);
1790 m_core_name = core_name;
1808 return m_core.
get();
1817 return m_core.
get();
1864 shape == rhs.
shape &&
1878 type3 type()
const {
return { get_core_name(),shape(),m_background_value,m_fill_value,m_fillable,m_levelset,m_touch_only_actives}; }
1887 m_shape = type.
shape;
1899 T m_background_value {T()}, m_fill_value {T()};
1900 bool m_touch_only_actives {
false}, m_fillable {
false}, m_levelset {
false}, m_is_initialized {
false};
1901 char m_levelset_halfwidth {0};
1903 std::string m_core_name;
array3(recursive_configurable *parent, const shape3 &shape, T value=T(), std::string core_name="")
Constructor for array3.
Definition: array3.h:56
void devide(int i, int j, int k, const T &value)
Divide by value on grid.
Definition: array3.h:727
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: array3.h:160
void flood_fill()
Perform flood fill. Grid should be set either level set of fillable beforehand.
Definition: array3.h:299
void operator=(const T &v)
Set all the grid values with an input value.
Definition: array3.h:862
unsigned w
Width of the shape.
Definition: shape.h:942
void increment(const T &value)
Increment value.
Definition: array3.h:987
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: array3.h:1436
void parallel_actives(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func)
Loop over all the active cells in parallel.
Definition: array3.h:1197
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: array3.h:1232
void dilate(int count=1)
Dilate cells.
Definition: array3.h:1688
bool filled() const
Get if a cell is filled.
Definition: array3.h:1104
std::string get_core_name() const
Get the core name of module of this grid.
Definition: array3.h:1798
void interruptible_serial_op(std::function< bool(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array3.h:1525
void copy_active_as(const array3< Y > &array, const vec3i &offset=vec3i())
Copy the states of active and inactive cells as same as input array with an offset.
Definition: array3.h:462
shape3 shape
Shape of the grid.
Definition: array3.h:1831
bool out_of_bounds(int i, int j, int k) const
Get if the position is outside of the index space of this shape.
Definition: shape.h:811
void interruptible_const_serial_actives(std::function< bool(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: array3.h:1611
virtual bool send_message(std::string message, void *ptr=nullptr)
Send a message.
Definition: messageable.h:48
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: array3.h:1571
void clear(const T &v)
Clear out the grid with the new backgroud value.
Definition: array3.h:506
void parallel_actives(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the active cells in parallel.
Definition: array3.h:1170
bool is_levelset() const
Return if the grid is set level set.
Definition: array3.h:292
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
Core module class for three dimensional array designed to be used in array3 class.
Definition: array_core3.h:38
void set(int i, int j, int k, const T &value)
Set value on grid.
Definition: array3.h:522
bool active(int i, int j, int k) const
Get if a position on grid is active.
Definition: array3.h:552
virtual void get(unsigned &nx, unsigned &ny, unsigned &nz, unsigned &element_size) const =0
Get grid information.
void activate_as_bit(const Y &array, const vec3i &offset=vec3i())
Activate cells at the same positons where an input array is active with an offset.
Definition: array3.h:414
void copy(const array3 &array)
Deep copy function for array3.
Definition: array3.h:181
void operator+=(const array3< T > &v)
Increment all the values with the values of an input array.
Definition: array3.h:873
bool safe_active(const vec3i &pi) const
Get if a position on grid is active. pi can be safely out of the domain.
Definition: array3.h:591
void set_background_value(const T &value)
Set the background value (alternatively, initial value) of the grid.
Definition: array3.h:484
void multiply(int i, int j, int k, const T &value)
Multiply value on grid.
Definition: array3.h:695
const T * ptr() const
Get const pointer to the value.
Definition: array3.h:1072
T get_background_value() const
Get the background value (alternatively, initial value) of the grid.
Definition: array3.h:477
virtual void setup_now(configuration &config=get_global_configuration()) override
Run recursive_load - recursive_configure - recursive_initialize processes.
Definition: configurable.h:227
const T * ptr(const vec3i &pi) const
Get the const pointer to the value at a position on grid.
Definition: array3.h:783
T background_value
Background value.
Definition: array3.h:1836
const T & operator()() const
Get the value.
Definition: array3.h:1113
void parallel_op(std::function< void(int i, int j, int k, iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array3.h:1186
T * ptr(const vec3i &pi)
Get the pointer to the value at a position on grid.
Definition: array3.h:774
void serial_all(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the cells in serial order.
Definition: array3.h:1390
bool active() const
Get if a cell is active.
Definition: array3.h:1097
void subtract(const vec3i &pi, const T &value)
Subtract value on grid.
Definition: array3.h:680
void const_parallel_all(std::function< void(int i, int j, int k, const const_iterator &it, int thread_index)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: array3.h:1315
const T & operator()() const
Get the value.
Definition: array3.h:1052
unsigned h
Height of the shape.
Definition: shape.h:947
const T & operator()(const vec3i &pi) const
Get the the value at a position on grid.
Definition: array3.h:808
void dilate(std::function< void(int i, int j, int k, iterator &it)> func, int count=1)
Dilate cells.
Definition: array3.h:1677
bool operator!=(const array3< T > &array) const
Return if the grid is different from an input array.
Definition: array3.h:819
void activate_as(const array3< Y > &array, const vec3i &offset=vec3i())
Activate cells at the same positons where an input array is active with an offset.
Definition: array3.h:398
void erode(std::function< bool(int i, int j, int k, const const_iterator &it, int thread_index)> func, int count=1)
Erode cells.
Definition: array3.h:1699
bool active(const vec3i &pi) const
Get if a position on grid is active.
Definition: array3.h:564
void set_as_fillable(const T &fill_value)
Set the grid as a grid that is fillable by flood fill.
Definition: array3.h:254
void clear()
Clear out the grid.
Definition: array3.h:493
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: array3.h:1789
size_t count() const
Count the number of cells of the grid of this shape.
Definition: shape.h:857
void set_off(int i, int j, int k)
Set a position on grid inactive.
Definition: array3.h:604
Read-only iterator.
Definition: array3.h:1090
void increment(const vec3i &pi, const T &value)
Increment value on grid.
Definition: array3.h:648
void operator*=(const T &v)
Multiply all the grid values with an input value.
Definition: array3.h:923
Structure that defines a three dimensional shape such as width, height and depth.
Definition: shape.h:478
void const_serial_actives(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: array3.h:1458
void const_serial_all(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: array3.h:1465
void serial_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array3.h:1372
void devide(const vec3i &pi, const T &value)
Divide by value on grid.
Definition: array3.h:738
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: array3.h:954
bool is_fillable() const
Return if the grid is set fillable.
Definition: array3.h:283
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: array3.h:1578
void serial_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array3.h:1356
unsigned d
Depth of the shape.
Definition: shape.h:952
void activate_inside_as(const array3< Y > &array, const vec3i &offset=vec3i())
Activate cells at the same positons where an input array is filled with an offset.
Definition: array3.h:430
void interruptible_serial_actives(std::function< bool(int i, int j, int k, iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array3.h:1536
void parallel_all(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func)
Loop over all the cells in parallel.
Definition: array3.h:1204
array3(const shape3 &shape, T value=T(), std::string core_name="")
Constructor for array3.
Definition: array3.h:87
const T & operator()(int i, int j, int k) const
Get the the value at a position on grid.
Definition: array3.h:796
void set_thread_num(int number)
Set the number of threads for parallel processing on this grid.
Definition: array3.h:945
bool is_levelset
Is grid level set.
Definition: array3.h:1851
void interruptible_const_serial_op(std::function< bool(int i, int j, int k, const const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: array3.h:1627
void operator/=(const T &v)
Divide all the grid values with an input value.
Definition: array3.h:934
void operator-=(const T &v)
Subtract all the grid values with an input value.
Definition: array3.h:912
bool operator==(const array3< T > &v) const
Return if the grid is same to an input array.
Definition: array3.h:830
virtual bool const_send_message(std::string message, void *ptr=nullptr) const
Send a message.
Definition: messageable.h:59
void const_parallel_actives(std::function< void(int i, int j, int k, const const_iterator &it, int thread_index)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: array3.h:1308
void swap(array3 &rhs)
Swap array.
Definition: array3.h:1755
const array_core3 * get_core() const
Get pointer to the core module.
Definition: array3.h:1807
void set_as_levelset_as(const array3 &array)
Set the grid as level set as same as an input array.
Definition: array3.h:274
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: array3.h:125
bool active() const
Get if a cell is active.
Definition: array3.h:1036
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
void set_off()
Inactivate a cell.
Definition: array3.h:977
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: array3.h:1420
void serial_actives(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array3.h:1383
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: array3.h:1248
void set_type(const type3 &type)
Set the type of this grid.
Definition: array3.h:1885
bool touch_only_actives
Are grid operations only allowed on active cells.
Definition: array3.h:1856
Collection of properties of this grid.
Definition: array3.h:1821
T * ptr()
Get pointer to the value.
Definition: array3.h:1065
void set_as_levelset(double bandwidth_half)
Set the grid as level set.
Definition: array3.h:242
array3(const array3 &array)
Copy constructor for array3.
Definition: array3.h:147
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: array3.h:1239
void operator+=(const T &v)
Increment all the grid values with an input value.
Definition: array3.h:901
void parallel_all(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the cells in parallel.
Definition: array3.h:1177
bool is_fillable
Is grid fillable.
Definition: array3.h:1846
void const_parallel_all(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the cells in parallel by read-only fashion.
Definition: array3.h:1277
const T * ptr(unsigned i, unsigned j, unsigned k) const
Get the const pointer to the value at a position on grid.
Definition: array3.h:765
void dilate(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: array3.h:1661
void const_parallel_actives(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: array3.h:1270
void interruptible_serial_all(std::function< bool(iterator &it)> func)
Loop over all the cells in serial order.
Definition: array3.h:1516
void multiply(const T &value)
Multiply value.
Definition: array3.h:1015
const T * ptr() const
Get const pointer to the value.
Definition: array3.h:1126
void const_serial_op(std::function< void(int i, int j, int k, const const_iterator &it)> func, bool type=ALL) const
Loop over cells in serial order by read-only fashion.
Definition: array3.h:1474
Writable iterator.
Definition: array3.h:959
T fill_value
Fill value.
Definition: array3.h:1841
bool operator==(const type3 &rhs) const
Comparison operator.
Definition: array3.h:1861
void interruptible_const_serial_all(std::function< bool(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the cells in serial order by read-only fashion.
Definition: array3.h:1618
const parallel_driver & get_parallel_driver() const
Get the const instance of parallel_driver of this grid.
Definition: array3.h:1780
void parallel_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in parallel.
Definition: array3.h:1143
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: array3.h:138
void const_parallel_inside(std::function< void(int i, int j, int k, const const_iterator &it, int thread_index)> func) const
Loop over all the filled cells in parallel.
Definition: array3.h:1344
void parallel_all(std::function< void(iterator &it)> func)
Loop over all the cells in parallel.
Definition: array3.h:1150
array3 & operator=(const array3 &array)
Deep copy operation for array3.
Definition: array3.h:169
void serial_all(std::function< void(iterator &it)> func)
Loop over all the cells in serial order.
Definition: array3.h:1363
bool safe_active(int i, int j, int k) const
Get if a position on grid is active. (i,j,k) can be safely out of the domain.
Definition: array3.h:577
void const_parallel_op(std::function< void(int i, int j, int k, const const_iterator &it, int thread_index)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: array3.h:1324
void const_parallel_inside(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the filled cells in parallel by read-only fashion.
Definition: array3.h:1297
size_t count() const
Function to count the number of active cells.
Definition: array3.h:360
void const_serial_inside(std::function< void(int i, int j, int k, const const_iterator &it)> func) const
Loop over filled the cells in serial order by read-only fashion.
Definition: array3.h:1496
void interruptible_serial_all(std::function< bool(int i, int j, int k, iterator &it)> func)
Loop over all the cells in serial order.
Definition: array3.h:1543
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: array3.h:1259
void parallel_op(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array3.h:1213
void increment(int i, int j, int k, const T &value)
Increment value on grid.
Definition: array3.h:631
bool filled() const
Get if a cell is filled.
Definition: array3.h:1043
Extended configurable class that holds multiple children of configurable.
Definition: configurable.h:126
std::vector< T > linearize() const
Flatten this grid to a fully linearized one dimendional array, of which can be accessed like array[i+...
Definition: array3.h:198
bool filled(int i, int j, int k) const
Function to get if a cell is filled.
Definition: array3.h:338
void interruptible_serial_actives(std::function< bool(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: array3.h:1509
bool filled(const vec3i &pi) const
Function to get if a cell is filled.
Definition: array3.h:351
void activate(const std::vector< vec3i > &active_entries, const vec3i &offset=vec3i())
Activate cells at the positons of active_entries with an offset.
Definition: array3.h:382
array3(recursive_configurable *parent, std::string core_name="")
Constructor for array3.
Definition: array3.h:69
Fixed sized vector structure.
Definition: vec.h:38
void initialize(const shape3 &shape, T value=T())
Allocate grid memory with value.
Definition: array3.h:227
void divide(const T &value)
Divide by value.
Definition: array3.h:1029
void set(const T &value)
Set a value.
Definition: array3.h:968
void parallel_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: array3.h:1159
void const_parallel_op(std::function< void(int i, int j, int k, const const_iterator &it)> func, bool type=ALL) const
Loop over cells in parallel by read-only fashion.
Definition: array3.h:1286
void set_off(const vec3i &pi)
Set a position on grid inactive.
Definition: array3.h:616
void erode(std::function< bool(int i, int j, int k, const const_iterator &it)> func, int count=1)
Erode cells.
Definition: array3.h:1733
Class that controls the settings of the program.
Definition: configuration.h:39
void set(const vec3i &pi, const T &value)
Set value on grid.
Definition: array3.h:537
Message class.
Definition: messageable.h:36
void interruptible_const_serial_inside(std::function< bool(const const_iterator &it)> func, bool type=ALL) const
Loop over all the filled cells in serial order by read-only fashion.
Definition: array3.h:1600
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
type3 type() const
Get the type of this grid.
Definition: array3.h:1878
std::vector< vec3i > actives() const
Function to return the list of active cells positions.
Definition: array3.h:367
void interruptible_serial_op(std::function< bool(int i, int j, int k, iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array3.h:1552
void subtract(int i, int j, int k, const T &value)
Subtract value on grid.
Definition: array3.h:663
array3(std::string core_name="")
Constructor for array3.
Definition: array3.h:76
std::vector< vec3i > fills() const
Function to return the list of filled cells.
Definition: array3.h:319
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: array3.h:1427
void serial_op(std::function< void(int i, int j, int k, iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: array3.h:1399
parallel_driver & get_parallel_driver()
Get the instance of parallel_driver of this grid.
Definition: array3.h:1771
void interruptible_const_serial_inside(std::function< bool(int i, int j, int k, const const_iterator &it)> func) const
Loop over all the filled cells in serial order by read-only fashion.
Definition: array3.h:1647
virtual void add_child(configurable *child)
Add a child instance.
Definition: configurable.h:191
array_core3 * get_core()
Get pointer to the core module.
Definition: array3.h:1816
void multiply(const vec3i &pi, const T &value)
Multiply value on grid.
Definition: array3.h:712
void activate_inside()
Activate all the filled cells.
Definition: array3.h:451
shape3 shape() const
Get the shape of the array.
Definition: array3.h:218
void subtract(const T &value)
Subtract value.
Definition: array3.h:1001
std::string core_name
Core name of the module.
Definition: array3.h:1826
T * ptr(unsigned i, unsigned j, unsigned k)
Get the pointer to the value at a position on grid.
Definition: array3.h:751
void operator-=(const array3< T > &v)
Subtract all the values with the values of an input array.
Definition: array3.h:887
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: array3.h:1447
void erode(int count=1)
Erode cells.
Definition: array3.h:1744
void set_as_fillable_as(const array3 &array)
Set the grid as fillable as same as an input array.
Definition: array3.h:265
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: array3.h:1587
void activate_all()
Activate all the cells.
Definition: array3.h:442
Three dimensional array class designed to be defined as instance member in recursive_configurable cla...
Definition: array3.h:42