Skip to content

Commit 6491dec

Browse files
committed
Report step failures via exceptions
1 parent ba9ed69 commit 6491dec

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

libraries/YarpCloudUtils/YarpCloudUtils-pcl.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ namespace
112112
filter->setKeepOrganized(true); // don't remove points from the cloud, fill holes with NaNs
113113
filter->setNegative(negative);
114114
filter->filter(*out);
115+
116+
if (out->empty())
117+
{
118+
throw std::runtime_error("got empty cloud after crop step");
119+
}
115120
}
116121

117122
template <typename T>
@@ -156,6 +161,11 @@ namespace
156161

157162
downsampler->setInputCloud(in);
158163
downsampler->filter(*out);
164+
165+
if (out->empty())
166+
{
167+
throw std::runtime_error("got empty cloud after downsampling step");
168+
}
159169
}
160170

161171
template <typename T>
@@ -253,6 +263,11 @@ namespace
253263

254264
processor->setInputCloud(in);
255265
processor->process(*out);
266+
267+
if (out->empty())
268+
{
269+
throw std::runtime_error("got empty cloud after cloud smoothing step");
270+
}
256271
}
257272

258273
template <typename T>
@@ -287,6 +302,11 @@ namespace
287302
estimator->setRadiusSearch(radiusSearch);
288303
estimator->setSearchMethod(tree);
289304
estimator->compute(*out);
305+
306+
if (out->empty())
307+
{
308+
throw std::runtime_error("got empty cloud after normal estimation step");
309+
}
290310
}
291311

292312
template <typename T>
@@ -589,6 +609,11 @@ namespace
589609

590610
processor->setInputMesh(in);
591611
processor->process(*out);
612+
613+
if (out->cloud.data.empty() || out->polygons.empty())
614+
{
615+
throw std::runtime_error("got empty mesh after mesh procesing step");
616+
}
592617
}
593618

594619
template <typename T>
@@ -623,6 +648,11 @@ namespace
623648

624649
reconstructNormal<pcl_concatenated>(cloudWithNormals, out, options);
625650
}
651+
652+
if (out->cloud.data.empty() || out->polygons.empty())
653+
{
654+
throw std::runtime_error("got empty mesh after surface reconstruction step");
655+
}
626656
}
627657

628658
template <typename T, std::enable_if_t<is_unsupported_pcl_type<T>, bool> = true>

0 commit comments

Comments
 (0)