////////////////////////////////////////////////////////////////////////////////////////
| 658 | |
| 659 | ///////////////////////////////////////////////////////////////////////////////////////////// |
| 660 | void |
| 661 | pcl::visualization::PCLVisualizer::addCoordinateSystem (double scale, const std::string &id, int viewport) |
| 662 | { |
| 663 | if (scale <= 0.0) |
| 664 | scale = 1.0; |
| 665 | vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New (); |
| 666 | axes->SetOrigin (0, 0, 0); |
| 667 | axes->SetScaleFactor (scale); |
| 668 | axes->Update (); |
| 669 | |
| 670 | vtkSmartPointer<vtkFloatArray> axes_colors = vtkSmartPointer<vtkFloatArray>::New (); |
| 671 | axes_colors->Allocate (6); |
| 672 | axes_colors->InsertNextValue (0.0); |
| 673 | axes_colors->InsertNextValue (0.0); |
| 674 | axes_colors->InsertNextValue (0.5); |
| 675 | axes_colors->InsertNextValue (0.5); |
| 676 | axes_colors->InsertNextValue (1.0); |
| 677 | axes_colors->InsertNextValue (1.0); |
| 678 | |
| 679 | vtkSmartPointer<vtkPolyData> axes_data = axes->GetOutput (); |
| 680 | axes_data->GetPointData ()->SetScalars (axes_colors); |
| 681 | |
| 682 | vtkSmartPointer<vtkTubeFilter> axes_tubes = vtkSmartPointer<vtkTubeFilter>::New (); |
| 683 | axes_tubes->SetInputData (axes_data); |
| 684 | axes_tubes->SetRadius (axes->GetScaleFactor () / 50.0); |
| 685 | axes_tubes->SetNumberOfSides (6); |
| 686 | |
| 687 | vtkSmartPointer<vtkPolyDataMapper> axes_mapper = vtkSmartPointer<vtkPolyDataMapper>::New (); |
| 688 | axes_mapper->SetScalarModeToUsePointData (); |
| 689 | axes_mapper->SetInputConnection (axes_tubes->GetOutputPort ()); |
| 690 | |
| 691 | vtkSmartPointer<vtkLODActor> axes_actor = vtkSmartPointer<vtkLODActor>::New (); |
| 692 | axes_actor->SetMapper (axes_mapper); |
| 693 | |
| 694 | // Save the ID and actor pair to the global actor map |
| 695 | (*coordinate_actor_map_) [id] = axes_actor; |
| 696 | |
| 697 | addActorToRenderer (axes_actor, viewport); |
| 698 | } |
| 699 | |
| 700 | ///////////////////////////////////////////////////////////////////////////////////////////// |
| 701 | void |