@@ -189,7 +189,9 @@ namespace
189
189
190
190
template <typename T, std::enable_if_t <is_unsupported_type<T>, bool > = true >
191
191
void meshFromCloudPCL (const typename pcl::PointCloud<T>::Ptr &, pcl::PolygonMesh::ConstPtr &, const yarp::sig::VectorOf<yarp::os::Property> &)
192
- {}
192
+ {
193
+ throw std::invalid_argument (" unsupported point type" ); // don't remove this
194
+ }
193
195
194
196
template <typename T, std::enable_if_t <!is_unsupported_type<T>, bool > = true >
195
197
void meshFromCloudPCL (const typename pcl::PointCloud<T>::Ptr & cloud, pcl::PolygonMesh::ConstPtr & mesh, const yarp::sig::VectorOf<yarp::os::Property> & options)
@@ -209,7 +211,9 @@ namespace
209
211
210
212
template <typename T1, typename T2, std::enable_if_t <is_unsupported_type<T1> || is_unsupported_type<T2>, bool > = true >
211
213
void processCloudPCL (const typename pcl::PointCloud<T1>::Ptr &, typename pcl::PointCloud<T2>::ConstPtr &, const yarp::sig::VectorOf<yarp::os::Property> &)
212
- {}
214
+ {
215
+ throw std::invalid_argument (" unsupported point type" ); // don't remove this
216
+ }
213
217
214
218
template <typename T1, typename T2, std::enable_if_t <!is_unsupported_type<T1> && !is_unsupported_type<T2>, bool > = true >
215
219
void processCloudPCL (const typename pcl::PointCloud<T1>::Ptr & in, typename pcl::PointCloud<T2>::ConstPtr & out, const yarp::sig::VectorOf<yarp::os::Property> & options)
@@ -281,17 +285,19 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
281
285
using pcl_input_type = typename pcl_type_from_yarp<T1>::type;
282
286
using pcl_output_type = typename pcl_type_from_yarp<T2>::type;
283
287
284
- // Force the compiler/linker to instantiate this signature of meshFromCloud for unsupported
285
- // point types. The following if clauses would make GCC strip several symbols from the .so.
286
- typename pcl::PointCloud<pcl_input_type>::Ptr pclCloud (new pcl::PointCloud<pcl_input_type>());
288
+ // This variable and its following checks aim to override compiler optimizations, thus forcing
289
+ // the compiler/linker to instantiate this signature of meshFromCloud for unsupported point types.
290
+ // Otherwise, plain is_unsupported_type checks would make GCC strip several symbols from the .so.
291
+
292
+ volatile auto dummy = true ;
287
293
288
- if (is_unsupported_type<pcl_input_type>)
294
+ if (is_unsupported_type<pcl_input_type> && dummy )
289
295
{
290
296
yError () << " unsupported input point type" << pcl_descriptor<pcl_input_type>::name;
291
297
return false ;
292
298
}
293
299
294
- if (is_unsupported_type<pcl_output_type>)
300
+ if (is_unsupported_type<pcl_output_type> && dummy )
295
301
{
296
302
yError () << " unsupported output point type" << pcl_descriptor<pcl_output_type>::name;
297
303
return false ;
@@ -303,6 +309,8 @@ bool meshFromCloud(const yarp::sig::PointCloud<T1> & cloud,
303
309
return false ;
304
310
}
305
311
312
+ typename pcl::PointCloud<pcl_input_type>::Ptr pclCloud (new pcl::PointCloud<pcl_input_type>());
313
+
306
314
// Convert YARP cloud to PCL cloud.
307
315
yarp::pcl::toPCL (cloud, *pclCloud);
308
316
@@ -354,15 +362,15 @@ bool processCloud(const yarp::sig::PointCloud<T1> & in,
354
362
using pcl_output_type = typename pcl_type_from_yarp<T2>::type;
355
363
356
364
// See analogous comment in meshFromCloud.
357
- typename pcl::PointCloud<pcl_input_type>:: Ptr pclCloudIn ( new pcl::PointCloud<pcl_input_type>()) ;
365
+ volatile auto dummy = true ;
358
366
359
- if (is_unsupported_type<pcl_input_type>)
367
+ if (is_unsupported_type<pcl_input_type> && dummy )
360
368
{
361
369
yError () << " unsupported input point type" << pcl_descriptor<pcl_input_type>::name;
362
370
return false ;
363
371
}
364
372
365
- if (is_unsupported_type<pcl_output_type>)
373
+ if (is_unsupported_type<pcl_output_type> && dummy )
366
374
{
367
375
yError () << " unsupported output point type" << pcl_descriptor<pcl_output_type>::name;
368
376
return false ;
@@ -374,6 +382,8 @@ bool processCloud(const yarp::sig::PointCloud<T1> & in,
374
382
return false ;
375
383
}
376
384
385
+ typename pcl::PointCloud<pcl_input_type>::Ptr pclCloudIn (new pcl::PointCloud<pcl_input_type>());
386
+
377
387
// Convert YARP cloud to PCL cloud.
378
388
yarp::pcl::toPCL (in, *pclCloudIn);
379
389
0 commit comments