我试图在CGAL上给点颜色到一个triangulation_3中。我只是以CGAL描述这里的例子为例
我对这个例子做了一个简单的修改,以便能够绘制三角剖分:
#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->info() = CGAL::Color(0,255,0);上添加了哪种颜色,方法绘制总是在显示的窗口中显示相同的红色点:

我知道代码正在构造一个包含颜色信息的数据结构,但是它可以独立于绘图方法,所以我认为窗口没有显示绿色点,因为这不是点的颜色。如果是的话,用抽签法得到带绿点的三角剖分是什么方法?
发布于 2020-05-14 06:06:29
在当前的形式中,观看者无法改变顶点或边缘的颜色。
但是修改代码很容易。
void compute_vertex(Vertex_const_handle vh) (此文件中的第92行)以使用以颜色为参数的add_point方法:add_point(vh->point(), vh->info());https://stackoverflow.com/questions/61786639
复制相似问题