Source file mesh_easymesh.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(** Put the full path if not in your search path. *)
let easymesh = "EasyMesh.exe"
open Printf
open Bigarray
class ['l] pslg = ['l] Mesh.pslg
let pslg = Mesh.pslg
let create = Mesh.create
let read (type l) (layout: l layout) fname : l Mesh.t =
match layout with
| C_layout -> Mesh_easymeshC.read Mesh_easymeshC.empty_pslg fname
| Fortran_layout -> Mesh_easymeshF.read Mesh_easymeshF.empty_pslg fname
let triangulate (type l) ~max_area (pslg: l pslg) =
let (fname_plsg, fh) = Filename.open_temp_file "EasyMesh" ".d" in
let fname = Filename.chop_extension fname_plsg in
(match Mesh.layout pslg with
| C_layout -> Mesh_easymeshC.output_pslg fh pslg max_area
| Fortran_layout -> Mesh_easymeshF.output_pslg fh pslg max_area);
close_out fh;
let _ = Sys.command (sprintf "%s %s -m" easymesh fname) in
let mesh : l Mesh.t = match Mesh.layout pslg with
| C_layout -> Mesh_easymeshC.read pslg fname
| Fortran_layout -> Mesh_easymeshF.read pslg fname in
Sys.remove (fname_plsg);
Sys.remove (fname ^ ".n");
Sys.remove (fname ^ ".e");
Sys.remove (fname ^ ".s");
mesh
let write (type l) (mesh: l Mesh.t) file =
match Mesh.layout mesh with
| C_layout -> Mesh_easymeshC.write mesh file
| Fortran_layout -> Mesh_easymeshF.write mesh file