summaryrefslogtreecommitdiffstats
path: root/Temparray.h
blob: e15ea22b68c0c32b710ed9ae89b4749996bb1ac5 (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
#ifndef _TEMPARRAY_H_
#define _TEMPARRAY_H_

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

class Temparray
{
  public:
    Temparray(float initialtemp, int x0, int y0, int z0);
    ~Temparray(){
      delete[] temperature;
      delete[] cubearray;
    }

    void setTemp(float temp, int x, int y, int z, int line, int pos){
      temperature[x*size[1]*size[2]*6*4 + y*size[2]*6*4 + z*6*4 + line*4 + pos] = temp;
      calcAverage();
    }
    void deactivateCube(int x, int y, int z){
      for(int i=0; i<6; i++){
        for(int j=0; j<4; j++){
          setTemp(-100, x, y, z, i, j);
        }
      }
    }
    std::list<Triangle> getTriangles();
    void calcTemp();

  private:
    float *temperature;
    Cubehole *cubearray;
    int size[3];
    float averagetemp;

    void setColor(int x, int y, int z, int line){
    }
    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++){
                setTemp(temp0, i, j, k, l, m);
              }
            }
          }
        }
      }
    }
    void calcAverage(){
      float tempcache = 0;
      int times = 0;
      for(int i=0; i<size[0]; i++){
        for(int j=0; j<size[1]; j++){
          for(int k=0; k<size[2]; k++){
            for(int l=0; l<6; l++){
              for(int m=0; m<4; m++){
                if(temperature[i*size[1]*size[2]*6*4 + j*size[2]*6*4 + k*6*4 + l*4 + m] != -100){
                  tempcache += temperature[i*size[1]*size[2]*6*4 + j*size[2]*6*4 + k*6*4 + l*4 + m];
                  ++times;
                }
              }
            }
          }
        }
      }
      averagetemp = tempcache/times;
    }
};

#endif /* _TEMPARRAY_H_ */