@@ -1598,13 +1598,10 @@ void TriangleMesh::RemoveVerticesByMask(const std::vector<bool> &vertex_mask) {
15981598
15991599std::shared_ptr<TriangleMesh> TriangleMesh::SelectByIndex (
16001600 const std::vector<size_t > &indices, bool cleanup) const {
1601- if (HasTriangleUvs ()) {
1602- utility::LogWarning (
1603- " [SelectByIndex] This mesh contains triangle uvs that are "
1604- " not handled in this function" );
1605- }
16061601 auto output = std::make_shared<TriangleMesh>();
1602+ bool has_triangle_material_ids = HasTriangleMaterialIds ();
16071603 bool has_triangle_normals = HasTriangleNormals ();
1604+ bool has_triangle_uvs = HasTriangleUvs ();
16081605 bool has_vertex_normals = HasVertexNormals ();
16091606 bool has_vertex_colors = HasVertexColors ();
16101607
@@ -1636,9 +1633,17 @@ std::shared_ptr<TriangleMesh> TriangleMesh::SelectByIndex(
16361633 if (nvidx0 >= 0 && nvidx1 >= 0 && nvidx2 >= 0 ) {
16371634 output->triangles_ .push_back (
16381635 Eigen::Vector3i (nvidx0, nvidx1, nvidx2));
1636+ if (has_triangle_material_ids) {
1637+ output->triangle_material_ids_ .push_back (triangle_material_ids_[tidx]);
1638+ }
16391639 if (has_triangle_normals) {
16401640 output->triangle_normals_ .push_back (triangle_normals_[tidx]);
16411641 }
1642+ if (has_triangle_uvs) {
1643+ output->triangle_uvs_ .push_back (triangle_uvs_[tidx * 3 + 0 ]);
1644+ output->triangle_uvs_ .push_back (triangle_uvs_[tidx * 3 + 1 ]);
1645+ output->triangle_uvs_ .push_back (triangle_uvs_[tidx * 3 + 2 ]);
1646+ }
16421647 }
16431648 }
16441649
0 commit comments