-
Notifications
You must be signed in to change notification settings - Fork 2
/
Mapnode.cpp
105 lines (85 loc) · 1.8 KB
/
Mapnode.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
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
98
99
100
101
102
103
104
#include "micropather.h"
#include "Mapnode.h"
//#include "Oceanmap2d.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
using namespace std;
/**mapndoe for the 2D-Grid**/
Mapnode2d::Mapnode2d ()
{
x = 0;
y = 0;
cost = 0.0;
parent = NULL;
}
Mapnode2d::Mapnode2d (const Mapnode2d & v)
{
x = v.x;
y = v.y;
cost = v.cost;
parent = NULL;
}
void Mapnode2d::load (FILE * fp)
{
int r;
r = fread (&x, sizeof (unsigned int), 1, fp);
r = fread (&y, sizeof (unsigned int), 1, fp);
r = fread (&cost, sizeof (float), 1, fp);
parent = NULL;
}
void Mapnode2d::save (FILE * fp) const
{
int r;
r = fwrite (&x, sizeof (unsigned int), 1, fp);
r = fwrite (&y, sizeof (unsigned int), 1, fp);
r = fwrite (&cost, sizeof (float), 1, fp);
}
void Mapnode2d::print (FILE * fp) const
{
fprintf (fp, "%d %d %f ", x, y, cost);
}
/**mapnode for the 3D-Grid**/
Mapnode3d::Mapnode3d ()
{
x = 0;
y = 0;
theta = 0.0;
//checkValue = 140;
cost = 0.0;
parent = NULL;
}
Mapnode3d::Mapnode3d (const Mapnode3d & v)
{
x = v.x;
y = v.y;
theta = v.theta;
//checkValue = v.checkValue;
cost = v.cost;
parent = NULL;
}
void Mapnode3d::load (FILE * fp)
{
int r;
r = fread (&x, sizeof (unsigned int), 1, fp);
r = fread (&y, sizeof (unsigned int), 1, fp);
r = fread (&theta, sizeof (double), 1, fp);
//r = fread (&checkValue, sizeof (int), 1, fp);
r = fread (&cost, sizeof (float), 1, fp);
parent = NULL;
}
void Mapnode3d::save (FILE * fp) const
{
int r;
r = fwrite (&x, sizeof (unsigned int), 1, fp);
r = fwrite (&y, sizeof (unsigned int), 1, fp);
r = fwrite (&theta, sizeof (double), 1, fp);
//r = fwrite (&checkValue, sizeof (int), 1, fp);
r = fwrite (&cost, sizeof (float), 1, fp);
}
void Mapnode3d::print (FILE * fp) const
{
fprintf (fp, "%d %d %f ", x, y, cost);
}