当前位置: 首页>>代码示例>>C++>>正文


C++ Neighborhood::insert方法代码示例

本文整理汇总了C++中Neighborhood::insert方法的典型用法代码示例。如果您正苦于以下问题:C++ Neighborhood::insert方法的具体用法?C++ Neighborhood::insert怎么用?C++ Neighborhood::insert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Neighborhood的用法示例。


在下文中一共展示了Neighborhood::insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: neighborhood

pcl2::Neighborhood
pcl2::computeFixedRadiusNeighborhood (Cloud & cloud, const MatF & query, float r)
{
  // Convert point cloud
  MatF xyz = cloud["xyz"];
  assert (xyz.rows () >= 1);
  assert (xyz.cols () == 3);
  pcl::PointCloud<pcl::PointXYZ>::Ptr input (new pcl::PointCloud<pcl::PointXYZ>);
  input->width = cloud.size ();
  input->height = 1;
  input->is_dense = false;
  input->points.resize (cloud.size ());
  for (size_t i = 0; i < xyz.rows (); ++i)
  {
    input->points[i].x = xyz (i, 0);
    input->points[i].y = xyz (i, 1);
    input->points[i].z = xyz (i, 2);
  }

  // Convert query point
  assert (query.rows () == 1);
  assert (query.cols () == 3);
  pcl::PointXYZ q;
  q.x = query (0, 0);
  q.y = query (0, 1);
  q.z = query (0, 2);
  
  // Perform neighbor search
  pcl::KdTreeFLANN<pcl::PointXYZ> tree;
  tree.setInputCloud (input);

  std::vector<int> idx_vec;
  std::vector<float> dist_vec;
  size_t k = (size_t) tree.radiusSearch (q, r, idx_vec, dist_vec);
  assert (k == idx_vec.size ());

  // Convert output
  EigenMat<int> neighbor_indices (k, 1);
  EigenMat<float> squared_distances (k, 1);
  for (size_t i = 0; i < k; ++i)
  {
    neighbor_indices (i, 0) = idx_vec[i];
    squared_distances (i, 0) = dist_vec[i];
  }

  //Cloud neighborhood = cloud (neighbor_indices);
  Neighborhood neighborhood (cloud, neighbor_indices);
  neighborhood.insert ("dist", squared_distances);
  return (neighborhood);
}
开发者ID:Javichu,项目名称:pcl2,代码行数:50,代码来源:neighbors.cpp

示例2: dfs

void Application::dfs(SparseGraph &G,VertexId v,Array1D<bool> &mark,
		      Neighborhood &component)
{
  Stack<VertexId> S;
  S.push(v);
  mark[v]=true;
  while(!S.isEmpty()) {
    VertexId v=S.pop();
    component.insert(v);
    bool shouldDelete;
    Neighborhood &children=*G.getNeighborsOf(v,shouldDelete);
    for(Neighborhood::iterator cur=children.begin(), end=children.end() ; 
	cur!=end ; ++cur) {
      VertexId child=*cur;
      if(mark[child]) continue;
      S.push(child);
      mark[child]=true;
      //component.insert(child);
    }
  }
}
开发者ID:bmajoros,项目名称:util,代码行数:21,代码来源:connected-components.C


注:本文中的Neighborhood::insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。