[vtkusers] Re: runtime error in vtkButterflySubdivisionFilter SORRY!

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Apr 28 10:56:10 EDT 2004


David,

	Once again, your program *can not* compile, or vc++ 7.1 is doing some 
really smart things -which I seriously doubt-.

	Please find attached the c++ code that works, it display a nicely 
image, with no access violation whatsoever

	Or use a floppy disk/network/usb key to copy *exactly* this program.

HTH
Mathieu

david michell wrote:
> Sorry!, once again missed a few lines.
>   
> "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.
> 
> #include "vtkUnstructuredGrid.h"
> #include "vtkPolyDataMapper.h"
> #include "vtkActor.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkIdType.h"
> #include "vtkCellArray.h"
> #include "vtkPoints.h"
> #include "vtkDoubleArray.h"
> #include "vtkFloatArray.h"
> #include "vtkProperty.h"
> #include "vtkContourFilter.h"
> #include "vtkContourGrid.h"
> #include "vtkPointData.h"
> #include "vtkPixel.h"
> #include "vtkPolyVertex.h"
> #include "vtkLookupTable.h"
> #include "vtkDelaunay2D.h"
> #include "vtkDelaunay3D.h"
> #include "vtkPolyData.h"
> #include "vtkDataSetMapper.h"
> #include "vtkTriangleFilter.h"
> #include "vtkPolyDataNormals.h"
> #include "vtkLinearSubdivisionFilter.h"
> #include "vtkButterflySubdivisionFilter.h"
> #include "vtkReverseSense.h"
> #include "vtkMarchingContourFilter.h"
> 
> 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*3];
> 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(del->GetOutput());
> contour3D->GenerateValues(4,0.0,3.0);
> contour3D->Update();
> 
> vtkPolyDataNormals *pn=vtkPolyDataNormals::New();
> pn->SetInput(contour3D->GetOutput());
> 
> vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();
> butr->SetInput(pn->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();
> } 
> 
> 
> 
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: butter.cxx
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040428/84f74b3e/attachment.asc>


More information about the vtkusers mailing list