Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- open Printf
- open ExtLib
- let vtk = "test.vtk";;
- let grabVtkSizeInfo path =
- let ic = open_in path in
- let rec iterateTillInfoFilled l channel =
- if (List.length l) = 2 then l
- else
- let line = input_line channel in
- if ((String.exists line "DIMENSIONS") || (String.exists line "POINT_DATA")) then
- iterateTillInfoFilled ((List.tl (String.nsplit line " ")) :: l) channel
- else iterateTillInfoFilled l channel
- in
- try Some (iterateTillInfoFilled [] ic) with End_of_file -> None
- let pgm = "test.pgm";;
- let oc = open_out pgm;;
- let dimInfo = String.join " " (List.hd (List.filter (fun l -> (List.length l) > 1) (Option.default [] (grabVtkSizeInfo "140408aX_t01_ch01.vtk"))));;
- fprintf oc "P2\n%d %d\n%d\n%s" 5 5 255 dimInfo;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement