33#ifndef DART_MATH_DETAIL_TRIMESH_IMPL_HPP_
34#define DART_MATH_DETAIL_TRIMESH_IMPL_HPP_
36#include <Eigen/Geometry>
66 computeTriangleNormals();
68 this->mVertexNormals.clear();
69 this->mVertexNormals.resize(this->mVertices.size(), Vector3::Zero());
71 for (
auto i = 0
u;
i < mTriangles.size(); ++
i)
74 this->mVertexNormals[
triangle[0]] += mTriangleNormals[
i];
75 this->mVertexNormals[
triangle[1]] += mTriangleNormals[
i];
76 this->mVertexNormals[
triangle[2]] += mTriangleNormals[
i];
79 this->normalizeVertexNormals();
86 return !mTriangles.empty();
93 return hasTriangles() && mTriangles.size() == mTriangleNormals.size();
107 return mTriangleNormals;
115 mTriangleNormals.clear();
136 Base::operator+=(
other);
140 if ((!hasTriangles() || hasTriangleNormals()) &&
other.hasTriangleNormals())
142 mTriangleNormals.insert(
143 mTriangleNormals.end(),
144 other.mTriangleNormals.begin(),
145 other.mTriangleNormals.end());
149 mTriangleNormals.clear();
153 mTriangles.resize(mTriangles.size() +
other.mTriangles.size());
154 for (
auto i = 0
u;
i <
other.mTriangles.size(); ++
i)
171 auto mesh = std::make_shared<TriMesh<S>>();
181 mTriangleNormals.resize(mTriangles.size());
183 for (
auto i = 0
u;
i < mTriangles.size(); ++
i)
190 mTriangleNormals[
i] =
v01.cross(
v02);
193 normalizeTriangleNormals();
200 for (
auto& normal : mTriangleNormals)
This class represents triangle meshes.
Definition TriMesh.hpp:46
std::vector< Triangle > Triangles
Definition TriMesh.hpp:56
TriMesh & operator+=(const TriMesh &other)
Addition assignment operator.
Definition TriMesh-impl.hpp:128
void clear() override
Clears all the data in the trimesh.
Definition TriMesh-impl.hpp:112
const Triangles & getTriangles() const
Returns the triangles of the mesh.
Definition TriMesh-impl.hpp:98
TriMesh operator+(const TriMesh &other) const
Addition operator.
Definition TriMesh-impl.hpp:121
void computeTriangleNormals()
Computes triangle normals.
Definition TriMesh-impl.hpp:179
void normalizeTriangleNormals()
Normalizes triangle normals.
Definition TriMesh-impl.hpp:198
void setTriangles(const Vertices &vertices, const Triangles &triangles)
Sets vertices and triangles.
Definition TriMesh-impl.hpp:53
const Normals & getTriangleNormals() const
Returns the triangle normals of the mesh.
Definition TriMesh-impl.hpp:105
typename Base::Vertices Vertices
Definition TriMesh.hpp:54
bool hasTriangles() const
Returns true if the mesh contains triangles.
Definition TriMesh-impl.hpp:84
std::shared_ptr< TriMesh< S > > generateConvexHull(bool optimize=true) const
Generates a convex hull that encloses the trimesh.
Definition TriMesh-impl.hpp:164
typename Base::Normals Normals
Definition TriMesh.hpp:55
TriMesh()
Default constructor.
Definition TriMesh-impl.hpp:46
bool hasTriangleNormals() const
Returns true if the mesh contains triangle normals.
Definition TriMesh-impl.hpp:91
void computeVertexNormals()
Computes vertex normals.
Definition TriMesh-impl.hpp:64
typename Base::Vector3 Vector3
Definition TriMesh.hpp:52
Eigen::Matrix< Index, 3, 1 > Triangle
Definition TriMesh.hpp:53
Definition BulletCollisionDetector.cpp:60