Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

SUMA_coarsen.c File Reference

#include "SUMA_suma.h"
#include "SUMA_GeomComp.h"
#include "SUMA_gts.h"

Go to the source code of this file.


Defines

#define SURFPATCH_MAX_SURF   1

Functions

void usage_SUMA_coarsen (SUMA_GENERIC_ARGV_PARSE *ps)
SUMA_GENERIC_PROG_OPTIONS_STRUCTSUMA_coarsen_ParseInput (char *argv[], int argc, SUMA_GENERIC_ARGV_PARSE *ps)
 parse the arguments for SurfSmooth program

double distance (SUMA_SurfaceObject *SO, int n, int m)
int main (int argc, char *argv[])

Variables

SUMA_SurfaceViewerSUMAg_cSV = NULL
SUMA_SurfaceViewerSUMAg_SVv = NULL
int SUMAg_N_SVv = 0
SUMA_DOSUMAg_DOv = NULL
int SUMAg_N_DOv = 0
SUMA_CommonFieldsSUMAg_CF = NULL

Define Documentation

#define SURFPATCH_MAX_SURF   1
 

Maximum number of input surfaces

Definition at line 22 of file SUMA_coarsen.c.


Function Documentation

double distance SUMA_SurfaceObject   SO,
int    n,
int    m
 

Definition at line 164 of file SUMA_coarsen.c.

References i, and SUMA_SurfaceObject::NodeList.

Referenced by allocate_closest(), main(), SUMA_XYZ_XYZmap(), and SUMA_XYZmap_XYZ().

00165 {
00166    int i;
00167    double result = 0;
00168    for (i = 0; i<3; i++)
00169       result += pow(SO->NodeList[n*3+i] - SO->NodeList[m*3+i], 2);
00170    return sqrt(result);
00171 }

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 174 of file SUMA_coarsen.c.

References argc, i, LocalHead, SUMA_GENERIC_PROG_OPTIONS_STRUCT::out_prefix, SUMA_Alloc_DisplayObject_Struct(), SUMA_Boolean, SUMA_coarsen_ParseInput(), SUMA_free, SUMA_Free_CommonFields(), SUMA_Free_Displayable_Object_Vect(), SUMA_Free_Generic_Prog_Options_Struct(), SUMA_Free_Surface_Object(), SUMA_FreeGenericArgParse(), SUMA_IO_args_2_spec(), SUMA_LH, SUMA_Load_Spec_Surf(), SUMA_mainENTRY, SUMA_MAX_DISPLAYABLE_OBJECTS, SUMA_Mesh_Resample(), SUMA_Parse_IO_Args(), SUMA_Prefix2SurfaceName(), SUMA_RETURN, SUMA_S_Err, SUMA_Save_Surface_Object(), SUMA_SL_Err, SUMA_STANDALONE_INIT, SUMAg_N_DOv, SUMA_GENERIC_PROG_OPTIONS_STRUCT::SurfFileFormat, SUMA_GENERIC_PROG_OPTIONS_STRUCT::SurfFileType, SUMA_GENERIC_ARGV_PARSE::sv, usage_SUMA_coarsen(), and SUMA_GENERIC_PROG_OPTIONS_STRUCT::v0.

