[vtkusers] unknown crash using marchingcontourfilter

david michell davidmichell at rediffmail.com
Tue Jul 13 06:49:38 EDT 2004


An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040713/357a960b/attachment.htm>
-------------- next part --------------
hi everone,
i was working on contour plot, and iam sending the code below.
iam encountering crashes for reasons, iam not sure.
it happens only on some kinds of data.i have even put for what data it crashes
please help me.
thank you,
david michell

#define VTK_USE_ANSI_STDLIB

#include "vtk/vtkUnstructuredGrid.h"

#include "vtk/vtkPolyDataMapper.h"

#include "vtk/vtkActor.h"

#include "vtk/vtkRenderer.h"

#include "vtk/vtkRenderWindow.h"

#include "vtk/vtkRenderWindowInteractor.h"

#include "vtk/vtkIdType.h"

#include "vtk/vtkCellArray.h"

#include "vtk/vtkPoints.h"

#include "vtk/vtkDoubleArray.h"

#include "vtk/vtkFloatArray.h"

#include "vtk/vtkProperty.h"

#include "vtk/vtkContourFilter.h"

#include "vtk/vtkContourGrid.h"

#include "vtk/vtkExtractVOI.h"

#include "vtk/vtkGaussianSplatter.h"

#include "vtk/vtkPointData.h"

#include "vtk/vtkPixel.h"

#include "vtk/vtkPolyVertex.h"

#include "vtk/vtkShepardMethod.h"

#include "vtk/vtkLookupTable.h"

#include "vtk/vtkDelaunay2D.h"

#include "vtk/vtkDelaunay3D.h"

#include "vtk/vtkPolyData.h"

#include "vtk/vtkDataSetMapper.h"

#include "vtk/vtkPolyDataNormals.h"

#include "vtk/vtkButterflySubdivisionFilter.h"

#include "vtk/vtkReverseSense.h"

#include "vtk/vtkSurfaceReconstructionFilter.h"

#include "vtk/vtkContourFilter.h"

#include "vtk/vtkDataSetToImageFilter.h"

#include "vtk/vtkPolyDataToImageStencil.h"

#include "vtk/vtkGeometryFilter.h"

#include "vtk/vtkStripper.h"

#include "vtk/vtkLinkEdgels.h"

#include "vtk/vtkThreshold.h"

#include "vtk/vtkMarchingContourFilter.h"

#include "vtk/vtkMarchingSquares.h"

#include "vtk/vtkImageData.h"

#include "stdio.h"

#include "vtk/vtkCardinalSpline.h"

#include "vtk/vtkIdType.h"

int main(int argc,char* argv[])

{

vtkRenderer *ren=vtkRenderer::New();

vtkRenderWindow *win=vtkRenderWindow::New();

win->AddRenderer(ren);

vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();

win->SetInteractor(iren);

iren->Initialize();

 

 

vtkPoints *points=vtkPoints::New();



vtkDoubleArray *scalar=vtkDoubleArray::New();


int i,counter;

double temp;

double *data;


int npts=10000;


points->SetNumberOfPoints(npts);

scalar->SetNumberOfTuples(npts);

data=new double[npts*3];

 

for (i=0;i<npts;i++)

{

data[i*3]=sin(i*22.0/7); 
data[i*3+1]=cos(i/1.0)*sin(i/1.0); 

//uncomment the two following lines to reproduce crash
//data[i*3]=i/1000.0;
//data[i*3+1]=cos(i/1000.0);

data[i*3+2]=0.0;//leave this as 0.0

points->InsertPoint(i,data[i*3],data[i*3+1],data[i*3+2]);

double temp=i%1000;

scalar->InsertValue(i,temp);

}

vtkPolyData *m_spData=vtkPolyData::New();

m_spData->Allocate(npts*3);

m_spData->SetPoints(points);

m_spData->GetPointData()->SetScalars(scalar);

m_spData->Modified();

m_spData->Update();

 

vtkDelaunay2D *del=vtkDelaunay2D::New();

del->SetInput(m_spData);

del->SetTolerance(0.000001);

del->Update();

vtkPolyData *temp1=del->GetOutput();

/* i want the contour lines to be curved, so iam doing this */ 

/* but what happens to the scalars during subdivision??? */

/* IS THERE SOME OTHER WAY TO GET CURVY LINES */

/* sometimes it even crashes depending on the input data, is there some way to avoid this filter

and pass the output of delaunay2D to marchingcontourfilter 

and then do something to the output of marchingcontourfilter 

to get curvy lines */

vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();

butr->SetInput(temp1);

butr->SetNumberOfSubdivisions(3);

butr->Update();


vtkPolyData *temp2=butr->GetOutput();

vtkMarchingContourFilter *contour2D=vtkMarchingContourFilter::New();

contour2D->SetInput(temp2);

contour2D->GenerateValues(10,0.0,10.0);

contour2D->Update();

 

vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();

mapper->SetInput(contour2D->GetOutput());


vtkActor *surface=vtkActor::New();

surface->SetMapper(mapper);

ren->AddActor(surface);

 

iren->Start();

return 1;

}



More information about the vtkusers mailing list