【问题标题】:Color points on CGAL Triangulation_3CGAL Triangulation_3 上的色点
【发布时间】:2020-05-13 23:29:58
【问题描述】:

我正在尝试为 CGAL 上的 triangulation_3 中的点赋予颜色。我只是以 CGAL describe here 中的例子为例

我对这个例子做了一个简单的修改,以便能够绘制三角剖分:

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Delaunay_triangulation_cell_base_3.h>
#include <CGAL/Triangulation_vertex_base_with_info_3.h>
#include <CGAL/IO/Color.h>
#include <CGAL/draw_triangulation_3.h>

typedef CGAL::Exact_predicates_inexact_constructions_kernel         K;
typedef CGAL::Triangulation_vertex_base_with_info_3<CGAL::Color, K> Vb;
typedef CGAL::Delaunay_triangulation_cell_base_3<K>                 Cb;
typedef CGAL::Triangulation_data_structure_3<Vb, Cb>                Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds>                      Delaunay;
typedef Delaunay::Point                                             Point;
int main()
{
  Delaunay T;
  T.insert(Point(0,0,0));
  T.insert(Point(1,0,0));
  T.insert(Point(0,1,0));
  T.insert(Point(0,0,1));
  T.insert(Point(2,2,2));
  T.insert(Point(-1,0,1));
  // Set the color of finite vertices of degree 6 to red.
  Delaunay::Finite_vertices_iterator vit;
  for (Delaunay::Vertex_handle v : T.finite_vertex_handles())
      if (T.degree(v) == 6)
    v->info() = CGAL::Color(0,255,0);

  CGAL::draw(T);
  return 0;
}

但是无论我在v-&gt;info() = CGAL::Color(0,255,0); 上涂上哪种颜色,draw 方法总是在显示的窗口中给出相同的红点:

我知道代码正在构建一个包含颜色信息的数据结构,但这可能与 draw 方法无关,所以我认为窗口没有显示绿点,因为这不是给点着色的方法.如果是这样,使用draw方法获得绿点三角剖分的方法是什么?'。

【问题讨论】:

    标签: colors point cgal triangulation


    【解决方案1】:

    在当前形式下,查看器无法更改顶点或边的颜色。

    但是修改代码很容易。

    1. 将文件draw_triangulation_3.h复制到您的项目中
    2. 编辑方法void compute_vertex(Vertex_const_handle vh),(此文件中的第92行)以使用带有颜色作为参数的add_point方法:add_point(vh-&gt;point(), vh-&gt;info());

    【讨论】:

      猜你喜欢
      • 2021-03-21
      • 1970-01-01
      • 2017-12-22
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-31
      • 1970-01-01
      相关资源
      最近更新 更多