46 using Index = Parent::Index;
48 RaycasterMeshDerived(std::shared_ptr<MeshType> mesh)
49 : m_mesh(std::move(mesh))
54 std::shared_ptr<MeshType> get_mesh_ptr()
const {
return m_mesh; }
56 Index get_dim()
const override {
return m_mesh->get_dim(); }
57 Index get_vertex_per_facet()
const override {
return m_mesh->get_vertex_per_facet(); }
58 Index get_num_vertices()
const override {
return m_mesh->get_num_vertices(); };
59 Index get_num_facets()
const override {
return m_mesh->get_num_facets(); };
61 std::vector<float> vertices_to_float()
const override
63 auto& data = m_mesh->get_vertices();
66 const Index size = rows * cols;
70 std::vector<float> float_data;
71 float_data.reserve(size + 1);
72 float_data.resize(size);
73 vertices_to_float(float_data.data());
78 std::vector<unsigned> indices_to_int()
const override
80 auto& data = m_mesh->get_facets();
83 const Index size = rows * cols;
87 std::vector<unsigned> int_data;
88 int_data.reserve(size + 1);
89 int_data.resize(size);
90 indices_to_int(int_data.data());
95 void vertices_to_float(
float* buf)
const override
97 auto& data = m_mesh->get_vertices();
100 if (get_dim() == 3) {
102 for (Index i = 0; i < rows; ++i) {
103 for (Index j = 0; j < cols; ++j) {
107 }
else if (get_dim() == 2) {
108 for (Index i = 0; i < rows; ++i) {
109 for (Index j = 0; j < 2; ++j) {
117 void indices_to_int(
unsigned* buf)
const override
119 auto& data = m_mesh->get_facets();
122 for (Index i = 0; i < rows; ++i) {
123 for (Index j = 0; j < cols; ++j) {
129 std::shared_ptr<MeshType> m_mesh;
constexpr auto safe_cast(SourceType value) -> std::enable_if_t<!std::is_same< SourceType, TargetType >::value, TargetType >
Perform safe cast from SourceType to TargetType, where "safe" means:
Definition safe_cast.h:50