DART 6.12.2
Loading...
Searching...
No Matches
Mesh.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_MESH_HPP_
34#define DART_MATH_MESH_HPP_
35
36#include <vector>
37
38#include <Eigen/Core>
39
40namespace dart {
41namespace math {
42
44template <typename S_>
45class Mesh
46{
47public:
48 // Type aliases
49 using S = S_;
50 using Index = std::size_t;
51 using Vector3 = Eigen::Matrix<S, 3, 1>;
52 using Vertices = std::vector<Vector3>;
53 using Normals = std::vector<Vector3>;
54 using Indices = std::vector<Index>;
55
57 virtual ~Mesh();
58
60 bool hasVertices() const;
61
63 bool hasVertexNormals() const;
64
66 const Vertices& getVertices() const;
67
69 const Normals& getVertexNormals() const;
70
72 virtual void clear();
73
75 bool isEmpty() const;
76
78 void translate(const Vector3& translation);
79
81 Mesh operator+(const Mesh& other) const;
82
84 Mesh& operator+=(const Mesh& other);
85
86protected:
88 Mesh();
89
92
95
98};
99
102
103} // namespace math
104} // namespace dart
105
107
108#endif // DART_MATH_MESH_HPP_
Base class for meshes.
Definition Mesh.hpp:46
const Vertices & getVertices() const
Returns the vertices of the mesh.
Definition Mesh-impl.hpp:64
Eigen::Matrix< S, 3, 1 > Vector3
Definition Mesh.hpp:51
Mesh operator+(const Mesh &other) const
Addition operator.
Definition Mesh-impl.hpp:103
Vertices mVertices
Vertices of the mesh.
Definition Mesh.hpp:94
bool isEmpty() const
Returns true if the mesh has no vertices.
Definition Mesh-impl.hpp:86
std::vector< Vector3 > Normals
Definition Mesh.hpp:53
std::size_t Index
Definition Mesh.hpp:50
virtual ~Mesh()
Destructor.
Definition Mesh-impl.hpp:43
std::vector< Vector3 > Vertices
Definition Mesh.hpp:52
bool hasVertices() const
Returns true if the mesh contains vertices.
Definition Mesh-impl.hpp:50
std::vector< Index > Indices
Definition Mesh.hpp:54
Normals mVertexNormals
Vertex normals of the mesh.
Definition Mesh.hpp:97
virtual void clear()
Clears all the vertices and vertex normals.
Definition Mesh-impl.hpp:78
Mesh()
Default constructor.
Definition Mesh-impl.hpp:138
void normalizeVertexNormals()
Normalizes the vertex normals.
Definition Mesh-impl.hpp:145
bool hasVertexNormals() const
Returns true if the mesh contains vertex normals.
Definition Mesh-impl.hpp:57
void translate(const Vector3 &translation)
Translates the mesh vertices by adding translation to the vertices.
Definition Mesh-impl.hpp:93
const Normals & getVertexNormals() const
Returns the vertex normals of the mesh.
Definition Mesh-impl.hpp:71
Mesh & operator+=(const Mesh &other)
Addition assignment operator.
Definition Mesh-impl.hpp:110
S_ S
Definition Mesh.hpp:49
Definition BulletCollisionDetector.cpp:60