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


C++ KDTree::add方法代码示例

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


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

示例1: if


//.........这里部分代码省略.........
  //===========================================================================================================================
  // Load points
  //===========================================================================================================================

  TheaArray<Vector3> sample_positions;
  TheaArray<Vector3> sample_normals;
  if (loadSamples(samples_path, sample_positions, sample_normals))
    return -1;

  bool has_normals = (!sample_positions.empty() && sample_normals.size() == sample_positions.size());

  THEA_CONSOLE << "Loaded " << sample_positions.size() << " sample(s) from " << samples_path;

  //===========================================================================================================================
  // Load mesh or dense samples
  //===========================================================================================================================

  TheaArray<Vector3> dense_positions;
  TheaArray<Vector3> dense_normals;
  bool dense_has_normals = false;
  KDTree kdtree;
  if (mesh_path != "-")
  {
    // First try to load the file as a set of points
    int dense_load_status = loadSamples(mesh_path, dense_positions, dense_normals);
    dense_has_normals = (!dense_positions.empty() && dense_normals.size() == dense_positions.size());

    if (dense_load_status != 0 && dense_load_status != UNSUPPORTED_FORMAT)
    {
      return -1;
    }
    else if (dense_load_status == 0)
    {
      THEA_CONSOLE << dense_positions.size() << " extra samples added from: " << mesh_path;
    }
    else  // Now try to load the file as a mesh, if the above failed
    {
      MG mg;
      try
      {
        mg.load(mesh_path);
      }
      THEA_STANDARD_CATCH_BLOCKS(return -1;, ERROR, "Could not load mesh %s", mesh_path.c_str())

      THEA_CONSOLE << "Loaded mesh from " << mesh_path;

      // Make sure the mesh is properly scaled
      AxisAlignedBox3 mesh_bounds = mg.getBounds();
      AxisAlignedBox3 samples_bounds;
      for (array_size_t i = 0; i < sample_positions.size(); ++i)
        samples_bounds.merge(sample_positions[i]);

      Real scale_error = (mesh_bounds.getLow()  - samples_bounds.getLow()).length()
                       + (mesh_bounds.getHigh() - samples_bounds.getHigh()).length();
      if (scale_error > 0.01 * mesh_bounds.getExtent().length())
      {
        // Rescale the mesh
        Real scale = (samples_bounds.getExtent() / mesh_bounds.getExtent()).max();  // samples give a smaller bound than the
                                                                                    // true bound, so take the axis in which
                                                                                    // the approximation is best

        AffineTransform3 tr = AffineTransform3::translation(samples_bounds.getCenter())
                            * AffineTransform3::scaling(scale)
                            * AffineTransform3::translation(-mesh_bounds.getCenter());
        MeshTransformer func(tr);
        mg.forEachMeshUntil(&func);
开发者ID:daerduoCarey,项目名称:Thea,代码行数:67,代码来源:SampleGraph.cpp


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