【软件安装】ubuntu+CGAL+QT可视化+draw_triangulation_2+draw_triangulation_3

CGAL下载:

Release CGAL-5.5 · CGAL/cgal · GitHub

CGAL-5.5-examples.zip

Source code (tar.gz) 

不需要编译,解压到合适位置即可。

CGAL-5.5-examples是官方给出的测试例子,附带测试数据。

CGAL 开源项目很高兴地宣布 CGAL 5.5 版,即计算几何算法库。

除了对现有软件包的修复和一般增强之外,自 CGAL 5.4 以来,以下内容发生了变化:
3D Alpha Wrapping(新包装)
    该组件将 3D 三角形网格、汤或点集作为输入,并生成包含输入的有效(水密、无交叉和组合 2 流形)表面三角形网格。
    This component takes a 3D triangle mesh, soup, or point set as input, and generates a valid (watertight, intersection-free, and combinatorially 2-manifold) surface triangle mesh that contains the input.

    该算法从输入的松散边界框开始,通过收缩包装和细化 3D Delaunay 三角剖分继续进行。
    The algorithm proceeds by shrink-wrapping and refining a 3D Delaunay triangulation, starting from a loose bounding box of the input.
    
    两个用户定义的参数(alpha和offset)分别控制收缩包装过程可以进入的腔的最大尺寸,以及最终曲面网格对输入的紧密度。一旦组合起来,这些参数就提供了一种方法,以权衡输入的保真度和输出的复杂性。 
    Two user-defined parameters, alpha and offset, offer control over the maximum size of cavities where the shrink-wrapping process can enter, and the tightness of the final surface mesh to the input, respectively. Once combined, these parameters provide a means to trade fidelity to the input for complexity of the output.

    另见公告页面。

2D 直骨架和多边形偏移(重大更改)

    修复函数 CGAL::create_exterior_skeleton_and_offset_polygons_with_holes_2() 的输出
    不考虑外框的偏移量。
    修复了未计算孔偏移的带孔多边形外部偏移的计算

3D 凸壳

    添加了函数 CGAL::convex_hull_3() 的重载,它将结果写入索引三角形集。

二维多边形

    添加顶点、边和孔范围。
    GeneralPolygonWithHoles_2 概念现在需要嵌套类型 Polygon_2 而不是 General_polygon_2。

2D 正则化布尔集操作

    概念 GeneralPolygonSetTraits_2 现在需要嵌套类型 Construct_polygon_with_holes_2 而不是 Construct_general_polygon_with_holes_2。

组合图

    删除了 CGAL 4.9 和 4.10 中不推荐使用的旧代码(全局函数和与飞镖相关的信息)。

二维排列

    修复了特征类模板 Arr_geodesic_arc_on_sphere_traits_2 的 intersect_2、compare_y_at_x_right 和 compare_y_at_x_left 函数对象,用于处理球体上的测地线弧,并对追踪特征应用了一个小的语法修复。

四面体网格生成

    添加了函数 remove_isolated_vertices() 作为四面体网格生成的后处理步骤。

多边形网格处理

    添加了函数 CGAL::Polygon_mesh_processing::orient_triangle_soup_with_reference_triangle_soup(),它可以根据参考三角形汤中最近面的方向重新定位三角形汤的面。
    添加了函数 CGAL::Polygon_mesh_processing::compatible_orientations(),它可以从不同的连接组件中检索面的方向的(不)兼容性。
    添加了函数 CGAL::Polygon_mesh_processing::tangential_relaxation(),它将基于区域的切向网格平滑应用于曲面三角形网格的顶点。
    将命名参数访问者添加到函数 triangulate_hole(),它可以使用回调跟踪进度。
    在基于 corefinement 的方法的访问者中添加了更多功能来跟踪进度。

表面网格简化

    基于 Trettner 和 Kobbelt 的概率方法(使用概率二次曲线的快速和稳健的 QEF 最小化)引入了 Garland-Heckbert 简化算法的四种变体:GarlandHeckbert_plane_policies、GarlandHeckbert_probabilistic_plane_policies、GarlandHeckbert_triangle_policies 和 GarlandHeckbert_probabilistic_triangle_policies。
    GarlandHeckbert_policies 类已被弃用,GarlandHeckbert_plane_policies 取而代之。

点集处理

    一个新的可选命名参数 min_points_per_cell 已添加到 grid_simplify_point_set()。通过在单元格中添加最少数量的点以保留一个点,还可以过滤掉低密度区域和异常值:在密集采样点云的情况下,这比使用网格简化然后去除异常值产生更好的结果,同时非常广阔。默认值为 1 以将先前的行为保持为默认值。

dD 空间搜索

    将成员函数 write_graphviz() 添加到 Kd_tree 类中,该类以 Graphviz 格式将树写入流中。

