Mercurial > hg > minc-tools
annotate testdir/minc.c @ 2552:345f8c960657
added ezminc library
author | Vladimir S. FONOV <vladimir.fonov@gmail.com> |
---|---|
date | Thu, 08 Dec 2011 18:47:56 -0500 |
parents | 7e6acd35cce9 |
children |
rev | line source |
---|---|
209 | 1 /* ----------------------------- MNI Header ----------------------------------- |
2 @NAME : test | |
3 @INPUT : | |
4 @OUTPUT : | |
5 @RETURNS : | |
6 @DESCRIPTION: | |
7 @METHOD : | |
8 @GLOBALS : | |
9 @CALLS : | |
10 @CREATED : | |
11 @MODIFIED : | |
12 ---------------------------------------------------------------------------- */ | |
2186 | 13 #if HAVE_CONFIG_H |
14 #include "config.h" | |
15 #endif | |
209 | 16 #include <stdlib.h> |
17 #include <stdio.h> | |
18 #include <minc.h> | |
19 | |
1917 | 20 int main() |
209 | 21 { |
22 int cdf, cdf2; | |
2428 | 23 int img; |
209 | 24 int dim[MAX_VAR_DIMS]; |
25 int dim2[MAX_VAR_DIMS]; | |
26 long start[MAX_VAR_DIMS]; | |
27 long count[MAX_VAR_DIMS]; | |
28 double image[256*256]; | |
2428 | 29 int i, j, k, ioff; |
209 | 30 |
31 ncopts=NC_VERBOSE|NC_FATAL; | |
1730
96d12845c11f
Use micreate() and miclose() instead of nccreate() and ncclose(). But this test is unused as of now.
bert <bert>
parents:
209
diff
changeset
|
32 cdf=micreate("test.mnc",NC_CLOBBER); |
209 | 33 count[2]=5; |
34 count[1]=3; | |
35 count[0]=7; | |
36 dim[2]=ncdimdef(cdf, MIzspace, count[2]); | |
37 dim[1]=ncdimdef(cdf, MIxspace, count[1]); | |
38 dim[0]=ncdimdef(cdf, MIyspace, count[0]); | |
39 dim2[0]=ncdimdef(cdf, MItime, NC_UNLIMITED); | |
40 dim2[1]=dim[0]; | |
41 dim2[2]=dim[1]; | |
42 img=ncvardef(cdf, MIimage, NC_SHORT, 3, dim); | |
43 (void) ncvardef(cdf, "testvar", NC_FLOAT, 2, dim2); | |
44 (void) miattputstr(cdf, img, MIsigntype, MI_SIGNED); | |
45 for (j=0; j<count[0]; j++) { | |
46 for (i=0; i<count[1]; i++) { | |
47 ioff=(j*count[1]+i)*count[2]; | |
48 for (k=0; k<count[2]; k++) | |
49 image[ioff+k]=ioff+k+10; | |
50 } | |
51 } | |
1730
96d12845c11f
Use micreate() and miclose() instead of nccreate() and ncclose(). But this test is unused as of now.
bert <bert>
parents:
209
diff
changeset
|
52 cdf2=micreate("test2.mnc",NC_CLOBBER); |
209 | 53 (void) ncdimdef(cdf2, "junkdim", NC_UNLIMITED); |
54 (void) micopy_all_var_defs(cdf, cdf2, 1, &img); | |
55 (void) ncendef(cdf2); | |
56 (void) ncendef(cdf); | |
57 (void) miset_coords(3,0L,start); | |
58 (void) mivarput(cdf, img, start, count, NC_DOUBLE, NULL, image); | |
59 | |
60 (void) micopy_all_var_values(cdf, cdf2, 1, &img); | |
1730
96d12845c11f
Use micreate() and miclose() instead of nccreate() and ncclose(). But this test is unused as of now.
bert <bert>
parents:
209
diff
changeset
|
61 (void) miclose(cdf2); |
96d12845c11f
Use micreate() and miclose() instead of nccreate() and ncclose(). But this test is unused as of now.
bert <bert>
parents:
209
diff
changeset
|
62 (void) miclose(cdf); |
209 | 63 return(0); |
64 } |