-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVisMap.cpp
More file actions
47 lines (42 loc) · 1.05 KB
/
VisMap.cpp
File metadata and controls
47 lines (42 loc) · 1.05 KB
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
#include "VisMap.h"
#include "Tools.h"
bool Init_Vis_Map(Vis_Map* vsm, size_t height, size_t widht, size_t depth, int init_sym)
{
vsm->widht = widht;
vsm->height = height;
vsm->depth = depth;
if(!vsm) return false;
for (size_t i = 0; i < depth; i++)
{
for (size_t j = 0; j < height; j++)
{
vsm->map[i][j] = (int*)_Malloc(sizeof(size_t) * widht);
if (!vsm->map[i][j]) return false;//todo: add meneger errors!
for (size_t k = 0; k < widht; k++)
{
vsm->map[j][i][k] = init_sym;
}
}
}
return true;
}
int decart_Vsm_Get(Vis_Map* vsm, size_t height, size_t widht, size_t depth)
{
return vsm->map[vsm->depth - depth][vsm->height - height][widht];
}
void decart_Vsm_Set(Vis_Map* vsm, size_t height, size_t widht, size_t depth, int sym)
{
vsm->map[vsm->depth - depth][vsm->height - height][widht] = sym;
}
bool Free_Vis_Map(Vis_Map* vsm, size_t height, size_t widht, size_t depth)
{
//todo: add function is_empty
for (size_t i = 0; i < depth; i++)
{
for (size_t j = 0; j < height; j++)
{
free(vsm->map[i][j]);
}
}
return true;
}