Shiokaze Framework
A research-oriented fluid solver for computer graphics
bitarray3.h
Go to the documentation of this file.
1 /*
2 ** bitarray3.h
3 **
4 ** This is part of Shiokaze, a research-oriented fluid solver for computer graphics.
5 ** Created by Ryoichi Ando <rand@nii.ac.jp> on August 8, 2018.
6 **
7 ** Permission is hereby granted, free of charge, to any person obtaining a copy of
8 ** this software and associated documentation files (the "Software"), to deal in
9 ** the Software without restriction, including without limitation the rights to use,
10 ** copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
11 ** Software, and to permit persons to whom the Software is furnished to do so,
12 ** subject to the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included in all copies
15 ** or substantial portions of the Software.
16 **
17 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21 ** CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22 ** OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24 //
25 #ifndef SHKZ_BITARRAY3_H
26 #define SHKZ_BITARRAY3_H
27 //
28 #include <shiokaze/math/vec.h>
30 #include <cassert>
31 #include <cstdio>
32 #include <algorithm>
33 #include <utility>
34 #include <shiokaze/math/shape.h>
35 #include "array_core3.h"
36 //
38 //
39 template <class T> class array3;
41 class bitarray3 : public recursive_configurable, public messageable {
44 public:
55  bitarray3( recursive_configurable *parent, const shape3 &shape, std::string core_name="" ) :
56  m_core_name(core_name), m_shape(shape) {
57  if( parent ) parent->add_child(this);
58  else setup_now();
59  }
68  bitarray3( recursive_configurable *parent, std::string core_name="" ) : bitarray3(parent,shape3(0,0,0),core_name) {}
75  bitarray3( std::string core_name="" ) : bitarray3(nullptr,shape3(0,0,0),core_name) {}
84  bitarray3( const shape3 &shape, std::string core_name="" ) : bitarray3(nullptr,shape,core_name) {}
85  //
86 private:
87  //
88  virtual void load( configuration &config ) override {
89  if( m_core_name.empty()) {
90  m_core_name = shkz_default_array_core3;
91  } else {
92  auto pos = m_core_name.find('*');
93  if( pos != std::string::npos ) {
94  m_core_name.erase(pos,1);
95  m_core_name.insert(pos,shkz_default_array_core3);
96  }
97  }
98  m_core = array_core3::quick_load_module(config,m_core_name);
99  }
100  //
101  virtual void configure( configuration &config ) override {
102  m_core->recursive_configure(config);
103  }
104  //
105  virtual void post_initialize() override {
106  if( shape().count() && ! m_is_initialized ) {
107  initialize(m_shape);
108  }
109  }
110  //
111 public:
122  virtual bool send_message( std::string message, void *ptr ) override {
123  return get_core()->send_message(message,ptr);
124  }
135  virtual bool const_send_message( std::string message, void *ptr ) const override {
136  return get_core()->const_send_message(message,ptr);
137  }
144  bitarray3( const bitarray3 &array ) {
145  m_core_name = array.m_core_name;
146  setup_now();
147  copy(array);
148  }
155  bitarray3& operator=(const bitarray3 &array) {
156  if( this != &array ) {
157  copy(array);
158  }
159  return *this;
160  }
167  void copy( const bitarray3 &array ) {
168  if( this != &array ) {
169  set_type(array.type());
170  assert(m_core);
171  if( array.m_core ) {
172  m_core->copy(*array.get_core(),[&](void *target, const void *src){},m_parallel);
173  }
174  }
175  }
176  virtual ~bitarray3() {
177  clear();
178  }
185  shape3 shape() const { return m_shape; }
192  void initialize( const shape3 &shape ) {
193  clear();
194  m_core->initialize(shape.w,shape.h,shape.d,0);
195  m_shape = shape;
196  m_is_initialized = true;
197  }
204  size_t count () const { return m_core->count(m_parallel); }
205  std::vector<vec3i> actives() const {
206  std::vector<vec3i> result;
207  const_serial_actives([&](int i, int j, int k) {
208  result.push_back(vec3i(i,j,k));
209  });
210  return result;
211  }
220  void activate( const std::vector<vec3i> &active_entries, const vec3i &offset=vec3i() ) {
221  for( const auto &e : active_entries ) {
222  const vec3i &pi = e + offset;
223  if( ! shape().out_of_bounds(pi) && ! (*this)(pi)) {
224  set(pi);
225  }
226  }
227  }
236  template <class Y> void activate_as( const array3<Y> &array, const vec3i &offset=vec3i() ) {
237  array.const_serial_actives([&](int i, int j, int k, const auto &it) {
238  const vec3i &pi = vec3i(i,j,k) + offset;
239  if( ! this->shape().out_of_bounds(pi) && ! (*this)(pi)) {
240  this->set(pi);
241  }
242  });
243  }
252  template <class Y> void activate_as_bit( const Y &array, const vec3i &offset=vec3i() ) {
253  array.const_serial_actives([&](int i, int j, int k) {
254  const vec3i &pi = vec3i(i,j,k) + offset;
255  if( ! this->shape().out_of_bounds(pi) && ! (*this)(pi)) {
256  this->set(pi);
257  }
258  });
259  }
268  template <class Y> void activate_inside_as( const array3<Y> &array, const vec3i &offset=vec3i() ) {
269  array.const_serial_inside([&](int i, int j, int k, const auto &it) {
270  const vec3i &pi = vec3i(i,j,k) + offset;
271  if( ! this->shape().out_of_bounds(pi) && ! (*this)(pi)) {
272  this->set(pi);
273  }
274  });
275  }
280  void activate_all() {
281  parallel_all([&](auto &it) {
282  it.set();
283  });
284  }
293  void copy_active_as( const bitarray3 &array, const vec3i &offset=vec3i() ) {
294  parallel_actives([&](int i, int j, int k, auto &it, int tn) {
295  const vec3i &pi = vec3i(i,j,k) + offset;
296  if( ! this->shape().out_of_bounds(pi) ) {
297  if( (*this)(pi) && ! array(pi)) {
298  it.set_off();
299  }
300  }
301  });
302  activate_as_bit(array,offset);
303  }
312  void clear() {
313  parallel_actives([&](iterator& it) {
314  it.set_off();
315  });
316  }
327  void set( int i, int j, int k ) {
328  m_core->set(i,j,k,[&](void *value_ptr, bool &active){
329  active = true;
330  });
331  }
338  void set( const vec3i &pi ) {
339  set(pi[0],pi[1],pi[2]);
340  }
353  bool operator()( int i, int j, int k ) const {
354  bool filled (false);
355  return (*m_core)(i,j,k,filled) != nullptr;
356  }
365  bool operator()( const vec3i &pi ) const {
366  return (*this)(pi[0],pi[1],pi[2]);
367  }
380  bool safe_get( int i, int j, int k ) const {
381  if( ! m_shape.out_of_bounds(i,j,k)) {
382  return (*this)(i,j,k);
383  }
384  return false;
385  }
394  bool safe_get( const vec3i &pi ) const {
395  return (*this)(pi[0],pi[1],pi[2]);
396  }
407  void set_off( int i, int j, int k ) {
408  m_core->set(i,j,k,[&](void *value_ptr, bool &active){
409  active = false;
410  });
411  }
418  void set_off( const vec3i &pi ) {
419  set_off(pi[0],pi[1],pi[2]);
420  }
429  bool operator!=( const bitarray3 &array ) const {
430  return ! (*this == array);
431  }
440  bool operator==(const bitarray3 &v) const {
441  if( v.type() == type() ) {
442  bool differnt (false);
443  interruptible_const_serial_actives([&]( int i, int j, int k) {
444  if( ! v(i,j,k)) {
445  differnt = true;
446  return true;
447  } else {
448  return false;
449  }
450  });
451  return ! differnt;
452  }
453  return false;
454  }
461  void set_thread_num( int number ) {
462  m_parallel.set_thread_num(number);
463  }
470  int get_thread_num() const {
471  return m_parallel.get_thread_num();
472  }
475  class iterator {
476  friend class bitarray3;
477  public:
484  void set() {
485  m_active = true;
486  }
491  void set_off() {
492  m_active = false;
493  }
498  bool operator()() const {
499  return m_active;
500  }
501  private:
502  iterator( bool &_active ) : m_active(_active) {}
503  bool &m_active;
504  };
508  friend class bitarray3;
509  public:
514  bool operator()() const {
515  return m_active;
516  }
517  private:
518  const_iterator( const bool &_active ) : m_active(_active) {}
519  const bool &m_active;
520  };
521  //
522  enum { ACTIVES = true, ALL = false };
529  void parallel_actives( std::function<void(iterator& it)> func ) { parallel_op(func,ACTIVES); }
536  void parallel_all( std::function<void(iterator& it)> func ) { parallel_op(func,ALL); }
545  void parallel_op( std::function<void(iterator& it)> func, bool type=ALL ) {
546  parallel_op([func](int i, int j, int k, iterator& it, int thread_index){
547  func(it);
548  },type);
549  }
556  void parallel_actives( std::function<void(int i, int j, int k, iterator& it)> func ) { parallel_op(func,ACTIVES); }
563  void parallel_all( std::function<void(int i, int j, int k, iterator& it)> func ) { parallel_op(func,ALL); }
572  void parallel_op( std::function<void(int i, int j, int k, iterator& it)> func, bool type=ALL ) {
573  parallel_op([func](int i, int j, int k, iterator& it, int thread_index){
574  func(i,j,k,it);
575  },type);
576  }
583  void parallel_actives( std::function<void(int i, int j, int k, iterator& it, int thread_index)> func ) { parallel_op(func,ACTIVES); }
590  void parallel_all( std::function<void(int i, int j, int k, iterator& it, int thread_index)> func ) { parallel_op(func,ALL); }
599  void parallel_op( std::function<void(int i, int j, int k, iterator& it, int thread_index)> func, bool type=ALL ) {
600  if( type == ACTIVES ) {
601  m_core->parallel_actives([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_n ){
602  iterator it(active);
603  func(i,j,k,it,thread_n);
604  },m_parallel);
605  } else {
606  m_core->parallel_all([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_n ){
607  iterator it(active);
608  func(i,j,k,it,thread_n);
609  },m_parallel);
610  }
611  }
618  void const_parallel_all( std::function<void(const const_iterator& it)> func) const { const_parallel_op(func,ALL); }
627  void const_parallel_op( std::function<void(const const_iterator& it)> func, bool type=ALL ) const {
628  const_parallel_op([func](int i, int j, int k, const const_iterator& it, int thread_index){
629  func(it);
630  },type);
631  }
638  void const_parallel_actives( std::function<void(int i, int j, int k)> func ) const {
639  const_parallel_op([&](int i, int j, int k, const const_iterator& it) { func(i,j,k); }, ACTIVES); }
646  void const_parallel_all( std::function<void(int i, int j, int k, const const_iterator& it)> func ) const { const_parallel_op(func,ALL); }
655  void const_parallel_op( std::function<void(int i, int j, int k, const const_iterator& it)> func, bool type=ALL ) const {
656  const_parallel_op([func](int i, int j, int k, const const_iterator& it, int thread_index){
657  func(i,j,k,it);
658  },type);
659  }
666  void const_parallel_actives( std::function<void(int i, int j, int k, int thread_index)> func ) const {
667  const_parallel_op([&](int i, int j, int k, const const_iterator& it, int thread_index){ return func(i,j,k,thread_index); }, ACTIVES); }
674  void const_parallel_all( std::function<void(int i, int j, int k, const const_iterator& it, int thread_index)> func ) const { const_parallel_op(func,ALL); }
683  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 {
684  if( type == ACTIVES ) {
685  m_core->const_parallel_actives([&](int i, int j, int k, const void *value_ptr, const bool &filled, int thread_n ){
686  bool active(true);
687  const_iterator it(active);
688  func(i,j,k,it,thread_n);
689  },m_parallel);
690  } else {
691  m_core->const_parallel_all([&](int i, int j, int k, const void *value_ptr, const bool &active, const bool &filled, int thread_n ){
692  const_iterator it(active);
693  func(i,j,k,it,thread_n);
694  },m_parallel);
695  }
696  }
703  void serial_actives( std::function<void(iterator& it)> func) { serial_op(func,ACTIVES); }
710  void serial_all( std::function<void(iterator& it)> func) { serial_op(func,ALL); }
719  void serial_op( std::function<void(iterator& it)> func, bool type=ALL ) {
720  serial_op([func](int i, int j, int k, iterator& it){
721  func(it);
722  },type);
723  }
730  void serial_actives( std::function<void(int i, int j, int k, iterator& it)> func ) { serial_op(func,ACTIVES); }
737  void serial_all( std::function<void(int i, int j, int k, iterator& it)> func ) { serial_op(func,ALL); }
746  void serial_op( std::function<void(int i, int j, int k, iterator& it)> func, bool type=ALL ) {
747  if( type == ACTIVES ) {
748  m_core->serial_actives([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled ){
749  iterator it(active);
750  func(i,j,k,it);
751  return false;
752  });
753  } else {
754  m_core->serial_all([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled ){
755  iterator it(active);
756  func(i,j,k,it);
757  return false;
758  });
759  }
760  }
767  void const_serial_all( std::function<void(const const_iterator& it)> func ) const { const_serial_op(func,ALL); }
776  void const_serial_op( std::function<void(const const_iterator& it)> func, bool type=ALL ) const {
777  const_serial_op([func](int i, int j, int k, const const_iterator& it){
778  func(it);
779  },type);
780  }
787  void const_serial_actives( std::function<void(int i, int j, int k)> func ) const {
788  const_serial_op([&](int i, int j, int k, const const_iterator& it) { func(i,j,k); }, ACTIVES); }
795  void const_serial_all( std::function<void(int i, int j, int k, const const_iterator& it)> func ) const { const_serial_op(func,ALL); }
804  void const_serial_op( std::function<void(int i, int j, int k, const const_iterator& it)> func, bool type=ALL ) const {
805  if( type == ACTIVES ) {
806  m_core->const_serial_actives([&](int i, int j, int k, const void *value_ptr, const bool &filled ){
807  bool active(true);
808  const_iterator it(active);
809  func(i,j,k,it);
810  return false;
811  });
812  } else {
813  m_core->const_serial_all([&](int i, int j, int k, const void *value_ptr, const bool &active, const bool &filled ){
814  const_iterator it(active);
815  func(i,j,k,it);
816  return false;
817  });
818  }
819  }
826  void interruptible_serial_actives( std::function<bool(iterator& it)> func ) { interruptible_serial_op(func,ACTIVES); }
833  void interruptible_serial_all( std::function<bool(iterator& it)> func ) { interruptible_serial_op(func,ALL); }
842  void interruptible_serial_op( std::function<bool(iterator& it)> func, bool type=ALL ) {
843  interruptible_serial_op([func](int i, int j, int k, iterator& it){
844  return func(it);
845  },type);
846  }
853  void interruptible_serial_actives( std::function<bool(int i, int j, int k, iterator& it)> func ) { interruptible_serial_op(func,ACTIVES); }
860  void interruptible_serial_all( std::function<bool(int i, int j, int k, iterator& it)> func ) { interruptible_serial_op(func,ALL); }
869  void interruptible_serial_op( std::function<bool(int i, int j, int k, iterator& it)> func, bool type=ALL ) {
870  if( type == ACTIVES ) {
871  m_core->serial_actives([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled ){
872  iterator it(active);
873  return func(i,j,k,it);
874  });
875  } else {
876  m_core->serial_all([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled ){
877  iterator it(active);
878  return func(i,j,k,it);
879  });
880  }
881  }
888  void interruptible_const_serial_all( std::function<bool(const const_iterator& it)> func ) const { interruptible_const_serial_op(func,ALL); }
897  void interruptible_const_serial_op( std::function<bool(const const_iterator& it)> func, bool type=ALL ) const {
898  const_serial_op([func](int i, int j, int k, const const_iterator& it){
899  return func(it);
900  },type);
901  }
908  void interruptible_const_serial_actives( std::function<bool(int i, int j, int k)> func ) const {
909  interruptible_const_serial_op([&](int i, int j, int k, const const_iterator& it){ return func(i,j,k); }, ACTIVES); }
916  void interruptible_const_serial_all( std::function<bool(int i, int j, int k, const const_iterator& it)> func ) const { interruptible_const_serial_op(func,ALL); }
925  void interruptible_const_serial_op( std::function<bool(int i, int j, int k, const const_iterator& it)> func, bool type=ALL ) const {
926  if( type == ACTIVES ) {
927  m_core->const_serial_actives([&](int i, int j, int k, const void *value_ptr, const bool &filled ){
928  bool active(true);
929  const_iterator it(active);
930  return func(i,j,k,it);
931  });
932  } else {
933  m_core->const_serial_all([&](int i, int j, int k, const void *value_ptr, const bool &active, const bool &filled ){
934  const_iterator it(active);
935  return func(i,j,k,it);
936  });
937  }
938  }
947  void dilate( std::function<void(int i, int j, int k, iterator& it, int thread_index )> func, int count=1 ) {
948  while( count -- ) {
949  m_core->dilate([&](int i, int j, int k, void *value_ptr, bool &active, const bool &filled, int thread_index) {
950  iterator it(active);
951  func(i,j,k,it,thread_index);
952  },m_parallel);
953  }
954  }
963  void dilate( std::function<void(int i, int j, int k, iterator& it)> func, int count=1 ) {
964  dilate([&](int i, int j, int k, iterator& it, int thread_index) {
965  func(i,j,k,it);
966  },count);
967  }
974  void dilate( int count=1 ) {
975  dilate([&](int i, int j, int k, iterator& it){ it.set(); },count);
976  }
985  void erode( std::function<bool(int i, int j, int k, int thread_index)> func, int count=1 ) {
986  //
987  std::vector<std::vector<vec3i> > off_positions(get_thread_num());
988  //
989  while( count -- ) {
990  const_parallel_actives([&](int i, int j, int k, int tn) {
991  bool exit_loop (false);
992  for( int dim : DIMS3 ) {
993  for( int dir=-1; dir<=1; dir+=2 ) {
994  const vec3i &pi = vec3i(i,j,k) + dir*vec3i(dim==0,dim==1,dim==2);
995  if( ! this->shape().out_of_bounds(pi) && ! (*this)(pi)) {
996  if( func(i,j,k,tn)) {
997  off_positions[tn].push_back(vec3i(i,j,k));
998  exit_loop = true;
999  break;
1000  }
1001  }
1002  }
1003  if( exit_loop ) break;
1004  }
1005  });
1006  for( const auto &bucket : off_positions ) for( const auto &pi : bucket ) {
1007  set_off(pi);
1008  }
1009  }
1010  }
1019  void erode( std::function<bool(int i, int j, int k)> func, int count=1 ) {
1020  erode([&](int i, int j, int k, int thread_index) {
1021  return func(i,j,k);
1022  },count);
1023  }
1030  void erode( int count=1 ) {
1031  erode([&](int i, int j, int k, int thread_index) {
1032  return true;
1033  },count);
1034  }
1041  void swap( bitarray3& rhs ) {
1042  m_core.swap(rhs.m_core);
1043  std::swap(m_shape,rhs.m_shape);
1044  }
1052  return m_parallel;
1053  }
1061  return m_parallel;
1062  }
1069  void set_core_name( std::string core_name ) {
1070  m_core_name = core_name;
1071  }
1078  std::string get_core_name() const {
1079  return m_core_name;
1080  }
1087  const array_core3 * get_core() const {
1088  return m_core.get();
1089  }
1097  return m_core.get();
1098  }
1101  struct type3 {
1106  std::string core_name;
1118  bool operator==( const type3 &type ) const {
1119  return core_name == type.core_name && shape == type.shape;
1120  }
1121  };
1128  type3 type() const { return { get_core_name(),shape() }; }
1135  void set_type( const type3 &type ) {
1136  m_core_name = type.core_name;
1137  m_shape = type.shape;
1138  }
1139  //
1140 private:
1141  //
1142  shape3 m_shape;
1143  parallel_driver m_parallel{this};
1144  array3_ptr m_core;
1145  bool m_is_initialized {false};
1146  std::string m_core_name;
1147 };
1148 //
1150 //
1151 #endif
bitarray3::dilate
void dilate(std::function< void(int i, int j, int k, iterator &it, int thread_index)> func, int count=1)
Dilate cells.
Definition: bitarray3.h:947
bitarray3::set_off
void set_off(int i, int j, int k)
Set a position on grid inactive.
Definition: bitarray3.h:407
bitarray3::iterator::set_off
void set_off()
Inactivate a cell.
Definition: bitarray3.h:491
shape.h
shape3::w
unsigned w
Width of the shape.
Definition: shape.h:942
bitarray3::operator()
bool operator()(int i, int j, int k) const
Get if a position on grid is active.
Definition: bitarray3.h:353
bitarray3::parallel_actives
void parallel_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitarray3.h:529
bitarray3::initialize
void initialize(const shape3 &shape)
Allocate grid memory with value.
Definition: bitarray3.h:192
bitarray3::erode
void erode(std::function< bool(int i, int j, int k, int thread_index)> func, int count=1)
Erode cells.
Definition: bitarray3.h:985
array_core3.h
shape3::out_of_bounds
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
bitarray3::dilate
void dilate(std::function< void(int i, int j, int k, iterator &it)> func, int count=1)
Dilate cells.
Definition: bitarray3.h:963
bitarray3::copy_active_as
void copy_active_as(const bitarray3 &array, const vec3i &offset=vec3i())
Copy the states of active and inactive cells as same as input array with an offset.
Definition: bitarray3.h:293
messageable::send_message
virtual bool send_message(std::string message, void *ptr=nullptr)
Send a message.
Definition: messageable.h:48
bitarray3::set_off
void set_off(const vec3i &pi)
Set a position on grid inactive.
Definition: bitarray3.h:418
parallel_driver
Class that facilitates the use of parallel_core class for parallel loop.
Definition: parallel_driver.h:44
array_core3
Core module class for three dimensional array designed to be used in array3 class.
Definition: array_core3.h:38
bitarray3::parallel_all
void parallel_all(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitarray3.h:563
bitarray3::const_serial_op
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: bitarray3.h:776
bitarray3::get_core
array_core3 * get_core()
Get pointer to the core module.
Definition: bitarray3.h:1096
bitarray3::clear
void clear()
Clear out the grid.
Definition: bitarray3.h:312
recursive_configurable::setup_now
virtual void setup_now(configuration &config=get_global_configuration()) override
Run recursive_load - recursive_configure - recursive_initialize processes.
Definition: configurable.h:227
bitarray3::const_serial_actives
void const_serial_actives(std::function< void(int i, int j, int k)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitarray3.h:787
bitarray3::get_parallel_driver
parallel_driver & get_parallel_driver()
Get the instance of parallel_driver of this grid.
Definition: bitarray3.h:1051
bitarray3::erode
void erode(int count=1)
Erode cells.
Definition: bitarray3.h:1030
bitarray3
Three dimensional bit grid class designed to be defined as instance member in recursive_configurable ...
Definition: bitarray3.h:43
bitarray3::const_parallel_all
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: bitarray3.h:618
shape3::h
unsigned h
Height of the shape.
Definition: shape.h:947
bitarray3::parallel_op
void parallel_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitarray3.h:545
bitarray3::bitarray3
bitarray3(recursive_configurable *parent, const shape3 &shape, std::string core_name="")
Constructor for bitarray3.
Definition: bitarray3.h:55
bitarray3::activate_as
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: bitarray3.h:236
bitarray3::parallel_all
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: bitarray3.h:590
bitarray3::set
void set(int i, int j, int k)
Set value on grid.
Definition: bitarray3.h:327
bitarray3::get_thread_num
int get_thread_num() const
Get the current number of threads for parallel processing on this grid.
Definition: bitarray3.h:470
bitarray3::const_parallel_op
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: bitarray3.h:655
bitarray3::parallel_all
void parallel_all(std::function< void(iterator &it)> func)
Loop over all the cells in parallel.
Definition: bitarray3.h:536
bitarray3::set
void set(const vec3i &pi)
Set value on grid.
Definition: bitarray3.h:338
bitarray3::const_serial_all
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: bitarray3.h:767
shape3
Structure that defines a three dimensional shape such as width, height and depth.
Definition: shape.h:478
bitarray3::iterator
Writable iterator.
Definition: bitarray3.h:475
bitarray3::serial_actives
void serial_actives(std::function< void(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitarray3.h:703
bitarray3::safe_get
bool safe_get(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: bitarray3.h:380
bitarray3::const_serial_op
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: bitarray3.h:804
bitarray3::shape
shape3 shape() const
Get the shape of the array.
Definition: bitarray3.h:185
bitarray3::parallel_op
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: bitarray3.h:599
shape3::d
unsigned d
Depth of the shape.
Definition: shape.h:952
bitarray3::operator=
bitarray3 & operator=(const bitarray3 &array)
Deep copy operation for bitarray3.
Definition: bitarray3.h:155
bitarray3::operator!=
bool operator!=(const bitarray3 &array) const
Return if the grid is different from an input array.
Definition: bitarray3.h:429
bitarray3::operator()
bool operator()(const vec3i &pi) const
Get if a position on grid is active.
Definition: bitarray3.h:365
bitarray3::iterator::set
void set()
Set a value.
Definition: bitarray3.h:484
parallel_driver::get_thread_num
int get_thread_num() const
Get the number of maximal threads set.
Definition: parallel_driver.h:80
bitarray3::bitarray3
bitarray3(const bitarray3 &array)
Copy constructor for bitarray3.
Definition: bitarray3.h:144
bitarray3::const_iterator
Read-only iterator.
Definition: bitarray3.h:507
messageable::const_send_message
virtual bool const_send_message(std::string message, void *ptr=nullptr) const
Send a message.
Definition: messageable.h:59
bitarray3::safe_get
bool safe_get(const vec3i &pi) const
Get if a position on grid is active. pi can be safely out of the domain.
Definition: bitarray3.h:394
bitarray3::interruptible_serial_op
void interruptible_serial_op(std::function< bool(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitarray3.h:842
SHKZ_BEGIN_NAMESPACE
#define SHKZ_BEGIN_NAMESPACE
Name space beggining definition for shiokaze.
Definition: common.h:39
array3::const_serial_actives
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
bitarray3::send_message
virtual bool send_message(std::string message, void *ptr) override
Send a message to the core module.
Definition: bitarray3.h:122
bitarray3::bitarray3
bitarray3(recursive_configurable *parent, std::string core_name="")
Constructor for bitarray3.
Definition: bitarray3.h:68
bitarray3::serial_actives
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: bitarray3.h:730
bitarray3::set_type
void set_type(const type3 &type)
Set the type of this grid.
Definition: bitarray3.h:1135
bitarray3::iterator::operator()
bool operator()() const
Get if a cell is active.
Definition: bitarray3.h:498
bitarray3::interruptible_serial_all
void interruptible_serial_all(std::function< bool(iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitarray3.h:833
bitarray3::type
type3 type() const
Get the type of this grid.
Definition: bitarray3.h:1128
bitarray3::interruptible_const_serial_all
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: bitarray3.h:916
bitarray3::const_parallel_all
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: bitarray3.h:646
parallel_driver::set_thread_num
void set_thread_num(int maximal_threads)
Set the number of maximal threads set.
Definition: parallel_driver.h:89
bitarray3::const_parallel_op
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: bitarray3.h:627
bitarray3::type3::core_name
std::string core_name
Core name of the module.
Definition: bitarray3.h:1106
bitarray3::set_core_name
void set_core_name(std::string core_name)
Set the core name of module of this grid.
Definition: bitarray3.h:1069
bitarray3::const_parallel_op
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: bitarray3.h:683
bitarray3::activate_all
void activate_all()
Activate all the cells.
Definition: bitarray3.h:280
bitarray3::serial_op
void serial_op(std::function< void(iterator &it)> func, bool type=ALL)
Loop over cells in serial order.
Definition: bitarray3.h:719
bitarray3::type3
Collection of properties of this grid.
Definition: bitarray3.h:1101
bitarray3::dilate
void dilate(int count=1)
Dilate cells.
Definition: bitarray3.h:974
bitarray3::activate_inside_as
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: bitarray3.h:268
bitarray3::activate
void activate(const std::vector< vec3i > &active_entries, const vec3i &offset=vec3i())
Activate cells at the positons of active_entries with an offset.
Definition: bitarray3.h:220
bitarray3::parallel_actives
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: bitarray3.h:583
bitarray3::get_core
const array_core3 * get_core() const
Get pointer to the core module.
Definition: bitarray3.h:1087
bitarray3::const_parallel_actives
void const_parallel_actives(std::function< void(int i, int j, int k)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitarray3.h:638
recursive_configurable
Extended configurable class that holds multiple children of configurable.
Definition: configurable.h:126
parallel_driver.h
bitarray3::get_core_name
std::string get_core_name() const
Get the core name of module of this grid.
Definition: bitarray3.h:1078
bitarray3::get_parallel_driver
const parallel_driver & get_parallel_driver() const
Get the const instance of parallel_driver of this grid.
Definition: bitarray3.h:1060
bitarray3::interruptible_const_serial_op
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: bitarray3.h:925
bitarray3::type3::operator==
bool operator==(const type3 &type) const
Check equality.
Definition: bitarray3.h:1118
bitarray3::interruptible_serial_all
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: bitarray3.h:860
vec
Fixed sized vector structure.
Definition: vec.h:38
bitarray3::set_thread_num
void set_thread_num(int number)
Set the number of threads for parallel processing on this grid.
Definition: bitarray3.h:461
bitarray3::interruptible_serial_actives
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: bitarray3.h:853
bitarray3::interruptible_const_serial_all
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: bitarray3.h:888
bitarray3::const_iterator::operator()
bool operator()() const
Get if a cell is active.
Definition: bitarray3.h:514
vec.h
bitarray3::bitarray3
bitarray3(const shape3 &shape, std::string core_name="")
Constructor for bitarray3.
Definition: bitarray3.h:84
bitarray3::activate_as_bit
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: bitarray3.h:252
bitarray3::const_serial_all
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: bitarray3.h:795
bitarray3::interruptible_serial_actives
void interruptible_serial_actives(std::function< bool(iterator &it)> func)
Loop over all the active cells in serial order.
Definition: bitarray3.h:826
bitarray3::parallel_actives
void parallel_actives(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the active cells in parallel.
Definition: bitarray3.h:556
bitarray3::interruptible_serial_op
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: bitarray3.h:869
configuration
Class that controls the settings of the program.
Definition: configuration.h:39
messageable
Message class.
Definition: messageable.h:36
bitarray3::interruptible_const_serial_actives
void interruptible_const_serial_actives(std::function< bool(int i, int j, int k)> func) const
Loop over all the active cells in serial order by read-only fashion.
Definition: bitarray3.h:908
SHKZ_END_NAMESPACE
#define SHKZ_END_NAMESPACE
Name space end definition for shiokaze.
Definition: common.h:44
bitarray3::parallel_op
void parallel_op(std::function< void(int i, int j, int k, iterator &it)> func, bool type=ALL)
Loop over cells in parallel.
Definition: bitarray3.h:572
bitarray3::const_send_message
virtual bool const_send_message(std::string message, void *ptr) const override
Send a message to the core module.
Definition: bitarray3.h:135
bitarray3::erode
void erode(std::function< bool(int i, int j, int k)> func, int count=1)
Erode cells.
Definition: bitarray3.h:1019
bitarray3::serial_all
void serial_all(std::function< void(iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitarray3.h:710
bitarray3::type3::shape
shape3 shape
Shape of the grid.
Definition: bitarray3.h:1111
bitarray3::operator==
bool operator==(const bitarray3 &v) const
Return if the grid is same to an input array.
Definition: bitarray3.h:440
bitarray3::swap
void swap(bitarray3 &rhs)
Swap array.
Definition: bitarray3.h:1041
bitarray3::interruptible_const_serial_op
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: bitarray3.h:897
bitarray3::serial_all
void serial_all(std::function< void(int i, int j, int k, iterator &it)> func)
Loop over all the cells in serial order.
Definition: bitarray3.h:737
bitarray3::const_parallel_actives
void const_parallel_actives(std::function< void(int i, int j, int k, int thread_index)> func) const
Loop over all the active cells in parallel by read-only fashion.
Definition: bitarray3.h:666
bitarray3::const_parallel_all
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: bitarray3.h:674
recursive_configurable::add_child
virtual void add_child(configurable *child)
Add a child instance.
Definition: configurable.h:191
bitarray3::serial_op
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: bitarray3.h:746
bitarray3::count
size_t count() const
Function to count the number of active cells.
Definition: bitarray3.h:204
array3::const_serial_inside
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
bitarray3::copy
void copy(const bitarray3 &array)
Deep copy function for bitarray3.
Definition: bitarray3.h:167
bitarray3::bitarray3
bitarray3(std::string core_name="")
Constructor for bitarray3.
Definition: bitarray3.h:75
array3
Three dimensional array class designed to be defined as instance member in recursive_configurable cla...
Definition: array3.h:42