-
Notifications
You must be signed in to change notification settings - Fork 2
/
radial.cpp
59 lines (56 loc) · 1.94 KB
/
radial.cpp
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
#include "radial.h"
#include "QDebug"
Radial::Radial()
{
}
std::vector<Parent_Algorithm::Coordinate> Radial::Generate_Filling(int16_t*** voxels, short int numCubes,int n, std::vector<Parent_Algorithm::Coordinate> grains)
{
unsigned int counter_max = pow(numCubes,3);
while (!grains.empty())
{
Coordinate temp;
int16_t x,y,z;
std::vector<Coordinate> newGrains;
for(size_t i = 0; i < grains.size(); i++)
{
temp = grains[i];
x = temp.x;
y = temp.y;
z = temp.z;
for (int16_t k = -1; k < 2; k++)
{
for(int16_t p = -1; p < 2; p++)
{
for(int16_t l = -1; l < 2; l++)
{
int16_t newX = k+x;
int16_t newY = p+y;
int16_t newZ = l+z;
bool isValidXYZ = (newX >= 0 && newX < numCubes) && (newY >= 0 && newY < numCubes) && (newZ >= 0 && newZ < numCubes) && voxels[newX][newY][newZ] == 0;
bool XYZ = (k == 0) || (p == 0) || (l == 0);
if (isValidXYZ)
{
if(XYZ)
{
voxels[newX][newY][newZ] = voxels[x][y][z];
newGrains.push_back({newX,newY,newZ});
counter++;
}
}
}
}
}
}
grains.clear();
grains.insert(grains.end(), newGrains.begin(), newGrains.end());
IterationNumber++;
double o = (double)counter/counter_max;
qDebug().nospace() << o << "\t" << IterationNumber << "\t" << grains.size();
// Перевірка, чи потрібна анімація
if (n == 1)
{
break;
}
}
return grains;
}