@@ -1331,6 +1331,58 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
1331
1331
return (true );
1332
1332
}
1333
1333
1334
+ // ///////////////////////////////////////////////////////////////////////////////////////////
1335
+ bool
1336
+ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
1337
+ int property, double val1, double val2, const std::string &id, int )
1338
+ {
1339
+ // Check to see if this ID entry already exists (has it been already added to the visualizer?)
1340
+ CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
1341
+
1342
+ if (am_it == cloud_actor_map_->end ())
1343
+ {
1344
+ pcl::console::print_error (" [setPointCloudRenderingProperties] Could not find any PointCloud datasets with id <%s>!\n " , id.c_str ());
1345
+ return (false );
1346
+ }
1347
+ // Get the actor pointer
1348
+ vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second .actor );
1349
+ if (!actor)
1350
+ return (false );
1351
+
1352
+ switch (property)
1353
+ {
1354
+ case PCL_VISUALIZER_LUT_RANGE:
1355
+ {
1356
+ // Check if the mapper has scalars
1357
+ if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
1358
+ break ;
1359
+
1360
+ // Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
1361
+ if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars () ->IsA (" vtkUnsignedCharArray" ))
1362
+ break ;
1363
+
1364
+ // Check that range values are correct
1365
+ if (val1 >= val2)
1366
+ {
1367
+ PCL_WARN (" [setShapeRenderingProperties] Range max must be greater than range min!\n " );
1368
+ return (false );
1369
+ }
1370
+
1371
+ // Update LUT
1372
+ actor->GetMapper ()->GetLookupTable ()->SetRange (val1, val2);
1373
+ actor->GetMapper ()->UseLookupTableScalarRangeOn ();
1374
+ style_->updateLookUpTableDisplay (false );
1375
+ break ;
1376
+ }
1377
+ default :
1378
+ {
1379
+ pcl::console::print_error (" [setPointCloudRenderingProperties] Unknown property (%d) specified!\n " , property);
1380
+ return (false );
1381
+ }
1382
+ }
1383
+ return (true );
1384
+ }
1385
+
1334
1386
// ///////////////////////////////////////////////////////////////////////////////////////////
1335
1387
bool
1336
1388
pcl::visualization::PCLVisualizer::getPointCloudRenderingProperties (int property, double &value, const std::string &id)
@@ -1447,6 +1499,28 @@ pcl::visualization::PCLVisualizer::setPointCloudRenderingProperties (
1447
1499
style_->updateLookUpTableDisplay (false );
1448
1500
break ;
1449
1501
}
1502
+ case PCL_VISUALIZER_LUT_RANGE:
1503
+ {
1504
+ // Check if the mapper has scalars
1505
+ if (!actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ())
1506
+ break ;
1507
+
1508
+ // Check that scalars are not unisgned char (i.e. check if a LUT is used to colormap scalars assuming vtk ColorMode is Default)
1509
+ if (actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars () ->IsA (" vtkUnsignedCharArray" ))
1510
+ break ;
1511
+
1512
+ switch (int (value))
1513
+ {
1514
+ case PCL_VISUALIZER_LUT_RANGE_AUTO:
1515
+ double range[2 ];
1516
+ actor->GetMapper ()->GetInput ()->GetPointData ()->GetScalars ()->GetRange (range);
1517
+ actor->GetMapper ()->GetLookupTable ()->SetRange (range[0 ], range[1 ]);
1518
+ actor->GetMapper ()->UseLookupTableScalarRangeOn ();
1519
+ style_->updateLookUpTableDisplay (false );
1520
+ break ;
1521
+ }
1522
+ break ;
1523
+ }
1450
1524
default :
1451
1525
{
1452
1526
pcl::console::print_error (" [setPointCloudRenderingProperties] Unknown property (%d) specified!\n " , property);
0 commit comments