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 std::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 std::uint32_t old_height = input.
height;
58 std::uint32_t old_width = input.
width;
59 std::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 std::size_t& amount)
81 "[pcl::common::expandRows] error: amount must be ]0.."
82 << (input.
height/2) <<
"] !");
84 std::uint32_t old_height = input.
height;
85 std::uint32_t new_height = old_height + 2*amount;
86 std::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
98 const std::size_t& amount)
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 std::size_t old_height = input.
height;
111 std::size_t old_width = input.
width;
112 std::size_t new_width = old_width + 2*amount;
113 if (&input != &output)
115 output.
reserve (new_width * old_height);
116 for (std::size_t j = 0; j < old_height; ++j)
117 for(std::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 std::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 std::uint32_t old_height = input.
height;
139 std::uint32_t new_height = old_height + 2*amount;
140 std::uint32_t old_width = input.
width;
141 if (&input != &output)
143 output.
reserve (new_height * old_width);
144 for(std::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 std::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 std::size_t old_height = input.
height;
169 std::size_t old_width = input.
width;
170 std::size_t new_width = old_width + 2*amount;
171 if (&input != &output)
173 output.
reserve (new_width * old_height);
174 for (std::size_t j = 0; j < old_height; ++j)
175 for(std::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 std::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 std::uint32_t old_height = input.
height;
196 std::uint32_t new_height = old_height + 2*amount;
197 std::uint32_t old_width = input.
width;
198 if (&input != &output)
200 output.
reserve (new_height * old_width);
201 for(std::size_t i = 0; i < amount; i++)
203 const auto extra_odd = output.
height % 2;
204 auto up = output.
begin () + (2*i + extra_odd) * old_width;
205 output.
insert (output.
begin (), up, up + old_width);
206 auto bottom = output.
end () - (2*i+1) * old_width;
207 output.
insert (output.
end (), bottom, bottom + old_width);
209 output.
width = old_width;
210 output.
height = new_height;
213 template <
typename Po
intT>
void
215 const std::size_t& amount)
217 if (amount <= 0 || amount > (input.
height/2))
219 "[pcl::common::deleteRows] error: amount must be ]0.."
220 << (input.
height/2) <<
"] !");
222 std::uint32_t old_height = input.
height;
223 std::uint32_t old_width = input.
width;
225 output.
erase (output.
end () - amount * old_width, output.
end ());
226 output.
height = old_height - 2*amount;
227 output.
width = old_width;
230 template <
typename Po
intT>
void
232 const std::size_t& amount)
234 if (amount <= 0 || amount > (input.
width/2))
236 "[pcl::common::deleteCols] error: amount must be in ]0.."
237 << (input.
width/2) <<
"] !");
241 "[pcl::common::deleteCols] error: "
242 <<
"columns delete requires organised point cloud");
244 std::uint32_t old_height = input.
height;
245 std::uint32_t old_width = input.
width;
246 std::uint32_t new_width = old_width - 2 * amount;
247 for(std::size_t j = 0; j < old_height; j++)
250 output.
erase (start, start + amount);
251 start = output.
begin () + (j+1) * new_width;
252 output.
erase (start, start + amount);
254 output.
height = old_height;
255 output.
width = new_width;