[vtkusers] Re: runtime error in vtkButterflySubdivisionFilter SORRY!

david michell davidmichell at rediffmail.com
Tue Apr 27 00:01:32 EDT 2004


An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040427/0cd7ff33/attachment.htm>
-------------- next part --------------
  
Iam sorry, I just forgot to add in a few lines.
I dont have internet on my pc, so I have to type in the whole code on the internet machine.
So missed some lines while typing here is the code.

> "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.

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+1]=(double)(i+100)/npts;
data[i*3+2]=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);

points->InsertPoint(i,data[i*3+0],data[i*3+1],data[i*3+2]);
pv->GetPointIds()->SetId(i,i)
}

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