Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Printf
- open ExtLib
- let vtk = "test.vtk";;
- let stream_filter p stream =
- let rec next i =
- try
- let value = Stream.next stream in
- if p value then Some value else next i
- with Stream.Failure -> None in
- Stream.from next;;
- let grabVtkSizeInfo path =
- let ic = open_in path in
- let lineStream = Stream.from (fun _ ->
- try Some (input_line ic) with End_of_file -> None) in
- let s = (stream_filter (fun s -> String.exists s "DIMENSIONS") lineStream) in
- try Some (Stream.next s) with Stream.Failure -> None;;
- let pgm = "test.pgm";;
- let oc = open_out pgm;;
- let info = Option.default "" (grabVtkSizeInfo "140408aX_t01_ch01.vtk");;
- fprintf oc "P2\n%d %d\n%d\n%s" 5 5 255 info;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement