-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.c
66 lines (59 loc) · 2.07 KB
/
init.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: msorin <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/15 16:42:23 by msorin #+# #+# */
/* Updated: 2016/11/15 16:44:05 by msorin ### ########.fr */
/* */
/* ************************************************************************** */
#include <fdf.h>
t_aff **copy_calc(t_aff **calc, t_int d)
{
t_aff **ret;
t_int it;
ret = (t_aff **)ft_memalloc(sizeof(t_aff *) * d.y);
it.y = 0;
while (it.y < d.y)
{
ret[it.y] = (t_aff *)ft_memalloc(sizeof(t_aff) * d.x);
it.x = 0;
while (it.x < d.x)
{
ret[it.y][it.x].x = calc[it.y][it.x].x;
ret[it.y][it.x].y = calc[it.y][it.x].y;
ret[it.y][it.x].z = calc[it.y][it.x].z;
it.x++;
}
it.y++;
}
return (ret);
}
double *init_double(double *db, size_t sz)
{
db = (double *)ft_memalloc(sizeof(double) * sz);
return (db);
}
t_aff *init_t_aff(t_aff *ta, size_t sz)
{
ta = (t_aff *)ft_memalloc(sizeof(t_aff) * sz);
return (ta);
}
void init_map(t_map *map)
{
map->c_map.x = 0;
map->c_map.y = 0;
map->mm = 0;
map->map = (int**)ft_memalloc(0);
}
void init_calc(t_calc *calc, t_map map)
{
calc->o_z = (double **)ft_memalloc(sizeof(double *) * map.c_map.y);
calc->o_z = ft_tdoublemap(calc->o_z, init_double, map.c_map.y, map.c_map.x);
PCPC = (t_aff **)ft_memalloc(sizeof(t_aff *) * map.c_map.y);
PCPC = ft_tt_affmap(PCPC, init_t_aff, map.c_map.y, map.c_map.x);
PCCP = (t_aff **)ft_memalloc(sizeof(t_aff *) * map.c_map.y);
PCCP = ft_tt_affmap(PCCP, init_t_aff, map.c_map.y, map.c_map.x);
}