4#include "celldimension.h"
5#include "../myMath/myMath.h"
7template<
unsigned int N>
9 static const unsigned int value = 2 * PowerOfTwo<N-1>::value;
14 static const unsigned int value = 1;
18template <
unsigned int N>
19struct TriangularNumber {
20 static const unsigned int value = N * (N + 1) / 2;
24class RectangularIteratorCells {
26 RectangularIteratorCells(CellDimension& A_, CellDimension &B_);
31 CellDimension getCell() {
return P; }
33 bool goon() {
return weiter; }
42 int level[DimensionSparseGrid];
49class CellIndexDirection{
53 for(
int d=0; d<DimensionSparseGrid; d++) directions[d]=Left;
55 void setDirection(
int d, Direction dir){directions[d]=dir;}
56 Direction getDirection(
int d){
return directions[d];}
58 Direction directions[DimensionSparseGrid];
63class CellIndexIterator{
65 CellIndexIterator(CellDimension* parent_){
67 IndexDimension centerOfCell;
68 for(
int d=0; d< DimensionSparseGrid; d++){
69 level[d]= parent_->getDepth(d);
70 centerOfCell.replace(d, parent_->getIndex(d));
75 for(
int d=0; d<DimensionSparseGrid; d++){
76 A = A.nextLeft(d,level[d]);
77 B = B.nextRight(d,level[d]);
79 cellIndexDirection.setDirection(d,Left);
103 CellIndexIterator(CellIndexIterator
const &iterator_parent){
104 A = iterator_parent.A;
105 B = iterator_parent.B;
106 for(
int d=0; d<DimensionSparseGrid; d++){
107 level[d]=iterator_parent.level[d];
108 cellIndexDirection.setDirection(d,iterator_parent.getCellIndexDirection().getDirection(d));
112 weiter = iterator_parent.weiter;
132 CellIndexIterator(CellDimension* parent_, IndexDimension& indexDimension, Direction* dir){
134 IndexDimension centerOfCell;
135 for(
int d=0; d< DimensionSparseGrid; d++){
136 level[d]= parent_->getDepth(d);
137 centerOfCell.replace(d, parent_->getIndex(d));
142 for(
int d=0; d<DimensionSparseGrid; d++){
143 A = A.nextLeft(d,level[d]);
144 B = B.nextRight(d,level[d]);
156 IndexDimension getIndex() {
163 IndexDimension getIndexByBinary(
int i){
166 bool binary[DimensionSparseGrid];
168 for (
int d = DimensionSparseGrid - 1; d >= 0; --d) {
173 IndexDimension Index=A;
174 for(
int d=0; d<DimensionSparseGrid; d++){
176 Index = Index.nextRight(d,level[d]);
177 cellIndexDirection.setDirection(d,Right);
179 cellIndexDirection.setDirection(d,Left);
190 CellIndexDirection getCellIndexDirection()
const {
return cellIndexDirection;}
208 int number_indices = PowerOfTwo<DimensionSparseGrid>::value;
211 int level[DimensionSparseGrid];
213 CellIndexDirection cellIndexDirection;