Point Cloud Library (PCL)  1.9.1
point_types.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  * $Id$
35  *
36  */
37 
38 #ifndef PCL_CUDA_POINT_TYPES_H_
39 #define PCL_CUDA_POINT_TYPES_H_
40 
41 #include <pcl/cuda/common/point_type_rgb.h>
42 #include <cuda.h>
43 
44 namespace pcl
45 {
46 namespace cuda
47 {
48  /** \brief Default point xyz-rgb structure. */
49  struct /*__align__(16)*/ PointXYZRGB
50  {
51  inline __host__ __device__ PointXYZRGB () {}
52  inline __host__ __device__ PointXYZRGB (float _x, float _y, float _z, int _rgb) :
53  x(_x), y(_y), z(_z), rgb(_rgb) {}
54 
55  // Declare a union for XYZ
56  union
57  {
58  float3 xyz;
59  struct
60  {
61  float x;
62  float y;
63  float z;
64  };
65  };
67 
68  inline __host__ __device__ bool operator == (const PointXYZRGB &rhs)
69  {
70  return (x == rhs.x && y == rhs.y && z == rhs.z && rgb == rhs.rgb);
71  }
72 
73  // this allows direct assignment of a PointXYZRGB to float3...
74  inline __host__ __device__ operator float3 () const
75  {
76  return xyz;
77  }
78 
79  const inline __host__ __device__ PointXYZRGB operator - (const PointXYZRGB &rhs) const
80  {
81  PointXYZRGB res = *this;
82  res -= rhs;
83  return (res);
84 // xyz = -rhs.xyz;
85 // rgb = -rhs.rgb;
86 // return (*this -= rhs);
87  }
88 
89  inline __host__ __device__ PointXYZRGB& operator += (const PointXYZRGB &rhs)
90  {
91  xyz += rhs.xyz;
92  rgb += rhs.rgb;
93  return (*this);
94  }
95 
96  inline __host__ __device__ PointXYZRGB& operator -= (const PointXYZRGB &rhs)
97  {
98  xyz -= rhs.xyz;
99  rgb -= rhs.rgb;
100  return (*this);
101  }
102 
103  inline __host__ __device__ PointXYZRGB& operator *= (const PointXYZRGB &rhs)
104  {
105  xyz *= rhs.xyz;
106  rgb *= rhs.rgb;
107  return (*this);
108  }
109 
110  inline __host__ __device__ PointXYZRGB& operator /= (const PointXYZRGB &rhs)
111  {
112  xyz /= rhs.xyz;
113  rgb /= rhs.rgb;
114  return (*this);
115  }
116  };
117 
118  /** \brief Default point xyz-rgb structure. */
120  {
121  inline __host__ __device__ PointXYZRGBNormal () {}
122  inline __host__ __device__ PointXYZRGBNormal (float _x, float _y, float _z, int _rgb) :
123  x(_x), y(_y), z(_z), rgb(_rgb) {}
124 
125  // Declare a union for XYZ
126  union
127  {
128  float3 xyz;
129  struct
130  {
131  float x;
132  float y;
133  float z;
134  };
135  };
136  RGB rgb;
137  union
138  {
139  float4 normal;
140  struct
141  {
142  float normal_x;
143  float normal_y;
144  float normal_z;
145  float curvature;
146  };
147  };
148 
149  inline __host__ __device__ bool operator == (const PointXYZRGBNormal &rhs)
150  {
151  return (x == rhs.x && y == rhs.y && z == rhs.z && rgb == rhs.rgb && normal_x == rhs.normal_x && normal_y == rhs.normal_y && normal_z == rhs.normal_z);
152  }
153 
154  // this allows direct assignment of a PointXYZRGBNormal to float3...
155  inline __host__ __device__ operator float3 () const
156  {
157  return xyz;
158  }
159 
160  const inline __host__ __device__ PointXYZRGBNormal operator - (const PointXYZRGBNormal &rhs) const
161  {
162  PointXYZRGBNormal res = *this;
163  res -= rhs;
164  return (res);
165 // xyz = -rhs.xyz;
166 // rgb = -rhs.rgb;
167 // return (*this -= rhs);
168  }
169 
170  inline __host__ __device__ PointXYZRGBNormal& operator += (const PointXYZRGBNormal &rhs)
171  {
172  xyz += rhs.xyz;
173  rgb += rhs.rgb;
174  normal += rhs.normal;
175  return (*this);
176  }
177 
178  inline __host__ __device__ PointXYZRGBNormal& operator -= (const PointXYZRGBNormal &rhs)
179  {
180  xyz -= rhs.xyz;
181  rgb -= rhs.rgb;
182  normal -= rhs.normal;
183  return (*this);
184  }
185 
186  inline __host__ __device__ PointXYZRGBNormal& operator *= (const PointXYZRGBNormal &rhs)
187  {
188  xyz *= rhs.xyz;
189  rgb *= rhs.rgb;
190  normal *= rhs.normal;
191  return (*this);
192  }
193 
194  inline __host__ __device__ PointXYZRGBNormal& operator /= (const PointXYZRGBNormal &rhs)
195  {
196  xyz /= rhs.xyz;
197  rgb /= rhs.rgb;
198  normal /= rhs.normal;
199  return (*this);
200  }
201  };
202 } // namespace
203 } // namespace
204 
205 #endif //#ifndef PCL_CUDA_POINT_TYPES_H_
206 
__host__ __device__ PointXYZRGB & operator*=(const PointXYZRGB &rhs)
Definition: point_types.h:103
__host__ __device__ PointXYZRGB & operator/=(const PointXYZRGB &rhs)
Definition: point_types.h:110
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
__host__ __device__ PointXYZRGB & operator-=(const PointXYZRGB &rhs)
Definition: point_types.h:96
__host__ __device__ PointXYZRGB()
Definition: point_types.h:51
__host__ __device__ PointXYZRGB(float _x, float _y, float _z, int _rgb)
Definition: point_types.h:52
__host__ __device__ bool operator==(const PointXYZRGB &rhs)
Definition: point_types.h:68
const __host__ __device__ PointXYZRGB operator-(const PointXYZRGB &rhs) const
Definition: point_types.h:79
struct __align__(16) PointXYZRGBNormal
Default point xyz-rgb structure.
Definition: point_types.h:119
__host__ __device__ PointXYZRGB & operator+=(const PointXYZRGB &rhs)
Definition: point_types.h:89
Default RGB structure, defined as a union over 4 chars.
Default point xyz-rgb structure.
Definition: point_types.h:49
A point structure representing Euclidean xyz coordinates, and the RGB color, together with normal coo...