00001 #include <pcl/apps/cloud_composer/point_selectors/selection_event.h> 00002 00003 #include <pcl/point_types.h> 00004 00005 pcl::cloud_composer::SelectionEvent::~SelectionEvent () 00006 { 00007 renderer_->RemoveActor (selected_actor_); 00008 } 00009 00010 00011 void 00012 pcl::cloud_composer::SelectionEvent::findIndicesInItem (CloudItem* cloud_item, pcl::PointIndices::Ptr indices) 00013 { 00014 // WE DONT NEED TO DO THIS SEARCH BECAUSE WE HAVE A 1-1 CORRESPONDENCE VTK TO PCL 00015 // THIS IS ONLY THE CASE FOR CLOUDS WITH NO NANs 00016 //Go through every point in the selected data set and find the matching index in this cloud 00017 //pcl::search::KdTree<pcl::PointXYZ>::Ptr search = cloud_item->data (KD_TREE_SEARCH).value <pcl::search::Search<pcl::PointXYZ>::Ptr> (); 00018 // double dblpts[3]; 00019 // PointXYZ pt; 00020 // std::vector<int> indices; 00021 // std::vector<float> distances; 00022 /*for (int i = 0; i < points->GetNumberOfPoints (); ++i) 00023 { 00024 points->GetPoint(i, dblpts); 00025 pt.x = dblpts[0]; 00026 pt.y = dblpts[1]; 00027 pt.z = dblpts[2]; 00028 search->radiusSearch (pt,0.001,indices,distances); 00029 if (indices.size () == 1) 00030 { 00031 id_list.append (indices[0]); 00032 } 00033 //If there are multiple found we need to only assign it to one cloud 00034 else if (indices.size () > 1) 00035 { 00036 int idx = 0; 00037 while (used_indices.contains (indices[idx])) 00038 ++idx; 00039 if (idx < indices.size ()) 00040 { 00041 used_indices.append (indices[idx]); 00042 id_list.append (indices[idx]); 00043 } 00044 else 00045 qCritical () << "More found points in selection than are possible from cloud items!"; 00046 } 00047 00048 }*/ 00049 if (id_selected_data_map_.contains (cloud_item->getId ())) 00050 { 00051 vtkPolyData* points_in_item = id_selected_data_map_.value (cloud_item->getId ()); 00052 vtkIdTypeArray* point_ids = vtkIdTypeArray::SafeDownCast(points_in_item->GetPointData ()->GetArray ("vtkIdFilter_Ids")); 00053 00054 indices->indices.resize (point_ids->GetNumberOfTuples ()); 00055 for(int i =0; i < point_ids->GetNumberOfTuples (); ++i) 00056 { 00057 //qDebug () << "id="<<point_ids->GetValue (i); 00058 indices->indices[i] = point_ids->GetValue (i); 00059 } 00060 //qDebug () << points_in_item->GetNumberOfPoints () << " selected points in "<<cloud_item->getId (); 00061 } 00062 00063 }