Source file mesh_graphics.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
(** Displaying the mesh with Graphics *)
open Printf
open Bigarray
open Graphics
let draw (type l) ?width ?height ?color ?points ?point_idx ?triangle_idx
?voronoi ?point_marker_color
(mesh: l Mesh.t) =
match Mesh.layout mesh with
| C_layout ->
Mesh_graphicsC.draw ?width ?height ?color ?points ?point_idx ?triangle_idx
?voronoi ?point_marker_color mesh
| Fortran_layout ->
Mesh_graphicsF.draw ?width ?height ?color ?points ?point_idx ?triangle_idx
?voronoi ?point_marker_color mesh
let init_graph width height =
let xbd = 10 and ybd = 10 in
open_graph (sprintf " %ix%i-40+40" (width + 2 * xbd) (height + 2 * ybd));
moveto xbd ybd
let hold_graph () =
try
while true do
let status = wait_next_event [Button_down; Key_pressed] in
if status.button
|| (status.keypressed && (status.key = 'q' || status.key = 'Q')) then (
close_graph();
raise Exit
);
done
with Exit -> ()
let display ?(width=600) ?(height=600) ?color ?points ?point_idx ?triangle_idx
?voronoi ?point_marker_color mesh =
init_graph width height;
set_window_title("Mesh (" ^ Filename.basename Sys.argv.(0) ^ ")");
draw ~width ~height ?color ?points ?point_idx ?triangle_idx
?voronoi ?point_marker_color
mesh;
hold_graph()
let level_curves (type l) ?(width=600) ?(height=600) ?boundary (mesh: l Mesh.t)
(z: l Mesh.vec) ?level_eq levels =
match Mesh.layout mesh with
| C_layout ->
Mesh_graphicsC.level_curves ~width ~height ?boundary
mesh z ?level_eq levels
| Fortran_layout ->
Mesh_graphicsF.level_curves ~width ~height ?boundary
mesh z ?level_eq levels
let display_level_curves ?(width=600) ?(height=600) ?boundary mesh z
?level_eq levels =
init_graph width height;
set_window_title("Mesh (" ^ Filename.basename Sys.argv.(0) ^ ")");
level_curves ~width ~height ?boundary mesh z ?level_eq levels;
hold_graph()
let super_level (type l) ?(width=600) ?(height=600) ?boundary (mesh: l Mesh.t)
(z: l Mesh.vec) level color =
match Mesh.layout mesh with
| C_layout ->
Mesh_graphicsC.super_level ~width ~height ?boundary mesh z level color
| Fortran_layout ->
Mesh_graphicsF.super_level ~width ~height ?boundary mesh z level color
let sub_level (type l) ?(width=600) ?(height=600) ?boundary (mesh: l Mesh.t)
(z: l Mesh.vec) level color =
match Mesh.layout mesh with
| C_layout -> Mesh_graphicsC.sub_level ~width ~height ?boundary
mesh z level color
| Fortran_layout -> Mesh_graphicsF.sub_level ~width ~height ?boundary
mesh z level color