from CGAL.CGAL_Kernel import Point_2 from CGAL.CGAL_Mesh_2 import Mesh_2_Constrained_Delaunay_triangulation_2 from CGAL.CGAL_Mesh_2 import Delaunay_mesh_size_criteria_2 from CGAL import CGAL_Mesh_2 cdt=Mesh_2_Constrained_Delaunay_triangulation_2() va = cdt.insert(Point_2(-4,0)) vb = cdt.insert(Point_2(0,-1)) vc = cdt.insert(Point_2(4,0)) vd = cdt.insert(Point_2(0,1)) cdt.insert(Point_2(2, 0.6)) cdt.insert_constraint(va, vb) cdt.insert_constraint(vb, vc) cdt.insert_constraint(vc, vd) cdt.insert_constraint(vd, va) print "Number of vertices: ", cdt.number_of_vertices() print "Meshing the triangulation..." CGAL_Mesh_2.refine_Delaunay_mesh_2(cdt,Delaunay_mesh_size_criteria_2(0.125, 0.5)) print "Number of vertices: ", cdt.number_of_vertices()
vb = cdt.insert(Point_2(-5., 5.)) vc = cdt.insert(Point_2(4., 3.)) vd = cdt.insert(Point_2(5., -5.)) ve = cdt.insert(Point_2(6., 6.)) vf = cdt.insert(Point_2(-6., 6.)) vg = cdt.insert(Point_2(-6., -6.)) vh = cdt.insert(Point_2(6., -6.)) cdt.insert_constraint(va, vb) cdt.insert_constraint(vb, vc) cdt.insert_constraint(vc, vd) cdt.insert_constraint(vd, va) cdt.insert_constraint(ve, vf) cdt.insert_constraint(vf, vg) cdt.insert_constraint(vg, vh) cdt.insert_constraint(vh, ve) print("Number of vertices before: ", cdt.number_of_vertices()) #make it conforming Delaunay CGAL_Mesh_2.make_conforming_Delaunay_2(cdt) print("Number of vertices after make_conforming_Delaunay_2: ", cdt.number_of_vertices()) #then make it conforming Gabriel CGAL_Mesh_2.make_conforming_Gabriel_2(cdt) print("Number of vertices after make_conforming_Gabriel_2: ", cdt.number_of_vertices())
#construct a constrained triangulation va = cdt.insert(Point_2( 5., 5.)) vb = cdt.insert(Point_2(-5., 5.)) vc = cdt.insert(Point_2( 4., 3.)) vd = cdt.insert(Point_2( 5.,-5.)) ve = cdt.insert(Point_2( 6., 6.)) vf = cdt.insert(Point_2(-6., 6.)) vg = cdt.insert(Point_2(-6.,-6.)) vh = cdt.insert(Point_2( 6.,-6.)) cdt.insert_constraint(va,vb) cdt.insert_constraint(vb,vc) cdt.insert_constraint(vc,vd) cdt.insert_constraint(vd,va) cdt.insert_constraint(ve,vf) cdt.insert_constraint(vf,vg) cdt.insert_constraint(vg,vh) cdt.insert_constraint(vh,ve) print("Number of vertices before: ", cdt.number_of_vertices()) #make it conforming Delaunay CGAL_Mesh_2.make_conforming_Delaunay_2(cdt) print("Number of vertices after make_conforming_Delaunay_2: ", cdt.number_of_vertices()) #then make it conforming Gabriel CGAL_Mesh_2.make_conforming_Gabriel_2(cdt) print("Number of vertices after make_conforming_Gabriel_2: ", cdt.number_of_vertices())
from __future__ import print_function from CGAL.CGAL_Kernel import Point_2 from CGAL.CGAL_Mesh_2 import Mesh_2_Constrained_Delaunay_triangulation_2 from CGAL.CGAL_Mesh_2 import Delaunay_mesh_size_criteria_2 from CGAL import CGAL_Mesh_2 cdt = Mesh_2_Constrained_Delaunay_triangulation_2() va = cdt.insert(Point_2(-4, 0)) vb = cdt.insert(Point_2(0, -1)) vc = cdt.insert(Point_2(4, 0)) vd = cdt.insert(Point_2(0, 1)) cdt.insert(Point_2(2, 0.6)) cdt.insert_constraint(va, vb) cdt.insert_constraint(vb, vc) cdt.insert_constraint(vc, vd) cdt.insert_constraint(vd, va) print("Number of vertices: ", cdt.number_of_vertices()) print("Meshing the triangulation...") CGAL_Mesh_2.refine_Delaunay_mesh_2(cdt, Delaunay_mesh_size_criteria_2(0.125, 0.5)) print("Number of vertices: ", cdt.number_of_vertices())
from CGAL.CGAL_Mesh_2 import Delaunay_mesh_size_criteria_2 from CGAL.CGAL_Mesh_2 import Default_Delaunay_mesher_2 from CGAL.CGAL_Mesh_2 import Mesh_2_parameters from CGAL import CGAL_Mesh_2 cdt = Mesh_2_Constrained_Delaunay_triangulation_2() va = cdt.insert(Point_2(-2, 0)) vb = cdt.insert(Point_2(0, -2)) vc = cdt.insert(Point_2(2, 0)) vd = cdt.insert(Point_2(0, 1)) cdt.insert(Point_2(2, 0.6)) cdt.insert_constraint(va, vb) cdt.insert_constraint(vb, vc) cdt.insert_constraint(vc, vd) cdt.insert_constraint(vd, va) print("Number of vertices: ", cdt.number_of_vertices()) print("Meshing...") mesher = Default_Delaunay_mesher_2(cdt) mesher.set_criteria(Delaunay_mesh_size_criteria_2(0.125, 0.05)) mesher.refine_mesh() print("Number of vertices: ", cdt.number_of_vertices()) print("Run Lloyd optimization...") params = Mesh_2_parameters() params.set_max_iteration_number(10) CGAL_Mesh_2.lloyd_optimize_mesh_2(cdt, params) print("done.") print("Number of vertices: ", cdt.number_of_vertices())