DART 6.12.2
Loading...
Searching...
No Matches
TriMesh.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2021, The DART development contributors
3 * All rights reserved.
4 *
5 * The list of contributors can be found at:
6 * https://github.com/dartsim/dart/blob/master/LICENSE
7 *
8 * This file is provided under the following "BSD-style" License:
9 * Redistribution and use in source and binary forms, with or
10 * without modification, are permitted provided that the following
11 * conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19 * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
26 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef DART_MATH_TRIMESH_HPP_
34#define DART_MATH_TRIMESH_HPP_
35
36#include <memory>
37
38#include "dart/math/Mesh.hpp"
39
40namespace dart {
41namespace math {
42
44template <typename S_>
45class TriMesh : public Mesh<S_>
46{
47public:
48 // Type aliases
49 using S = S_;
50 using Base = Mesh<S>;
51 using Index = typename Base::Index;
52 using Vector3 = typename Base::Vector3;
53 using Triangle = Eigen::Matrix<Index, 3, 1>;
54 using Vertices = typename Base::Vertices;
55 using Normals = typename Base::Normals;
56 using Triangles = std::vector<Triangle>;
57
59 TriMesh();
60
62 ~TriMesh() override = default;
63
66
69
71 bool hasTriangles() const;
72
74 bool hasTriangleNormals() const;
75
77 const Triangles& getTriangles() const;
78
80 const Normals& getTriangleNormals() const;
81
83 void clear() override;
84
86 TriMesh operator+(const TriMesh& other) const;
87
90
95 std::shared_ptr<TriMesh<S>> generateConvexHull(bool optimize = true) const;
96
97protected:
100
103
106
109};
110
111extern template class TriMesh<double>;
112
115
116} // namespace math
117} // namespace dart
118
120
121#endif // DART_MATH_TRIMESH_HPP_
Base class for meshes.
Definition Mesh.hpp:46
Eigen::Matrix< S, 3, 1 > Vector3
Definition Mesh.hpp:51
std::vector< Vector3 > Normals
Definition Mesh.hpp:53
std::size_t Index
Definition Mesh.hpp:50
std::vector< Vector3 > Vertices
Definition Mesh.hpp:52
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
typename Base::Index Index
Definition TriMesh.hpp:51
void normalizeTriangleNormals()
Normalizes triangle normals.
Definition TriMesh-impl.hpp:198
Triangles mTriangles
Triangle indices of the mesh.
Definition TriMesh.hpp:105
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
S_ S
Definition TriMesh.hpp:49
TriMesh()
Default constructor.
Definition TriMesh-impl.hpp:46
Normals mTriangleNormals
Triangle normals of the mesh.
Definition TriMesh.hpp:108
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
~TriMesh() override=default
Destructor.
Definition BulletCollisionDetector.cpp:60