42 #include <pcl/common/spring.h>
51 template <
typename Po
intT>
void
53 const PointT& val,
const std::size_t& amount)
57 "[pcl::common::expandColumns] error: amount must be ]0.."
58 << (input.
width/2) <<
"] !");
62 "[pcl::common::expandColumns] error: "
63 <<
"columns expansion requires organised point cloud");
65 std::uint32_t old_height = input.
height;
66 std::uint32_t old_width = input.
width;
67 std::uint32_t new_width = old_width + 2*amount;
68 if (&input != &output)
70 output.
reserve (new_width * old_height);
71 for (
int j = 0; j < output.
height; ++j)
74 output.
insert (start, amount, val);
75 start = output.
begin() + (j * new_width) + old_width + amount;
76 output.
insert (start, amount, val);
77 output.
height = old_height;
79 output.
width = new_width;
80 output.
height = old_height;
83 template <
typename Po
intT>
void
85 const PointT& val,
const std::size_t& amount)
89 "[pcl::common::expandRows] error: amount must be ]0.."
90 << (input.
height/2) <<
"] !");
92 std::uint32_t old_height = input.
height;
93 std::uint32_t new_height = old_height + 2*amount;
94 std::uint32_t old_width = input.
width;
95 if (&input != &output)
97 output.
reserve (new_height * old_width);
98 output.
insert (output.
begin (), amount * old_width, val);
99 output.
insert (output.
end (), amount * old_width, val);
100 output.
width = old_width;
101 output.
height = new_height;
104 template <
typename Po
intT>
void
106 const std::size_t& amount)
110 "[pcl::common::duplicateColumns] error: amount must be ]0.."
111 << (input.
width/2) <<
"] !");
115 "[pcl::common::duplicateColumns] error: "
116 <<
"columns expansion requires organised point cloud");
118 std::size_t old_height = input.
height;
119 std::size_t old_width = input.
width;
120 std::size_t new_width = old_width + 2*amount;
121 if (&input != &output)
123 output.
reserve (new_width * old_height);
124 for (std::size_t j = 0; j < old_height; ++j)
125 for(std::size_t i = 0; i < amount; ++i)
128 output.
insert (start, *start);
129 start = output.
begin () + (j * new_width) + old_width + i;
130 output.
insert (start, *start);
133 output.
width = new_width;
134 output.
height = old_height;
137 template <
typename Po
intT>
void
139 const std::size_t& amount)
141 if (amount <= 0 || amount > (input.
height/2))
143 "[pcl::common::duplicateRows] error: amount must be ]0.."
144 << (input.
height/2) <<
"] !");
146 std::uint32_t old_height = input.
height;
147 std::uint32_t new_height = old_height + 2*amount;
148 std::uint32_t old_width = input.
width;
149 if (&input != &output)
151 output.
reserve (new_height * old_width);
152 for(std::size_t i = 0; i < amount; ++i)
155 output.
insert (output.
end (), output.
end () - old_width, output.
end ());
158 output.
width = old_width;
159 output.
height = new_height;
162 template <
typename Po
intT>
void
164 const std::size_t& amount)
168 "[pcl::common::mirrorColumns] error: amount must be ]0.."
169 << (input.
width/2) <<
"] !");
173 "[pcl::common::mirrorColumns] error: "
174 <<
"columns expansion requires organised point cloud");
176 std::size_t old_height = input.
height;
177 std::size_t old_width = input.
width;
178 std::size_t new_width = old_width + 2*amount;
179 if (&input != &output)
181 output.
reserve (new_width * old_height);
182 for (std::size_t j = 0; j < old_height; ++j)
183 for(std::size_t i = 0; i < amount; ++i)
186 output.
insert (start, *(start + 2*i));
187 start = output.
begin () + (j * new_width) + old_width + 2*i;
188 output.
insert (start+1, *(start - 2*i));
190 output.
width = new_width;
191 output.
height = old_height;
194 template <
typename Po
intT>
void
196 const std::size_t& amount)
198 if (amount <= 0 || amount > (input.
height/2))
200 "[pcl::common::mirrorRows] error: amount must be ]0.."
201 << (input.
height/2) <<
"] !");
203 std::uint32_t old_height = input.
height;
204 std::uint32_t new_height = old_height + 2*amount;
205 std::uint32_t old_width = input.
width;
206 if (&input != &output)
208 output.
reserve (new_height * old_width);
209 for(std::size_t i = 0; i < amount; i++)
211 const auto extra_odd = output.
height % 2;
212 auto up = output.
begin () + (2*i + extra_odd) * old_width;
213 output.
insert (output.
begin (), up, up + old_width);
214 auto bottom = output.
end () - (2*i+1) * old_width;
215 output.
insert (output.
end (), bottom, bottom + old_width);
217 output.
width = old_width;
218 output.
height = new_height;
221 template <
typename Po
intT>
void
223 const std::size_t& amount)
225 if (amount <= 0 || amount > (input.
height/2))
227 "[pcl::common::deleteRows] error: amount must be ]0.."
228 << (input.
height/2) <<
"] !");
230 std::uint32_t old_height = input.
height;
231 std::uint32_t old_width = input.
width;
233 output.
erase (output.
end () - amount * old_width, output.
end ());
234 output.
height = old_height - 2*amount;
235 output.
width = old_width;
238 template <
typename Po
intT>
void
240 const std::size_t& amount)
242 if (amount <= 0 || amount > (input.
width/2))
244 "[pcl::common::deleteCols] error: amount must be in ]0.."
245 << (input.
width/2) <<
"] !");
249 "[pcl::common::deleteCols] error: "
250 <<
"columns delete requires organised point cloud");
252 std::uint32_t old_height = input.
height;
253 std::uint32_t old_width = input.
width;
254 std::uint32_t new_width = old_width - 2 * amount;
255 for(std::size_t j = 0; j < old_height; j++)
258 output.
erase (start, start + amount);
259 start = output.
begin () + (j+1) * new_width;
260 output.
erase (start, start + amount);
262 output.
height = old_height;
263 output.
width = new_width;