/////////////////////////////////////////////////////////////////////////////////////
| 122 | |
| 123 | ////////////////////////////////////////////////////////////////////////////////////////// |
| 124 | void |
| 125 | pcl::visualization::ImageViewer::addRGBImage ( |
| 126 | const unsigned char* rgb_data, unsigned width, unsigned height, |
| 127 | const std::string &layer_id, double opacity, bool autoresize) |
| 128 | { |
| 129 | if (autoresize && |
| 130 | (static_cast<unsigned>(getSize ()[0]) != width || |
| 131 | static_cast<unsigned>(getSize ()[1]) != height)) |
| 132 | setSize (width, height); |
| 133 | |
| 134 | // Check to see if this ID entry already exists (has it been already added to the visualizer?) |
| 135 | auto am_it = std::find_if (layer_map_.begin (), layer_map_.end (), LayerComparator (layer_id)); |
| 136 | if (am_it == layer_map_.end ()) |
| 137 | { |
| 138 | PCL_DEBUG ("[pcl::visualization::ImageViewer::addRGBImage] No layer with ID='%s' found. Creating new one...\n", layer_id.c_str ()); |
| 139 | am_it = createLayer (layer_id, width, height, opacity, false); |
| 140 | } |
| 141 | |
| 142 | void* data = const_cast<void*> (reinterpret_cast<const void*> (rgb_data)); |
| 143 | |
| 144 | vtkSmartPointer<vtkImageData> image = vtkSmartPointer<vtkImageData>::New (); |
| 145 | image->SetExtent (0, width - 1, 0, height - 1, 0, 0); |
| 146 | image->AllocateScalars (VTK_UNSIGNED_CHAR, 3); |
| 147 | image->GetPointData ()->GetScalars ()->SetVoidArray (data, 3 * width * height, 1); |
| 148 | algo_->SetInputData (image); |
| 149 | algo_->Update (); |
| 150 | slice_->GetMapper ()->SetInputConnection (algo_->GetOutputPort ()); |
| 151 | ren_->ResetCamera (); |
| 152 | ren_->GetActiveCamera ()->SetParallelScale (0.5 * win_->GetSize ()[1]); |
| 153 | } |
| 154 | |
| 155 | ////////////////////////////////////////////////////////////////////////////////////////// |
| 156 | void |