<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>[vtkusers] Problem with VTK4.4 + BCB6 + WinXP Pro</TITLE>
</HEAD>
<BODY>
<P><FONT SIZE=2>Hi Dean,</FONT>
</P>
<P><FONT SIZE=2>To demo the problem with VTK4.4 + BCB6, I created a small demo out of VTK\Examples\GUI\Win32\vtkBorland\ProjectDemo\Project_vtkDemo and /VTK/Examples/DataManipulation/Cxx/Arrays.cxx. I simply replaced the the button event handler with Arrays.cxx.</FONT></P>
<P><FONT SIZE=2>When my demo program calls vtkCellArray->InsertNextCell(4), I got an Excess Violation. BCB error message says</FONT>
<BR><FONT SIZE=2>"Access violation at the address 0040263F in module Project_vtkDemo.exe. Write of address 00000000." The BCB debugger pointed to the error code in VTK below:</FONT></P>
<P><FONT SIZE=2>inline void vtkIdTypeArray::InsertValue(vtkIdType id, vtkIdType i)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR><FONT SIZE=2> if ( id >= this->Size )</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> this->ResizeAndExtend(id+1);</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2> this->Array[id] = i; <------------ Error code inside VTK</FONT>
<BR><FONT SIZE=2> if ( id > this->MaxId )</FONT>
<BR><FONT SIZE=2> {</FONT>
<BR><FONT SIZE=2> this->MaxId = id;</FONT>
<BR><FONT SIZE=2> }</FONT>
<BR><FONT SIZE=2>} </FONT>
</P>
<P><FONT SIZE=2>FYI, I had no problem to run the TCL version of the same code /VTK/Examples/DataManipulation/TCL/Arrays.tcl under VTK4.4.</FONT></P>
<P><FONT SIZE=2>Thank you for your time.</FONT>
</P>
<P><FONT SIZE=2>Yang</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=2>----------- My Demo Code Below -----------</FONT>
</P>
<P><FONT SIZE=2>void __fastcall TVTK_Form::bc1Click(TObject *Sender)</FONT>
<BR><FONT SIZE=2>{</FONT>
<BR><FONT SIZE=2> vtkFloatArray* pcoords = vtkFloatArray::New();</FONT>
<BR><FONT SIZE=2> pcoords->SetNumberOfComponents(3);</FONT>
<BR><FONT SIZE=2> pcoords->SetNumberOfTuples(4);</FONT>
<BR><FONT SIZE=2> float pts[4][3] = { {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0},</FONT>
<BR><FONT SIZE=2> {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0} };</FONT>
<BR><FONT SIZE=2> for (int i=0; i<4; i++) pcoords->SetTuple(i, pts[i]);</FONT>
</P>
<P><FONT SIZE=2> vtkPoints* points = vtkPoints::New();</FONT>
<BR><FONT SIZE=2> points->SetData(pcoords);</FONT>
</P>
<P><FONT SIZE=2> vtkCellArray* strips = vtkCellArray::New();</FONT>
</P>
<P><FONT SIZE=2> strips->InsertNextCell(4); <------------------ Caused Access Violation</FONT>
</P>
<P><FONT SIZE=2> strips->InsertCellPoint(0);</FONT>
<BR><FONT SIZE=2> strips->InsertCellPoint(1);</FONT>
<BR><FONT SIZE=2> strips->InsertCellPoint(2);</FONT>
<BR><FONT SIZE=2> strips->InsertCellPoint(3);</FONT>
</P>
<P><FONT SIZE=2> vtkIntArray* temperature = vtkIntArray::New();</FONT>
<BR><FONT SIZE=2> temperature->SetName("Temperature");</FONT>
<BR><FONT SIZE=2> temperature->InsertNextValue(10);</FONT>
<BR><FONT SIZE=2> temperature->InsertNextValue(20);</FONT>
<BR><FONT SIZE=2> temperature->InsertNextValue(30);</FONT>
<BR><FONT SIZE=2> temperature->InsertNextValue(40);</FONT>
</P>
<P><FONT SIZE=2> vtkDoubleArray* vorticity = vtkDoubleArray::New();</FONT>
<BR><FONT SIZE=2> vorticity->SetName("Vorticity");</FONT>
<BR><FONT SIZE=2> vorticity->InsertNextValue(2.7);</FONT>
<BR><FONT SIZE=2> vorticity->InsertNextValue(4.1);</FONT>
<BR><FONT SIZE=2> vorticity->InsertNextValue(5.3);</FONT>
<BR><FONT SIZE=2> vorticity->InsertNextValue(3.4);</FONT>
</P>
<P><FONT SIZE=2> vtkPolyData* polydata = vtkPolyData::New();</FONT>
<BR><FONT SIZE=2> polydata->SetPoints(points);</FONT>
<BR><FONT SIZE=2> polydata->SetStrips(strips);</FONT>
<BR><FONT SIZE=2> polydata->GetPointData()->SetScalars(temperature);</FONT>
<BR><FONT SIZE=2> polydata->GetPointData()->AddArray(vorticity);</FONT>
<BR><FONT SIZE=2> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();</FONT>
<BR><FONT SIZE=2> mapper->SetInput(polydata);</FONT>
<BR><FONT SIZE=2> mapper->SetScalarRange(0, 40);</FONT>
</P>
<P><FONT SIZE=2> vtkActor* actor = vtkActor::New();</FONT>
<BR><FONT SIZE=2> actor->SetMapper(mapper);</FONT>
<BR><FONT SIZE=2> vtkWindow1->GetRenderer()->AddActor(actor);</FONT>
</P>
<P><FONT SIZE=2> pcoords->Delete();</FONT>
<BR><FONT SIZE=2> points->Delete();</FONT>
<BR><FONT SIZE=2> strips->Delete();</FONT>
<BR><FONT SIZE=2> temperature->Delete();</FONT>
<BR><FONT SIZE=2> vorticity->Delete();</FONT>
<BR><FONT SIZE=2> polydata->Delete();</FONT>
<BR><FONT SIZE=2> mapper->Delete();</FONT>
<BR><FONT SIZE=2> actor->Delete();</FONT>
</P>
<P><FONT SIZE=2> vtkWindow1->GetRenderer()->ResetCamera();</FONT>
<BR><FONT SIZE=2> vtkWindow1->Invalidate();</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>
<BR>
<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Dean Inglis [<A HREF="mailto:dean.inglis@camris.ca">mailto:dean.inglis@camris.ca</A>] </FONT>
<BR><FONT SIZE=2>Sent: Monday, March 29, 2004 10:56 AM</FONT>
<BR><FONT SIZE=2>To: vtkusers archive</FONT>
<BR><FONT SIZE=2>Cc: Yang@AGIUSA.COM</FONT>
<BR><FONT SIZE=2>Subject: Re: [vtkusers] Display model coordinate with vtkImagePlaneWidget</FONT>
</P>
<BR>
<P><FONT SIZE=2>Hi Yang,</FONT>
</P>
<P><FONT SIZE=2>>continuous cursoring is found in vtk4.4 and up, but I could not make my</FONT>
<BR><FONT SIZE=2>BCB6</FONT>
<BR><FONT SIZE=2>>project to work with vtk4.4. I am still using vtk4.2. This may be </FONT>
<BR><FONT SIZE=2>>another sign to abandon BCB.</FONT>
</P>
<P><FONT SIZE=2>that's odd. I have about 6 different active projects that successfully compile and run error free both on BCB5 and BCB6 with latest cvs VTK release (Intel Pentium 4 processors, Windows 2000 OS). What specific problems are you having?</FONT></P>
<P><FONT SIZE=2>Dean</FONT>
</P>
<BR>
</BODY>
</HTML>