Point Cloud Library (PCL)  1.14.1-dev
point_type_rgb.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Willow Garage, Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  */
35 
36 #pragma once
37 
38 #include <cuda.h>
39 #include <pcl/cuda/cutil_math.h>
40 
41 #ifdef RGB
42 # undef RGB
43 #endif
44 
45 namespace pcl
46 {
47 namespace cuda
48 {
49 
50  /** \brief Default RGB structure, defined as a union over 4 chars. */
51  union RGB
52  {
53  int rgb;
54  struct
55  {
56  char r;
57  char g;
58  char b;
59  char alpha;
60  };
61 
62  inline __host__ __device__ RGB () {}
63  inline __host__ __device__ RGB (int _rgb) : rgb(_rgb) {}
64  inline __host__ __device__ RGB (char _r, char _g, char _b, char _alpha) :
65  r(_r), g(_g), b(_b), alpha(_alpha) {}
66 
67  inline __host__ __device__ bool operator == (const RGB &rhs) const
68  {
69  return (r == rhs.r && g == rhs.g && b == rhs.b && alpha == rhs.alpha);
70  }
71 
72  inline __host__ __device__ RGB operator - (RGB &rhs)
73  {
74  RGB res = *this;
75  res -= rhs;
76  return (res);
77  }
78 
79  inline __host__ __device__ RGB& operator += (const RGB &rhs)
80  {
81  r += rhs.r;
82  g += rhs.g;
83  b += rhs.b;
84  alpha += rhs.alpha;
85  return (*this);
86  }
87 
88  inline __host__ __device__ RGB& operator -= (const RGB &rhs)
89  {
90  r -= rhs.r;
91  g -= rhs.g;
92  b -= rhs.b;
93  alpha -= rhs.alpha;
94  return (*this);
95  }
96 
97  inline __host__ __device__ RGB& operator *= (const RGB &rhs)
98  {
99  r *= rhs.r;
100  g *= rhs.g;
101  b *= rhs.b;
102  alpha *= rhs.alpha;
103  return (*this);
104  }
105 
106  inline __host__ __device__ RGB& operator /= (const RGB &rhs)
107  {
108  r /= rhs.r;
109  g /= rhs.g;
110  b /= rhs.b;
111  alpha /= rhs.alpha;
112  return (*this);
113  }
114  };
115 
116 } // namespace
117 } // namespace
Default RGB structure, defined as a union over 4 chars.
__host__ __device__ RGB()
__host__ __device__ RGB & operator-=(const RGB &rhs)
__host__ __device__ RGB & operator*=(const RGB &rhs)
__host__ __device__ RGB operator-(RGB &rhs)
__host__ __device__ RGB(int _rgb)
__host__ __device__ bool operator==(const RGB &rhs) const
__host__ __device__ RGB(char _r, char _g, char _b, char _alpha)
__host__ __device__ RGB & operator/=(const RGB &rhs)
__host__ __device__ RGB & operator+=(const RGB &rhs)