00175 {/* Main */
00176    static char FuncName[]={"SurfMesh"};
00177    SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt=NULL;
00178    int SO_read = -1;
00179    int i = 0;
00180    SUMA_SurfaceObject *SO = NULL, *S2 = NULL;
00181    void *SO_name = NULL;
00182    SUMA_Boolean exists = NOPE;
00183    FILE* out = NULL;
00184    SUMA_GENERIC_ARGV_PARSE *ps=NULL;
00185    SUMA_SurfSpecFile *Spec = NULL;
00186    int N_Spec=0;
00187    SUMA_Boolean LocalHead = NOPE;
00188 
00189    SUMA_mainENTRY;
00190 
00191    SUMA_STANDALONE_INIT;
00192 
00193 
00194    ps = SUMA_Parse_IO_Args(argc, argv, "-i;-t;-spec;-s;-sv;-o;");
00195    
00196    /* Allocate space for DO structure */
00197    SUMAg_DOv = SUMA_Alloc_DisplayObject_Struct (SUMA_MAX_DISPLAYABLE_OBJECTS);
00198 
00199    if (argc < 4)
00200    {
00201       usage_SUMA_coarsen(ps);
00202       exit (1);
00203    }
00204 
00205    Opt = SUMA_coarsen_ParseInput (argv, argc, ps);
00206 
00207    Spec = SUMA_IO_args_2_spec(ps, &N_Spec);
00208    if (N_Spec != 1) {
00209       SUMA_S_Err("Multiple spec at input.");
00210       exit(1);
00211    }
00212 
00213    SO = SUMA_Load_Spec_Surf(Spec, 0, ps->sv[0], 0);
00214    if (!SO) {
00215          fprintf (SUMA_STDERR,"Error %s:\n"
00216                               "Failed to find surface\n"
00217                               "in spec file. \n",
00218                               FuncName );
00219          exit(1);
00220       
00221    }   
00222    
00223    S2 = SUMA_Mesh_Resample (SO, Opt->v0);
00224       
00225    SO_name = SUMA_Prefix2SurfaceName(Opt->out_prefix, NULL, NULL, Opt->SurfFileType, &exists);
00226    if (exists) {
00227       fprintf(SUMA_STDERR,"Error %s:\nOutput file(s) %s* on disk.\nWill not overwrite.\n", FuncName, Opt->out_prefix);
00228       exit(1);
00229    }
00230    
00231    /* write the surfaces to disk */
00232    fprintf (SUMA_STDERR,"%s: Writing surface  ...\n", FuncName);
00233    if (!SUMA_Save_Surface_Object (SO_name, S2, Opt->SurfFileType, Opt->SurfFileFormat, NULL)) {
00234       fprintf (SUMA_STDERR,"Error %s: Failed to write surface object.\n", FuncName);
00235       exit (1);
00236    }
00237       
00238 
00239    SUMA_LH("clean up");
00240    
00241    /* free SO_name for now */
00242    if (SO_name) SUMA_free(SO_name); SO_name = NULL;
00243    if (SO) SUMA_Free_Surface_Object(SO); SO = NULL;
00244    if (S2) SUMA_Free_Surface_Object(S2); S2 = NULL;
00245    if (ps) SUMA_FreeGenericArgParse(ps); ps = NULL;
00246    if (Spec) SUMA_free(Spec); Spec = NULL;
00247    if (Opt) Opt = SUMA_Free_Generic_Prog_Options_Struct(Opt);
00248    if (!SUMA_Free_Displayable_Object_Vect (SUMAg_DOv, SUMAg_N_DOv)) {
00249       SUMA_SL_Err("DO Cleanup Failed!");
00250    }
00251    
00252    if (!SUMA_Free_CommonFields(SUMAg_CF)) {SUMA_SL_Err("SUMAg_CF Cleanup Failed!");}
00253 
00254    SUMA_RETURN(0);
00255 }

SUMA_GENERIC_PROG_OPTIONS_STRUCT* SUMA_coarsen_ParseInput char *    argv[],
int    argc,
SUMA_GENERIC_ARGV_PARSE   ps
 

parse the arguments for SurfSmooth program

Parameters:
argv  (char *)
argc  (int)
Returns:
Opt (SUMA_coarsen_OPTIONS *) options structure. To free it, use SUMA_free(Opt->out_prefix); SUMA_free(Opt);

Definition at line 78 of file SUMA_coarsen.c.

