|
Point Cloud Library (PCL)
1.4.0
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2010, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * $Id: point_types.hpp 3746 2011-12-31 22:19:47Z rusu $ 00035 * 00036 */ 00037 00038 #ifndef PCL_IMPL_POINT_TYPES_HPP_ 00039 #define PCL_IMPL_POINT_TYPES_HPP_ 00040 00041 // Define all PCL point types 00042 #define PCL_POINT_TYPES \ 00043 (pcl::PointXYZ) \ 00044 (pcl::PointXYZI) \ 00045 (pcl::PointXYZL) \ 00046 (pcl::PointXYZRGBA) \ 00047 (pcl::PointXYZRGB) \ 00048 (pcl::PointXYZRGBL) \ 00049 (pcl::PointXYZHSV) \ 00050 (pcl::PointXY) \ 00051 (pcl::InterestPoint) \ 00052 (pcl::Normal) \ 00053 (pcl::PointNormal) \ 00054 (pcl::PointXYZRGBNormal) \ 00055 (pcl::PointXYZINormal) \ 00056 (pcl::PointWithRange) \ 00057 (pcl::PointWithViewpoint) \ 00058 (pcl::MomentInvariants) \ 00059 (pcl::PrincipalRadiiRSD) \ 00060 (pcl::Boundary) \ 00061 (pcl::PrincipalCurvatures) \ 00062 (pcl::PFHSignature125) \ 00063 (pcl::PFHRGBSignature250) \ 00064 (pcl::PPFSignature) \ 00065 (pcl::PPFRGBSignature) \ 00066 (pcl::NormalBasedSignature12) \ 00067 (pcl::FPFHSignature33) \ 00068 (pcl::VFHSignature308) \ 00069 (pcl::Narf36) \ 00070 (pcl::IntensityGradient) \ 00071 (pcl::PointWithScale) 00072 00073 // Define all point types that include XYZ data 00074 #define PCL_XYZ_POINT_TYPES \ 00075 (pcl::PointXYZ) \ 00076 (pcl::PointXYZI) \ 00077 (pcl::PointXYZL) \ 00078 (pcl::PointXYZRGBA) \ 00079 (pcl::PointXYZRGB) \ 00080 (pcl::PointXYZRGBL) \ 00081 (pcl::PointXYZHSV) \ 00082 (pcl::InterestPoint) \ 00083 (pcl::PointNormal) \ 00084 (pcl::PointXYZRGBNormal) \ 00085 (pcl::PointXYZINormal) \ 00086 (pcl::PointWithRange) \ 00087 (pcl::PointWithViewpoint) \ 00088 (pcl::PointWithScale) 00089 00090 // Define all point types with XYZ and label 00091 #define PCL_XYZL_POINT_TYPES \ 00092 (pcl::PointXYZL) \ 00093 (pcl::PointXYZRGBL) 00094 00095 // Define all point types that include normal[3] data 00096 #define PCL_NORMAL_POINT_TYPES \ 00097 (pcl::Normal) \ 00098 (pcl::PointNormal) \ 00099 (pcl::PointXYZRGBNormal) \ 00100 (pcl::PointXYZINormal) 00101 00102 // Define all point types that represent features 00103 #define PCL_FEATURE_POINT_TYPES \ 00104 (pcl::PFHSignature125) \ 00105 (pcl::PFHRGBSignature250) \ 00106 (pcl::PPFSignature) \ 00107 (pcl::PPFRGBSignature) \ 00108 (pcl::NormalBasedSignature12) \ 00109 (pcl::FPFHSignature33) \ 00110 (pcl::VFHSignature308) \ 00111 (pcl::Narf36) 00112 00113 namespace pcl 00114 { 00115 00116 template <typename PointT> inline bool 00117 isFinite (PointT &pt) 00118 { 00119 if (!pcl_isfinite (pt.x) || !pcl_isfinite (pt.y) || !pcl_isfinite (pt.z)) 00120 return (false); 00121 return (true); 00122 } 00123 00124 #define PCL_ADD_POINT4D \ 00125 EIGEN_ALIGN16 \ 00126 union { \ 00127 float data[4]; \ 00128 struct { \ 00129 float x; \ 00130 float y; \ 00131 float z; \ 00132 }; \ 00133 }; \ 00134 inline Eigen::Map<Eigen::Vector3f> getVector3fMap () { return (Eigen::Vector3f::Map (data)); } \ 00135 inline const Eigen::Map<const Eigen::Vector3f> getVector3fMap () const { return (Eigen::Vector3f::Map (data)); } \ 00136 inline Eigen::Map<Eigen::Vector4f, Eigen::Aligned> getVector4fMap () { return (Eigen::Vector4f::MapAligned (data)); } \ 00137 inline const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> getVector4fMap () const { return (Eigen::Vector4f::MapAligned (data)); } \ 00138 inline Eigen::Map<Eigen::Array3f> getArray3fMap () { return (Eigen::Array3f::Map (data)); } \ 00139 inline const Eigen::Map<const Eigen::Array3f> getArray3fMap () const { return (Eigen::Array3f::Map (data)); } \ 00140 inline Eigen::Map<Eigen::Array4f, Eigen::Aligned> getArray4fMap () { return (Eigen::Array4f::MapAligned (data)); } \ 00141 inline const Eigen::Map<const Eigen::Array4f, Eigen::Aligned> getArray4fMap () const { return (Eigen::Array4f::MapAligned (data)); } 00142 00143 #define PCL_ADD_NORMAL4D \ 00144 EIGEN_ALIGN16 \ 00145 union { \ 00146 float data_n[4]; \ 00147 float normal[3]; \ 00148 struct { \ 00149 float normal_x; \ 00150 float normal_y; \ 00151 float normal_z; \ 00152 }; \ 00153 }; \ 00154 inline Eigen::Map<Eigen::Vector3f> getNormalVector3fMap () { return (Eigen::Vector3f::Map (data_n)); } \ 00155 inline const Eigen::Map<const Eigen::Vector3f> getNormalVector3fMap () const { return (Eigen::Vector3f::Map (data_n)); } \ 00156 inline Eigen::Map<Eigen::Vector4f, Eigen::Aligned> getNormalVector4fMap () { return (Eigen::Vector4f::MapAligned (data_n)); } \ 00157 inline const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> getNormalVector4fMap () const { return (Eigen::Vector4f::MapAligned (data_n)); } 00158 00159 typedef Eigen::Map<Eigen::Array3f> Array3fMap; 00160 typedef const Eigen::Map<const Eigen::Array3f> Array3fMapConst; 00161 typedef Eigen::Map<Eigen::Array4f, Eigen::Aligned> Array4fMap; 00162 typedef const Eigen::Map<const Eigen::Array4f, Eigen::Aligned> Array4fMapConst; 00163 typedef Eigen::Map<Eigen::Vector3f> Vector3fMap; 00164 typedef const Eigen::Map<const Eigen::Vector3f> Vector3fMapConst; 00165 typedef Eigen::Map<Eigen::Vector4f, Eigen::Aligned> Vector4fMap; 00166 typedef const Eigen::Map<const Eigen::Vector4f, Eigen::Aligned> Vector4fMapConst; 00167 00168 struct _PointXYZ 00169 { 00170 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00171 EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 00172 }; 00173 00174 /*struct PointXYZ 00175 { 00176 ADD_4D_POINT_WITH_XYZ; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00177 //inline PointXYZ() {} 00178 //inline PointXYZ(float x, float y, float z) : x(x), y(y), z(z) {} 00179 };*/ 00183 struct EIGEN_ALIGN16 PointXYZ : public _PointXYZ 00184 { 00185 inline PointXYZ() 00186 { 00187 x = y = z = 0.0f; 00188 data[3] = 1.0f; 00189 } 00190 inline PointXYZ (float _x, float _y, float _z) 00191 { x = _x; y = _y; z = _z; data[3] = 1.0f;} 00192 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00193 }; 00194 00195 inline std::ostream& operator << (std::ostream& os, const PointXYZ& p) 00196 { 00197 os << "(" << p.x << "," << p.y << "," << p.z << ")"; 00198 return (os); 00199 } 00200 00220 struct RGB 00221 { 00222 union 00223 { 00224 struct 00225 { 00226 uint8_t b; 00227 uint8_t g; 00228 uint8_t r; 00229 uint8_t a; 00230 }; 00231 uint32_t rgba; 00232 }; 00233 }; 00234 00238 struct EIGEN_ALIGN16 PointXYZI 00239 { 00240 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00241 union 00242 { 00243 struct 00244 { 00245 float intensity; 00246 }; 00247 float data_c[4]; 00248 }; 00249 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00250 }; 00251 inline std::ostream& operator << (std::ostream& os, const PointXYZI& p) 00252 { 00253 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.intensity << ")"; 00254 return (os); 00255 } 00256 00257 struct EIGEN_ALIGN16 PointXYZL 00258 { 00259 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00260 union 00261 { 00262 struct 00263 { 00264 uint8_t label; 00265 }; 00266 uint32_t data_l; 00267 }; 00268 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00269 }; 00270 inline std::ostream& operator << (std::ostream& os, const PointXYZL& p) 00271 { 00272 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.label << ")"; 00273 return (os); 00274 } 00275 00296 struct EIGEN_ALIGN16 _PointXYZRGBA 00297 { 00298 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00299 EIGEN_ALIGN16 00300 union 00301 { 00302 struct 00303 { 00304 uint8_t b; 00305 uint8_t g; 00306 uint8_t r; 00307 uint8_t _unused; 00308 }; 00309 uint32_t rgba; 00310 }; 00311 00312 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00313 }; 00314 00315 struct PointXYZRGBA : public _PointXYZRGBA 00316 { 00317 inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); } 00318 inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); } 00319 inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); } 00320 inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); } 00321 }; 00322 00323 inline std::ostream& operator << (std::ostream& os, const PointXYZRGBA& p) 00324 { 00325 unsigned char* rgba_ptr = (unsigned char*)&p.rgba; 00326 os << "(" << p.x << "," << p.y << "," << p.z << " - " << (int)(*rgba_ptr) << "," << (int)(*(rgba_ptr+1)) << "," << (int)(*(rgba_ptr+2)) << "," <<(int)(*(rgba_ptr+3)) << ")"; 00327 return (os); 00328 } 00329 00330 struct EIGEN_ALIGN16 _PointXYZRGB 00331 { 00332 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00333 union 00334 { 00335 union 00336 { 00337 struct 00338 { 00339 uint8_t b; 00340 uint8_t g; 00341 uint8_t r; 00342 uint8_t _unused; 00343 }; 00344 float rgb; 00345 }; 00346 uint32_t rgba; 00347 }; 00348 00349 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00350 }; 00351 00352 struct EIGEN_ALIGN16 _PointXYZRGBL 00353 { 00354 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00355 union 00356 { 00357 union 00358 { 00359 struct 00360 { 00361 uint8_t b; 00362 uint8_t g; 00363 uint8_t r; 00364 uint8_t label; 00365 }; 00366 float rgb; 00367 }; 00368 uint32_t rgba; 00369 }; 00370 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00371 }; 00372 00404 struct EIGEN_ALIGN16 PointXYZRGB : public _PointXYZRGB 00405 { 00406 inline PointXYZRGB () 00407 { 00408 _unused = 0; 00409 } 00410 inline PointXYZRGB (uint8_t _r, uint8_t _g, uint8_t _b) 00411 { 00412 r = _r; 00413 g = _g; 00414 b = _b; 00415 _unused = 0; 00416 } 00417 00418 inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); } 00419 inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); } 00420 inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); } 00421 inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); } 00422 00423 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00424 }; 00425 inline std::ostream& operator << (std::ostream& os, const PointXYZRGB& p) 00426 { 00427 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.r << "," << p.g << "," << p.b << ")"; 00428 return (os); 00429 } 00430 00431 struct EIGEN_ALIGN16 PointXYZRGBL : public _PointXYZRGBL 00432 { 00433 inline PointXYZRGBL () 00434 { 00435 label = 255; 00436 } 00437 inline PointXYZRGBL (uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _label) 00438 { 00439 r = _r; 00440 g = _g; 00441 b = _b; 00442 label = _label; 00443 } 00444 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00445 }; 00446 inline std::ostream& operator << (std::ostream& os, const PointXYZRGBL& p) 00447 { 00448 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.r << "," << p.g << "," << p.b << " - " << p.label << ")"; 00449 return (os); 00450 } 00451 00452 struct _PointXYZHSV 00453 { 00454 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00455 union 00456 { 00457 struct 00458 { 00459 float h; 00460 float s; 00461 float v; 00462 }; 00463 float data_c[4]; 00464 }; 00465 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00466 } EIGEN_ALIGN16; 00467 00468 struct EIGEN_ALIGN16 PointXYZHSV : public _PointXYZHSV 00469 { 00470 inline PointXYZHSV () 00471 { 00472 data_c[3] = 0; 00473 } 00474 inline PointXYZHSV (float _h, float _v, float _s) 00475 { 00476 h = _h; v = _v; s = _s; 00477 data_c[3] = 0; 00478 } 00479 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00480 }; 00481 inline std::ostream& operator << (std::ostream& os, const PointXYZHSV& p) 00482 { 00483 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.h << " , " << p.s << " , " << p.v << ")"; 00484 return (os); 00485 } 00486 00487 00491 struct PointXY 00492 { 00493 float x; 00494 float y; 00495 }; 00496 inline std::ostream& operator << (std::ostream& os, const PointXY& p) 00497 { 00498 os << "(" << p.x << "," << p.y << ")"; 00499 return (os); 00500 } 00501 00505 struct EIGEN_ALIGN16 InterestPoint 00506 { 00507 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00508 union 00509 { 00510 struct 00511 { 00512 float strength; 00513 }; 00514 float data_c[4]; 00515 }; 00516 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00517 }; 00518 inline std::ostream& operator << (std::ostream& os, const InterestPoint& p) 00519 { 00520 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.strength << ")"; 00521 return (os); 00522 } 00523 00527 struct EIGEN_ALIGN16 Normal 00528 { 00529 PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4]) 00530 union 00531 { 00532 struct 00533 { 00534 float curvature; 00535 }; 00536 float data_c[4]; 00537 }; 00538 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00539 }; 00540 inline std::ostream& operator << (std::ostream& os, const Normal& p) 00541 { 00542 os << "(" << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")"; 00543 return (os); 00544 } 00545 00549 struct EIGEN_ALIGN16 PointNormal 00550 { 00551 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00552 PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4]) 00553 union 00554 { 00555 struct 00556 { 00557 float curvature; 00558 }; 00559 float data_c[4]; 00560 }; 00561 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00562 }; 00563 inline std::ostream& operator << (std::ostream& os, const PointNormal& p) 00564 { 00565 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")"; 00566 return (os); 00567 } 00568 00598 struct EIGEN_ALIGN16 _PointXYZRGBNormal 00599 { 00600 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00601 PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4]) 00602 union 00603 { 00604 struct 00605 { 00606 // RGB union 00607 union 00608 { 00609 struct 00610 { 00611 uint8_t b; 00612 uint8_t g; 00613 uint8_t r; 00614 uint8_t _unused; 00615 }; 00616 float rgb; 00617 uint32_t rgba; 00618 }; 00619 float curvature; 00620 }; 00621 float data_c[4]; 00622 }; 00623 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00624 }; 00625 struct PointXYZRGBNormal : public _PointXYZRGBNormal 00626 { 00627 inline PointXYZRGBNormal () 00628 { 00629 _unused = 0; 00630 data[3] = 1.0f; 00631 data_n[3] = 0.0f; 00632 } 00633 00634 inline Eigen::Vector3i getRGBVector3i () { return (Eigen::Vector3i (r, g, b)); } 00635 inline const Eigen::Vector3i getRGBVector3i () const { return (Eigen::Vector3i (r, g, b)); } 00636 inline Eigen::Vector4i getRGBVector4i () { return (Eigen::Vector4i (r, g, b, 0)); } 00637 inline const Eigen::Vector4i getRGBVector4i () const { return (Eigen::Vector4i (r, g, b, 0)); } 00638 }; 00639 inline std::ostream& operator << (std::ostream& os, const PointXYZRGBNormal& p) 00640 { 00641 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.rgb << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.r << ", " << p.g << ", " << p.b << " - " << p.curvature << ")"; 00642 return (os); 00643 } 00644 00648 struct EIGEN_ALIGN16 PointXYZINormal 00649 { 00650 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00651 PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4]) 00652 union 00653 { 00654 struct 00655 { 00656 float intensity; 00657 float curvature; 00658 }; 00659 float data_c[4]; 00660 }; 00661 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00662 }; 00663 inline std::ostream& operator << (std::ostream& os, const PointXYZINormal& p) 00664 { 00665 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.intensity << " - " << p.normal[0] << "," << p.normal[1] << "," << p.normal[2] << " - " << p.curvature << ")"; 00666 return (os); 00667 } 00668 00672 struct EIGEN_ALIGN16 PointWithRange 00673 { 00674 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00675 union 00676 { 00677 struct 00678 { 00679 float range; 00680 }; 00681 float data_c[4]; 00682 }; 00683 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00684 }; 00685 inline std::ostream& operator << (std::ostream& os, const PointWithRange& p) 00686 { 00687 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.range << ")"; 00688 return (os); 00689 } 00690 00691 struct EIGEN_ALIGN16 _PointWithViewpoint 00692 { 00693 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 00694 union 00695 { 00696 struct 00697 { 00698 float vp_x; 00699 float vp_y; 00700 float vp_z; 00701 }; 00702 float data_c[4]; 00703 }; 00704 EIGEN_MAKE_ALIGNED_OPERATOR_NEW; 00705 }; 00706 00710 struct EIGEN_ALIGN16 PointWithViewpoint : public _PointWithViewpoint 00711 { 00712 PointWithViewpoint(float _x=0.0f, float _y=0.0f, float _z=0.0f, float _vp_x=0.0f, float _vp_y=0.0f, float _vp_z=0.0f) 00713 { 00714 x=_x; y=_y; z=_z; data[3] = 1.0f; 00715 vp_x=_vp_x; vp_y=_vp_y; vp_z=_vp_z; 00716 } 00717 }; 00718 inline std::ostream& operator << (std::ostream& os, const PointWithViewpoint& p) 00719 { 00720 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.vp_x << "," << p.vp_y << "," << p.vp_z << ")"; 00721 return (os); 00722 } 00723 00727 struct MomentInvariants 00728 { 00729 float j1, j2, j3; 00730 }; 00731 inline std::ostream& operator << (std::ostream& os, const MomentInvariants& p) 00732 { 00733 os << "(" << p.j1 << "," << p.j2 << "," << p.j3 << ")"; 00734 return (os); 00735 } 00736 00740 struct PrincipalRadiiRSD 00741 { 00742 float r_min, r_max; 00743 }; 00744 inline std::ostream& operator << (std::ostream& os, const PrincipalRadiiRSD& p) 00745 { 00746 os << "(" << p.r_min << "," << p.r_max << ")"; 00747 return (os); 00748 } 00749 00753 struct Boundary 00754 { 00755 uint8_t boundary_point; 00756 }; 00757 inline std::ostream& operator << (std::ostream& os, const Boundary& p) 00758 { 00759 os << p.boundary_point; 00760 return (os); 00761 } 00762 00766 struct PrincipalCurvatures 00767 { 00768 union 00769 { 00770 float principal_curvature[3]; 00771 struct 00772 { 00773 float principal_curvature_x; 00774 float principal_curvature_y; 00775 float principal_curvature_z; 00776 }; 00777 }; 00778 float pc1; 00779 float pc2; 00780 }; 00781 inline std::ostream& operator << (std::ostream& os, const PrincipalCurvatures& p) 00782 { 00783 os << "(" << p.principal_curvature[0] << "," << p.principal_curvature[1] << "," << p.principal_curvature[2] << " - " << p.pc1 << "," << p.pc2 << ")"; 00784 return (os); 00785 } 00786 00790 struct PFHSignature125 00791 { 00792 float histogram[125]; 00793 }; 00794 inline std::ostream& operator << (std::ostream& os, const PFHSignature125& p) 00795 { 00796 for (int i = 0; i < 125; ++i) 00797 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 124 ? ", " : ")"); 00798 return (os); 00799 } 00800 00804 struct PFHRGBSignature250 00805 { 00806 float histogram[250]; 00807 }; 00808 inline std::ostream& operator << (std::ostream& os, const PFHRGBSignature250& p) 00809 { 00810 for (int i = 0; i < 250; ++i) 00811 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 249 ? ", " : ")"); 00812 return (os); 00813 } 00814 00818 struct PPFSignature 00819 { 00820 float f1, f2, f3, f4; 00821 float alpha_m; 00822 }; 00823 inline std::ostream& operator << (std::ostream& os, const PPFSignature& p) 00824 { 00825 os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " << p.alpha_m << ")"; 00826 return (os); 00827 } 00828 00832 struct PPFRGBSignature 00833 { 00834 float f1, f2, f3, f4; 00835 float r_ratio, g_ratio, b_ratio; 00836 float alpha_m; 00837 }; 00838 inline std::ostream& operator << (std::ostream& os, const PPFRGBSignature& p) 00839 { 00840 os << "(" << p.f1 << ", " << p.f2 << ", " << p.f3 << ", " << p.f4 << ", " << 00841 p.r_ratio << ", " << p.g_ratio << ", " << p.b_ratio << ", " << p.alpha_m << ")"; 00842 return (os); 00843 } 00844 00849 struct NormalBasedSignature12 00850 { 00851 float values[12]; 00852 }; 00853 inline std::ostream& operator << (std::ostream& os, const NormalBasedSignature12& p) 00854 { 00855 for (int i = 0; i < 12; ++i) 00856 os << (i == 0 ? "(" : "") << p.values[i] << (i < 11 ? ", " : ")"); 00857 return (os); 00858 } 00859 00863 struct SHOT 00864 { 00865 std::vector<float> descriptor; 00866 float rf[9]; 00867 }; 00868 00869 inline std::ostream& operator << (std::ostream& os, const SHOT& p) 00870 { 00871 for (int i = 0; i < 9; ++i) 00872 os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); 00873 for (size_t i = 0; i < p.descriptor.size (); ++i) 00874 os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < p.descriptor.size()-1 ? ", " : ")"); 00875 return (os); 00876 } 00877 00881 //struct _SHOT352 00882 //{ 00883 // 00885 // float descriptor[352]; 00886 // float rf[9]; 00887 // uint32_t size; 00888 //}; 00889 //struct SHOT352 : public _SHOT352 00890 //{ 00891 // SHOT352 () 00892 // { 00893 // size = 352; 00894 // } 00895 //}; 00896 //inline std::ostream& operator << (std::ostream& os, const SHOT352& p) 00897 //{ 00898 // for (int i = 0; i < 9; ++i) 00899 // os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); 00900 // for (uint32_t i = 0; i < p.size; ++i) 00901 // os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 351 ? ", " : ")"); 00902 // return (os); 00903 //} 00904 // 00905 // 00907 // * \ingroup common 00908 // */ 00909 //struct _SHOT1344 00910 //{ 00912 // float descriptor[1344]; 00913 // float rf[9]; 00914 // uint32_t size; 00915 //}; 00916 //struct SHOT1344 : public _SHOT1344 00917 //{ 00918 // SHOT1344 () 00919 // { 00920 // size = 1344; 00921 // } 00922 //}; 00923 //inline std::ostream& operator << (std::ostream& os, const SHOT1344& p) 00924 //{ 00925 // for (int i = 0; i < 9; ++i) 00926 // os << (i == 0 ? "(" : "") << p.rf[i] << (i < 8 ? ", " : ")"); 00927 // for (uint32_t i = 0; i < p.size; ++i) 00928 // os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 1343 ? ", " : ")"); 00929 // return (os); 00930 //} 00931 00935 struct FPFHSignature33 00936 { 00937 float histogram[33]; 00938 }; 00939 inline std::ostream& operator << (std::ostream& os, const FPFHSignature33& p) 00940 { 00941 for (int i = 0; i < 33; ++i) 00942 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 32 ? ", " : ")"); 00943 return (os); 00944 } 00945 00949 struct VFHSignature308 00950 { 00951 float histogram[308]; 00952 }; 00953 inline std::ostream& operator << (std::ostream& os, const VFHSignature308& p) 00954 { 00955 for (int i = 0; i < 308; ++i) 00956 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < 307 ? ", " : ")"); 00957 return (os); 00958 } 00959 00963 struct GFPFHSignature16 00964 { 00965 float histogram[16]; 00966 static int descriptorSize() { return 16; } 00967 }; 00968 inline std::ostream& operator << (std::ostream& os, const GFPFHSignature16& p) 00969 { 00970 for (int i = 0; i < p.descriptorSize (); ++i) 00971 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < (p.descriptorSize () - 1) ? ", " : ")"); 00972 return (os); 00973 } 00974 00978 struct Narf36 00979 { 00980 float x, y, z, roll, pitch, yaw; 00981 float descriptor[36]; 00982 }; 00983 inline std::ostream& operator << (std::ostream& os, const Narf36& p) 00984 { 00985 os << p.x<<","<<p.y<<","<<p.z<<" - "<<p.roll*360.0/M_PI<<"deg,"<<p.pitch*360.0/M_PI<<"deg,"<<p.yaw*360.0/M_PI<<"deg - "; 00986 for (int i = 0; i < 36; ++i) 00987 os << (i == 0 ? "(" : "") << p.descriptor[i] << (i < 35 ? ", " : ")"); 00988 return (os); 00989 } 00990 00994 struct BorderDescription 00995 { 00996 int x, y; 00997 BorderTraits traits; 00998 //std::vector<const BorderDescription*> neighbors; 00999 }; 01000 01001 inline std::ostream& operator << (std::ostream& os, const BorderDescription& p) 01002 { 01003 os << "(" << p.x << "," << p.y << ")"; 01004 return (os); 01005 } 01006 01010 struct IntensityGradient 01011 { 01012 union 01013 { 01014 float gradient[3]; 01015 struct 01016 { 01017 float gradient_x; 01018 float gradient_y; 01019 float gradient_z; 01020 }; 01021 }; 01022 }; 01023 inline std::ostream& operator << (std::ostream& os, const IntensityGradient& p) 01024 { 01025 os << "(" << p.gradient[0] << "," << p.gradient[1] << "," << p.gradient[2] << ")"; 01026 return (os); 01027 } 01028 01032 template <int N> 01033 struct Histogram 01034 { 01035 float histogram[N]; 01036 }; 01037 template <int N> 01038 inline std::ostream& operator << (std::ostream& os, const Histogram<N>& p) 01039 { 01040 for (int i = 0; i < N; ++i) 01041 os << (i == 0 ? "(" : "") << p.histogram[i] << (i < N-1 ? ", " : ")"); 01042 return (os); 01043 } 01044 01048 struct EIGEN_ALIGN16 PointWithScale 01049 { 01050 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 01051 float scale; 01052 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 01053 }; 01054 inline std::ostream& operator << (std::ostream& os, const PointWithScale& p) 01055 { 01056 os << "(" << p.x << "," << p.y << "," << p.z << " - " << p.scale << ")"; 01057 return (os); 01058 } 01059 01063 struct EIGEN_ALIGN16 PointSurfel 01064 { 01065 PCL_ADD_POINT4D; // This adds the members x,y,z which can also be accessed using the point (which is float[4]) 01066 PCL_ADD_NORMAL4D; // This adds the member normal[3] which can also be accessed using the point (which is float[4]) 01067 union 01068 { 01069 struct 01070 { 01071 uint32_t rgba; 01072 float radius; 01073 float confidence; 01074 float curvature; 01075 }; 01076 float data_c[4]; 01077 }; 01078 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 01079 }; 01080 inline std::ostream& operator << (std::ostream& os, const PointSurfel& p) 01081 { 01082 unsigned char* rgba_ptr = (unsigned char*)&p.rgba; 01083 os << 01084 "(" << p.x << "," << p.y << "," << p.z << " - " << 01085 p.normal_x << "," << p.normal_y << "," << p.normal_z << " - " << 01086 (int)(*rgba_ptr) << "," << (int)(*(rgba_ptr+1)) << "," << (int)(*(rgba_ptr+2)) << "," <<(int)(*(rgba_ptr+3)) << " - " << 01087 p.radius << " - " << p.confidence << " - " << p.curvature << ")"; 01088 return (os); 01089 } 01090 01091 template <typename PointType1, typename PointType2> inline float 01092 squaredEuclideanDistance (const PointType1& p1, const PointType2& p2) 01093 { 01094 float diff_x = p2.x - p1.x, diff_y = p2.y - p1.y, diff_z = p2.z - p1.z; 01095 return (diff_x*diff_x + diff_y*diff_y + diff_z*diff_z); 01096 } 01097 01098 template <typename PointType1, typename PointType2> inline float 01099 euclideanDistance (const PointType1& p1, const PointType2& p2) 01100 { 01101 return (sqrtf (squaredEuclideanDistance (p1, p2))); 01102 } 01103 01104 template <typename PointType> inline bool 01105 hasValidXYZ (const PointType& p) 01106 { 01107 return (pcl_isfinite (p.x) && pcl_isfinite (p.y) && pcl_isfinite (p.z)); 01108 } 01109 01110 } // End namespace 01111 01112 #endif
1.7.6.1