Пример #1
0
void main(int argc, char *argv[], char *envp[])
{
    fftw_complex *in, *out;
    fftw_plan p;
    size_t N = 1024;
    char tag[80];
    char *endp = NULL;

    if(argc>1 && ( *argv[1]=='?' || *argv[1]=='-' ) ) usage(argv[0]);

    errno = 0;
    if(argc>1) N = strtoul(argv[1],&endp,0); if(errno) perror("N"); errno = 0;
         if(endp && tolower(*endp)=='k') N *= 1024;
    else if(endp && tolower(*endp)=='m') N *= 1024*1024;

    // DEMONSTRATE taking the N-pt FFT of complex value input
    // and extracting an N-pt power spectrum estimate from the result

    in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
    p = fftw_plan_dft_1d(N, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

    // vspectra_fftw.c (taking input from COMPLEX samples from RTL-SDR dongle)
    snprintf(tag,sizeof(tag),"FFT INPUT (%d I+Q values, %d pt FFT)", N, N);
    input_complex(in, N, tag);
    //dump(in,N,"INPUT-COMPLEX");
    fftw_execute(p);
    //dump(out,N,"OUTPUT-COMPLEX");
    snprintf(tag,sizeof(tag),"FFT OUTPUT (%d spectral bins, %d pt FFT)", N, N);
    output_complex(out, N, tag, -1);

    fftw_destroy_plan(p);
    fftw_free(in); fftw_free(out);

    // DEMONSTRATE taking the 2*N-pt FFT of real value input
    // and extracting an N-pt power spectrum estimate from the result

    in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N * 2);
    out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N * 2);
    p = fftw_plan_dft_1d(N * 2, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

    // vspectra_pci_fftw.c (taking input from REAL samples from a single ADC)
    snprintf(tag,sizeof(tag),"FFT INPUT (%d real values, %d pt FFT)", 4*N, 2*N);
    input_real(in, N * 2, tag );
    //dump(in,N,"INPUT-REAL");
    fftw_execute(p);
    //dump(out,N,"OUTPUT-REAL");
    snprintf(tag,sizeof(tag),"FFT OUTPUT (%d spectral bins, %d pt FFT)", N, 2*N);
    output_real(out, N * 2, tag, -1);

    fftw_destroy_plan(p);
    fftw_free(in); fftw_free(out);
}
Пример #2
0
int  main(
    int   argc,
    char  *argv[] )
{
    Volume               volume;
    BOOLEAN              world_space;
    int                  continuity;
    Real                 x, y, z;
    char                 *input_filename;
    static char          *dim_names[] = { MIxspace, MIyspace, MIzspace };

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( "", &input_filename ) )
    {
        print( "Need args.\n" );
        return( 1 );
    }

    (void) get_int_argument( 0, &continuity );
    world_space = (argc > 3);

    if( input_volume( input_filename, 3, dim_names, NC_UNSPECIFIED, FALSE,
                      0.0, 0.0, TRUE, &volume,
                      (minc_input_options *) NULL ) != OK )
        return( 1 );

    print( "Enter x, y, z: " );
    while( input_real( stdin, &x ) == OK &&
           input_real( stdin, &y ) == OK &&
           input_real( stdin, &z ) == OK )
    {
        check( volume, world_space, continuity, x, y, z );
        print( "\nEnter x, y, z: " );
    }

    return( 0 );
}
Пример #3
0
int  main(
    int    argc,
    char   *argv[] )
{
    FILE            *file;
    Status          status;
    char            *input_filename, *output_filename;
    int             n_triangles, n_objects;
    Point           centre;
    object_struct   *object, **object_list;
    polygons_struct *polygons;
    Real            x, y, z, rx, ry, rz;

    status = OK;

    initialize_argument_processing( argc, argv );

    if( !get_string_argument( "", &input_filename ) ||
        !get_string_argument( "", &output_filename ) )
    {
        (void) fprintf( stderr,
             "Usage:  input_filename output_filename [n_triangles]\n" );
        return( 1 );
    }

    (void) get_int_argument( 128, &n_triangles );

    if( open_file( input_filename, READ_FILE, ASCII_FORMAT, &file ) != OK )
        return( 1 );

    n_objects = 0;

    while( input_real( file, &x ) == OK &&
           input_real( file, &y ) == OK &&
           input_real( file, &z ) == OK &&
           input_real( file, &rx ) == OK &&
           input_real( file, &ry ) == OK &&
           input_real( file, &rz ) == OK )
    {
        object = create_object( POLYGONS );
        polygons = get_polygons_ptr(object);
        fill_Point( centre, x, y, z );
        create_tetrahedral_sphere( &centre, rx, ry, rz, n_triangles, polygons );
        compute_polygon_normals( polygons );

        ADD_ELEMENT_TO_ARRAY( object_list, n_objects, object, 10 );
    }

    status = output_graphics_file( output_filename, BINARY_FORMAT, n_objects,
                                   object_list );

    return( status != OK );
}