41 #ifndef PCL_SURFACE_ORGANIZED_FAST_MESH_HPP_ 42 #define PCL_SURFACE_ORGANIZED_FAST_MESH_HPP_ 48 template <
typename Po
intInT>
void 51 reconstructPolygons (output.polygons);
54 int x_idx = pcl::getFieldIndex (output.cloud,
"x");
55 int y_idx = pcl::getFieldIndex (output.cloud,
"y");
56 int z_idx = pcl::getFieldIndex (output.cloud,
"z");
57 if (x_idx == -1 || y_idx == -1 || z_idx == -1)
63 for (
unsigned int i = 0; i < input_->points.size (); ++i)
65 resetPointData (i, output, 0.0
f, x_idx, y_idx, z_idx);
69 template <
typename Po
intInT>
void 72 reconstructPolygons (polygons);
76 template <
typename Po
intInT>
void 79 if (triangulation_type_ == TRIANGLE_RIGHT_CUT)
80 makeRightCutMesh (polygons);
81 else if (triangulation_type_ == TRIANGLE_LEFT_CUT)
82 makeLeftCutMesh (polygons);
83 else if (triangulation_type_ == TRIANGLE_ADAPTIVE_CUT)
84 makeAdaptiveCutMesh (polygons);
85 else if (triangulation_type_ == QUAD_MESH)
86 makeQuadMesh (polygons);
90 template <
typename Po
intInT>
void 93 int last_column = input_->width - triangle_pixel_size_columns_;
94 int last_row = input_->height - triangle_pixel_size_rows_;
96 int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
97 int y_big_incr = triangle_pixel_size_rows_ * input_->width,
98 x_big_incr = y_big_incr + triangle_pixel_size_columns_;
100 polygons.resize (input_->width * input_->height);
103 for (
int y = 0; y < last_row; y += triangle_pixel_size_rows_)
106 i = y * input_->width;
107 index_right = i + triangle_pixel_size_columns_;
108 index_down = i + y_big_incr;
109 index_down_right = i + x_big_incr;
112 for (
int x = 0;
x < last_column;
x += triangle_pixel_size_columns_,
113 i += triangle_pixel_size_columns_,
114 index_right += triangle_pixel_size_columns_,
115 index_down += triangle_pixel_size_columns_,
116 index_down_right += triangle_pixel_size_columns_)
118 if (isValidQuad (i, index_right, index_down_right, index_down))
119 if (store_shadowed_faces_ || !isShadowedQuad (i, index_right, index_down_right, index_down))
120 addQuad (i, index_right, index_down_right, index_down, idx++, polygons);
123 polygons.resize (idx);
127 template <
typename Po
intInT>
void 130 int last_column = input_->width - triangle_pixel_size_columns_;
131 int last_row = input_->height - triangle_pixel_size_rows_;
133 int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
134 int y_big_incr = triangle_pixel_size_rows_ * input_->width,
135 x_big_incr = y_big_incr + triangle_pixel_size_columns_;
137 polygons.resize (input_->width * input_->height * 2);
140 for (
int y = 0; y < last_row; y += triangle_pixel_size_rows_)
143 i = y * input_->width;
144 index_right = i + triangle_pixel_size_columns_;
145 index_down = i + y_big_incr;
146 index_down_right = i + x_big_incr;
149 for (
int x = 0;
x < last_column;
x += triangle_pixel_size_columns_,
150 i += triangle_pixel_size_columns_,
151 index_right += triangle_pixel_size_columns_,
152 index_down += triangle_pixel_size_columns_,
153 index_down_right += triangle_pixel_size_columns_)
155 if (isValidTriangle (i, index_down_right, index_right))
156 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down_right, index_right))
157 addTriangle (i, index_down_right, index_right, idx++, polygons);
159 if (isValidTriangle (i, index_down, index_down_right))
160 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_down_right))
161 addTriangle (i, index_down, index_down_right, idx++, polygons);
164 polygons.resize (idx);
168 template <
typename Po
intInT>
void 171 int last_column = input_->width - triangle_pixel_size_columns_;
172 int last_row = input_->height - triangle_pixel_size_rows_;
174 int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
175 int y_big_incr = triangle_pixel_size_rows_ * input_->width,
176 x_big_incr = y_big_incr + triangle_pixel_size_columns_;
178 polygons.resize (input_->width * input_->height * 2);
181 for (
int y = 0; y < last_row; y += triangle_pixel_size_rows_)
184 i = y * input_->width;
185 index_right = i + triangle_pixel_size_columns_;
186 index_down = i + y_big_incr;
187 index_down_right = i + x_big_incr;
190 for (
int x = 0;
x < last_column;
x += triangle_pixel_size_columns_,
191 i += triangle_pixel_size_columns_,
192 index_right += triangle_pixel_size_columns_,
193 index_down += triangle_pixel_size_columns_,
194 index_down_right += triangle_pixel_size_columns_)
196 if (isValidTriangle (i, index_down, index_right))
197 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
198 addTriangle (i, index_down, index_right, idx++, polygons);
200 if (isValidTriangle (index_right, index_down, index_down_right))
201 if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
202 addTriangle (index_right, index_down, index_down_right, idx++, polygons);
205 polygons.resize (idx);
209 template <
typename Po
intInT>
void 212 int last_column = input_->width - triangle_pixel_size_columns_;
213 int last_row = input_->height - triangle_pixel_size_rows_;
215 int i = 0, index_down = 0, index_right = 0, index_down_right = 0, idx = 0;
216 int y_big_incr = triangle_pixel_size_rows_ * input_->width,
217 x_big_incr = y_big_incr + triangle_pixel_size_columns_;
219 polygons.resize (input_->width * input_->height * 2);
222 for (
int y = 0; y < last_row; y += triangle_pixel_size_rows_)
225 i = y * input_->width;
226 index_right = i + triangle_pixel_size_columns_;
227 index_down = i + y_big_incr;
228 index_down_right = i + x_big_incr;
231 for (
int x = 0;
x < last_column;
x += triangle_pixel_size_columns_,
232 i += triangle_pixel_size_columns_,
233 index_right += triangle_pixel_size_columns_,
234 index_down += triangle_pixel_size_columns_,
235 index_down_right += triangle_pixel_size_columns_)
237 const bool right_cut_upper = isValidTriangle (i, index_down_right, index_right);
238 const bool right_cut_lower = isValidTriangle (i, index_down, index_down_right);
239 const bool left_cut_upper = isValidTriangle (i, index_down, index_right);
240 const bool left_cut_lower = isValidTriangle (index_right, index_down, index_down_right);
242 if (right_cut_upper && right_cut_lower && left_cut_upper && left_cut_lower)
244 float dist_right_cut = fabsf (input_->points[index_down].z - input_->points[index_right].z);
245 float dist_left_cut = fabsf (input_->points[i].z - input_->points[index_down_right].z);
246 if (dist_right_cut >= dist_left_cut)
248 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down_right, index_right))
249 addTriangle (i, index_down_right, index_right, idx++, polygons);
250 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_down_right))
251 addTriangle (i, index_down, index_down_right, idx++, polygons);
255 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
256 addTriangle (i, index_down, index_right, idx++, polygons);
257 if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
258 addTriangle (index_right, index_down, index_down_right, idx++, polygons);
264 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down_right, index_right))
265 addTriangle (i, index_down_right, index_right, idx++, polygons);
267 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_down_right))
268 addTriangle (i, index_down, index_down_right, idx++, polygons);
270 if (store_shadowed_faces_ || !isShadowedTriangle (i, index_down, index_right))
271 addTriangle (i, index_down, index_right, idx++, polygons);
273 if (store_shadowed_faces_ || !isShadowedTriangle (index_right, index_down, index_down_right))
274 addTriangle (index_right, index_down, index_down_right, idx++, polygons);
278 polygons.resize (idx);
281 #define PCL_INSTANTIATE_OrganizedFastMesh(T) \ 282 template class PCL_EXPORTS pcl::OrganizedFastMesh<T>; 284 #endif // PCL_SURFACE_ORGANIZED_FAST_MESH_HPP_ bool RTABMAP_EXP isFinite(const cv::Point3f &pt)
void reconstructPolygons(std::vector< pcl::Vertices > &polygons)
Perform the actual polygonal reconstruction.
void makeRightCutMesh(std::vector< pcl::Vertices > &polygons)
Create a right cut mesh.
void makeQuadMesh(std::vector< pcl::Vertices > &polygons)
Create a quad mesh.
void makeLeftCutMesh(std::vector< pcl::Vertices > &polygons)
Create a left cut mesh.
virtual void performReconstruction(std::vector< pcl::Vertices > &polygons)
Create the surface.
void makeAdaptiveCutMesh(std::vector< pcl::Vertices > &polygons)
Create an adaptive cut mesh.
ULogger class and convenient macros.