19 std::fill(
normals.begin(),
normals.end(), Eigen::Vector3<T>::Zero());
20 const auto verticesNum =
static_cast<int>(
vertices.size());
21 for (
const auto& face :
faces) {
23 if (std::any_of(face.begin(), face.end(), [verticesNum](
int idx) {
24 return idx < 0 || idx >= verticesNum;
32 const Eigen::Vector3<T>
normal =
40 for (
const auto& faceIdx : face) {
44 for (
size_t i = 0; i <
normals.size(); i++) {
45 const T len =
normals[i].norm();
53template <
typename T,
typename T2,
int N>
54std::vector<Eigen::Vector<T2, N>>
castVectors(
const std::vector<Eigen::Vector<T, N>>& vec_in) {
55 std::vector<Eigen::Vector<T2, N>> result;
56 result.reserve(vec_in.size());
57 for (
const auto& v : vec_in) {
58 result.push_back(v.template
cast<T2>());
T normal(const T &mean, const T &sigma)
Normally distributed value via the global Random singleton.
bool IsNanNoOpt(float f)
NaN check function that isn't optimized away by fastmath.
std::vector< Eigen::Vector< T2, N > > castVectors(const std::vector< Eigen::Vector< T, N > > &vec_in)
Vector3P< S > cross(const Eigen::MatrixBase< Derived > &v1, const Vector3P< S > &v2)
Computes cross product of Eigen::Vector3f and Vector3P.
decltype(auto) cast(const ContainerType< ObjectType > &originalContainer)
Casts the scalar type of objects in a container that support the cast<>() method.
A generic mesh representation with support for vertices, faces, lines, and texture coordinates.
std::vector< uint32_t > polyFaces
Packed polygon face vertex indices (all polygons concatenated back-to-back).
std::vector< Eigen::Vector3i > texcoord_faces
List of texture coordinate indices per face Maps each face to its corresponding texture coordinates.
std::vector< std::vector< int32_t > > texcoord_lines
List of texture coordinate indices per line Maps each line to its corresponding texture coordinates.
std::vector< uint32_t > polyFaceSizes
Number of vertices in each polygon face.
std::vector< uint32_t > polyTexcoordFaces
Packed polygon face texture coordinate indices (same layout as polyFaces).
std::vector< Eigen::Vector2f > texcoords
List of texture coordinates (UV coordinates).
void updateNormals()
Compute vertex normals by averaging connected face normals.
std::vector< T > confidence
List of per-vertex confidence values Higher values typically indicate higher confidence in the vertex...
std::vector< Eigen::Vector3< T > > vertices
List of mesh vertices in 3D space.
std::vector< Eigen::Vector3< T > > normals
List of vertex normals (same size as vertices when computed).
std::vector< std::vector< int32_t > > lines
List of polylines defined by vertex indices Each inner vector represents a single polyline.
void reset()
Reset the mesh by clearing all data.
std::vector< Eigen::Vector3i > faces
List of triangular faces defined by vertex indices.
std::vector< Eigen::Vector3b > colors
List of per-vertex RGB colors (0-255 for each channel).
MeshT< T2 > cast() const
Cast the mesh to a different scalar type.