Код: Выделить всё
#include
#include
#include
#include
#include
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3 Vb;
typedef CGAL::Delaunay_triangulation_cell_base_3 Cb;
typedef CGAL::Triangulation_data_structure_3 Tds;
typedef CGAL::Delaunay_triangulation_3 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::IO::red();
return 0;
}
я делаю это через привязки, потому что это в контексте сценария, который в противном случае работает лучше всего. Есть несколько вещей, в которых я не уверен, например, если Python Tuple является эквивалентом команды std :: make_pair (точка (x, y, z), значение) или если я правильно настраиваю структуру данных триангуляции. Тем не менее, это гипотетические проблемы, потому что реальная проблема заключается в том, что сценарий сбои в командах импорта из -за того, что он не обнаружил delaunay_triangulation_cell_base_3 или triangulation_vertex_base_with_info_3 в компилированном cgal kernel. Я также пытался импортировать из cgal.cgal_triangulation_3 , и это также не удается. Я не уверен, где эти сущности будут храниться в привязках, если не в этих местах. Учебное пособие, указанное выше, указывает на то, что они должны быть импортированы прямо из ядра. Я неправильно понимаю, где они находятся или каков их синтаксис, или это выглядит правильно, и я испытываю проблему установки? < /P>
Код: Выделить всё
from CGAL.CGAL_Kernel import Point_3
from CGAL.CGAL_Kernel import Delaunay_triangulation_cell_base_3
from CGAL.CGAL_Kernel import Triangulation_vertex_base_with_info_3
from CGAL.CGAL_Triangulation_3 import Triangulation_data_structure_3
from CGAL.CGAL_Triangulation_3 import Delaunay_triangulation_3
from CGAL.CGAL_Triangulation_3 import Ref_Locate_type_3
from CGAL.CGAL_Kernel import Ref_int
import numpy as np
# construct triangulation with info at each node
vertex_base=Triangulation_vertex_base_with_info_3(np.float32,CGAL.CGAL_Kernel)
dataStructure=Triangulation_data_structure_3(vertex_base,Delaunay_triangulation_cell_base)
T=Delaunay_triangulation_3(dataStructure)
NUMNODES=170000
NODES=np.random.rand(NUMNODES,3)
NODE_VALUES=np.random.rand(NUMNODES) # values stored at each node
L=[]
for ii in range(np.shape(NODES)[0]):
# not entirely sure if tuple is equivalent of
# std::make_pair(point(x,y,z),value)
temp=(Point_3(NODES[ii,0],NODES[ii,1],NODES[ii,2]),NODE_VALUES[ii])
T.insert(temp)
print(f'Triangulation made, # vertices: {T.number_of_vertices()}')
# T.locate() can't seem to query more than one point at a time
query_point=Point_3(0.5,0.5,0.5)
enclosingTets=T.locate(query_point,Ref_Locate_type_3(),Ref_int(),Ref_int())
for jj in range(1):
print(dir(enclosingTets.vertex(jj).point()))
print(enclosingTets.vertex(jj).point())
Подробнее здесь: https://stackoverflow.com/questions/796 ... ertex-info