Point Cloud Library (PCL) 1.12.1
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
45namespace pcl
46{
47namespace 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 r = -r;
75 g = -g;
76 b = -b;
77 alpha = -alpha;
78 return (*this);
79 }
80
81 inline __host__ __device__ RGB& operator += (const RGB &rhs)
82 {
83 r += rhs.r;
84 g += rhs.g;
85 b += rhs.b;
86 alpha += rhs.alpha;
87 return (*this);
88 }
89
90 inline __host__ __device__ RGB& operator -= (const RGB &rhs)
91 {
92 r -= rhs.r;
93 g -= rhs.g;
94 b -= rhs.b;
95 alpha -= rhs.alpha;
96 return (*this);
97 }
98
99 inline __host__ __device__ RGB& operator *= (const RGB &rhs)
100 {
101 r *= rhs.r;
102 g *= rhs.g;
103 b *= rhs.b;
104 alpha *= rhs.alpha;
105 return (*this);
106 }
107
108 inline __host__ __device__ RGB& operator /= (const RGB &rhs)
109 {
110 r /= rhs.r;
111 g /= rhs.g;
112 b /= rhs.b;
113 alpha /= rhs.alpha;
114 return (*this);
115 }
116 };
117
118} // namespace
119} // namespace
Default RGB structure, defined as a union over 4 chars.
__host__ __device__ RGB()
__host__ __device__ RGB & operator-=(const RGB &rhs)
__host__ __device__ RGB(int _rgb)
__host__ __device__ bool operator==(const RGB &rhs) const
__host__ __device__ RGB & operator+=(const RGB &rhs)
__host__ __device__ RGB(char _r, char _g, char _b, char _alpha)
__host__ __device__ RGB & operator-(RGB &rhs)
__host__ __device__ RGB & operator/=(const RGB &rhs)
__host__ __device__ RGB & operator*=(const RGB &rhs)