forked from pageldev/libOpenDRIVE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Embind.cpp
165 lines (143 loc) · 8.15 KB
/
Embind.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#ifdef __EMSCRIPTEN__
#include "LaneSection.h"
#include "Lanes.h"
#include "Mesh.h"
#include "OpenDriveMap.h"
#include "RefLine.h"
#include "Road.h"
#include "Utils.hpp"
#include <emscripten/bind.h>
namespace odr
{
EMSCRIPTEN_BINDINGS(OpenDriveMap)
{
/* arrays */
emscripten::value_array<std::array<size_t, 2>>("array<size_t, 2>").element(emscripten::index<0>()).element(emscripten::index<1>());
emscripten::value_array<Vec2D>("Vec2D").element(emscripten::index<0>()).element(emscripten::index<1>());
emscripten::value_array<Vec3D>("Vec3D").element(emscripten::index<0>()).element(emscripten::index<1>()).element(emscripten::index<2>());
/* vectors */
emscripten::register_vector<size_t>("vector<size_t>");
emscripten::register_vector<uint32_t>("vector<uint32_t>");
emscripten::register_vector<int>("vector<int>");
emscripten::register_vector<double>("vector<double>");
emscripten::register_vector<Vec2D>("vector<Vec2D>");
emscripten::register_vector<Vec3D>("vector<Vec3D>");
emscripten::register_vector<std::string>("vector<string>");
emscripten::register_vector<std::vector<Vec3D>>("vector<vector<Vec3D>>");
emscripten::register_vector<Mesh3D>("vector<Mesh3D>");
emscripten::register_vector<RoadMark>("vector<RoadMark>");
/* maps */
emscripten::register_map<size_t, std::string>("map<size_t, string>");
emscripten::register_map<size_t, double>("map<size_t, double>");
emscripten::register_map<size_t, int>("map<size_t, int>");
emscripten::register_map<int, double>("map<int, double>");
emscripten::register_map<double, std::shared_ptr<RoadGeometry>>("map<double, shared_ptr<RoadGeometry>>");
emscripten::register_map<std::string, std::shared_ptr<Road>>("map<string, shared_ptr<Road>>");
emscripten::register_map<int, std::shared_ptr<Lane>>("map<int, shared_ptr<Lane>>");
emscripten::register_map<double, std::shared_ptr<LaneSection>>("map<double, shared_ptr<LaneSection>>");
/* classes */
emscripten::class_<RoadGeometry>("RoadGeometry")
.smart_ptr<std::shared_ptr<RoadGeometry>>("shared_ptr<RoadGeometry>")
.function("get_xy", &RoadGeometry::get_xy)
.function("get_grad", &RoadGeometry::get_grad)
.property("s0", &RoadGeometry::s0);
emscripten::class_<CubicSpline>("CubicSpline")
.constructor<>()
.smart_ptr<std::shared_ptr<CubicSpline>>("shared_ptr<CubicSpline>")
.function("size", &CubicSpline::size)
.function("get", &CubicSpline::get)
.function("get_grad", &CubicSpline::get_grad)
.function("get_max", &CubicSpline::get_max);
emscripten::class_<RefLine>("RefLine")
.constructor<double>()
.smart_ptr<std::shared_ptr<RefLine>>("shared_ptr<RefLine>")
.function("get_xyz", &RefLine::get_xyz)
.function("get_grad", &RefLine::get_grad)
.function("get_line", &RefLine::get_line)
.function("match", &RefLine::match)
.property("length", &RefLine::length)
.property("elevation_profile", &RefLine::elevation_profile)
.property("s0_to_geometry", &RefLine::s0_to_geometry);
emscripten::class_<Mesh3D>("Mesh3D")
.function("get_obj", &Mesh3D::get_obj)
.property("vertices", &Mesh3D::vertices)
.property("indices", &Mesh3D::indices)
.property("normals", &Mesh3D::normals)
.property("st_coordinates", &Mesh3D::st_coordinates);
emscripten::class_<RoadMark>("RoadMark")
.property("s_start", &RoadMark::s_start)
.property("s_end", &RoadMark::s_end)
.property("t_offset", &RoadMark::t_offset)
.property("width", &RoadMark::width);
emscripten::class_<Lane>("Lane")
.constructor<int, bool, std::string>()
.smart_ptr<std::shared_ptr<Lane>>("shared_ptr<Lane>")
.function("get_surface_pt", &Lane::get_surface_pt, emscripten::allow_raw_pointers())
.function("get_mesh", &Lane::get_mesh, emscripten::allow_raw_pointers())
.function("get_roadmarks", &Lane::get_roadmarks)
.function("get_roadmark_mesh", &Lane::get_roadmark_mesh)
.property("inner_border", &Lane::inner_border)
.property("outer_border", &Lane::outer_border)
.property("id", &Lane::id)
.property("type", &Lane::type);
emscripten::class_<LaneSection>("LaneSection")
.constructor<double>()
.smart_ptr<std::shared_ptr<LaneSection>>("shared_ptr<LaneSection>")
.function("get_end", &LaneSection::get_end)
.function("get_lane", emscripten::select_overload<std::shared_ptr<Lane>(double, double)>(&LaneSection::get_lane))
.property("s0", &LaneSection::s0)
.property("id_to_lane", &LaneSection::id_to_lane);
emscripten::class_<Road>("Road")
.constructor<>()
.smart_ptr<std::shared_ptr<Road>>("shared_ptr<Road>")
.function("get_lanesection", emscripten::select_overload<std::shared_ptr<LaneSection>(double)>(&Road::get_lanesection))
.function("get_xyz", &Road::get_xyz, emscripten::allow_raw_pointers())
.property("id", &Road::id)
.property("junction", &Road::junction)
.property("length", &Road::length)
.property("lane_offset", &Road::lane_offset)
.property("lane_offset", &Road::superelevation)
.property("ref_line", &Road::ref_line)
.property("s_to_lanesection", &Road::s_to_lanesection);
emscripten::class_<RoadsMesh, emscripten::base<Mesh3D>>("RoadsMesh")
.function("get_road_id", &RoadsMesh::get_road_id)
.function("get_idx_interval_road", &RoadsMesh::get_idx_interval_road)
.property("road_start_indices", &RoadsMesh::road_start_indices);
emscripten::class_<LanesMesh, emscripten::base<RoadsMesh>>("LanesMesh")
.function("get_lanesec_s0", &LanesMesh::get_lanesec_s0)
.function("get_lane_id", &LanesMesh::get_lane_id)
.function("get_idx_interval_lanesec", &LanesMesh::get_idx_interval_lanesec)
.function("get_idx_interval_lane", &LanesMesh::get_idx_interval_lane)
.function("get_lane_outline_indices", &LanesMesh::get_lane_outline_indices)
.property("lanesec_start_indices", &LanesMesh::lanesec_start_indices)
.property("lane_start_indices", &LanesMesh::lane_start_indices);
emscripten::class_<RoadmarksMesh, emscripten::base<LanesMesh>>("RoadmarksMesh")
.function("get_roadmark_type", &RoadmarksMesh::get_roadmark_type)
.function("get_idx_interval_roadmark", &RoadmarksMesh::get_idx_interval_roadmark)
.function("get_roadmark_outline_indices", &RoadmarksMesh::get_roadmark_outline_indices)
.property("roadmark_type_start_indices", &RoadmarksMesh::roadmark_type_start_indices);
emscripten::class_<RoadObjectsMesh, emscripten::base<RoadsMesh>>("RoadObjectsMesh")
.function("get_road_object_id", &RoadObjectsMesh::get_road_object_id)
.function("get_idx_interval_road_object", &RoadObjectsMesh::get_idx_interval_road_object)
.property("road_object_start_indices", &RoadObjectsMesh::road_object_start_indices);
emscripten::class_<RoadNetworkMesh>("RoadNetworkMesh")
.property("lanes_mesh", &RoadNetworkMesh::lanes_mesh)
.property("roadmarks_mesh", &RoadNetworkMesh::roadmarks_mesh)
.property("road_objects_mesh", &RoadNetworkMesh::road_objects_mesh);
emscripten::value_object<OpenDriveMapConfig>("OpenDriveMapConfig")
.field("with_lateralProfile", &OpenDriveMapConfig::with_lateralProfile)
.field("with_laneHeight", &OpenDriveMapConfig::with_laneHeight)
.field("with_road_objects", &OpenDriveMapConfig::with_road_objects)
.field("center_map", &OpenDriveMapConfig::center_map)
.field("abs_z_for_for_local_road_obj_outline", &OpenDriveMapConfig::abs_z_for_for_local_road_obj_outline);
emscripten::class_<OpenDriveMap>("OpenDriveMap")
.constructor<std::string, OpenDriveMapConfig>()
.function("get_refline_segments", &OpenDriveMap::get_refline_lines)
.function("get_mesh", &OpenDriveMap::get_mesh)
.property("xodr_file", &OpenDriveMap::xodr_file)
.property("roads", &OpenDriveMap::roads)
.property("x_offs", &OpenDriveMap::x_offs)
.property("y_offs", &OpenDriveMap::y_offs);
}
} // namespace odr
#endif