forwards.h
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 #ifndef RVIZ_SELECTION_FORWARDS_H
31 #define RVIZ_SELECTION_FORWARDS_H
32 
33 #include <vector>
34 #include <set>
35 #include <map>
36 #include <boost/unordered_map.hpp>
37 #include <OgrePixelFormat.h>
38 #include <OgreColourValue.h>
39 
40 #include <ros/console.h>
41 
42 
43 namespace rviz
44 {
45 typedef uint32_t CollObjectHandle;
46 typedef std::vector<CollObjectHandle> V_CollObject;
47 typedef std::vector<V_CollObject> VV_CollObject;
48 typedef std::set<CollObjectHandle> S_CollObject;
49 
50 typedef std::set<uint64_t> S_uint64;
51 typedef std::vector<uint64_t> V_uint64;
52 
53 struct Picked
54 {
55  Picked(CollObjectHandle _handle = 0) : handle(_handle), pixel_count(1)
56  {
57  }
58 
59  CollObjectHandle handle;
61  S_uint64 extra_handles;
62 };
63 typedef boost::unordered_map<CollObjectHandle, Picked> M_Picked;
64 
65 
66 inline uint32_t colorToHandle(Ogre::PixelFormat fmt, uint32_t col)
67 {
68  uint32_t handle = 0;
69  if (fmt == Ogre::PF_A8R8G8B8 || fmt == Ogre::PF_X8R8G8B8 || fmt == Ogre::PF_R8G8B8)
70  {
71  handle = col & 0x00ffffff;
72  }
73  else if (fmt == Ogre::PF_R8G8B8A8)
74  {
75  handle = col >> 8;
76  }
77  else
78  {
79  ROS_DEBUG("Incompatible pixel format [%d]", fmt);
80  }
81 
82  return handle;
83 }
84 
85 inline CollObjectHandle colorToHandle(const Ogre::ColourValue& color)
86 {
87  return (int(color.r * 255) << 16) | (int(color.g * 255) << 8) | int(color.b * 255);
88 }
89 
90 
91 } // namespace rviz
92 
93 #endif
std::vector< uint64_t > V_uint64
Definition: forwards.h:51
boost::unordered_map< CollObjectHandle, Picked > M_Picked
Definition: forwards.h:63
S_uint64 extra_handles
Definition: forwards.h:61
CollObjectHandle handle
Definition: forwards.h:59
int pixel_count
Definition: forwards.h:60
std::vector< V_CollObject > VV_CollObject
Definition: forwards.h:47
std::vector< CollObjectHandle > V_CollObject
Definition: forwards.h:46
uint32_t colorToHandle(Ogre::PixelFormat fmt, uint32_t col)
Definition: forwards.h:66
std::set< uint64_t > S_uint64
Definition: forwards.h:50
std::set< CollObjectHandle > S_CollObject
Definition: forwards.h:48
Picked(CollObjectHandle _handle=0)
Definition: forwards.h:55
#define ROS_DEBUG(...)
uint32_t CollObjectHandle
Definition: forwards.h:45


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24