I am new to using these bindings, and I'm trying to construct a triangulation with floating-point values at each vertex. This would be similar to the below tutorial, only with type float instead of std::color as the vertex info:
#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>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_with_info_3<CGAL::IO::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::IO::red();
return 0;
}
My attempted implementation is below:
from CGAL.CGAL_Kernel import Point_3
from CGAL.CGAL_Kernel import Delaunay_triangulation_cell_base
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())
It is failing at the import commands and telling me that classes like Delaunay_triangulation_cell_base and Triangulation_vertex_base_with_info_3 cannot be imported from the compiled kernel. I'm not sure where these classes are stored in the bindings, if not there. Could this be an installation issue?
I am new to using these bindings, and I'm trying to construct a triangulation with floating-point values at each vertex. This would be similar to the below tutorial, only with type
floatinstead ofstd::coloras the vertex info:My attempted implementation is below:
It is failing at the
importcommands and telling me that classes likeDelaunay_triangulation_cell_baseandTriangulation_vertex_base_with_info_3cannot be imported from the compiled kernel. I'm not sure where these classes are stored in the bindings, if not there. Could this be an installation issue?