References SUMA_GENERIC_ARGV_PARSE::arg_checked, argc, i, SUMA_GENERIC_ARGV_PARSE::i_N_surfnames, ind, LocalHead, SUMA_GENERIC_ARGV_PARSE::o_FF, SUMA_GENERIC_ARGV_PARSE::o_FT, SUMA_GENERIC_ARGV_PARSE::o_N_surfnames, SUMA_GENERIC_ARGV_PARSE::o_surfnames, SUMA_GENERIC_PROG_OPTIONS_STRUCT::out_prefix, SUMA_GENERIC_ARGV_PARSE::s_N_surfnames, SUMA_Alloc_Generic_Prog_Options_Struct(), SUMA_ASCII, SUMA_Boolean, SUMA_copy_string(), SUMA_ENTRY, SUMA_free, SUMA_PLY, SUMA_Prefix2SurfaceName(), SUMA_RETURN, SUMA_S_Err, SUMA_SKIP_COMMON_OPTIONS, SUMA_GENERIC_PROG_OPTIONS_STRUCT::SurfFileFormat, SUMA_GENERIC_PROG_OPTIONS_STRUCT::SurfFileType, SUMA_GENERIC_ARGV_PARSE::t_N_surfnames, usage_SUMA_coarsen(), and SUMA_GENERIC_PROG_OPTIONS_STRUCT::v0.

Referenced by main().

00079 {
00080    static char FuncName[]={"SUMA_coarsen_ParseInput"};
00081    SUMA_GENERIC_PROG_OPTIONS_STRUCT *Opt=NULL;
00082    int kar, i, ind;
00083    char *outprefix;
00084    SUMA_Boolean brk = NOPE;
00085    void *SO_name=NULL;
00086    SUMA_Boolean exists = NOPE;
00087    SUMA_Boolean LocalHead = NOPE;
00088 
00089    SUMA_ENTRY;
00090 
00091    Opt = SUMA_Alloc_Generic_Prog_Options_Struct();
00092 
00093    kar = 1;
00094    Opt->out_prefix = NULL;
00095    Opt->v0 = .5;
00096    brk = NOPE;
00097 
00098    while (kar < argc)
00099    { /* loop accross command ine options */
00100       /*fprintf(stdout, "%s verbose: Parsing command line...\n", FuncName);*/
00101       if (strcmp(argv[kar], "-h") == 0 || strcmp(argv[kar], "-help") == 0)
00102       {
00103          usage_SUMA_coarsen(ps);
00104          exit (0);
00105       }
00106 
00107       SUMA_SKIP_COMMON_OPTIONS(brk, kar);
00108 
00109       
00110       if (!brk && (strcmp(argv[kar], "-edges") == 0))
00111       {
00112          if (kar+1 >= argc)
00113          {
00114             fprintf (SUMA_STDERR, "need a number after -edges \n");
00115             exit (1);
00116          }
00117          Opt->v0 = atof(argv[++kar]);
00118 
00119          brk = YUP;
00120       }
00121 
00122 
00123       if (!brk && !ps->arg_checked[kar])
00124       {
00125          fprintf (SUMA_STDERR,"Error %s:\nOption %s not understood. Try -help for usage\n", FuncName, argv[kar]);
00126          exit (1);
00127       } else
00128       {
00129          brk = NOPE;
00130          kar ++;
00131       }
00132 
00133    }
00134 
00135    /* check for only one surface at input */
00136    if (ps->s_N_surfnames + ps->i_N_surfnames + ps->t_N_surfnames != 1) {
00137       SUMA_S_Err("Multiple surface specifications used. Only one surface allowed.");
00138       exit(1);
00139    }
00140 
00141    /* write out the surface */
00142    if (ps->o_N_surfnames) {
00143       Opt->out_prefix = SUMA_copy_string(ps->o_surfnames[0]);
00144       Opt->SurfFileType = ps->o_FT[0];
00145       Opt->SurfFileFormat = ps->o_FF[0];
00146    } else {
00147       Opt->out_prefix = SUMA_copy_string("SurfMesh_out");
00148       Opt->SurfFileType = SUMA_PLY;
00149       Opt->SurfFileFormat = SUMA_ASCII;
00150    }
00151    SO_name = SUMA_Prefix2SurfaceName(Opt->out_prefix, NULL, NULL, Opt->SurfFileType, &exists);
00152    if (exists) {
00153       fprintf(SUMA_STDERR,"Error %s:\nOutput file(s) %s* on disk.\nWill not overwrite.\n", FuncName, Opt->out_prefix);
00154       exit(1);
00155    }
00156    /* free SO_name for now */
00157    if (SO_name) SUMA_free(SO_name); SO_name = NULL;
00158 
00159    
00160    SUMA_RETURN (Opt);
00161 
00162 }

