Skip to content

Commit 319b316

Browse files
committed
add sdk mesh type
1 parent d1e2fc6 commit 319b316

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed

src/viam/sdk/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ target_sources(viamsdk
6666
common/exception.cpp
6767
common/instance.cpp
6868
common/linear_algebra.cpp
69+
common/mesh.cpp
6970
common/pose.cpp
7071
common/proto_value.cpp
7172
common/utils.cpp
@@ -177,6 +178,7 @@ target_sources(viamsdk
177178
../../viam/sdk/common/exception.hpp
178179
../../viam/sdk/common/instance.hpp
179180
../../viam/sdk/common/linear_algebra.hpp
181+
../../viam/sdk/common/mesh.hpp
180182
../../viam/sdk/common/pose.hpp
181183
../../viam/sdk/common/proto_convert.hpp
182184
../../viam/sdk/common/proto_value.hpp

src/viam/sdk/common/mesh.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <viam/sdk/common/mesh.hpp>
2+
3+
#include <viam/sdk/common/utils.hpp>
4+
5+
#include <common/v1/common.pb.h>
6+
7+
namespace viam {
8+
namespace sdk {
9+
10+
namespace proto_convert_details {
11+
void to_proto_impl<mesh>::operator()(const mesh& self, common::v1::Mesh* proto) const {
12+
proto->set_content_type(self.content_type);
13+
proto->set_mesh(bytes_to_string(self.data));
14+
}
15+
16+
mesh from_proto_impl<common::v1::Mesh>::operator()(const common::v1::Mesh* proto) const {
17+
return mesh{proto->content_type(), string_to_bytes(proto->mesh())};
18+
}
19+
20+
} // namespace proto_convert_details
21+
} // namespace sdk
22+
} // namespace viam

src/viam/sdk/common/mesh.hpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#pragma once
2+
3+
#include <viam/sdk/common/proto_convert.hpp>
4+
5+
#include <string>
6+
#include <vector>
7+
8+
namespace viam {
9+
namespace common {
10+
namespace v1 {
11+
12+
class Mesh;
13+
14+
} // namespace v1
15+
} // namespace common
16+
} // namespace viam
17+
18+
namespace viam {
19+
namespace sdk {
20+
21+
struct mesh {
22+
std::string content_type;
23+
std::vector<unsigned char> data;
24+
};
25+
26+
namespace proto_convert_details {
27+
28+
template <>
29+
struct to_proto_impl<mesh> {
30+
void operator()(const mesh&, common::v1::Mesh*) const;
31+
};
32+
33+
template <>
34+
struct from_proto_impl<common::v1::Mesh> {
35+
mesh operator()(const common::v1::Mesh*) const;
36+
};
37+
38+
} // namespace proto_convert_details
39+
40+
} // namespace sdk
41+
} // namespace viam

0 commit comments

Comments
 (0)