• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#windowsobjective-ccocoaqt誰得pythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión4a110d1a94f513bb632f8de63ec9d086b7995c54 (tree)
Tiempo2015-03-26 11:46:50
AutorTakuo Yasunaga <yasunaga@bio....>
CommiterTakuo Yasunaga

Log Message

ticket: #34997

mrcImageMeanFreePathCalc

-lt -ls
ticket: #34432
under contruction

Cambiar Resumen

Diferencia incremental

--- a/src/Objects/DataManip/dmFile/inc/dmFile.h
+++ b/src/Objects/DataManip/dmFile/inc/dmFile.h
@@ -27,11 +27,33 @@ typedef __int16_t dmFileInteger2;
2727 typedef __int8_t dmFileInteger1;
2828
2929 typedef enum dmFileTagDataType {
30- dmFileTagDataTypeShort=2,
31- dmFileTagDataTypeLong =3,
32- dmFileTagDataTypeUShort =4,
30+ dmFileTagDataTypeInt2 =2,
31+ dmFileTagDataTypeInt4 =3,
32+ dmFileTagDataTypeUInt2 =4,
33+ dmFileTagDataTypeUInt4 =5,
34+ dmFileTagDataTypeReal4 =6,
35+ dmFileTagDataTypeReal8 =7,
36+ dmFileTagDataTypeBool1 =8,
37+ dmFileTagDataTypeChar1 =9,
38+ dmFileTagDataTypeInt1 =10,
39+ dmFileTagDataTypeInt8 =11,
40+ dmFileTagDataTypeStruct =15,
41+ dmFileTagDataTypeString =18,
42+ dmFileTagDataTypeArray =20
3343 } dmFileTagDataType;
3444
45+static size_t __dmFileTagDataTypeSize[24] = {
46+ 0, 0, 2, 4, 2, 4, 4, 8, 1, 1,
47+ 1, 8, 0, 0, 0, 0, 0, 0, 0, 0,
48+ 0, 0, 0, 0
49+};
50+
51+static char* __dmFileTagDataTypeFormat[24] = {
52+ 0, 0, "%d", "%d", "%u", "%u", "%f", "%f", "%d", "%c",
53+ "%d", "%d", 0, 0, 0, 0, 0, 0, 0, 0,
54+ 0, 0, 0, 0
55+};
56+
3557 // Header
3658 typedef struct dm3FileHeader {
3759 dmFileInteger4 version;
@@ -45,18 +67,8 @@ typedef struct dm4FileHeader {
4567 dmFileInteger4 byteOrder;
4668 } dm4FileHeader;
4769
48-// Root Tag Directory
49-typedef struct dm3FileRootTagDirectory {
50- dmFileInteger1 sortf;
51- dmFileInteger1 closef;
52- dmFileInteger4 numberOfTags;
53-} dm3FileRootTagDirectory;
54-
55-typedef struct dm4FileRootTagDirectory {
56- dmFileInteger1 sortf;
57- dmFileInteger1 closef;
58- dmFileInteger8 numberOfTags;
59-} dm4FileRootTagDirectory;
70+typedef struct dm3FileRootTagDirectory dm3FileRootTagDirectory;
71+typedef struct dm4FileRootTagDirectory dm4FileRootTagDirectory;
6072
6173 // Tag Directory
6274 typedef struct dm3FileTagDirectrory {
@@ -64,16 +76,36 @@ typedef struct dm3FileTagDirectrory {
6476 dmFileInteger2 tagNameLength; // Bytes
6577 char* tagName;
6678 dmFileInteger1 seperator[4];
67- dmFileInteger4 sizeDim;
68- dmFileInteger4* dim;
79+ dmFileInteger4 ninfo;
80+ dmFileInteger4* info;
81+ void* value;
82+ void** value2;
83+ dm3FileRootTagDirectory* tagDir;
6984 } dm3FileTagDirectrory;
7085
7186 typedef struct dm4FileTagDirectrory {
7287 dmFileInteger1 tagID;
7388 dmFileInteger2 tagNameLength; // Bytes
7489 char* tagName;
90+ dmFileInteger1 seperator[4];
91+ dm4FileRootTagDirectory* tagDir;
7592 } dm4FileTagDirectrory;
7693
94+// Root Tag Directory
95+struct dm3FileRootTagDirectory {
96+ dmFileInteger1 sortf;
97+ dmFileInteger1 closef;
98+ dmFileInteger4 numberOfTags;
99+ dm3FileTagDirectrory* Tags;
100+} ;
101+
102+struct dm4FileRootTagDirectory {
103+ dmFileInteger1 sortf;
104+ dmFileInteger1 closef;
105+ dmFileInteger8 numberOfTags;
106+ dm4FileTagDirectrory* Tags;
107+} ;
108+
77109 typedef struct dmFile {
78110 // Header
79111 dmFileInteger4 version;
@@ -82,7 +114,7 @@ typedef struct dmFile {
82114 // Root Tag
83115 dm3FileRootTagDirectory RootTag3;
84116 dm4FileRootTagDirectory RootTag4;
85-
117+ // Tail
86118 dmFileInteger8 Tail;
87119 } dmFile;
88120
@@ -98,8 +130,19 @@ extern "C" {
98130 extern void dmFileInfo(FILE* fpt, dmFile dm, int mode);
99131
100132 // in dmFileRead.c
133+extern void dmFileHeaderTailRead(FILE* fpt, dmFile* dm, char* message, int mode);
101134 extern void dmFileRead(FILE* fpt, dmFile* dm, char* message, int mode);
102-
135+extern void dmFile3HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode);
136+extern void dmFileTag3RootTagRead(FILE* fpt, dm3FileRootTagDirectory* dmRoot, char* message, int mode);
137+extern void dmFileTag3HeaderRead(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode);
138+extern void dmFileTag3Read(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode);
139+extern void dmFile4HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode);
140+extern void dmFileTag4RootTagRead(FILE* fpt, dm4FileRootTagDirectory* dmRoot, char* message, int mode);
141+extern void dmFileTag4HeaderRead(FILE* fpt, dm4FileTagDirectrory* dmTag, char* message, int mode);
142+extern void dmFileTag4Read(FILE* fpt, dm4FileTagDirectrory* dmTag, char* message, int mode);
143+
144+// in dmFileUtil.c
145+extern void dmFileValuePrint(FILE* fpt, void* value, dmFileTagDataType valueType, int n);
103146
104147 /* prototype end */
105148
--- /dev/null
+++ b/src/Objects/DataManip/dmFile/src/:
@@ -0,0 +1,153 @@
1+/*
2+# dmFile.h : $Revision$
3+# $Date$
4+# Created by $Author$
5+# Usage : dmFile.h
6+# Attention
7+# $Loccker$
8+# $State$
9+#
10+*/
11+/* $Log$ */
12+#ifndef DMFILE_H
13+#define DMFILE_H
14+
15+#include <stdio.h>
16+
17+/* constant begin */
18+
19+
20+/* constant end */
21+
22+/* struct begin */
23+
24+typedef __int64_t dmFileInteger8;
25+typedef __int32_t dmFileInteger4;
26+typedef __int16_t dmFileInteger2;
27+typedef __int8_t dmFileInteger1;
28+
29+typedef enum dmFileTagDataType {
30+ dmFileTagDataTypeInt2 =2,
31+ dmFileTagDataTypeInt4 =3,
32+ dmFileTagDataTypeUInt2 =4,
33+ dmFileTagDataTypeUInt4 =5,
34+ dmFileTagDataTypeReal4 =6,
35+ dmFileTagDataTypeReal8 =7,
36+ dmFileTagDataTypeBool1 =8,
37+ dmFileTagDataTypeChar1 =9,
38+ dmFileTagDataTypeInt1 =10,
39+ dmFileTagDataTypeInt8 =11,
40+ dmFileTagDataTypeStruct =15,
41+ dmFileTagDataTypeString =18,
42+ dmFileTagDataTypeArray =20
43+} dmFileTagDataType;
44+
45+static size_t __dmFileTagDataTypeSize[24] = {
46+ 0, 0, 2, 4, 2, 4, 4, 8, 1, 1,
47+ 1, 8, 0, 0, 0, 0, 0, 0, 0, 0,
48+ 0, 0, 0, 0
49+};
50+
51+static char* __dmFileTagDataTypeFormat[24] = {
52+ 0, 0, "%d", "%d", "%u", "%u", "%f", "%f", "%d", "%c",
53+ "%d", "%d", 0, 0, 0, 0, 0, 0, 0, 0,
54+ 0, 0, 0, 0
55+};
56+
57+// Header
58+typedef struct dm3FileHeader {
59+ dmFileInteger4 version;
60+ dmFileInteger4 rootLength;
61+ dmFileInteger4 byteOrder;
62+} dm3FileHeader;
63+
64+typedef struct dm4FileHeader {
65+ dmFileInteger4 version;
66+ dmFileInteger8 rootLength;
67+ dmFileInteger4 byteOrder;
68+} dm4FileHeader;
69+
70+typedef struct dm3FileRootTagDirectory dm3FileRootTagDirectory;
71+typedef struct dm4FileRootTagDirectory dm4FileRootTagDirectory;
72+
73+// Tag Directory
74+typedef struct dm3FileTagDirectrory {
75+ dmFileInteger1 tagID;
76+ dmFileInteger2 tagNameLength; // Bytes
77+ char* tagName;
78+ dmFileInteger1 seperator[4];
79+ dmFileInteger4 ninfo;
80+ dmFileInteger4* info;
81+ void* value;
82+ void** value2;
83+ dm3FileRootTagDirectory* tagDir;
84+} dm3FileTagDirectrory;
85+
86+typedef struct dm4FileTagDirectrory {
87+ dmFileInteger1 tagID;
88+ dmFileInteger2 tagNameLength; // Bytes
89+ char* tagName;
90+ dmFileInteger1 seperator[4];
91+ dm4FileRootTagDirectory* tagDir;
92+} dm4FileTagDirectrory;
93+
94+// Root Tag Directory
95+struct dm3FileRootTagDirectory {
96+ dmFileInteger1 sortf;
97+ dmFileInteger1 closef;
98+ dmFileInteger4 numberOfTags;
99+ dm3FileTagDirectrory* Tags;
100+} ;
101+
102+struct dm4FileRootTagDirectory {
103+ dmFileInteger1 sortf;
104+ dmFileInteger1 closef;
105+ dmFileInteger8 numberOfTags;
106+ dm4FileTagDirectrory* Tags;
107+} dm4FileRootTagDirectory;
108+
109+typedef struct dmFile {
110+ // Header
111+ dmFileInteger4 version;
112+ dm3FileHeader Header3;
113+ dm4FileHeader Header4;
114+ // Root Tag
115+ dm3FileRootTagDirectory RootTag3;
116+ dm4FileRootTagDirectory RootTag4;
117+ // Tail
118+ dmFileInteger8 Tail;
119+} dmFile;
120+
121+/* struct end */
122+
123+#ifdef __cplusplus
124+extern "C" {
125+#endif
126+
127+/* prototype begin */
128+
129+// in dfFileInfo.c
130+extern void dmFileInfo(FILE* fpt, dmFile dm, int mode);
131+
132+// in dmFileRead.c
133+extern void dmFileHeaderTailRead(FILE* fpt, dmFile* dm, char* message, int mode);
134+extern void dmFileRead(FILE* fpt, dmFile* dm, char* message, int mode);
135+extern void dmFile3HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode);
136+extern void dmFileTag3RootTagRead(FILE* fpt, dm3FileRootTagDirectory* dmRoot, char* message, int mode);
137+extern void dmFileTag3HeaderRead(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode);
138+extern void dmFileTag3Read(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode);
139+extern void dmFile4HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode);
140+extern void dmFileTag4RootTagRead(FILE* fpt, dm4FileRootTagDirectory* dmRoot, char* message, int mode);
141+extern void dmFileTag4HeaderRead(FILE* fpt, dm4FileTagDirectrory* dmTag, char* message, int mode);
142+extern void dmFileTag4Read(FILE* fpt, dm4FileTagDirectrory* dmTag, char* message, int mode);
143+
144+// in dmFileUtil.c
145+extern void dmFileValuePrint(FILE* fpt, void* value, dmFileTagDataType valueType, int n);
146+
147+/* prototype end */
148+
149+#ifdef __cplusplus
150+};
151+#endif
152+
153+#endif /* DMFILE_H */
--- a/src/Objects/DataManip/dmFile/src/dmFileInfo.c
+++ b/src/Objects/DataManip/dmFile/src/dmFileInfo.c
@@ -36,7 +36,7 @@ dmFileInfo(FILE* fpt, dmFile dm, int mode)
3636 break;
3737 }
3838 default: {
39- fprintf(stderr, "%d: Not supported version\n");
39+ fprintf(stderr, "%d: Not supported version\n", dm.version);
4040 break;
4141 }
4242
--- a/src/Objects/DataManip/dmFile/src/dmFileRead.c
+++ b/src/Objects/DataManip/dmFile/src/dmFileRead.c
@@ -10,7 +10,7 @@
1010 #%Z%
1111 */
1212 static char __sccs_id[] = "%Z%dmFileRead ver%I%; Date:%D% %Z%";
13-#undef DEBUG
13+#define DEBUG
1414 #include "genUtil.h"
1515 #include "Memory.h"
1616 #include "../inc/dmFile.h"
@@ -18,6 +18,71 @@ static char __sccs_id[] = "%Z%dmFileRead ver%I%; Date:%D% %Z%";
1818 void
1919 dmFileRead(FILE* fpt, dmFile* dm, char* message, int mode)
2020 {
21+ int i, j;
22+
23+ dmFileHeaderTailRead(fpt, dm, message, mode);
24+
25+ switch(dm->version) {
26+ case 3: {
27+ // Header
28+ dmFile3HeaderRead(fpt, dm, message, mode);
29+ // Root Tag
30+ dmFileTag3RootTagRead(fpt, &(dm->RootTag3), message, mode);
31+ for(i=0; i<dm->RootTag3.numberOfTags; i++) {
32+ DEBUGPRINT1("Tags-i: %d\n", i);
33+ dmFileTag3HeaderRead(fpt, &(dm->RootTag3.Tags[i]), message, mode);
34+ switch(dm->RootTag3.Tags[i].tagID) {
35+ case 0x12: {
36+
37+ break;
38+ }
39+ case 0x15: { // tag
40+ dmFileTag3Read(fpt, &(dm->RootTag3.Tags[i]), message, mode);
41+ break;
42+ }
43+ case 0x14: { // tag directories
44+ DEBUGPRINT("TAG DIRECTORIES\n");
45+ dm->RootTag3.Tags[i].tagDir = memoryAllocate(sizeof(dm3FileRootTagDirectory), message);
46+ dmFileTag3RootTagRead(fpt, dm->RootTag3.Tags[i].tagDir, message, mode);
47+ DEBUGPRINT1("Number of Tages: %d\n", dm->RootTag3.Tags[i].tagDir->numberOfTags);
48+ for(j=0; j<dm->RootTag3.Tags[i].tagDir->numberOfTags; j++) {
49+ DEBUGPRINT1("Tags-j(in tag directories): %d\n", j);
50+ dmFileTag3Read(fpt, &(dm->RootTag3.Tags[i].tagDir->Tags[j]), message, mode);
51+ }
52+ break;
53+ }
54+ case 0x0: {
55+ DEBUGPRINT("FILE END\n")
56+ return;
57+ break;
58+ }
59+ default: {
60+ fprintf(stderr, "Not supported tagID: %X\n", dm->RootTag3.Tags[i].tagID);
61+ //exit(EXIT_FAILURE);
62+ break;
63+ }
64+ }
65+ }
66+ break;
67+ }
68+ case 4: {
69+ // Header
70+ dmFile4HeaderRead(fpt, dm, message, mode);
71+ // Root Tag
72+ dmFileTag4RootTagRead(fpt, &(dm->RootTag4), message, mode);
73+ break;
74+ }
75+ default: {
76+ fprintf(stderr, "Not supported version: %d\n", dm->version);
77+ break;
78+ }
79+ }
80+}
81+
82+
83+void
84+dmFileHeaderTailRead(FILE* fpt, dmFile* dm, char* message, int mode)
85+{
2186 fseek(fpt, 0L, SEEK_SET);
2287 fread(&(dm->version), sizeof(dmFileInteger4), 1, fpt);
2388 #ifdef II
@@ -31,77 +96,160 @@ dmFileRead(FILE* fpt, dmFile* dm, char* message, int mode)
3196 fprintf(stderr, "This file is not dm3/dm4: version %d \n", dm->version);
3297 exit(EXIT_FAILURE);
3398 }
99+}
34100
35- switch(dm->version) {
36- case 3: {
37- // Header
38- fseek(fpt, 0L, SEEK_SET);
39- if(12!=sizeof(dm->Header4)) {
40- fprintf(stderr, "Size is strange: %lu expected 12\n", sizeof(dm->Header4));
41- fread(&(dm->Header3.version), sizeof(dm->Header3.version), 1, fpt);
42- fread(&(dm->Header3.rootLength), sizeof(dm->Header3.rootLength), 1, fpt);
43- fread(&(dm->Header3.byteOrder), sizeof(dm->Header3.byteOrder), 1, fpt);
44- } else {
45- DEBUGPRINT1("Header3 Size: %lu expect 12\n", sizeof(dm->Header4));
46- fread(&(dm->Header3), sizeof(dm->Header3), 1, fpt);
47- }
101+void
102+dmFile3HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode)
103+{
104+ // Header
105+ fseek(fpt, 0L, SEEK_SET);
106+ if(12!=sizeof(dm->Header4)) {
107+ fprintf(stderr, "Size is strange: %lu expected 12\n", sizeof(dm->Header4));
108+ fread(&(dm->Header3.version), sizeof(dm->Header3.version), 1, fpt);
109+ fread(&(dm->Header3.rootLength), sizeof(dm->Header3.rootLength), 1, fpt);
110+ fread(&(dm->Header3.byteOrder), sizeof(dm->Header3.byteOrder), 1, fpt);
111+ } else {
112+ DEBUGPRINT1("Header3 Size: %lu expect 12\n", sizeof(dm->Header4));
113+ fread(&(dm->Header3), sizeof(dm->Header3), 1, fpt);
114+ }
48115 #ifdef II
49- memoryByteSwap(&(dm->Header3.version), sizeof(dmFileInteger4), 1);
50- memoryByteSwap(&(dm->Header3.rootLength), sizeof(dmFileInteger4), 1);
51- memoryByteSwap(&(dm->Header3.byteOrder), sizeof(dmFileInteger4), 1);
116+ memoryByteSwap(&(dm->Header3.version), sizeof(dmFileInteger4), 1);
117+ memoryByteSwap(&(dm->Header3.rootLength), sizeof(dmFileInteger4), 1);
118+ memoryByteSwap(&(dm->Header3.byteOrder), sizeof(dmFileInteger4), 1);
52119 #endif
53- DEBUGPRINT1("version: %d\n", dm->Header3.version);
54- DEBUGPRINT1("RootLength: %d\n", dm->Header3.rootLength);
55- DEBUGPRINT1("ByteOrder: %d\n", dm->Header3.byteOrder);
120+ DEBUGPRINT1("version: %d\n", dm->Header3.version);
121+ DEBUGPRINT1("RootLength: %d\n", dm->Header3.rootLength);
122+ DEBUGPRINT1("ByteOrder: %d\n", dm->Header3.byteOrder);
123+}
56124
57- // Root Tag
58- fread(&(dm->RootTag3.sortf), sizeof(dmFileInteger1), 1, fpt);
59- fread(&(dm->RootTag3.closef), sizeof(dmFileInteger1), 1, fpt);
60- fread(&(dm->RootTag3.numberOfTags), sizeof(dmFileInteger4), 1, fpt);
125+
126+void
127+dmFile4HeaderRead(FILE* fpt, dmFile* dm, char* message, int mode)
128+{
129+ // Header
130+ fseek(fpt, 0L, SEEK_SET);
131+ if(16!=sizeof(dm->Header4)) {
132+ fprintf(stderr, "Size is strange: %lu expected 16\n", sizeof(dm->Header4));
133+ fread(&(dm->Header4.version), sizeof(dm->Header4.version), 1, fpt);
134+ fread(&(dm->Header4.rootLength), sizeof(dm->Header4.rootLength), 1, fpt);
135+ fread(&(dm->Header4.byteOrder), sizeof(dm->Header4.byteOrder), 1, fpt);
136+ } else {
137+ DEBUGPRINT1("Header4 Size: %lu expect 16\n", sizeof(dm->Header4));
138+ fread(&(dm->Header4), sizeof(dm->Header4), 1, fpt);
139+ }
61140 #ifdef II
62- memoryByteSwap(&(dm->RootTag3.numberOfTags), sizeof(dmFileInteger4), 1);
141+ memoryByteSwap(&(dm->Header4.version), sizeof(dmFileInteger4), 1);
142+ memoryByteSwap(&(dm->Header4.rootLength), sizeof(dmFileInteger8), 1);
143+ memoryByteSwap(&(dm->Header4.byteOrder), sizeof(dmFileInteger4), 1);
63144 #endif
64- DEBUGPRINT1("sortf: %d\n", dm->RootTag3.sortf);
65- DEBUGPRINT1("closef: %d\n", dm->RootTag3.closef);
66- DEBUGPRINT1("numberOfTags: %d\n", dm->RootTag3.numberOfTags);
67- break;
68- }
69- case 4: {
70- // Header
71- fseek(fpt, 0L, SEEK_SET);
72- if(16!=sizeof(dm->Header4)) {
73- fprintf(stderr, "Size is strange: %lu expected 16\n", sizeof(dm->Header4));
74- fread(&(dm->Header4.version), sizeof(dm->Header4.version), 1, fpt);
75- fread(&(dm->Header4.rootLength), sizeof(dm->Header4.rootLength), 1, fpt);
76- fread(&(dm->Header4.byteOrder), sizeof(dm->Header4.byteOrder), 1, fpt);
77- } else {
78- DEBUGPRINT1("Header4 Size: %lu expect 16\n", sizeof(dm->Header4));
79- fread(&(dm->Header4), sizeof(dm->Header4), 1, fpt);
80- }
145+ DEBUGPRINT1("version: %d\n", dm->Header4.version);
146+ DEBUGPRINT1("RootLength: %lld\n", dm->Header4.rootLength);
147+ DEBUGPRINT1("ByteOrder: %d\n", dm->Header4.byteOrder);
148+}
149+
150+void
151+dmFileTag3RootTagRead(FILE* fpt, dm3FileRootTagDirectory* RootTag3, char* message, int mode)
152+{
153+ // Root Tag
154+ fread(&(RootTag3->sortf), sizeof(dmFileInteger1), 1, fpt);
155+ fread(&(RootTag3->closef), sizeof(dmFileInteger1), 1, fpt);
156+ fread(&(RootTag3->numberOfTags), sizeof(dmFileInteger4), 1, fpt);
81157 #ifdef II
82- memoryByteSwap(&(dm->Header4.version), sizeof(dmFileInteger4), 1);
83- memoryByteSwap(&(dm->Header4.rootLength), sizeof(dmFileInteger8), 1);
84- memoryByteSwap(&(dm->Header4.byteOrder), sizeof(dmFileInteger4), 1);
158+ memoryByteSwap(&(RootTag3->numberOfTags), sizeof(dmFileInteger4), 1);
85159 #endif
86- DEBUGPRINT1("version: %d\n", dm->Header4.version);
87- DEBUGPRINT1("RootLength: %lld\n", dm->Header4.rootLength);
88- DEBUGPRINT1("ByteOrder: %d\n", dm->Header4.byteOrder);
160+ DEBUGPRINT1("sortf: %d\n", RootTag3->sortf);
161+ DEBUGPRINT1("closef: %d\n", RootTag3->closef);
162+ DEBUGPRINT1("numberOfTags: %d\n", RootTag3->numberOfTags);
163+ RootTag3->Tags = (dm3FileTagDirectrory*)memoryAllocate(sizeof(dm3FileTagDirectrory)*RootTag3->numberOfTags, "in dmFileRead");
164+}
89165
90- // Root Tag
91- fread(&(dm->RootTag4.sortf), sizeof(dmFileInteger1), 1, fpt);
92- fread(&(dm->RootTag4.closef), sizeof(dmFileInteger1), 1, fpt);
93- fread(&(dm->RootTag4.numberOfTags), sizeof(dmFileInteger8), 1, fpt);
166+void
167+dmFileTag4RootTagRead(FILE* fpt, dm4FileRootTagDirectory* RootTag4, char* message, int mode)
168+{
169+ // Root Tag
170+ fread(&(RootTag4->sortf), sizeof(dmFileInteger1), 1, fpt);
171+ fread(&(RootTag4->closef), sizeof(dmFileInteger1), 1, fpt);
172+ fread(&(RootTag4->numberOfTags), sizeof(dmFileInteger8), 1, fpt);
173+#ifdef II
174+ memoryByteSwap(&(RootTag4->numberOfTags), sizeof(dmFileInteger8), 1);
175+#endif
176+ DEBUGPRINT1("sortf: %d\n", RootTag4->sortf);
177+ DEBUGPRINT1("closef: %d\n", RootTag4->closef);
178+ DEBUGPRINT1("numberOfTags: %lld\n", RootTag4->numberOfTags);
179+ RootTag4->Tags = (dm4FileTagDirectrory*)memoryAllocate(sizeof(dm4FileTagDirectrory)*RootTag4->numberOfTags, "in dmFileRead");
180+}
181+
182+void
183+dmFileTag3HeaderRead(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode)
184+{
185+ fread(&(dmTag->tagID), sizeof(dmFileInteger1), 1, fpt);
186+ fread(&(dmTag->tagNameLength), sizeof(dmFileInteger2), 1, fpt);
94187 #ifdef II
95- memoryByteSwap(&(dm->RootTag4.numberOfTags), sizeof(dmFileInteger8), 1);
188+ memoryByteSwap(&(dmTag->tagNameLength), sizeof(dmFileInteger2), 1);
96189 #endif
97- DEBUGPRINT1("sortf: %d\n", dm->RootTag4.sortf);
98- DEBUGPRINT1("closef: %d\n", dm->RootTag4.closef);
99- DEBUGPRINT1("numberOfTags: %lld\n", dm->RootTag4.numberOfTags);
190+ if(0<dmTag->tagNameLength) {
191+ dmTag->tagName = (char*)memoryAllocate(sizeof(char)*(dmTag->tagNameLength+1), "in dmFileRead");
192+ fread(dmTag->tagName, sizeof(char), dmTag->tagNameLength, fpt);
193+ }
194+ DEBUGPRINT3("tag %X %d %s\n", dmTag->tagID, dmTag->tagNameLength, dmTag->tagName);
195+}
196+
197+void
198+dmFileTag3Read(FILE* fpt, dm3FileTagDirectrory* dmTag, char* message, int mode)
199+{
200+ int j;
201+ DEBUGPRINT("TAG Read\n");
202+ fread(dmTag->seperator, sizeof(char), 4, fpt);
203+ fread(&(dmTag->ninfo), sizeof(dmFileInteger4), 1, fpt);
204+#ifdef II
205+ memoryByteSwap(&(dmTag->ninfo), sizeof(dmFileInteger4), 1);
206+#endif
207+ DEBUGPRINT1("tag ninfo %d\n", dmTag->ninfo);
208+ dmTag->info = (dmFileInteger4*)memoryAllocate(sizeof(dmFileInteger4)*dmTag->ninfo, "in dmFileRead");
209+ fread(dmTag->info, sizeof(dmFileInteger4), dmTag->ninfo, fpt);
210+#ifdef II
211+ memoryByteSwap(dmTag->info, sizeof(dmFileInteger4), dmTag->ninfo);
212+#endif
213+ DEBUGPRINT1("tag: %X\n", dmTag->info[0]);
214+ switch(dmTag->info[0]) {
215+ case dmFileTagDataTypeStruct: {
216+ DEBUGPRINT1("Struct: numEntry %d\n", dmTag->info[2]);
217+ // dmTag->info[2] ; num of Entries
218+ // dmTag->info[2*n + 4] ; data type of value-n
219+ dmTag->value2 = (void*)memoryAllocate(sizeof(void*)*dmTag->info[2], "in dmFileRead");
220+ for(j=0; j<dmTag->info[2]; j++) {
221+ DEBUGPRINT2("value %d %d\n", j, dmTag->info[2*j+4]);
222+ dmTag->value2[j] = memoryAllocate(__dmFileTagDataTypeSize[dmTag->info[2*j+4]], "in dmFileRead");
223+ fread(dmTag->value2[j], __dmFileTagDataTypeSize[dmTag->info[2*j+4]], 1, fpt);
224+#ifdef II
225+ memoryByteSwap(dmTag->value2[j], __dmFileTagDataTypeSize[dmTag->info[2*j+4]], 1);
226+#endif
227+#ifdef DEBUG
228+ dmFileValuePrint(stderr, dmTag->value2[j], __dmFileTagDataTypeSize[dmTag->info[2*j+4]], 1);
229+#endif
230+ }
231+ break;
232+ }
233+ case dmFileTagDataTypeArray: {
234+ DEBUGPRINT1("ARRAY %d\n", dmTag->info[0]);
235+ // dmTag->info[0] ; data type
236+ // dmTag->info[1] ; data array size
237+ if(0<dmTag->info[1]) {
238+ dmTag->value = memoryAllocate(__dmFileTagDataTypeSize[dmTag->info[0]]*dmTag->info[1], "in dmFileRead");
239+ fread(dmTag->value, __dmFileTagDataTypeSize[dmTag->info[0]], dmTag->info[1], fpt);
240+#ifdef DEBUG
241+ dmFileValuePrint(stderr, dmTag->value, __dmFileTagDataTypeSize[dmTag->info[0]], dmTag->info[1]);
242+#endif
243+ } else {
244+ fprintf(stderr, "Not supported data type for array: %d\n", dmTag->info[1]);
245+ }
100246 break;
101247 }
102248 default: {
103- fprintf(stderr, "Not supported version: %d\n", dm->version);
249+ fprintf(stderr, "Not supported tagType: %d\n", dmTag->info[j]);
104250 break;
105251 }
106252 }
107253 }
254+
255+
--- /dev/null
+++ b/src/Objects/DataManip/dmFile/src/dmFileUtil.c
@@ -0,0 +1,90 @@
1+/*
2+# %M% %Y% %I%
3+# The latest update : %G% at %U%
4+#
5+#%Z% dmFileUtil ver %I%
6+#%Z% Created by
7+#%Z%
8+#%Z% Usage : dmFileUtil
9+#%Z% Attention
10+#%Z%
11+*/
12+static char __sccs_id[] = "%Z%dmFileUtil ver%I%; Date:%D% %Z%";
13+
14+#include "../inc/dmFile.h"
15+
16+void
17+dmFileValuePrint(FILE* fpt, void* value, dmFileTagDataType valueType, int n)
18+{
19+ int i;
20+ switch(valueType) {
21+ case dmFileTagDataTypeInt2: {
22+ for(i=0; i<n; i++) {
23+ fprintf(fpt, "%d ", ((dmFileInteger2*)value)[i]);
24+ }
25+ break;
26+ }
27+ case dmFileTagDataTypeInt4: {
28+ for(i=0; i<n; i++) {
29+ fprintf(fpt, "%d ", ((dmFileInteger4*)value)[i]);
30+ }
31+ break;
32+ }
33+ case dmFileTagDataTypeUInt2: {
34+ for(i=0; i<n; i++) {
35+ fprintf(fpt, "%u ", ((dmFileInteger2*)value)[i]);
36+ }
37+ break;
38+ }
39+ case dmFileTagDataTypeUInt4: {
40+ for(i=0; i<n; i++) {
41+ fprintf(fpt, "%u ", ((dmFileInteger4*)value)[i]);
42+ }
43+ break;
44+ }
45+ case dmFileTagDataTypeReal4: {
46+ for(i=0; i<n; i++) {
47+ fprintf(fpt, "%f ", ((float*)value)[i]);
48+ }
49+ break;
50+ }
51+ case dmFileTagDataTypeReal8: {
52+ for(i=0; i<n; i++) {
53+ fprintf(fpt, "%f ", ((double*)value)[i]);
54+ }
55+ break;
56+ }
57+ case dmFileTagDataTypeBool1: {
58+ for(i=0; i<n; i++) {
59+ fprintf(fpt, "%d ", ((char*)value)[i]);
60+ }
61+ break;
62+ }
63+ case dmFileTagDataTypeChar1: {
64+ for(i=0; i<n; i++) {
65+ fprintf(fpt, "%c ", ((char*)value)[i]);
66+ }
67+ break;
68+ }
69+ case dmFileTagDataTypeInt1: {
70+ for(i=0; i<n; i++) {
71+ fprintf(fpt, "%d ", ((char*)value)[i]);
72+ }
73+ break;
74+ }
75+ case dmFileTagDataTypeInt8: {
76+ for(i=0; i<n; i++) {
77+ fprintf(fpt, "%d ", ((char*)value)[i]);
78+ }
79+ break;
80+ }
81+ case dmFileTagDataTypeString: {
82+ fprintf(fpt, "%s", (char*)value);
83+ }
84+ default: {
85+ fprintf(stderr, "Not supported valueType: %d\n", valueType);
86+ break;
87+ }
88+ }
89+ fprintf(fpt, "\n");
90+}
--- a/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/mrcImageMeanFreePathCalc.c
+++ b/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/mrcImageMeanFreePathCalc.c
@@ -131,7 +131,17 @@ additionalUsage()
131131 void
132132 lmrcImageMeanFreePathCalcModePrint(FILE* fpt)
133133 {
134+ fprintf(fpt, ">>>> mode \n");
134135 fprintf(fpt, "%d: AlongZ-axis\n", MeanFreePathCalcModeAlongZaxis);
136+ fprintf(fpt, "+%d: Length is shown in real using HeaderLength \n", MeanFreePathCalcModeRealLength);
137+
138+ fprintf(fpt, ">>>> line shape\n");
139+ fprintf(fpt, "%d: LineShape-Rectangle\n", lmrcImageMeanFreePathCalcLineShapeRectangle);
140+ fprintf(fpt, "%d: LineShape-Disk\n", lmrcImageMeanFreePathCalcLineShapeDisk);
141+ fprintf(fpt, ">>>> line mode\n");
142+ fprintf(fpt, "%d: LineMode-And \n", lmrcImageMeanFreePathCalcLineModeAnd);
143+ fprintf(fpt, "%d: LineMode-Or \n", lmrcImageMeanFreePathCalcLineModeOr);
144+ fprintf(fpt, "%d: LineMode-GE(Greater than or equal to) \n", lmrcImageMeanFreePathCalcLineModeGE);
135145 }
136146
137147 void
@@ -424,7 +434,9 @@ double
424434 lmrcImageMeanFreePathCalcBWEvaluation(mrcImage* in, lmrcImageMeanFreePathCalcInfo* linfo, lmrcImageMeanFreePathCalcMode mode)
425435 {
426436 double data, data0;
437+ double rx, ry, r0x, r0y;
427438 mrcImageParaTypeReal srcx, srcy;
439+ int max;
428440
429441 switch(linfo->LineShape) {
430442 case lmrcImageMeanFreePathCalcLineShapeRectangle: {
@@ -437,6 +449,101 @@ lmrcImageMeanFreePathCalcBWEvaluation(mrcImage* in, lmrcImageMeanFreePathCalcInf
437449 data *= data0;
438450 }
439451 }
452+ if(0<data) data = 1;
453+ break;
454+ }
455+ case lmrcImageMeanFreePathCalcLineModeOr: {
456+ data = 0;
457+ for(srcy=linfo->min.y; srcy<linfo->max.y; srcy++) {
458+ for(srcx=linfo->min.x; srcx<linfo->max.x; srcx++) {
459+ mrcPixelDataGet(in, srcx, srcy, linfo->cur.z, &data0, mrcPixelRePart, mrcPixelHowNearest);
460+ data += data0;
461+ if(0<data) break;
462+ }
463+ if(0<data) break;
464+ }
465+ if(0<data) data = 1;
466+ break;
467+ }
468+ case lmrcImageMeanFreePathCalcLineModeGE: {
469+ data = 0;
470+ max = 0;
471+ for(srcy=linfo->min.y; srcy<linfo->max.y; srcy++) {
472+ for(srcx=linfo->min.x; srcx<linfo->max.x; srcx++) {
473+ mrcPixelDataGet(in, srcx, srcy, linfo->cur.z, &data0, mrcPixelRePart, mrcPixelHowNearest);
474+ data += data0;
475+ max++;
476+ }
477+ }
478+ if(max/2<=data) {
479+ data = 1;
480+ }
481+ break;
482+ }
483+ default: {
484+ fprintf(stderr, "Not supported Line Mode: %d\n", linfo->LineMode);
485+ exit(EXIT_FAILURE);
486+ break;
487+ }
488+ }
489+ break;
490+ }
491+ case lmrcImageMeanFreePathCalcLineShapeDisk: {
492+ r0x = (linfo->max.x - linfo->cur.x);
493+ r0y = (linfo->max.y - linfo->cur.y);
494+ switch(linfo->LineMode) {
495+ case lmrcImageMeanFreePathCalcLineModeAnd: {
496+ data = 1;
497+ for(srcy=linfo->min.y; srcy<=linfo->max.y; srcy++) {
498+ ry = SQR((srcy - linfo->cur.y)/r0y);
499+ for(srcx=linfo->min.x; srcx<linfo->max.x; srcx++) {
500+ rx = SQR((srcx - linfo->cur.x)/r0x);
501+
502+ if(rx + ry <= 1) {
503+ mrcPixelDataGet(in, srcx, srcy, linfo->cur.z, &data0, mrcPixelRePart, mrcPixelHowNearest);
504+ data *= data0;
505+ }
506+ }
507+ }
508+ if(0<data) data = 1;
509+ break;
510+ }
511+ case lmrcImageMeanFreePathCalcLineModeOr: {
512+ data = 0;
513+ for(srcy=linfo->min.y; srcy<linfo->max.y; srcy++) {
514+ ry = SQR((srcy - linfo->cur.y)/r0y);
515+ for(srcx=linfo->min.x; srcx<linfo->max.x; srcx++) {
516+ rx = SQR((srcx - linfo->cur.x)/r0x);
517+
518+ if(rx + ry <= 1) {
519+ mrcPixelDataGet(in, srcx, srcy, linfo->cur.z, &data0, mrcPixelRePart, mrcPixelHowNearest);
520+ data += data0;
521+ if(0<data) break;
522+ }
523+ }
524+ if(0<data) break;
525+ }
526+ if(0<data) data = 1;
527+ break;
528+ }
529+ case lmrcImageMeanFreePathCalcLineModeGE: {
530+ data = 0;
531+ max = 0;
532+ for(srcy=linfo->min.y; srcy<linfo->max.y; srcy++) {
533+ ry = SQR((srcy - linfo->cur.y)/r0y);
534+ for(srcx=linfo->min.x; srcx<linfo->max.x; srcx++) {
535+ rx = SQR((srcx - linfo->cur.x)/r0x);
536+
537+ if(rx + ry <= 1) {
538+ mrcPixelDataGet(in, srcx, srcy, linfo->cur.z, &data0, mrcPixelRePart, mrcPixelHowNearest);
539+ data += data0;
540+ max++;
541+ }
542+ }
543+ }
544+ if(max/2<=data) {
545+ data = 1;
546+ }
440547 break;
441548 }
442549 default: {
--- a/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/mrcImageMeanFreePathCalc.html
+++ b/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/mrcImageMeanFreePathCalc.html
@@ -21,7 +21,16 @@ Options:
2121 [-c[onfig] configFile (NULL ).as(inFile ) ] :Optional :ConfigurationFile
2222 [-m[ode] mode (0 ).as(Integer ) ] :Optional :Mode
2323 ----- Additional Usage -----
24+>>>> mode
2425 0: AlongZ-axis
26++16: Length is shown in real using HeaderLength
27+>>>> line shape
28+0: LineShape-Rectangle
29+1: LineShape-Disk
30+>>>> line mode
31+0: LineMode-And
32+1: LineMode-Or
33+2: LineMode-GE(Greater than or equal to)
2534 </PRE>
2635 </BODY>
2736 </HTML>
--- a/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/test/Makefile
+++ b/src/Tools/mrcImage/mrcImageMeanFreePathCalc/src/test/Makefile
@@ -3,7 +3,7 @@ include ../../../Config/Define.inc
33 include ../../../../Config/Define.inc
44 include ../../../../../Config/Define.inc
55
6-all: help exec exec2
6+all: help exec exec2 exec3
77
88 help:
99 @echo "----- Help Message Check -----"
@@ -21,6 +21,15 @@ exec2:
2121 ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp216 -m 16 -Ow data/test.white216 -Owe data/test.whiteEdge216 -Ob data/test.black216 -Obe data/test.blackEdge216 -lt 2 2
2222 @echo "----- Calc check -----"
2323
24+exec3:
25+ @echo "----- Execution Check -----"
26+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-00 -m 0 -Ow data/test.white3-00 -Owe data/test.whiteEdge3-00 -Ob data/test.black3-00 -Obe data/test.blackEdge3-00 -lt 3 3 -ls 0 -lm 0
27+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-01 -m 0 -Ow data/test.white3-01 -Owe data/test.whiteEdge3-01 -Ob data/test.black3-01 -Obe data/test.blackEdge3-01 -lt 3 3 -ls 0 -lm 1
28+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-02 -m 0 -Ow data/test.white3-02 -Owe data/test.whiteEdge3-02 -Ob data/test.black3-02 -Obe data/test.blackEdge3-02 -lt 3 3 -ls 0 -lm 2
29+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-10 -m 0 -Ow data/test.white3-10 -Owe data/test.whiteEdge3-10 -Ob data/test.black3-10 -Obe data/test.blackEdge3-10 -lt 3 3 -ls 1 -lm 0
30+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-11 -m 0 -Ow data/test.white3-11 -Owe data/test.whiteEdge3-11 -Ob data/test.black3-11 -Obe data/test.blackEdge3-11 -lt 3 3 -ls 1 -lm 1
31+ ../$(OSTYPE)/$(OBJECTNAME) -i data/test.bin -o data/test.mfp3-12 -m 0 -Ow data/test.white3-12 -Owe data/test.whiteEdge3-12 -Ob data/test.black3-12 -Obe data/test.blackEdge3-12 -lt 3 3 -ls 1 -lm 2
32+
2433 init:
2534 pdb2mrc -i data/121p.pdb2 -o data/test.mrc -nx 32 -ny 32 -nz 32 -dx 2 -dy 2 -dz 2 -Sx -32 -Sy -32 -Sz -32 -sig 1.6 -w 1.0
2635 mrcImageBinalization -i data/test.mrc -o data/test.bin -m 32