moveit2
The MoveIt Motion Planning Framework for ROS 2.
mesh_shape.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #pragma once
31 
32 #include <rviz_rendering/objects/shape.hpp>
33 
34 namespace Ogre
35 {
36 class ManualObject;
37 }
38 
39 // TODO(JafarAbdi): This's taken from https://github.com/ros2/rviz for MoveIt 2 beta release -- remove when it's ported
40 namespace rviz_rendering
41 {
68 class MeshShape : public Shape
69 {
70 public:
77  MeshShape(Ogre::SceneManager* scene_manager, Ogre::SceneNode* parent_node = nullptr);
78  ~MeshShape() override;
79 
80  /* \brief Estimate the number of vertices ahead of time. */
81  void estimateVertexCount(size_t vcount);
82 
84  void beginTriangles();
85 
92  void addVertex(const Ogre::Vector3& position);
93 
100  void addVertex(const Ogre::Vector3& position, const Ogre::Vector3& normal);
101 
108  void addVertex(const Ogre::Vector3& position, const Ogre::Vector3& normal, const Ogre::ColourValue& color);
109 
111  void addNormal(const Ogre::Vector3& normal);
112 
114  void addColor(const Ogre::ColourValue& color);
115 
117  void addTriangle(unsigned int p1, unsigned int p2, unsigned int p3);
118 
121  void endTriangles();
122 
124  void clear();
125 
127  Ogre::ManualObject* getManualObject()
128  {
129  return manual_object_;
130  }
131 
132 private:
133  // true in between calls to beginTriangles() and endTriangles()
134  bool started_;
135  Ogre::ManualObject* manual_object_;
136 };
137 
138 } // namespace rviz_rendering
This class allows constructing Ogre shapes manually, from triangle lists.
Definition: mesh_shape.hpp:69
void addColor(const Ogre::ColourValue &color)
Add color for a vertex.
Definition: mesh_shape.cpp:106
void beginTriangles()
Start adding triangles to the mesh.
Definition: mesh_shape.cpp:65
void addTriangle(unsigned int p1, unsigned int p2, unsigned int p3)
Add a triangle by indexing in the defined vertices.
Definition: mesh_shape.cpp:111
void addVertex(const Ogre::Vector3 &position)
Add a vertex to the mesh (no normal defined). If using this function only (not using addTriangle()) i...
Definition: mesh_shape.cpp:80
MeshShape(Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node=nullptr)
Constructor.
Definition: mesh_shape.cpp:45
void clear()
Clear the mesh.
Definition: mesh_shape.cpp:138
void estimateVertexCount(size_t vcount)
Definition: mesh_shape.cpp:59
void endTriangles()
Notify that the set of triangles to add is complete. No more triangles can be added,...
Definition: mesh_shape.cpp:116
void addNormal(const Ogre::Vector3 &normal)
Add normal for a vertex.
Definition: mesh_shape.cpp:101
Ogre::ManualObject * getManualObject()
Get the manual object created for the mesh.
Definition: mesh_shape.hpp:127