void usage_SUMA_coarsen SUMA_GENERIC_ARGV_PARSE   ps
 

Definition at line 33 of file SUMA_coarsen.c.

References SUMA_free, SUMA_help_basics(), SUMA_help_IO_Args(), and SUMA_New_Additions().

Referenced by main(), and SUMA_coarsen_ParseInput().

00034 {
00035    static char FuncName[]={"usage_SUMA_coarsen"};
00036    char * s = NULL, *sio=NULL;
00037    s = SUMA_help_basics();
00038    sio = SUMA_help_IO_Args (ps);
00039    printf ( "\nUsage:\n"
00040             "  SurfMesh <-i_TYPE SURFACE> <-o_TYPE OUTPUT> <-edges FRAC> \n"
00041             "           [-sv SURF_VOL]\n"
00042             " \n"
00043             "  Example:\n"
00044             "  SurfMesh -i_ply surf1.ply -o_ply surf1_half -edges 0.5\n"
00045             "\n"
00046             "  Mandatory parameters:\n"
00047             "     -i_TYPE SURFACE: Input surface. See below for details. \n"
00048             "              You can also use the -t* method or\n"
00049             "              the -spec SPECFILE -surf SURFACE method.\n"
00050             "     -o_TYPE OUTPUT: Output surface, see below.\n"  
00051             "     -edges FRAC: surface will be simplified to number of\n"
00052             "              edges times FRAC (fraction). Default is .5\n"
00053             "              refines surface if edges > 1\n"
00054             "\n"
00055             "%s"
00056             "\n"
00057             "%s"
00058             "\n",sio,s); SUMA_free(sio); sio = NULL;SUMA_free(s); s = NULL;
00059    s = SUMA_New_Additions(0, 1); printf("%s\n", s);SUMA_free(s); s = NULL;
00060    printf(  " Originally written by Jakub Otwinowski.\n"
00061             " Now maintained by Ziad S. Saad SSCC/NIMH/NIH ziad@nih.gov     \n");
00062    printf(  " This program uses the GTS library gts.sf.net\n"
00063             " for fun read \"Fast and memory efficient polygonal simplification\" (1998) \n"
00064             " and \"Evaluation of memoryless simplification\" (1999) by Lindstrom and Turk.\n");
00065    exit (0);
00066 }

Variable Documentation

SUMA_CommonFields* SUMAg_CF = NULL
 

Global pointer to structure containing info common to all viewers

Definition at line 31 of file SUMA_coarsen.c.

SUMA_SurfaceViewer* SUMAg_cSV = NULL
 

Global pointer to current Surface Viewer structure

Definition at line 25 of file SUMA_coarsen.c.

SUMA_DO* SUMAg_DOv = NULL
 

Global pointer to Displayable Object structure vector

Definition at line 29 of file SUMA_coarsen.c.

int SUMAg_N_DOv = 0
 

Number of DOs stored in DOv

Definition at line 30 of file SUMA_coarsen.c.

Referenced by main().

int SUMAg_N_SVv = 0
 

Number of SVs realized by X

Definition at line 28 of file SUMA_coarsen.c.

SUMA_SurfaceViewer* SUMAg_SVv = NULL
 

Global pointer to the vector containing the various Surface Viewer Structures SUMAg_SVv contains SUMA_MAX_SURF_VIEWERS structures

Definition at line 26 of file SUMA_coarsen.c.

 

Powered by Plone

This site conforms to the following standards: