CGAL / cgal-swig-bindings

CGAL bindings using SWIG
Other
338 stars 92 forks source link

How can I set `Point_range` for mesh seed in Python #224

Closed SorooshMani-NOAA closed 1 year ago

SorooshMani-NOAA commented 1 year ago

I'm trying to use CGAL_Mesh_2.refine_Delaunay_mesh_2 function to generate mesh for my domain. When I try to pass in a list of Point_2 objects as the second argument, I get the following error:

Traceback (most recent call last):
  File "SCRIPT_PATH/river_meshing.py", line 215, in mesh
    CGAL_Mesh_2.refine_Delaunay_mesh_2(cdt, list_of_seeds)
  File "ENV_PATH/lib/python3.10/site-packages/CGAL/CGAL_Mesh_2.py", line 2156, in refine_Delaunay_mesh_2
    return _CGAL_Mesh_2.refine_Delaunay_mesh_2(*args)
TypeError: Wrong number or type of arguments for overloaded function 'refine_Delaunay_mesh_2'.
  Possible C/C++ prototypes are:
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_2_SWIG_wrapper &,Criteria_wrapper< DM2_C >)
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_2_SWIG_wrapper &,Point_range,Criteria_wrapper< DM2_C >,bool)
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_2_SWIG_wrapper &,Point_range,Criteria_wrapper< DM2_C >)
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_plus_2_SWIG_wrapper &,Criteria_wrapper< DM2_C_plus >)
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_plus_2_SWIG_wrapper &,Point_range,Criteria_wrapper< DM2_C_plus >,bool)
    refine_Delaunay_mesh_2(Mesh_2_Constrained_Delaunay_triangulation_plus_2_SWIG_wrapper &,Point_range,Criteria_wrapper< DM2_C_plus >)

My code is something like this:

from CGAL import CGAL_Mesh_2
from CGAL.CGAL_Mesh_2 import Delaunay_mesh_size_criteria_2
from CGAL.CGAL_Mesh_2 import Mesh_2_Constrained_Delaunay_triangulation_2
from CGAL.CGAL_Kernel import Point_2

cdt = Mesh_2_Constrained_Delaunay_triangulation_2()
for init_nd in init_nodes:
    cdt.insert(Point_2(init_nd.x, init_nd.y))
...
for vert_handle_0, vert_handle_1 in constraint_edges_vert_handles:
    cdt.insert_constraint(vert_handle_0, vert_handle_1)

list_of_seeds = [Point_2(pt.x, pt.y) for pt in pts_out]
CGAL_Mesh_2.refine_Delaunay_mesh_2(cdt, list_of_seeds)
SorooshMani-NOAA commented 1 year ago

I'm sorry for creating this ticket. There was a typo in the script that I was running and after creating the ticket I noticed and fixed it and now it accepts list of seeds Point_2 objects