DART 6.10.1
Loading...
Searching...
No Matches
LineSegmentShape.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_DYNAMICS_LINESEGMENTSHAPE_HPP_
34#define DART_DYNAMICS_LINESEGMENTSHAPE_HPP_
35
37
38namespace dart {
39namespace dynamics {
40
45class LineSegmentShape : public Shape
46{
47public:
49 LineSegmentShape(float _thickness = 1.0f);
50
53 const Eigen::Vector3d& _v1,
54 const Eigen::Vector3d& _v2,
55 float _thickness = 1.0f);
56
57 // Documentation inherited.
58 const std::string& getType() const override;
59
61 static const std::string& getStaticType();
62
64 void setThickness(float _thickness);
65
67 float getThickness() const;
68
70 std::size_t addVertex(const Eigen::Vector3d& _v);
71
73 std::size_t addVertex(const Eigen::Vector3d& _v, std::size_t _parent);
74
80 void removeVertex(std::size_t _idx);
81
83 void setVertex(std::size_t _idx, const Eigen::Vector3d& _v);
84
87 const Eigen::Vector3d& getVertex(std::size_t _idx) const;
88
90 const std::vector<Eigen::Vector3d>& getVertices() const;
91
93 void addConnection(std::size_t _idx1, std::size_t _idx2);
94
97 void removeConnection(std::size_t _vertexIdx1, std::size_t _vertexIdx2);
98
102 void removeConnection(std::size_t _connectionIdx);
103
106
109 Eigen::Matrix3d computeInertia(double mass) const override;
110
111 // TODO(MXG): Consider supporting colors-per-vertex
112
113protected:
114 // Documentation inherited.
115 void updateBoundingBox() const override;
116
117 // Documentation inherited
118 void updateVolume() const override;
119
122
124 std::vector<Eigen::Vector3d> mVertices;
125
128
131 static const Eigen::Vector3d mDummyVertex;
132};
133
134} // namespace dynamics
135} // namespace dart
136
137#endif // DART_DYNAMICS_LINESEGMENTSHAPE_HPP_
The LineSegmentShape facilitates creating graphs of line segments.
Definition LineSegmentShape.hpp:46
static const Eigen::Vector3d mDummyVertex
A dummy vertex that can be returned when an out-of-bounds vertex is requested.
Definition LineSegmentShape.hpp:131
float getThickness() const
Get the line thickness/width used for rendering.
Definition LineSegmentShape.cpp:104
Eigen::Matrix3d computeInertia(double mass) const override
The returned inertia matrix will be like a very thin cylinder.
Definition LineSegmentShape.cpp:299
void updateVolume() const override
Updates volume.
Definition LineSegmentShape.cpp:391
const Eigen::Vector3d & getVertex(std::size_t _idx) const
Get the location of the specified vertex.
Definition LineSegmentShape.cpp:195
void setThickness(float _thickness)
Set the line thickness/width for rendering.
Definition LineSegmentShape.cpp:90
float mThickness
Line thickness for rendering.
Definition LineSegmentShape.hpp:121
std::vector< Eigen::Vector3d > mVertices
Vector of vertices.
Definition LineSegmentShape.hpp:124
static const std::string & getStaticType()
Returns shape type for this class.
Definition LineSegmentShape.cpp:83
void updateBoundingBox() const override
Updates bounding box.
Definition LineSegmentShape.cpp:363
void addConnection(std::size_t _idx1, std::size_t _idx2)
Create a connection between the two specified vertices.
Definition LineSegmentShape.cpp:222
std::size_t addVertex(const Eigen::Vector3d &_v)
Add a vertex as a child to the last vertex that was added.
Definition LineSegmentShape.cpp:110
common::aligned_vector< Eigen::Vector2i > mConnections
Vector of connections.
Definition LineSegmentShape.hpp:127
void removeConnection(std::size_t _vertexIdx1, std::size_t _vertexIdx2)
Search for a connection between two vertices and break it if it exists.
Definition LineSegmentShape.cpp:246
const std::string & getType() const override
Returns a string representing the shape type.
Definition LineSegmentShape.cpp:77
void removeVertex(std::size_t _idx)
Remove a vertex from the list of vertices.
Definition LineSegmentShape.cpp:153
void setVertex(std::size_t _idx, const Eigen::Vector3d &_v)
Change the location of the specified vertex.
Definition LineSegmentShape.cpp:175
const std::vector< Eigen::Vector3d > & getVertices() const
Get all the vertices.
Definition LineSegmentShape.cpp:216
const common::aligned_vector< Eigen::Vector2i > & getConnections() const
Get all the connections.
Definition LineSegmentShape.cpp:293
Definition Shape.hpp:54
std::vector< _Tp, Eigen::aligned_allocator< _Tp > > aligned_vector
Definition Memory.hpp:71
Definition BulletCollisionDetector.cpp:65