https://github.com/ma-tech/Woolz
Tip revision: 69935063db51c8d4508180e67cbb22ba05c7f121 authored by richard on 05 February 2004, 13:06:21 UTC
Set conversion to use WLZ_NINT for integer values. For some reason under
Set conversion to use WLZ_NINT for integer values. For some reason under
Tip revision: 6993506
WlzIsEmpty.c
#pragma ident "MRC HGU $Id$"
/************************************************************************
* Copyright : 1994 Medical Research Council, UK. *
* All rights reserved. *
*************************************************************************
* Address : MRC Human Genetics Unit, *
* Western General Hospital, *
* Edinburgh, EH4 2XU, UK. *
*************************************************************************
* Project : Woolz Library *
* File : WlzIsEmpty.c *
*************************************************************************
* This module has been copied from the original woolz library and *
* modified for the public domain distribution. The original authors of *
* the code and the original file headers and comments are in the *
* HISTORY file. *
*************************************************************************
* Author Name : Richard Baldock *
* Author Login: richard@hgu.mrc.ac.uk *
* Date : Thu Nov 30 09:52:24 2000 *
* $Revision$ *
* $Name$ *
* Synopsis : *
*************************************************************************
* Maintenance : date - name - comments (Last changes at the top) *
************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <Wlz.h>
/* externals required by getopt - not in ANSI C standard */
#ifdef __STDC__ /* [ */
extern int getopt(int argc, char * const *argv, const char *optstring);
extern int optind, opterr, optopt;
extern char *optarg;
#endif /* __STDC__ ] */
static void usage(char *proc_str)
{
fprintf(stderr,
"Usage:\t%s [-h] [<input file>]\n"
"\tDetermine it the given woolz object(s) is empty\n"
"\tOptions are:\n"
"\t -h Help - prints this usage message\n"
"",
proc_str);
return;
}
int main(int argc,
char **argv)
{
WlzObject *obj;
FILE *inFile;
char optList[] = "h";
int option;
int count, vol;
const char *errMsg;
WlzErrorNum errNum = WLZ_ERR_NONE;
/* read the argument list and check for an input file */
opterr = 0;
while( (option = getopt(argc, argv, optList)) != EOF ){
switch( option ){
case '~': /* dummy to avoid compiler warning */
break;
case 'h':
default:
usage(argv[0]);
return( 1 );
}
}
inFile = stdin;
if( optind < argc ){
if( (inFile = fopen(*(argv+optind), "r")) == NULL ){
fprintf(stderr, "%s: can't open file %s\n", argv[0], *(argv+optind));
usage(argv[0]);
return( 1 );
}
}
count = 0;
while( (obj = WlzReadObj(inFile, NULL)) != NULL )
{
count++;
if( WlzIsEmpty(obj, &errNum) ){
fprintf(stderr, "Object %d: empty\n", count);
}
else {
if( errNum != WLZ_ERR_NONE ){
(void )WlzStringFromErrorNum(errNum, &errMsg);
fprintf(stderr,
"%s: Object %d: error in determining if empty (%s).\n",
*argv, count, errMsg);
}
else {
fprintf(stderr, "Object %d: not empty\n", count);
}
}
WlzFreeObj( obj );
}
return( 0 );
}