<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1106" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>hi everybody</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>i have a problem with the Execute method of my
class. If i call it directly in a Tcl script, there is no problem but if I
call via a write method (look at the script below) it doesn't launch it and says
that there is an error. I domn't understand why</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>in attached, I have put the files</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>thomas</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>*********************</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>package require vtklocal</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>vtkImageReaderDB inter<BR>inter SetFileName tazc
<BR>inter SetBeginX 1<BR>inter SetBeginY 1<BR>inter SetEndX 199<BR>inter SetEndY
189<BR>inter SetXResolution 1<BR>inter SetYResolution 1<BR>puts [[inter
GetOutput] GetNumberOfPoints]<BR>[inter GetOutput] Print</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>vtkTIFFWriter w<BR>w SetInput [inter
GetOutput]<BR>w SetFileName "points.tiff"<BR>w Write</FONT></DIV>
<DIV><FONT face=Arial size=2>*****************</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>void vtkImageReaderDB::Execute() {</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> cout<<"debut
reader"<<endl;<BR> PGconn
*conn;<BR> PGresult
*res;<BR> <BR>
int
i,<BR>
j;<BR> int
X,<BR> Y,<BR> OriX,<BR> OriY,<BR> DelX,<BR> DelY,<BR> NameOfImage;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /*<BR> *
begin, by setting the parameters for a backend connection if
the<BR> * parameters are null, then the system will try
to use reasonable<BR> * defaults by looking up
environment variables or, failing that,<BR> * using
hardwired constants<BR> */<BR> pghost
=
"xander.cs.uno.edu";
/* host name of the backend server */<BR> pgport =
"8000";
/* port of the backend server */<BR> pgoptions =
NULL; /* special
options to start up the
backend<BR>
* server */<BR> pgtty =
NULL;
/* debugging tty for the backend server */<BR> <BR>
dbName = "mydb"; /* change this to the name of your
test<BR>
* database */<BR> <BR> login = "thomas";<BR> pass =
"fthomas123";</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /* make a connection to the
database */<BR> conn = PQsetdbLogin(pghost, pgport, pgoptions,
pgtty, dbName, login, pass);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> /*<BR> *
check to see that the backend connection was successfully
made<BR> */<BR> if (PQstatus(conn) ==
CONNECTION_BAD)<BR>
{<BR> fprintf(stderr, "Connection to
database '%s' failed.\n", dbName);<BR>
fprintf(stderr, "%s",
PQerrorMessage(conn));<BR>
PQfinish(conn);<BR> }</FONT></DIV>
<DIV> </DIV><FONT face=Arial size=2>
<DIV><BR> /* start a transaction block
*/<BR> res = PQexec(conn, "BEGIN");<BR> if
(!res || PQresultStatus(res) != PGRES_COMMAND_OK)<BR>
{<BR> fprintf(stderr, "BEGIN command
failed\n");<BR>
PQclear(res);<BR>
PQfinish(conn);<BR> }<BR> </DIV>
<DIV> </DIV>
<DIV> /*<BR> * should PQclear PGresult
whenever it is no longer needed to avoid<BR> * memory
leaks<BR> */<BR> PQclear(res);</DIV>
<DIV> </DIV>
<DIV> /*<BR> * reading information
concerning the image in GENERAL TABLE<BR> */<BR> char
lecture[70];<BR> j = sprintf( lecture, "%s", "DECLARE mycursor BINARY
CURSOR FOR SELECT * FROM taz WHERE ImageName='");<BR> j += sprintf( lecture
+ j, "%s", FileName);<BR> j += sprintf( lecture + j, "%s","'");</DIV>
<DIV> </DIV>
<DIV> res = PQexec(conn,lecture);<BR> if (!res ||
PQresultStatus(res) != PGRES_COMMAND_OK)
{<BR> fprintf(stderr, "DECLARE CURSOR
command failed\n");<BR>
PQclear(res);<BR>
PQfinish(conn);<BR> }<BR>
PQclear(res);<BR> <BR> res = PQexec(conn, "FETCH ALL in
mycursor");<BR> if (!res || PQresultStatus(res) !=
PGRES_TUPLES_OK) {<BR> fprintf(stderr,
"FETCH ALL command didn't return tuples
properly\n");<BR>
PQclear(res);<BR>
PQfinish(conn);<BR> }</DIV>
<DIV> </DIV>
<DIV> NameOfImage = PQfnumber(res, "ImageName");<BR> X =
PQfnumber(res, "NumOfX");<BR> Y = PQfnumber(res, "NumOfY");<BR> OriX =
PQfnumber(res, "OriginX");<BR> OriY = PQfnumber(res,
"OriginY");<BR> DelX = PQfnumber(res, "DeltaX");<BR> DelY =
PQfnumber(res, "DeltaY");</DIV>
<DIV> </DIV>
<DIV><BR> int
Xval;<BR> int
Yval;<BR> float
OriXval;<BR> float
OriYval;<BR> float
DelXval;<BR> float
DelYval;<BR> char *Nameval;</DIV>
<DIV> </DIV>
<DIV> i=0;</DIV>
<DIV> </DIV>
<DIV> /* we hard-wire this to the fields we know about */<BR> Nameval
= PQgetvalue(res, i, NameOfImage);<BR> Xval = *(int *) PQgetvalue(res, i,
X);<BR> Yval = *(int *) PQgetvalue(res, i, Y);<BR> OriXval = *(float
*) PQgetvalue(res, i, OriX);<BR> OriYval = *(float *) PQgetvalue(res, i,
OriY);<BR> DelXval = *(float *) PQgetvalue(res, i, DelX);<BR> DelYval
= *(float *) PQgetvalue(res, i, DelY);</DIV>
<DIV> </DIV>
<DIV>//writing the values on
screen<BR> cout<<Nameval<<endl;<BR> printf("x = %d\n",
Xval);<BR> printf("y = %d\n", Yval);<BR> printf("OriX = %f\n",
OriXval);<BR> printf("OriY = %f\n", OriYval);<BR> printf("DelX =
%f\n", DelXval);<BR> printf("DelY = %f\n", DelYval);</DIV>
<DIV> </DIV>
<DIV><BR> /* close the cursor */<BR> res = PQexec(conn, "CLOSE
mycursor");<BR> PQclear(res);</DIV>
<DIV> </DIV>
<DIV> //initializing a vtkImageData<BR> int DimX =
Xval/XResolution;<BR> int DimY = Yval/YResolution;<BR> float DeltaX =
DelXval * (XResolution);<BR> float DeltaY = DelYval * (YResolution);</DIV>
<DIV> </DIV>
<DIV>cout<<DimX<<" "<<DimY<<" "<<DeltaX<<"
"<<DeltaY<<endl;</DIV>
<DIV> </DIV>
<DIV> vtkImageData *sp =
vtkImageData::New();<BR> sp->SetDimensions(DimX, DimY,
1);<BR> sp->SetOrigin(OriXval, OriYval,
0);<BR> sp->SetSpacing(DeltaX, DeltaY,
0);<BR> sp->SetScalarTypeToUnsignedChar();</DIV>
<DIV> </DIV>
<DIV><BR> this->GetOutput()->SetDimensions(DimX, DimY,
1);<BR> this->GetOutput()->SetOrigin(OriXval, OriYval,
0);<BR> this->GetOutput()->SetSpacing(DeltaX, DeltaY,
0);<BR> this->GetOutput()->SetScalarTypeToUnsignedChar();</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> //read the z value<BR> float *readValue;</DIV>
<DIV> </DIV>
<DIV> for (i = BeginY; i <= EndY; i = i + YResolution) {</DIV>
<DIV> </DIV>
<DIV> j = sprintf( lecture, "%s", "DECLARE mycursorb BINARY
CURSOR FOR SELECT * FROM "); //changer le select * en select juste ce qui
faut????<BR> j += sprintf( lecture + j, "%s",
Nameval);<BR> j += sprintf( lecture + j, "%s", " WHERE
c0=");<BR> j += sprintf( lecture + j, "%d",
i);<BR> <BR> res = PQexec(conn,lecture);<BR> if (!res
|| PQresultStatus(res) != PGRES_COMMAND_OK)
{<BR> fprintf(stderr, "DECLARE
CURSOR command failed\n");<BR>
PQclear(res);<BR>
PQfinish(conn);<BR> }<BR> PQclear(res);</DIV>
<DIV> </DIV>
<DIV> res = PQexec(conn, "FETCH ALL in mycursorb");<BR>
if (!res || PQresultStatus(res) != PGRES_TUPLES_OK)
{<BR> fprintf(stderr, "FETCH ALL
command didn't return tuples
properly\n");<BR>
PQclear(res);<BR>
PQfinish(conn);<BR> }<BR> <BR>cout<<i<<endl;</DIV>
<DIV> </DIV>
<DIV> //put the value into the scalar field of the
vtkImageData<BR> for (j = BeginX; j <= EndX; j = j + XResolution)
{<BR> unsigned char* pixel = (unsigned char*)
sp->GetScalarPointer(j-1,i-1,0);<BR> readValue = (float *)
PQgetvalue(res, 0, j);<BR> *pixel = (unsigned char)
*readValue;<BR> unsigned char* pixelb = (unsigned char*)
this->GetOutput()->GetScalarPointer(j-1,i-1,0);<BR> *pixelb
= (unsigned char) *readValue;<BR> }</DIV>
<DIV> </DIV>
<DIV> <BR> /* close the cursor */<BR> res =
PQexec(conn, "CLOSE mycursorb");<BR> PQclear(res);</DIV>
<DIV> </DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV> //creating an image</DIV>
<DIV> </DIV>
<DIV> vtkTIFFWriter *tiff =
vtkTIFFWriter::New();<BR> tiff->SetFileName("taz.tif");<BR> tiff->SetInput(sp);<BR> tiff->Write();<BR> cout<<tiff->GetFileName()<<endl;</DIV>
<DIV> </DIV>
<DIV> <BR> /* commit the transaction */<BR> res = PQexec(conn,
"COMMIT");<BR> PQclear(res);<BR> <BR> /* close the connection to
the database and cleanup */<BR> PQfinish(conn);</DIV>
<DIV> </DIV>
<DIV><BR>}</FONT></DIV></BODY></HTML>