SCM Repository
View of /trunk/src/compiler/fields/image-info.sml
Parent Directory
|
Revision Log
Revision 239 -
(download)
(annotate)
Fri Aug 6 00:36:04 2010 UTC (10 years, 6 months ago) by jhr
File size: 2335 byte(s)
Fri Aug 6 00:36:04 2010 UTC (10 years, 6 months ago) by jhr
File size: 2335 byte(s)
Working on image-info input
(* image-info.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Information about a NRRD file *) structure ImageInfo : sig datatype info = ImgInfo of { id : OS.FileSys.file_id, (* ID of image file *) dim : int, (* dimension of space *) ty : RawTypes.ty, (* types of scalar samples *) origin : FloatLit.float list, (* center of first sample *) sizes : int list (* number of samples along each axis *) } (* are the underlying files the same? *) val same : info * info -> bool (* hash value (based on image file ID) *) val hash : info -> word (* get image info from a Nrrd file *) val getInfo : string -> info val toString : info -> string end = struct datatype info = ImgInfo of { id : OS.FileSys.file_id, (* ID of image file *) dim : int, (* dimension of space *) ty : RawTypes.ty, (* types of scalar samples *) origin : FloatLit.float list, (* center of first sample *) sizes : int list (* number of samples along each axis *) } fun same (ImgInfo{id=a, ...}, ImgInfo{id=b, ...}) = (a = b) fun hash (ImgInfo{id, ...}) = OS.FileSys.hash id fun getInfo fileName = let (* FIXME: check that file exists! *) val {version, header} = RunDNorm.run fileName fun set (r, v) = (r := SOME v) fun get (tag, r) = (case !r of NONE => raise Fail("missing "^tag) | SOME v => v) val ty = ref NONE val dim = ref NONE fun doValue ("type", v) = set(ty, RawTypes.fromString v) | doValue ("dimension", v) = () | doValue ("space dimension", v) = set (dim, valOf(Int.fromString v)) | doValue ("sizes", v) = () | doValue ("space directions", v) = () | doValue ("kinds", v) = () | doValue ("endian", v) = () | doValue ("encoding", v) = () | doValue ("space origin", v) = () | doValue _ = () in Log.msg (concat[fileName, " file header:\n"]); List.app (fn (tag, value) => Log.msg(concat[" ", tag, ": ", value, "\n"])) header; List.app doValue header; ImgInfo{ id = OS.FileSys.fileId fileName, dim = get ("space dimension", dim), ty = get ("type", ty), origin = [], (* FIXME *) sizes = [] (* FIXME *) } end fun toString (ImgInfo{...}) = "IMAGE" (* FIXME *) end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |