DART  6.10.1
PointCloudShape.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_POINTCLOUDSHAPE_HPP_
34 #define DART_DYNAMICS_POINTCLOUDSHAPE_HPP_
35 
36 #include "dart/dynamics/Shape.hpp"
37 
38 #if HAVE_OCTOMAP
39 # include <octomap/Pointcloud.h>
40 #endif
41 
42 namespace dart {
43 namespace dynamics {
44 
46 class PointCloudShape : public Shape
47 {
48 public:
49  enum ColorMode
50  {
53 
56 
59  };
60 
62  {
63  BOX = 0,
67  };
68 
72  explicit PointCloudShape(double visualSize = 0.01);
73 
75  ~PointCloudShape() override = default;
76 
77  // Documentation inherited.
78  const std::string& getType() const override;
79 
80  // Documentation inherited.
81  Eigen::Matrix3d computeInertia(double mass) const override;
82 
84  static const std::string& getStaticType();
85 
87  void reserve(std::size_t size);
88 
90  void addPoint(const Eigen::Vector3d& point);
91 
93  void addPoint(const std::vector<Eigen::Vector3d>& points);
94 
96  void setPoint(const std::vector<Eigen::Vector3d>& points);
97 
98 #if HAVE_OCTOMAP
100  void setPoints(::octomap::Pointcloud& pointCloud);
101 
103  void addPoints(::octomap::Pointcloud& pointCloud);
104 #endif
105 
107  const std::vector<Eigen::Vector3d>& getPoints() const;
108 
110  std::size_t getNumPoints() const;
111 
113  void removeAllPoints();
114 
117 
120 
122  void setColorMode(ColorMode mode);
123 
125  ColorMode getColorMode() const;
126 
130  void setOverallColor(const Eigen::Vector4d& color);
131 
133  Eigen::Vector4d getOverallColor() const;
134 
139  void setColors(const std::vector<
140  Eigen::Vector4d,
141  Eigen::aligned_allocator<Eigen::Vector4d>>& colors);
142 
144  const std::vector<Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d>>&
145  getColors() const;
146 
148  void setVisualSize(double size);
149 
151  double getVisualSize() const;
152 
153  // Documentation inherited.
154  void notifyColorUpdated(const Eigen::Vector4d& color) override;
155 
156 protected:
157  // Documentation inherited.
158  void updateVolume() const override;
159 
160  // Documentation inherited.
161  void updateBoundingBox() const override;
162 
164  std::vector<Eigen::Vector3d> mPoints;
165 
168 
171 
173  std::vector<Eigen::Vector4d, Eigen::aligned_allocator<Eigen::Vector4d>>
175 
177  double mVisualSize;
178 };
179 
180 } // namespace dynamics
181 } // namespace dart
182 
183 #endif // DART_DYNAMICS_POINTCLOUDSHAPE_HPP_
std::string type
Definition: SdfParser.cpp:82
The PointCloudShape represents point cloud data.
Definition: PointCloudShape.hpp:47
PointShapeType getPointShapeType() const
Returns the point shape type.
Definition: PointCloudShape.cpp:161
double mVisualSize
The size of visual object that represents each point.
Definition: PointCloudShape.hpp:177
Eigen::Vector4d getOverallColor() const
Returns the overall color.
Definition: PointCloudShape.cpp:186
const std::vector< Eigen::Vector4d, Eigen::aligned_allocator< Eigen::Vector4d > > & getColors() const
Returns the point cloud colors.
Definition: PointCloudShape.cpp:217
PointCloudShape(double visualSize=0.01)
Constructor.
Definition: PointCloudShape.cpp:55
void setPointShapeType(PointShapeType type)
Sets the point shape type.
Definition: PointCloudShape.cpp:151
PointShapeType mPointShapeType
The point shape type.
Definition: PointCloudShape.hpp:167
ColorMode
Definition: PointCloudShape.hpp:50
@ BIND_PER_POINT
Use one color per point.
Definition: PointCloudShape.hpp:58
@ BIND_OVERALL
Use one color for all the points.
Definition: PointCloudShape.hpp:55
@ USE_SHAPE_COLOR
Use the color specified by the ShapeAspect. This is the default.
Definition: PointCloudShape.hpp:52
void setColorMode(ColorMode mode)
Sets the color mode.
Definition: PointCloudShape.cpp:167
std::vector< Eigen::Vector3d > mPoints
List of points.
Definition: PointCloudShape.hpp:164
std::size_t getNumPoints() const
Returns the number of points.
Definition: PointCloudShape.cpp:139
void setColors(const std::vector< Eigen::Vector4d, Eigen::aligned_allocator< Eigen::Vector4d >> &colors)
Sets the point cloud colors.
Definition: PointCloudShape.cpp:207
double getVisualSize() const
Returns size of visual object that represents each point.
Definition: PointCloudShape.cpp:230
void addPoint(const Eigen::Vector3d &point)
Adds a point to this point cloud.
Definition: PointCloudShape.cpp:90
Eigen::Matrix3d computeInertia(double mass) const override
Computes the inertia.
Definition: PointCloudShape.cpp:71
PointShapeType
Definition: PointCloudShape.hpp:62
@ POINT
Vertex.
Definition: PointCloudShape.hpp:66
@ BILLBOARD_CIRCLE
2D circle always facing the screen
Definition: PointCloudShape.hpp:65
@ BILLBOARD_SQUARE
2D square always facing the screen
Definition: PointCloudShape.hpp:64
@ BOX
3D volumetric box
Definition: PointCloudShape.hpp:63
void removeAllPoints()
Removes all the points.
Definition: PointCloudShape.cpp:145
~PointCloudShape() override=default
Destructor.
ColorMode mColorMode
The color mode.
Definition: PointCloudShape.hpp:170
void reserve(std::size_t size)
Reserves the point list by size.
Definition: PointCloudShape.cpp:84
const std::string & getType() const override
Returns a string representing the shape type.
Definition: PointCloudShape.cpp:65
void setOverallColor(const Eigen::Vector4d &color)
Sets the overall color.
Definition: PointCloudShape.cpp:179
void updateBoundingBox() const override
Updates bounding box.
Definition: PointCloudShape.cpp:249
std::vector< Eigen::Vector4d, Eigen::aligned_allocator< Eigen::Vector4d > > mColors
List of colors.
Definition: PointCloudShape.hpp:174
ColorMode getColorMode() const
Returns the color mode.
Definition: PointCloudShape.cpp:173
void notifyColorUpdated(const Eigen::Vector4d &color) override
Notify that the color (rgba) of this shape has updated.
Definition: PointCloudShape.cpp:236
void setPoint(const std::vector< Eigen::Vector3d > &points)
Replaces points with points.
Definition: PointCloudShape.cpp:106
void updateVolume() const override
Updates volume.
Definition: PointCloudShape.cpp:242
const std::vector< Eigen::Vector3d > & getPoints() const
Returns the list of points.
Definition: PointCloudShape.cpp:133
void setVisualSize(double size)
Sets size of visual object that represents each point.
Definition: PointCloudShape.cpp:223
static const std::string & getStaticType()
Returns shape type for this class.
Definition: PointCloudShape.cpp:77
Definition: Shape.hpp:54
Definition: BulletCollisionDetector.cpp:65