123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134(* File: mesh_triangle.ml
Copyright (C) 2009-
Christophe Troestler <Christophe.Troestler@umons.ac.be>
WWW: http://math.umons.ac.be/an/software/
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3 or
later as published by the Free Software Foundation, with the special
exception on linking described in the file LICENSE.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
LICENSE for more details. *)openBigarrayopenMesh_utilsexternalinit:unit->unit="ocaml_triangle_init"let()=init()includeMesh_triangle_commonletpslg?(hole:'aMesh.matoption)?(region:'aMesh.matoption)?(point_attribute:'aMesh.matoption)?(point_marker:'aMesh.int_vecoption)(point:'aMesh.mat)?(segment_marker:'aMesh.int_vecoption)(segment:'aMesh.int_mat)=ifMesh_utils.is_c_layout(Array2.layoutpoint)thenletm=Mesh_triangleC.pslg~hole:(mat_opt_to_chole)~region:(mat_opt_to_cregion)~point_attribute:(mat_opt_to_cpoint_attribute)~point_marker:(vec_opt_to_cpoint_marker)~point:(mat_to_cpoint)~segment_marker:(vec_opt_to_csegment_marker)~segment:(mat_to_csegment)in(Obj.magic(m:c_layoutpslg):'apslg)elseletm=Mesh_triangleF.pslg~hole:(mat_opt_to_fortranhole)~region:(mat_opt_to_fortranregion)~point_attribute:(mat_opt_to_fortranpoint_attribute)~point_marker:(vec_opt_to_fortranpoint_marker)~point:(mat_to_fortranpoint)~segment_marker:(vec_opt_to_fortransegment_marker)~segment:(mat_to_fortransegment)in(Obj.magic(m:fortran_layoutpslg):'apslg)lettriangle?delaunay?min_angle?max_area?region_area?max_steiner?voronoi?edge?neighbor?subparam?triangle_area?check_finite?debug?verbose?triunsuitable~pslg~refinemesh=letlayout=Array2.layoutmesh#pointinifis_c_layoutlayoutthenlettriangle_area=matchtriangle_areawith|None->None|Somev->Some(vec_to_cv)inletres=Mesh_triangleC.triangulate?delaunay?min_angle?max_area?region_area?max_steiner?voronoi?neighbor?edge?subparam?triangle_area?triunsuitable?check_finite?debug?verbose~pslg~refine(mesh_to_cmesh)in(Obj.magic(res:c_layoutt*c_layoutvoronoi):'at*'avoronoi)elselettriangle_area=matchtriangle_areawith|None->None|Somev->Some(vec_to_fortranv)inletres=Mesh_triangleF.triangulate?delaunay?min_angle?max_area?region_area?max_steiner?voronoi?neighbor?edge?subparam?triangle_area?triunsuitable?check_finite?debug?verbose~pslg~refine(mesh_to_fortranmesh)in(Obj.magic(res:fortran_layoutt*fortran_layoutvoronoi):'at*'avoronoi)lettriangulate?delaunay?min_angle?max_area?region_area?max_steiner?voronoi?edge?neighbor?subparam?triunsuitable?check_finite?debug?verbosepslg=letmesh=mesh_of_pslgpslgintriangle?delaunay?min_angle?max_area?region_area?max_steiner?voronoi?edge?neighbor?subparam?triunsuitable?check_finite?debug?verbose~pslg:true~refine:falsemeshletrefine?delaunay?min_angle?max_area?max_steiner?voronoi?edge?neighbor?subparam?triangle_area?triunsuitable?check_finite?debug?verbosemesh=triangle?delaunay?min_angle?max_area?max_steiner?voronoi?edge?neighbor?subparam?triangle_area?triunsuitable?check_finite?debug?verbose~pslg:false~refine:truemeshletcopy(mesh:'lt)=extend_mesh(Mesh.copy(mesh:>_Mesh.t))~point_attribute:(copy_matmesh#point_attribute)~triangle_attribute:(copy_matmesh#triangle_attribute)letsubmesh?poslen=mesh_transformmesh(funm->Mesh_triangleC.subm?poslen)(funm->Mesh_triangleF.subm?poslen)letpermute_points(mesh:'l#t)?(inv=false)perm:'lt=mesh_transformmesh(funm->Mesh_triangleC.permute_pointsm~inv(vec_to_cperm))(funm->Mesh_triangleF.permute_pointsm~inv(vec_to_fortranperm))letpermute_triangles(mesh:'l#t)?(inv=false)perm:'lt=mesh_transformmesh(funm->Mesh_triangleC.permute_trianglesm~inv(vec_to_cperm))(funm->Mesh_triangleF.permute_trianglesm~inv(vec_to_fortranperm))(* Loading various formats *)(* Save to triangle format *)(* let save mesh filename =
* (\* .node file *\)
* let fh = open_out (filename ^ ".node") in
* close_out fh
* (\* .ele file *\)
* (\* .poly file *\)
* (\* .edge file *\)
* (\* .neigh file *\) *)