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