49 using Index = Parent::Index;
51 RaycasterMeshDerived(std::shared_ptr<MeshType> mesh)
52 : m_mesh(std::move(mesh))
57 std::shared_ptr<MeshType> get_mesh_ptr()
const {
return m_mesh; }
59 Index get_dim()
const override {
return m_mesh->get_dim(); }
60 Index get_vertex_per_facet()
const override {
return m_mesh->get_vertex_per_facet(); }
61 Index get_num_vertices()
const override {
return m_mesh->get_num_vertices(); };
62 Index get_num_facets()
const override {
return m_mesh->get_num_facets(); };
64 std::vector<float> vertices_to_float()
const override
66 auto& data = m_mesh->get_vertices();
69 const Index size = rows * cols;
73 std::vector<float> float_data;
74 float_data.reserve(size + 1);
75 float_data.resize(size);
76 vertices_to_float(float_data.data());
81 std::vector<unsigned> indices_to_int()
const override
83 auto& data = m_mesh->get_facets();
86 const Index size = rows * cols;
90 std::vector<unsigned> int_data;
91 int_data.reserve(size + 1);
92 int_data.resize(size);
93 indices_to_int(int_data.data());
98 void vertices_to_float(
float* buf)
const override
100 auto& data = m_mesh->get_vertices();
103 if (get_dim() == 3) {
105 for (Index i = 0; i < rows; ++i) {
106 for (Index j = 0; j < cols; ++j) {
110 }
else if (get_dim() == 2) {
111 for (Index i = 0; i < rows; ++i) {
112 for (Index j = 0; j < 2; ++j) {
120 void indices_to_int(
unsigned* buf)
const override
122 auto& data = m_mesh->get_facets();
125 for (Index i = 0; i < rows; ++i) {
126 for (Index j = 0; j < cols; ++j) {
132 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