将变量添加到CGAL的Point类
问题描述:
我试图给CGAL的Point_3类添加一个颜色变量(无符号字符),以便在做Delaunay三角测量后可以访问颜色。将变量添加到CGAL的Point类
我曾尝试使用Triangulation_vertex_base_with_info_3存储这样的颜色(以下为http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Triangulation_3/Chapter_main.html#Subsection_39.5.3的例子)
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3<unsigned char, K> Vb;
typedef CGAL::Triangulation_data_structure_3<Vb> Tds;
typedef CGAL::Delaunay_triangulation_3<K, Tds> Triangulation;
typedef Triangulation::Point CGAL_Point;
//...
//here I make a vector of pairs of points and their color
std::vector<std::pair<CGAL_Point, unsigned char> > points;
Point currentPoint;
for (int i=0; i<roiPoints.size(); i++){
currentPoint=roiPoints[i];
points.push_back(std::make_pair(CGAL_Point(currentPoint.x, currentPoint.y, currentPoint.z), roiColors[i]));
}
//...
//triangulation
T.clear();
T.insert(points.begin(), points.end());
什么其实我是想实现的是能够通过三角测量来访问顶点颜色::四面体类做三角剖分后。
假设我在(x,y,z)处有一个点P。在三角测量之后,我发现包含这个点P的四面体t,并且我可以访问这个四面体的顶点(使用t.vertex(0..3))。这将返回Point_3类型的顶点,我无法访问之前存储的颜色。
我想办法做到这一点是创建我自己的Point类,其中包含的颜色信息。这很容易,但我不明白如何使用这个类而不是Point_3。我发现我还必须编写自己的内核来做到这一点,并在http://www.cgal.org/Manual/latest/doc_html/cgal_manual/Kernel_23/Chapter_main.html#Section_11.5的例子,但我不知道我应该使用什么内核作为基类或我的内核甚至应包含什么功能。
我甚至发现了两个类似的主题在这里计算器: Customizing CGAL Kernel with my own Point class 和 CGAL: Inheritance and the kernel 但他们并没有帮助我。
谢谢你的帮助!
我已经使用链接的例子来设置顶点的颜色(请参阅我已附加的代码),但是我没有设法通过使用定位的四面体访问颜色。你能更具体地说我该怎么做?谢谢! – ppalasek 2012-04-26 15:24:53
我明白了! Cell_iterator ci = T.locate(CGAL_Point(x,y,z));现在我可以用ci-> vertex(index) - > info()来访问颜色,其中index = 0..3。我不知道我可以从cell_iterator访问顶点。谢谢! – ppalasek 2012-04-26 16:16:06