1+ """
2+ Software License Agreement (BSD License)
3+
4+ Point Cloud Library (PCL) - www.pointclouds.org
5+ Copyright (c) 2010, Willow Garage, Inc.
6+ Copyright (c) 2012-, Open Perception, Inc.
7+
8+ All rights reserved.
9+
10+ Redistribution and use in source and binary forms, with or without
11+ modification, are permitted provided that the following conditions
12+ are met:
13+
14+ * Redistributions of source code must retain the above copyright
15+ notice, this list of conditions and the following disclaimer.
16+ * Redistributions in binary form must reproduce the above
17+ copyright notice, this list of conditions and the following
18+ disclaimer in the documentation and/or other materials provided
19+ with the distribution.
20+ * Neither the name of the copyright holder(s) nor the names of its
21+ contributors may be used to endorse or promote products derived
22+ from this software without specific prior written permission.
23+
24+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+ POSSIBILITY OF SUCH DAMAGE.
36+ """
37+
38+ @info " Caesar.jl is loading (but not exporting) tools requiring Colors.jl; e.g. Caesar._PCL"
39+
40+ module _PCL
41+
42+ using DocStringExtensions
43+ using StaticArrays
44+ using .. Colors
45+
46+ # # hold off on exports, users can in the mean-time use/import via e.g. _PCL.PointXYZ
47+ # export PointT, PointXYZ, PointXYZRGB, PointXYZRGBA
48+ # export PCLHeader, PointCloud
49+
50+ abstract type PointT end
51+
52+ """
53+ $TYPEDEF
54+
55+ See https://pointclouds.org/documentation/point__types_8hpp_source.html
56+ """
57+ Base. @kwdef struct PointXYZ{C <: Colorant , T <: Number } <: PointT
58+ color:: C = RGBA (1 ,1 ,1 ,1 )
59+ data:: SVector{4,T} = SVector (0 ,0 ,0 ,Float32 (1 ))
60+ end
61+
62+ # Construct helpers nearest to PCL
63+ PointXYZRGBA ( x:: Real = 0 , y:: Real = 0 , z:: Real = Float32 (1 );
64+ r:: Real = 1 ,g:: Real = 1 ,b:: Real = 1 , alpha:: Real = 1 ,
65+ color:: Colorant = RGBA (r,g,b,alpha),
66+ pos= SA[x,y,z], data= SA[pos... ,1 ] ) = PointXYZ (;color,data)
67+ #
68+ PointXYZRGB ( x:: Real = 0 , y:: Real = 0 , z:: Real = Float32 (1 );
69+ r:: Real = 1 ,g:: Real = 1 ,b:: Real = 1 ,
70+ color:: Colorant = RGB (r,g,b),
71+ pos= SA[x,y,z], data= SA[pos... ,1 ] ) = PointXYZ (;color,data)
72+ #
73+
74+ function Base. getproperty (p:: PointXYZ , f:: Symbol )
75+ if f == :x
76+ return getfield (p, :data )[1 ]
77+ elseif f == :y
78+ return getfield (p, :data )[2 ]
79+ elseif f == :z
80+ return getfield (p, :data )[3 ]
81+ elseif f == :r
82+ return getfield (p, :color ). r
83+ elseif f == :g
84+ return getfield (p, :color ). g
85+ elseif f == :b
86+ return getfield (p, :color ). b
87+ elseif f == :alpha
88+ return getfield (p, :color ). alpha
89+ elseif f == :data || f == :pos
90+ return getfield (p, :data )
91+ elseif f == :color || f == :rgb
92+ return getfield (p, :color )
93+ end
94+ error (" PointXYZ has no field $f " )
95+ end
96+
97+
98+ """
99+ $TYPEDEF
100+
101+ See https://pointclouds.org/documentation/structpcl_1_1_p_c_l_header.html
102+ """
103+ Base. @kwdef struct PCLHeader
104+ seq:: UInt32 = UInt32 (0 )
105+ stamp:: UInt64 = UInt64 (0 )
106+ frame_id:: String = " "
107+ end
108+
109+ Base. @kwdef struct PointCloud
110+ header:: PCLHeader = PCLHeader ()
111+ """ vector of points representing the point cloud """
112+ points:: Vector{<:PointT} = Vector {PointXYZ{RGBA{Colors.FixedPointNumbers.N0f8}, Float32}} ()
113+ end
114+
115+
116+
117+ end
0 commit comments