【问题标题】:how can I store collapsed edges using CGAL如何使用 CGAL 存储折叠的边缘
【发布时间】:2019-02-23 11:10:04
【问题描述】:

我正在 QT-creator 上创建一个应用程序,并使用 CGAL 将 .off 文件读取为 Linear_cell_complex_for_bgl_combinatorial_map_helper 并使用 edge_collapse 方法对其进行简化。 我想存储折叠边列表、事件顶点、点位置和其他需要的信息,以便再次重新插入删除的边。

我的代码

namespace SMS = CGAL::Surface_mesh_simplification ;
typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper<2, 3, MyTraits>::type LCC;

typedef boost::graph_traits<LCC>::vertex_descriptor vertex_descriptor;
typedef SMS::Edge_profile<LCC> Profile ;
struct Stats
{
  Stats() :  collapsed(0) {}
  std::size_t collapsed ;
} ;

struct My_visitor : SMS::Edge_collapse_visitor_base<LCC>
{

My_visitor( Stats* s) : stats(s){}
void OnCollapsed( Profile const&, vertex_descriptor )
  {
    ++ stats->collapsed;
  }

Stats* stats ;
};


    namespace SMS = CGAL::Surface_mesh_simplification ;

    SMS::Count_stop_predicate<LCC> stop(1000);
    Stats stats ;

    My_visitor vis(&stats) ;

 int r = SMS::edge_collapse
   (lcc
    ,stop
    ,CGAL::parameters::halfedge_index_map(get(CGAL::halfedge_index, lcc))
             .vertex_index_map(get(boost::vertex_index, lcc))
             .get_cost(SMS::Edge_length_cost<LCC>())
   .get_placement(SMS::Midpoint_placement<LCC>()).visitor(vis)
    );

 std::cout << "\nEdges collapsed: "  << stats.collapsed
            << std::endl;

我尝试使用 Edge_collapse_visitor_base 来获取折叠边缘的数量,但我不知道如何获取与折叠边缘相关的信息。

感谢您的帮助。

【问题讨论】:

  • 回调中的vertex_descriptor中是否有你想要的信息?

标签: c++ qt computational-geometry cgal


【解决方案1】:

我在 github 上有一个 branch,我使用访问者记录边缘崩溃。我向访问者添加了进一步的回调,以便可以撤消边缘折叠。我使它适用于 CGAL::Surface_mesh 以及 OpenMesh。

【讨论】:

  • 我找不到 我正在使用 cgal 4.13 我在这里评论是因为另一个 github 问题已关闭
  • @n.m 分支 [还创建了该头文件。见github.com/CGAL/cgal/compare/…
【解决方案2】:

查看定义访问者类的概念:EdgeCollapseSimplificationVisitor。如果你实现OnCollapsing 方法。它的参数Profile const &amp; profile 包含您需要的所有信息。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2018-08-12
  • 2017-04-14
  • 2012-09-11
  • 2018-10-30
  • 1970-01-01
  • 1970-01-01
  • 2022-10-25
  • 2022-09-30
相关资源
最近更新 更多