VIP: Volume Image Processing


TivoliIO_util.h
Go to the documentation of this file.
1/*****************************************************************************
2 * PROJECT : V.I.P. Library
3 * MODULE NAME : vip/TivoliIO_util.h * TYPE : Header
4 * AUTHOR : see below * CREATION : 12/09/1994
5 * VERSION : 0.1 * REVISION :
6 * LANGUAGE : C * EXAMPLE :
7 * DEVICE : Sun SPARC Station 5
8 *****************************************************************************
9 *
10 * DESCRIPTION : B. Verdonck, T. Geraud, J.F. Mangin
11 * modified //
12 *
13 * Copyright (c) 1994
14 * Dept. IMA TELECOM Paris
15 * 46, rue Barrault F-75634 PARIS Cedex 13
16 * All Rights Reserved
17 *
18 * This file groups general utility functions used allover the
19 * tivoli library. Please contact B.V. before adding additional
20 * functions.
21 *
22 *****************************************************************************
23 *
24 * USED MODULES :
25 *
26 *****************************************************************************
27 * REVISIONS : DATE | AUTHOR | DESCRIPTION
28 *--------------------|--------------|----------------------------------------
29 * / / | |
30 *****************************************************************************/
31
32
33#ifndef VIP_TIVOLI_UTIL_H
34#define VIP_TIVOLI_UTIL_H
35
36/* Ignore __attribute__ on non-GCC compilers */
37#if !(defined(__GNUC__) || defined(__attribute__))
38#define __attribute__(a) /* nothing */
39#endif
40
41
42#include <stdlib.h>
43#include <stdio.h>
44
45/*JFM*/
46/*define bete et mechants*/
47
48#define SHOW_LIM 1
49#define HIDE_LIM 0
50
51/* boolean values */
52
53#define VTRUE 1
54#define VFALSE 0
55
56#define YES 1
57#define NO 0
58
59#define ONE 1
60#define ZERO 0
61
62/* value returned by testing functions */
63
64#define OK 1
65#define PB 0
66
67/* first argument of tracing function 'printftrace' */
68
69#define IN 1
70#define MSG 2
71#define OUT 3
72
73/* flag modes */
74
75#define ON 1
76#define OFF 0
77
78/* default dir for help and usage files */
79#define T_HELPDIR "T_HELPDIR"
80/* this has changed: this constant now contains the name of the
81 * environment-variable in which to look for the help-directory
82 */
83
84/* Bert: (see also volmanip.h) */
85
86#define WORLD 1
87#define DATA 2
88
89typedef struct {
90 double x, y, z;
91 int state; } Coord;
92
93typedef struct {
94 float x, y, z; } CoordF;
95
96typedef struct {
98
99typedef struct {
101
102typedef struct {
104 int state; } Angle;
105 /* phi: in the xy-plane */
106 /* theta: perp. to xy-plane */
107/* def of Coord, LineCoord, PlaneCoord, Angle */
108
109#ifdef __cplusplus
110extern "C" {
111#endif
112
113
114/* global flags */
115
116extern int TRACE; /* trace mode by default */
117extern int VERBOSE; /* verb11ose mode by default */
118extern int EXEC; /* execution mode by default */
119
120/***************************/
121/* */
122/* handy MACROS */
123/* */
124/***************************/
125
126/*----------------------------------------------------------------------------*/
127
128 #define vinilum(a,b) ((a)<(b)?(a):(b))
129 #define vaxilum(a,b) ((a)>(b)?(a):(b))
130
131/*----------------------------------------------------------------------------*/
132
133
134/***************************/
135/* */
136/* safe ALLOCATION */
137/* */
138/***************************/
139
140
141/*----------------------------------------------------------------------------*/
142 extern
144/*
145 abort program execution if there is no more memory available ;
146 otherwise do 'malloc'
147*/
148/*----------------------------------------------------------------------------*/
149(
150 size_t size
151);
152
153
154/*----------------------------------------------------------------------------*/
155 extern
157/*
158 abort program execution if there is no more memory available ;
159 otherwise do 'calloc'
160*/
161/*----------------------------------------------------------------------------*/
162(
163 size_t nelem,
164 size_t elsize
165);
166
167
168/*-----------------------------------------------------------------------------*/
169 extern
170 void **matAlloc
171
172/* allocate (if possible) a consecutive memory segment for a matrix by using
173 callocT.
174*/
175/*-----------------------------------------------------------------------------*/
176(
177 int lines,
178 int columns,
179 int elem_size
180);
181
182/*-----------------------------------------------------------------------------*/
183 extern
185
186/* Free memory allocated to a matrix.
187*/
188/*-----------------------------------------------------------------------------*/
189(
190 void ** mat
191);
192
193/*----------------------------------------------------------------------------*/
194
195char *charMalloc(size_t length);
196/*----------------------------------------------------------------------------*/
197
198
199/*==============================*
200 | |
201 | error processing functions |
202 | |
203 *==============================*/
204
205/*----------------------------------------------------------------------------*/
206 extern
207 void exitError ( char *errorText );
208
209/*----------------------------------------------------------------------------*/
210
211/*----------------------------------------------------------------------------*/
212 extern
214/*
215 abort program execution after printing the name of the function
216 where problems occure
217*/
218/*----------------------------------------------------------------------------*/
219(
220 char *fname
221) __attribute__((__noreturn__));
222
223
224/*----------------------------------------------------------------------------*/
225 extern
227/*
228 if 'TRACE' is 'ON', print in file "./trace.txt" a trace message ;
229 otherwise, do nothing
230*/
231/*----------------------------------------------------------------------------*/
232(
233 int mode,
234 char *fmt, ...
235);
236
237/***************************/
238/* */
239/* USER I/O- functions */
240/* */
241/***************************/
242
243/* Ask for a float */
244/**********************/
245float ask_float(float *def, float *mini, float *maxi, char *comment);
246
247/*-----------------------------------------------*/
248/*demande un entier en specifiant eventuellement les bornes (qui
249sont toujours actives) selon la valeur de show (true,false)*/
250extern int getMyInt( int liminf, int limsup, int show);
251/*JFM*/
252
253/*----------------------------------------------------*/
254/*demande un float (meme convention que getMyInt)*/
255extern float getMyFloat( float liminf, float limsup, int show);
256/*JFM*/
257
258/*-------------------------------------------------*/
259/*demande une chaine de caractere en posant une question*/
260extern char *getMyName( char *question, int maxsize);
261/*JFM*/
262
263/*---------------------------------------------------------*/
264/*demande une reponse oui ou non a une question*/
265extern int getManicheanRep(char *question);
266/*JFM*/
267
268
269/***************************/
270/* */
271/* DISK I/O- functions */
272/* */
273/***************************/
274
275/*----------------------------------------------------------------------------*/
276 extern
278/* Function for printing data arrays in MATLAB format.
279*/
280/*----------------------------------------------------------------------------*/
281(
282 char name[],
283 int rows,
284 int cols,
285 double **array
286);
287
288extern int file_open_read(FILE **fp, const char *name);
289extern int file_open_write(FILE **fp, const char *name);
290extern int file_open_append(FILE **fp, const char *name);
291extern int file_close(FILE **fp);
292
293extern int file_write(void *ptr, size_t size, size_t length, FILE *fp);
294
295extern int m_filename(char *base, char *name, int number);
296extern int m_point_filename(char *base, char *name, int number);
297extern int m_zero_filename(char *base, char *name, int number);
298
299extern char *composeName ( char *baseName, char *ext1, char *ext2 );
300
301
302
303/***************************/
304/* */
305/* ROUND - functions */
306/* */
307/***************************/
308
309int roundD2I(double f);
310long int roundFloat2Long(float f);
311int roundFloat2Int(float f);
312unsigned char roundFloat2UChar(float f);
313
314/*********************************/
315/* */
316/* HELP- USAGE - functions */
317/* */
318/*********************************/
319int printUsage(char *usageOf);
320/* Searches usage information in a text file "<usageOf>_U.txt".
321 path: ./
322 or the path indicated in the T_HELPDIR constant
323 Output goes to stdout.
324 Lines beginning with a '%' are skipped.
325*/
326
327int printHelp(char *helpon);
328/* Same behaviour as printUsage, but for a file "<helpon>_H.txt".
329 After the helptext, "<helpon>_U.txt" is given also.
330*/
331
332#ifdef __cplusplus
333}
334#endif
335
336#endif /* TIVOLI_UTIL_H */
int file_write(void *ptr, size_t size, size_t length, FILE *fp)
void printftrace(int mode, char *fmt,...)
int file_open_read(FILE **fp, const char *name)
void * callocT(size_t nelem, size_t elsize)
int file_open_write(FILE **fp, const char *name)
char * getMyName(char *question, int maxsize)
void ** matAlloc(int lines, int columns, int elem_size)
float ask_float(float *def, float *mini, float *maxi, char *comment)
int file_close(FILE **fp)
void matFree(void **mat)
int getMyInt(int liminf, int limsup, int show)
void * mallocT(size_t size)
int EXEC
int printHelp(char *helpon)
float getMyFloat(float liminf, float limsup, int show)
char * composeName(char *baseName, char *ext1, char *ext2)
int m_filename(char *base, char *name, int number)
int printUsage(char *usageOf)
#define __attribute__(a)
void exitError(char *errorText)
int m_point_filename(char *base, char *name, int number)
int file_open_append(FILE **fp, const char *name)
int m_zero_filename(char *base, char *name, int number)
char * charMalloc(size_t length)
unsigned char roundFloat2UChar(float f)
int roundFloat2Int(float f)
int VERBOSE
int roundD2I(double f)
void printfexit(char *fname) __attribute__((__noreturn__))
int getManicheanRep(char *question)
void matPrint(char name[], int rows, int cols, double **array)
long int roundFloat2Long(float f)
#define TRACE
Definition cpp_defs.h:13
double cosphi
double costheta
double theta
double sinphi
double phi
double sintheta
float z
float x
float y
double x
double z
int state
double y