face_selection_tool.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Robot Operating System code by the University of Osnabrück
5  * Copyright (c) 2015, University of Osnabrück
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  *
21  * 3. Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived
23  * from this software without specific prior written permission.
24  *
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
30  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
33  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
34  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
35  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  *
38  *
39  *
40  * face_selection_tool.h
41  *
42  * authors: Henning Deeken <hdeeken@uos.de>
43  * Sebastian Pütz <spuetz@uos.de>
44  * Tristan Igelbrink <tigelbri@uos.de>
45  * Johannes Heitmann <joheitma@uos.de>
46  * Marcel Mrozinski <mmronzs@uos.de
47  *
48  */
49 
50 #ifndef FACE_SELECTION_TOOL_H
51 #define FACE_SELECTION_TOOL_H
52 
53 #include <vector>
54 #include <map>
55 #include <boost/lexical_cast.hpp>
56 
57 #include <QMessageBox>
58 #include <QApplication>
59 #include <QIcon>
60 
61 #include <ros/console.h>
64 #include <rviz/geometry.h>
65 
66 #include <rviz/display_context.h>
67 #include <rviz/frame_manager.h>
68 #include <rviz/display.h>
69 
70 #include <rviz/tool.h>
71 #include <rviz/tool_manager.h>
72 #include <rviz/display_group.h>
73 
74 #include <geometry_msgs/Point32.h>
75 #include <geometry_msgs/PoseStamped.h>
76 #include <mesh_msgs/TriangleMeshStamped.h>
77 #include <std_msgs/Int32.h>
78 
79 #ifndef Q_MOC_RUN
80 #include <rviz/mesh_loader.h>
81 
82 #include <OGRE/OgreManualObject.h>
83 #include <OGRE/OgreSceneNode.h>
84 #include <OGRE/OgreSceneManager.h>
85 #include <OGRE/OgreEntity.h>
86 #include <OGRE/OgreStringConverter.h>
87 #include <OGRE/OgreMaterialManager.h>
88 #include <OGRE/OgreRay.h>
89 #include <OGRE/OgreSceneQuery.h>
90 
91 #endif
92 
93 namespace rviz
94 {
95 class RosTopicProperty;
96 }
97 
110 // OGRE stuff
111 namespace Ogre
112 {
113 class SceneNode;
114 class Vector3;
115 } // namespace Ogre
116 
118 {
120 {
121  Q_OBJECT
122 public:
125  virtual void onInitialize();
126  virtual void activate();
127  virtual void deactivate();
128 
129  virtual int processKeyEvent(QKeyEvent* event, rviz::RenderPanel* panel);
130  virtual int processMouseEvent(rviz::ViewportMouseEvent& event);
131 
132  static const float BOX_SIZE_TOLERANCE;
133  static const size_t MAXIMUM_PICKED_FACES;
134 
135  void clearSelection();
136 
137  bool areFacesSelected();
138  void getSelectedFaces(size_t goalSection, std::string regionLabel, mesh_msgs::TriangleMesh& meshMsg);
139 
140 private Q_SLOTS:
141  void updateTopic();
142 
143 private:
144  void initNode();
145  void initOgre();
146 
147  void updateSelectionMesh();
148 
149  void meshCb(const mesh_msgs::TriangleMeshStamped::ConstPtr& mesh);
150 
151  void setTransform(const mesh_msgs::TriangleMeshStamped& mesh);
152  void setReferenceMesh(mesh_msgs::TriangleMesh mesh);
153  void getSegmentMesh(mesh_msgs::TriangleMesh& mesh);
154 
157 
158  bool singleRayQuery(rviz::ViewportMouseEvent& event, int num_results, Ogre::Ray& ray);
159 
160  void getIdentityOfSingleFace(Ogre::ManualObject* mesh, Ogre::Ray& ray, size_t& goalSection, size_t& goalIndex,
161  Ogre::Real& dist);
162 
163  void getRawManualObjectData(Ogre::ManualObject* mesh, size_t sectionNumber, size_t& vertexCount,
164  Ogre::Vector3*& vertices, size_t& indexCount, unsigned long*& indices);
165 
166  Ogre::SceneManager* scene_manager;
167  Ogre::ManualObject* reference_mesh;
168  Ogre::MaterialPtr reference_mesh_material;
169  Ogre::ManualObject* segment_mesh;
170  Ogre::MaterialPtr segment_mesh_material;
171  Ogre::SceneNode* scene_node;
172 
174 
175  std::map<size_t, std::vector<size_t> > m_goalFaces;
176 
179 
186  bool has_mesh;
187 
189  int reference_color_g = 155;
190  int reference_color_b = 155;
191  float reference_color_a = 0.5;
192 
195  int segment_color_b = 255;
196  float segment_color_a = 0.75;
197 };
198 } // namespace rviz_mesh_plugin
199 #endif
rviz_mesh_plugin::FaceSelectionTool::getIdentityOfSingleFace
void getIdentityOfSingleFace(Ogre::ManualObject *mesh, Ogre::Ray &ray, size_t &goalSection, size_t &goalIndex, Ogre::Real &dist)
Definition: face_selection_tool.cpp:488
rviz_mesh_plugin::FaceSelectionTool::segment_color_b
int segment_color_b
Definition: face_selection_tool.h:195
rviz::RosTopicProperty
Ogre
ros::Publisher
rviz::Tool
display_group.h
rviz_mesh_plugin::FaceSelectionTool::activate
virtual void activate()
Definition: face_selection_tool.cpp:180
mesh_loader.h
rviz_mesh_plugin::FaceSelectionTool::~FaceSelectionTool
~FaceSelectionTool()
Definition: face_selection_tool.cpp:81
rviz_mesh_plugin::FaceSelectionTool::FaceSelectionTool
FaceSelectionTool()
Definition: face_selection_tool.cpp:62
rviz_mesh_plugin::FaceSelectionTool::has_mesh
bool has_mesh
Definition: face_selection_tool.h:186
rviz_mesh_plugin::FaceSelectionTool::num_results
int num_results
Definition: face_selection_tool.h:185
rviz::ViewportMouseEvent
frame_manager.h
rviz_mesh_plugin::FaceSelectionTool::areFacesSelected
bool areFacesSelected()
Definition: face_selection_tool.cpp:268
viewport_mouse_event.h
rviz_mesh_plugin::FaceSelectionTool::n
ros::NodeHandle n
Definition: face_selection_tool.h:180
rviz_mesh_plugin::FaceSelectionTool::clearSelection
void clearSelection()
Definition: face_selection_tool.cpp:258
display.h
rviz_mesh_plugin::FaceSelectionTool::mesh_pub
ros::Publisher mesh_pub
Definition: face_selection_tool.h:182
rviz_mesh_plugin::FaceSelectionTool::segment_color_a
float segment_color_a
Definition: face_selection_tool.h:196
rviz_mesh_plugin::FaceSelectionTool::m_goalFaces
std::map< size_t, std::vector< size_t > > m_goalFaces
Definition: face_selection_tool.h:175
rviz_mesh_plugin::FaceSelectionTool::reference_color_g
int reference_color_g
Definition: face_selection_tool.h:189
visualization_manager.h
rviz_mesh_plugin::FaceSelectionTool::selectSingleFace
void selectSingleFace(rviz::ViewportMouseEvent &event)
Definition: face_selection_tool.cpp:414
tool_manager.h
rviz_mesh_plugin::FaceSelectionTool::updateSelectionMesh
void updateSelectionMesh()
Definition: face_selection_tool.cpp:273
console.h
rviz_mesh_plugin::FaceSelectionTool::id_pub
ros::Publisher id_pub
Definition: face_selection_tool.h:183
rviz_mesh_plugin::FaceSelectionTool::segment_color_g
int segment_color_g
Definition: face_selection_tool.h:194
rviz_mesh_plugin::FaceSelectionTool::reference_color_r
int reference_color_r
Definition: face_selection_tool.h:188
rviz_mesh_plugin::FaceSelectionTool::processKeyEvent
virtual int processKeyEvent(QKeyEvent *event, rviz::RenderPanel *panel)
Definition: face_selection_tool.cpp:312
rviz_mesh_plugin::FaceSelectionTool::mesh_topic
rviz::RosTopicProperty * mesh_topic
Definition: face_selection_tool.h:173
rviz
rviz_mesh_plugin::FaceSelectionTool::MAXIMUM_PICKED_FACES
static const size_t MAXIMUM_PICKED_FACES
Definition: face_selection_tool.h:133
Vector3
rviz_mesh_plugin::FaceSelectionTool::deselectSingleFace
void deselectSingleFace(rviz::ViewportMouseEvent &event)
Definition: face_selection_tool.cpp:458
rviz_mesh_plugin::FaceSelectionTool::reference_color_b
int reference_color_b
Definition: face_selection_tool.h:190
rviz_mesh_plugin::FaceSelectionTool::initNode
void initNode()
Definition: face_selection_tool.cpp:160
rviz_mesh_plugin::FaceSelectionTool::scene_manager
Ogre::SceneManager * scene_manager
Definition: face_selection_tool.h:166
rviz_mesh_plugin::FaceSelectionTool::m_singleSelect
bool m_singleSelect
Definition: face_selection_tool.h:177
rviz_mesh_plugin::FaceSelectionTool::reference_color_a
float reference_color_a
Definition: face_selection_tool.h:191
rviz_mesh_plugin::FaceSelectionTool::goal_pub
ros::Publisher goal_pub
Definition: face_selection_tool.h:184
rviz_mesh_plugin::FaceSelectionTool::getSelectedFaces
void getSelectedFaces(size_t goalSection, std::string regionLabel, mesh_msgs::TriangleMesh &meshMsg)
rviz_mesh_plugin::FaceSelectionTool::setReferenceMesh
void setReferenceMesh(mesh_msgs::TriangleMesh mesh)
Definition: face_selection_tool.cpp:205
rviz_mesh_plugin::FaceSelectionTool::BOX_SIZE_TOLERANCE
static const float BOX_SIZE_TOLERANCE
Definition: face_selection_tool.h:132
rviz_mesh_plugin
Definition: face_selection_tool.h:117
rviz_mesh_plugin::FaceSelectionTool::initOgre
void initOgre()
Definition: face_selection_tool.cpp:116
geometry.h
rviz_mesh_plugin::FaceSelectionTool::getRawManualObjectData
void getRawManualObjectData(Ogre::ManualObject *mesh, size_t sectionNumber, size_t &vertexCount, Ogre::Vector3 *&vertices, size_t &indexCount, unsigned long *&indices)
Definition: face_selection_tool.cpp:534
rviz_mesh_plugin::FaceSelectionTool
Definition: face_selection_tool.h:119
rviz_mesh_plugin::FaceSelectionTool::processMouseEvent
virtual int processMouseEvent(rviz::ViewportMouseEvent &event)
Definition: face_selection_tool.cpp:349
rviz_mesh_plugin::FaceSelectionTool::setTransform
void setTransform(const mesh_msgs::TriangleMeshStamped &mesh)
Definition: face_selection_tool.cpp:188
rviz_mesh_plugin::FaceSelectionTool::singleRayQuery
bool singleRayQuery(rviz::ViewportMouseEvent &event, int num_results, Ogre::Ray &ray)
Definition: face_selection_tool.cpp:392
rviz_mesh_plugin::FaceSelectionTool::segment_color_r
int segment_color_r
Definition: face_selection_tool.h:193
rviz_mesh_plugin::FaceSelectionTool::m_singleDeselect
bool m_singleDeselect
Definition: face_selection_tool.h:178
rviz_mesh_plugin::FaceSelectionTool::updateTopic
void updateTopic()
Definition: face_selection_tool.cpp:94
rviz_mesh_plugin::FaceSelectionTool::reference_mesh_material
Ogre::MaterialPtr reference_mesh_material
Definition: face_selection_tool.h:168
rviz_mesh_plugin::FaceSelectionTool::segment_mesh_material
Ogre::MaterialPtr segment_mesh_material
Definition: face_selection_tool.h:170
rviz_mesh_plugin::FaceSelectionTool::reference_mesh
Ogre::ManualObject * reference_mesh
Definition: face_selection_tool.h:167
rviz::RenderPanel
rviz_mesh_plugin::FaceSelectionTool::getSegmentMesh
void getSegmentMesh(mesh_msgs::TriangleMesh &mesh)
Definition: face_selection_tool.cpp:223
rviz_mesh_plugin::FaceSelectionTool::deactivate
virtual void deactivate()
Definition: face_selection_tool.cpp:184
rviz_mesh_plugin::FaceSelectionTool::meshCb
void meshCb(const mesh_msgs::TriangleMeshStamped::ConstPtr &mesh)
Definition: face_selection_tool.cpp:170
tool.h
rviz_mesh_plugin::FaceSelectionTool::onInitialize
virtual void onInitialize()
Definition: face_selection_tool.cpp:107
rviz_mesh_plugin::FaceSelectionTool::scene_node
Ogre::SceneNode * scene_node
Definition: face_selection_tool.h:171
rviz_mesh_plugin::FaceSelectionTool::mesh_sub
ros::Subscriber mesh_sub
Definition: face_selection_tool.h:181
rviz_mesh_plugin::FaceSelectionTool::segment_mesh
Ogre::ManualObject * segment_mesh
Definition: face_selection_tool.h:169
ros::NodeHandle
ros::Subscriber
display_context.h


rviz_mesh_plugin
Author(s): Sebastian Pütz , Henning Deeken , Marcel Mrozinski , Kristin Schmidt , Jan Philipp Vogtherr
autogenerated on Fri Feb 12 2021 04:03:57