CGAL 和 Boost 图形库 (BGL)

    在类 Face_filtered_graph 中添加了函数 invert_selection(),该函数切换图形的选中状态:选中的面被取消选中,未选中的面被选中。

qt下载和安装:

参考:QT5 安装(Ubuntu20.04) 详细_小小圆脸的博客-CSDN博客_ubuntu安装qt5

安装Qt的开发工具:

sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools

安装qtcreator:

sudo apt-get install qtcreator

安装qt:

sudo apt-get install qt5*

qt5svg下载:(参考:计算机中丢失qt5svg,在Linux中找不到“Qt5Svg”提供的包配置文件_山遙的博客-CSDN博客

sudo apt-get install libqt5svg5-dev

安装gmp:

下载地址:Gnu Mp 比格纳姆图书馆 (gmplib.org)

tar xf gmp-6.2.1.tar.xz

cd gmp-6.2.1

./configure --prefix=/home/lyl/download/gmp-6.2.1

make

make check

sudo make install

确认是否正确安装:/usr/lib/x86_64-linux-gnu/libgmp.so

 参考:Linux(Ubuntu)安装CGAL(非root)_Yilien10的博客-CSDN博客_linux安装cgal

安装mpfr:

下载地址:https://www.mpfr.org/mpfr-current/

tar xf mpfr-4.1.0.tar.xz

./configure --prefix=/home/lyl/download/mpfr-4.1.0 --with-gmp=/home/lyl/download/gmp-6.2.1

make

make check

sudo make install

确认是否正确安装:/usr/lib/x86_64-linux-gnu/libmpfr.so

CGAL测试例子编译和运行:

CMakeLists.txt

# Created by the script cgal_create_cmake_script
# This is the CMake script for compiling a CGAL application.

cmake_minimum_required(VERSION 3.1...3.23)
project(Triangulation_2_Examples)

# find_package(CGAL)
find_package(CGAL COMPONENTS Qt5)

# create a target per cppfile
file(
  GLOB cppfiles
  RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
foreach(cppfile ${cppfiles})
  create_single_source_cgal_program("${cppfile}")
endforeach()


if(CGAL_Qt5_FOUND)
  add_definitions(-DCGAL_USE_BASIC_VIEWER)
  target_link_libraries(draw_triangulation_2 PUBLIC CGAL::CGAL_Basic_viewer)
else()
  message(
    STATUS
      "NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled."
  )
endif()

find_package(CGAL COMPONENTS Qt5)

这里的find_package需要添加COMPONENTS Qt5,才能确定找到QT5(QT5的一些模块需要在之前被正确安装才行,比如svg),CGAL_Qt5_FOUND会被设置为ON,后续可以利用CGAL::CGAL_Basic_viewer进行可视化。

如果不想可视化,则可以用:

find_package(CGAL)

此时会提示:

NOTICE: The example draw_triangulation_2 requires Qt and will not be compiled.

也可以编译,但是没有可视化工具

cmake编译选项:

cmake -DCMAKE_BUILD_TYPE=Release -DCGAL_DIR=/home/leonjin/project/CGAL/cgal-5.5 ..

每一个列举出来的qt模块都是需要的。如果缺失,比如svg,则会编译会报错。

draw_triangulation_2.cpp

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Triangulation_2.h>
#include <CGAL/draw_triangulation_2.h>
#include <fstream>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_2<K>                            Triangulation;
typedef Triangulation::Point                                Point;

int main(int argc, char* argv[]) {
  std::ifstream in((argc>1)?argv[1]:"data/triangulation_prog1.cin");
  std::istream_iterator<Point> begin(in);
  std::istream_iterator<Point> end;

  Triangulation t;
  t.insert(begin, end);

  CGAL::draw(t);

  return EXIT_SUCCESS;
}

源码在:CGAL-5.5-examples/CGAL-5.5/examples/Triangulation_2

draw_triangulation_2运行:

./draw_triangulation_2 ../data/triangulation_prog1.cin

draw_triangulation_3.cpp

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/point_generators_3.h>
#include <CGAL/draw_triangulation_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K>                   DT3;
typedef CGAL::Creator_uniform_3<double,K::Point_3>          Creator;

int main()
{
  std::vector<K::Point_3> points;
  CGAL::Random_points_in_sphere_3<K::Point_3,Creator> g(1.0);
  std::copy_n(g, 50, std::back_inserter(points));

  DT3 dt3(points.begin(), points.end());

  CGAL::draw(dt3);

  return EXIT_SUCCESS;
}

源码在:CGAL-5.5-examples/CGAL-5.5/examples/Triangulation_3

draw_triangulation_3运行:

./draw_triangulation_3

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值