summaryrefslogtreecommitdiffstats
path: root/Temparray.h
blob: 19040a286caad3dbffe908b9e17daa2d399d4b58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef _TEMPARRAY_H_
#define _TEMPARRAY_H_

#include "Cubehole.h"
#include "gl.h"
#include "Triangle.h"
#include <list>
#include <math.h>

class Temparray
{
  public:
    Temparray(float initialtemp, int x0, int y0, int z0);
    Temparray(){}
    ~Temparray(){}
    void calcTemp();
    float& temperatureold(int x, int y, int z, int line, int pos) {
      return temparrayold[x*sy*sz*6*4 + y*sz*6*4 + z*6*4 + line*4 + pos];
    }
    float& temperaturenew(int x, int y, int z, int line, int pos) {
      return temparraynew[x*sy*sz*6*4 + y*sz*6*4 + z*6*4 + line*4 + pos];
    }
    std::list<Triangle> getTriangles();
    void coloring();
    
    void setprobetemp(float t){probetemp = t;}
    void setinput(float input0){input = input0;}
    
    float getaverage(){return averagetemp;}

  private:
    float *temparrayold, *temparraynew;
    Cubehole *cubearray;
    int sx, sy, sz, *weight1, maxweight;
    float averagetemp, earthtemp, probetemp, input, inputpower, factor;

    Cubehole& cubehole(int x, int y, int z, int line) {
      return cubearray[x*sy*sz*6 + y*sz*6 + z*6 + line];
    }
    int& weight(int x, int y, int z){
      return weight1[x*sy*sz + y*sz + z];
    }
    void mergetemperature(){
      for(int i=0; i<sx; i++){
        for(int j=0; j<sy; j++){
          for(int k=0; k<sz; k++){
            for(int l=0; l<6; l++){
              for(int m=0; m<4; m++){temperatureold(i, j, k, l, m)=temperaturenew(i, j, k, l, m);}}}}}}
    
    void tempInit(float temp0, int x0, int y0, int z0){
      for(int i=0; i<x0; i++){
        for(int j=0; j<y0; j++){
          for(int k=0; k<z0; k++){
            for(int l=0; l<6; l++){
              for(int m=0; m<4; m++){
                temperaturenew(i, j, k, l, m) = temp0;
                temperatureold(i, j, k, l, m) = temp0;
              }
            }
          }
        }
      }
      earthtemp=8;
    }
    void calcAverage(){
      float tempcache = 0;
      int times = 0;
      for(int i=0; i<sx; i++){
        for(int j=0; j<sy; j++){
          for(int k=0; k<sz; k++){
            for(int l=0; l<6; l++){
              for(int m=0; m<4; m++){
                tempcache += temperaturenew(i, j, k, l, m);
                ++times;
              }
            }
          }
        }
      }
      averagetemp = tempcache/times;
//      std::cerr << averagetemp << std::endl;
    }
    void calcweight();
    int howmanyweights(int weight0) {
      int counter = 0;
      for(int i=0; i<sx; ++i){
        for(int j=0; j<sy; ++j){
          for(int k=0; k<sz; ++k){
            if(weight(i, j, k) == weight0) ++counter;
          }
        }
      }
      return counter;
    }
};

#endif /* _TEMPARRAY_H_ */