[vtk-developers] possible vtkCursor3D bug

dean.inglis at camris.ca dean.inglis at camris.ca
Thu Jan 5 15:21:08 EST 2006


you may have noticed, I am trying to do some
house cleaning and getting all my borland builds
working right.  TestPointWidget has been failing
for some time so I thought I'd take a look.
the error I get on my Windows boxes is

ERROR: In C:\Builder\Sources\VTK\Common\vtkDataArrayTemplate.txx, line 169
vtkIdTypeArray (09B321EC): Unable to allocate 0 elements of size 4 bytes. 

which occurs from the callback function supplied
to the widget in the test: 

// This does the actual work: updates the probe.
// Callback for the interaction
class vtkmyPWCallback : public vtkCommand
{
public:
  static vtkmyPWCallback *New() 
    { return new vtkmyPWCallback; }
  virtual void Execute(vtkObject *caller, unsigned long, void*)
    {
      vtkPointWidget *pointWidget = reinterpret_cast<vtkPointWidget*>(caller);
          pointWidget->GetPolyData(this->PolyData);
      pointWidget->GetPolyData(this->PolyData);
      this->Actor->VisibilityOn();
    }
  vtkmyPWCallback():PolyData(0),Actor(0) {}
  vtkPolyData *PolyData;
  vtkActor *Actor;
};

incidentally, there is no need to call GetPolyData twice.  I think the problem is with vtkCursor3D.cxx
in the constructor:

vtkCursor3D::vtkCursor3D()
{
  vtkPoints *pts;

  this->Focus = vtkPolyData::New();
  pts = vtkPoints::New();
  pts->Allocate(1);
  pts->vtkPoints::InsertPoint(0, 0.0, 0.0, 0.0);
  this->Focus->SetPoints(pts);
  pts->Delete();

and what is also needed when there are no shadow
lines or bounding box (by default??) is 

  vtkCellArray* cell = vtkCellArray::New();
  cell->InsertCellPoint(0);
  this->Focus->SetVerts(cell);
  cell->Delete();

Anyway, adding this fixes the test for my builds.
Shall I commit the fix and eliminate the redundant
code in the callback?

Dean




More information about the vtk-developers mailing list