Thread View: comp.graphics.explorer
2 messages
2 total messages
Started by Howard Wai-Chun Yeung
Mon, 25 Jan 1993 19:58
Need help with my module
Author: Howard Wai-Chun Yeung
Date: Mon, 25 Jan 1993 19:58
Date: Mon, 25 Jan 1993 19:58
105 lines
2924 bytes
2924 bytes
I write the following simple program using module muilder functions.
The problem is that it cannot send the lattice data to other modules.
I make a connection to WriteLat(), but no data is written. It seems
like the lattice is empty. But I retrive the data pointer from the
lattice. It does have data!
The problem has bug me for a few days. I wish it will just be a small
mistake I am not aware of.
#include <stdio.h>
#include "cx/PortAccess.h"
#include "cx/DataTypes.h"
#include "cx/DataAccess.h"
#include "cx/UserFuncs.h"
#define MAX_DIM 250
#define SLICE_DIM 2
translate_u3l(file_name, x_dim, y_dim, z_dim, slice_no)
char *file_name;
long x_dim, y_dim, z_dim;
long slice_no;
{
char *var;
int *int_ptr;
int i, j, k, size = 1;
FILE *in_file;
char *lat_file;
long slice_dim[2];
cxPrimType prim_type = cx_prim_long;
cxLattice *lattice_2d;
/*check any parameter error*/
if (x_dim > 250 || y_dim >250 || z_dim >250)
{
printf("Dimension of the volume is too large.\n");
return 0;;
}
/*set the maximum number of slice available*/
cxInWdgtLongMinMaxSet("slice_no", 0, z_dim-1);
/* open the input file */
if((in_file=fopen(file_name, "r")) == NULL)
{
char str[128];
sprintf(str,"cannot open input file %s", lat_file);
cxModAlert( str );
fclose(in_file);
return 0;
}
if((var = (char *)malloc(size)) == NULL)
{
printf("Memory allocation failed\n");
exit(1);;
}
slice_dim[0] = x_dim;
slice_dim[1] = y_dim;
lattice_2d = cxLatNew(SLICE_DIM,slice_dim,NO_VARIABLE,prim_type,
SLICE_DIM,cx_coord_uniform);
/*no error in share memory allocation*/
if (!cxDataAllocErrorGet())
{
cxLatPtrGet(lattice_2d, NULL, &int_ptr, NULL, NULL);
}
else
{
printf("Lattice allocation error.\n");
return 0;
}
/*in_file then is the pointer to the opened file read only
the portion of file which is the slice*/
fseek(in_file, 0L, 0);
fseek(in_file, x_dim*y_dim*slice_no, 1);
/*x_dim is number of colums while y_dim is number of row*/
for (i=0; i<y_dim; i++){
for (j=0; j<x_dim; j++){
fread(var, size, 1, in_file);
int_ptr[i*x_dim + j] = (long) (*var);
}
}
/*x_dim is number of colums while y_dim is number of row*/
cxOutputDataSet(cxOutputPortOpen("slice_lattice"), lattice_2d);
free(var);
fclose(in_file);
return;
}
With thousand thanks!
Re: Need help with my module
Author: Robert Skinner
Date: Wed, 27 Jan 1993 01:02
Date: Wed, 27 Jan 1993 01:02
38 lines
1721 bytes
1721 bytes
In article <1993Jan25.195823.12754@alw.nih.gov>, howardy@freud.nia.nih.gov writes:
>
> /*x_dim is number of colums while y_dim is number of row*/
> cxOutputDataSet(cxOutputPortOpen("slice_lattice"), lattice_2d);
Everything looks OK to me. I'd start debugging at the output
and work my way up:
what does cxOutputPortOpen("slice_lattice") return?
-- should be >= 0, if not, then port "slice_lattice"
doesn't exist
what is lattice_2d?
-- should not be != NULL, if it is, then something
is wrong with the inputs to cxLatNew. Print them
out. If its not obvious what the problem is, post
another article.
Robert Skinner
PSALM OF THE TWENTY-THIRD YEAR
Dr. ( ) is my professor
I shall not pass.
He maketh me to exhibit mine ignorance before the whole class.
He telleth me more than I can write.
He lowreth mine grades.
Yea, though I walk through the corridors of knowledge, I do not learn.
He tryeth to teach me.
He writeth equations before me in hopes that I will understand them.
He bombardeth my head with integrations.
My calculator freezeth up.
Surely enthalpies and entropies shall follow me all the days of my life
And I shall dwell in the School of
Engineering forever.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads