40 #ifndef PCL_POINT_CLOUD_SPRING_IMPL_HPP_
41 #define PCL_POINT_CLOUD_SPRING_IMPL_HPP_
43 template <
typename Po
intT>
void
45 const PointT& val,
const size_t& amount)
49 "[pcl::common::expandColumns] error: amount must be ]0.."
50 << (input.
width/2) <<
"] !");
54 "[pcl::common::expandColumns] error: "
55 <<
"columns expansion requires organised point cloud");
57 uint32_t old_height = input.
height;
58 uint32_t old_width = input.
width;
59 uint32_t new_width = old_width + 2*amount;
60 if (&input != &output)
62 output.
reserve (new_width * old_height);
63 for (
int j = 0; j < output.
height; ++j)
66 output.
insert (start, amount, val);
67 start = output.
begin() + (j * new_width) + old_width + amount;
68 output.
insert (start, amount, val);
69 output.
height = old_height;
71 output.
width = new_width;
72 output.
height = old_height;
75 template <
typename Po
intT>
void
77 const PointT& val,
const size_t& amount)
81 "[pcl::common::expandRows] error: amount must be ]0.."
82 << (input.
height/2) <<
"] !");
84 uint32_t old_height = input.
height;
85 uint32_t new_height = old_height + 2*amount;
86 uint32_t old_width = input.
width;
87 if (&input != &output)
89 output.
reserve (new_height * old_width);
90 output.
insert (output.
begin (), amount * old_width, val);
91 output.
insert (output.
end (), amount * old_width, val);
92 output.
width = old_width;
93 output.
height = new_height;
96 template <
typename Po
intT>
void
102 "[pcl::common::duplicateColumns] error: amount must be ]0.."
103 << (input.
width/2) <<
"] !");
107 "[pcl::common::duplicateColumns] error: "
108 <<
"columns expansion requires organised point cloud");
110 size_t old_height = input.
height;
111 size_t old_width = input.
width;
112 size_t new_width = old_width + 2*amount;
113 if (&input != &output)
115 output.
reserve (new_width * old_height);
116 for (
size_t j = 0; j < old_height; ++j)
117 for(
size_t i = 0; i < amount; ++i)
120 output.
insert (start, *start);
121 start = output.
begin () + (j * new_width) + old_width + i;
122 output.
insert (start, *start);
125 output.
width = new_width;
126 output.
height = old_height;
129 template <
typename Po
intT>
void
131 const size_t& amount)
133 if (amount <= 0 || amount > (input.
height/2))
135 "[pcl::common::duplicateRows] error: amount must be ]0.."
136 << (input.
height/2) <<
"] !");
138 uint32_t old_height = input.
height;
139 uint32_t new_height = old_height + 2*amount;
140 uint32_t old_width = input.
width;
141 if (&input != &output)
143 output.
reserve (new_height * old_width);
144 for(
size_t i = 0; i < amount; ++i)
147 output.
insert (output.
end (), output.
end () - old_width, output.
end ());
150 output.
width = old_width;
151 output.
height = new_height;
154 template <
typename Po
intT>
void
156 const size_t& amount)
160 "[pcl::common::mirrorColumns] error: amount must be ]0.."
161 << (input.
width/2) <<
"] !");
165 "[pcl::common::mirrorColumns] error: "
166 <<
"columns expansion requires organised point cloud");
168 size_t old_height = input.
height;
169 size_t old_width = input.
width;
170 size_t new_width = old_width + 2*amount;
171 if (&input != &output)
173 output.
reserve (new_width * old_height);
174 for (
size_t j = 0; j < old_height; ++j)
175 for(
size_t i = 0; i < amount; ++i)
178 output.
insert (start, *(start + 2*i));
179 start = output.
begin () + (j * new_width) + old_width + 2*i;
180 output.
insert (start+1, *(start - 2*i));
182 output.
width = new_width;
183 output.
height = old_height;
186 template <
typename Po
intT>
void
188 const size_t& amount)
190 if (amount <= 0 || amount > (input.
height/2))
192 "[pcl::common::mirrorRows] error: amount must be ]0.."
193 << (input.
height/2) <<
"] !");
195 uint32_t old_height = input.
height;
196 uint32_t new_height = old_height + 2*amount;
197 uint32_t old_width = input.
width;
198 if (&input != &output)
200 output.
reserve (new_height * old_width);
201 for(
size_t i = 0; i < amount; i++)
204 if (output.
height % 2 == 0)
205 up = output.
begin () + (2*i) * old_width;
207 up = output.
begin () + (2*i+1) * old_width;
208 output.
insert (output.
begin (), up, up + old_width);
210 output.
insert (output.
end (), bottom, bottom + old_width);
212 output.
width = old_width;
213 output.
height = new_height;
216 template <
typename Po
intT>
void
218 const size_t& amount)
220 if (amount <= 0 || amount > (input.
height/2))
222 "[pcl::common::deleteRows] error: amount must be ]0.."
223 << (input.
height/2) <<
"] !");
225 uint32_t old_height = input.
height;
226 uint32_t old_width = input.
width;
228 output.
erase (output.
end () - amount * old_width, output.
end ());
229 output.
height = old_height - 2*amount;
230 output.
width = old_width;
233 template <
typename Po
intT>
void
235 const size_t& amount)
237 if (amount <= 0 || amount > (input.
width/2))
239 "[pcl::common::deleteCols] error: amount must be in ]0.."
240 << (input.
width/2) <<
"] !");
244 "[pcl::common::deleteCols] error: "
245 <<
"columns delete requires organised point cloud");
247 uint32_t old_height = input.
height;
248 uint32_t old_width = input.
width;
249 uint32_t new_width = old_width - 2 * amount;
250 for(
size_t j = 0; j < old_height; j++)
253 output.
erase (start, start + amount);
254 start = output.
begin () + (j+1) * new_width;
255 output.
erase (start, start + amount);
257 output.
height = old_height;
258 output.
width = new_width;
void mirrorColumns(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
expand point cloud mirroring amount right and left columns.
iterator insert(iterator position, const PointT &pt)
Insert a new point in the cloud, given an iterator.
void duplicateRows(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
expand point cloud duplicating the amount top and bottom rows times.
An exception thrown when init can not be performed should be used in all the PCLBase class inheritant...
void deleteRows(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
delete amount rows in top and bottom of point cloud
uint32_t width
The point cloud width (if organized as an image-structure).
VectorType::iterator iterator
void deleteCols(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
delete amount columns in top and bottom of point cloud
void expandRows(const PointCloud< PointT > &input, PointCloud< PointT > &output, const PointT &val, const size_t &amount)
expand point cloud inserting amount rows at the top and the bottom of a point cloud and filling them ...
uint32_t height
The point cloud height (if organized as an image-structure).
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
iterator erase(iterator position)
Erase a point in the cloud.
void expandColumns(const PointCloud< PointT > &input, PointCloud< PointT > &output, const PointT &val, const size_t &amount)
expand point cloud inserting amount columns at the right and the left of a point cloud and filling th...
void duplicateColumns(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
expand point cloud duplicating the amount right and left columns times.
A point structure representing Euclidean xyz coordinates, and the RGB color.
void mirrorRows(const PointCloud< PointT > &input, PointCloud< PointT > &output, const size_t &amount)
expand point cloud mirroring amount top and bottom rows.
PointCloud represents the base class in PCL for storing collections of 3D points. ...