Momentum
A library for solving nonlinear optimization problems related to human body kinematics
Loading...
Searching...
No Matches
mesh.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#pragma once
9
10#include <momentum/math/fwd.h>
11#include <momentum/math/types.h>
12
13namespace momentum {
14
19template <typename T>
20struct MeshT {
22 std::vector<Eigen::Vector3<T>> vertices;
23
25 std::vector<Eigen::Vector3<T>> normals;
26
28 std::vector<Eigen::Vector3i> faces;
29
32 std::vector<std::vector<int32_t>> lines;
33
35 std::vector<Eigen::Vector3b> colors;
36
39 std::vector<T> confidence;
40
49 // TODO: texcoords are hardcoded to float regardless of the mesh scalar type T; consider
50 // templating on T2 (or T) for consistency with vertices/normals/confidence.
51 std::vector<Eigen::Vector2f> texcoords;
52
55 std::vector<Eigen::Vector3i> texcoord_faces;
56
59 std::vector<std::vector<int32_t>> texcoord_lines;
60
67 std::vector<uint32_t> polyFaces;
68
73 std::vector<uint32_t> polyFaceSizes;
74
79 std::vector<uint32_t> polyTexcoordFaces;
80
88
97 template <typename T2>
98 [[nodiscard]] MeshT<T2> cast() const;
99
103 void reset();
104};
105
106} // namespace momentum
A generic mesh representation with support for vertices, faces, lines, and texture coordinates.
Definition mesh.h:20
std::vector< uint32_t > polyFaces
Definition mesh.h:67
std::vector< Eigen::Vector3i > texcoord_faces
Definition mesh.h:55
std::vector< std::vector< int32_t > > texcoord_lines
Definition mesh.h:59
std::vector< uint32_t > polyFaceSizes
Definition mesh.h:73
std::vector< uint32_t > polyTexcoordFaces
Definition mesh.h:79
std::vector< Eigen::Vector2f > texcoords
Definition mesh.h:51
void updateNormals()
Compute vertex normals by averaging connected face normals.
Definition mesh.cpp:17
std::vector< float > confidence
Definition mesh.h:39
std::vector< Eigen::Vector3< float > > vertices
Definition mesh.h:22
std::vector< Eigen::Vector3< float > > normals
Definition mesh.h:25
std::vector< std::vector< int32_t > > lines
Definition mesh.h:32
void reset()
Reset the mesh by clearing all data.
Definition mesh.cpp:83
std::vector< Eigen::Vector3i > faces
Definition mesh.h:28
std::vector< Eigen::Vector3b > colors
Definition mesh.h:35
MeshT< T2 > cast() const
Cast the mesh to a different scalar type.
Definition mesh.cpp:65