[vtkusers] runtime error in vtkButterflySubdivisionFilter

Mathieu Malaterre mathieu.malaterre at kitware.com
Mon Apr 26 09:53:12 EDT 2004


David,

	Your example can not compile on any compiler, could you please send us 
the one you used to reproduce the bug ?

	rev does not reference to anything, pv->GetPointIds should give you an 
error a compile time...

Thanks,
Mathieu

david michell wrote:
> Hi everyone,
> When I run the following code Iam getting a runtime error, the error message says 
> 
> "Unhandled exception at 0x006b146a(vtkCommon.dll) in Contour3D.exe
> 0xC0000005: Access violation writing location 0xde9261d8"
> 
> The debugger points to line 149 in vtkcelllinks.cxx
> 
> Iam using vtk4.2 and vc++ 7.1 .net enabled.
> I have put the code below.
> Is there something wrong with my code?
> Kindly help me out.
> David Michell
> 
> void main()
> {
> int npts=100;
> 
> vtkPoints * points=vtkPoints::New();
> points->SetNumberOfPoints(npts);
> 
> vtkPolyVertex *pv=vtkPolyVertex::New();
> pv->GetPointIds()->SetNumberOfIds(npts);
> 
> vtkDoubleArray *scalar=vtkDoubleArray::New();
> scalar->SetNumberOfTuples(npts);
> 
> double *data=new double[npts];
> for (int i=0;i<npts;i++)
> {
> data[i*3+0]=sin((double)i);
> data[i*3+0]=(double)(i+100)/npts;
> data[i*3+0]=tan((double(i));
> 
> if (i<25) scalar->InsertValue(i,0.0);
> if ((i>=25)&&(i<50)) scalar->InsertValue(i,1.0);
> if ((i>=50)&&(i<75)) scalar->InsertValue(i,2.0);
> if ((i>=75)&&(i<100)) scalar->InsertValue(i,3.0);
> }
> 
> vtkUnstructuredGrid *grid=vtkUnstructuredGrid::New();
> grid->Allocate(npts*3);
> grid->SetPoints(points);
> grid->InsertNextCell(pv->GetCellType(),pv->GetPointIds);
> grid->GetPointData()->SetScalars(scalar);
> grid->Modified();
> grid->Update();
> 
> vtkDelaunay3D *del=vtkDelaunay3D::New();
> del->SetInput(grid);
> del->SetTolerance(0.00001);
> del->BoundingTriangulationOff();
> 
> vtkMarchingContourFilter *contour3D=vtkMarchingContourFilter::New();
> contour3D->SetInput(rev->GetOutput());
> contour3D->GenerateValues(4,0.0,3.0);
> contour3D->Update();
> 
> vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();
> butr->SetInput(del->GetOutput());
> butr->SetNumberOfSubdivisions(3);
> 
> 
> vtkLookupTable *lut=vtkLookupTable::New();
> lut->SetHueRange(0.6,0);
> lut->SetSaturationRange(1.0,0);
> lut->SetValueRange(0.5,1.0);
> 
> vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();
> mapper->SetInput(butr->GetOutput());
> mapper->SetLookupTable(lut);
> mapper->SetScalarRange(0.0,5.0);
> 
> vtkActor *surface=vtkActor::New();
> surface->SetMapper(mapper);
> 
> vtkRenderer *ren=vtkRenderer::New();
> 
> vtkRenderWindow *win=vtkRenderWindow::New();
> win->AddRenderer(ren);
> 
> vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
> win->SetInteractor(iren);
> iren->Initialize();
> 
> ren->AddActor(surface);
> 
> iren->Start();
> 
> } 
> 
> 
> 
> 
> 






More information about the vtkusers mailing list