<P>
hi everyone,<BR>
I am working on vtkSurfaceReconstructionFilter.<BR>
I have a file of unstructured points and Iam trying to builda surface out of it.<BR>
Soemthing is wrong, its taking a looooong time to render and in the end it crashes.<BR>
I have put the code below.<BR>
Please help me.<BR>
Thank you,<BR>
David Michell<BR>
<BR>
#define VTK_USE_ANSI_STDLIB<BR>
<BR>
<BR>
#include "vtkUnstructuredGrid.h"<BR>
<BR>
#include "vtkPolyDataMapper.h"<BR>
#include "vtkActor.h"<BR>
#include "vtkRenderer.h"<BR>
#include "vtkRenderWindow.h"<BR>
#include "vtkRenderWindowInteractor.h"<BR>
#include "vtkIdType.h"<BR>
#include "vtkCellArray.h"<BR>
#include "vtkPoints.h"<BR>
#include "vtkDoubleArray.h"<BR>
#include "vtkProperty.h"<BR>
<BR>
#include "vtkButterflySubdivisionFilter.h"<BR>
#include "vtkReverseSense.h"<BR>
#include "vtkSurfaceReconstructionFilter.h"<BR>
#include "vtkContourFilter.h"<BR>
<BR>
<BR>
<BR>
#include "stdio.h"<BR>
<BR>
<BR>
<BR>
void main()<BR>
{<BR>
vtkRenderer *ren=vtkRenderer::New();<BR>
vtkRenderWindow *win=vtkRenderWindow::New();<BR>
win->AddRenderer(ren);<BR>
vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();<BR>
win->SetInteractor(iren);<BR>
iren->Initialize();<BR>
<BR>
FILE *fp;<BR>
fp=fopen("data.set","r");<BR>
int npts=25;<BR>
<BR>
double *data=new double[npts*3];<BR>
int i,counter;<BR>
double temp;<BR>
for (i=0;i<npts;i++)<BR>
{<BR>
fscanf(fp,"%lf",&temp);<BR>
data[i*3]=temp;//works if i do temp/100000000.0;<BR>
<BR>
fscanf(fp,"%lf",&temp);<BR>
data[i*3+1]=temp;<BR>
<BR>
fscanf(fp,"%lf",&temp);<BR>
data[i*3+2]=temp;<BR>
<BR>
fscanf(fp,"%lf",&temp);<BR>
}<BR>
<BR>
vtkIdType *m_saCellArray=new vtkIdType[npts];<BR>
for (counter=0;counter<npts;counter++)<BR>
{<BR>
m_saCellArray[counter]=counter;<BR>
}<BR>
vtkCellArray *m_spCells=vtkCellArray::New();<BR>
m_spCells->Allocate(m_spCells->EstimateSize(npts,1));<BR>
m_spCells->InsertNextCell(npts);<BR>
m_spCells->ReplaceCell(0,npts,m_saCellArray);<BR>
vtkDoubleArray *m_spPointSet=vtkDoubleArray::New(); <BR>
m_spPointSet->SetNumberOfComponents(3);<BR>
m_spPointSet->SetNumberOfTuples(npts);<BR>
m_spPointSet->SetArray(data,npts*3,1); <BR>
m_spPointSet->Modified();<BR>
vtkPoints *m_spPoints=vtkPoints::New();<BR>
m_spPoints->Allocate(npts*3);<BR>
m_spPoints->SetData(m_spPointSet);<BR>
vtkUnstructuredGrid *m_spData=vtkUnstructuredGrid::New();<BR>
m_spData->Allocate(npts*3);<BR>
m_spData->SetPoints(m_spPoints);<BR>
int *cell_type=new int[npts];<BR>
memset(cell_type,1,sizeof(int)*npts);<BR>
m_spData->SetCells(cell_type,m_spCells); <BR>
m_spData->Modified();<BR>
m_spData->Update();<BR>
vtkSurfaceReconstructionFilter *reconst=vtkSurfaceReconstructionFilter::New();<BR>
reconst->SetInput(m_spData);<BR>
vtkContourFilter *filter=vtkContourFilter::New();<BR>
filter->SetInput((vtkDataSet*)reconst->GetOutput());<BR>
filter->SetValue(0,0.0);<BR>
vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();<BR>
butr->SetInput(filter->GetOutput());<BR>
butr->SetNumberOfSubdivisions(3);<BR>
vtkReverseSense *rev=vtkReverseSense::New();<BR>
rev->SetInput(butr->GetOutput());<BR>
rev->ReverseCellsOn();<BR>
rev->ReverseNormalsOn();<BR>
vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();<BR>
mapper->SetInput(rev->GetOutput());<BR>
vtkActor *surface=vtkActor::New();<BR>
surface->SetMapper(mapper);<BR>
ren->AddActor(surface);<BR>
iren->Start();<BR>
}<BR>
/* these data must be put in a file called data.set<BR>
150000000.000000 1.000000 0.350000 1.500000<BR>
150000000.000000 1.500000 0.350000 1.000000<BR>
150000000.000000 1.500000 0.350000 1.500000<BR>
150000000.000000 2.000000 0.350000 1.500000<BR>
150000000.000000 7.000000 0.350000 1.500000<BR>
150000000.000000 8.000000 0.350000 1.500000<BR>
150000000.000000 1.000000 0.400000 1.000000<BR>
150000000.000000 1.500000 0.400000 0.500000<BR>
150000000.000000 1.500000 0.400000 1.000000<BR>
150000000.000000 1.500000 0.400000 1.000000<BR>
150000000.000000 1.500000 0.400000 1.000000<BR>
150000000.000000 1.500000 0.400000 1.000000<BR>
150000000.000000 1.500000 0.400000 1.500000<BR>
150000000.000000 2.000000 0.400000 1.000000<BR>
150000000.000000 7.000000 0.400000 1.500000<BR>
150000000.000000 0.500000 0.450000 1.000000<BR>
150000000.000000 0.500000 0.450000 1.000000<BR>
150000000.000000 1.500000 0.450000 0.500000<BR>
150000000.000000 1.500000 0.450000 1.000000<BR>
150000000.000000 1.500000 0.450000 1.000000<BR>
200000000.000000 1.500000 0.350000 1.000000<BR>
200000000.000000 2.000000 0.350000 0.500000<BR>
200000000.000000 7.000000 0.350000 1.500000<BR>
200000000.000000 8.000000 0.350000 1.500000<BR>
200000000.000000 1.000000 0.400000 1.000000<BR>
*/<BR>
</P>
<br><br>
<A target="_blank" HREF="http://clients.rediff.com/signature/track_sig.asp"><IMG SRC="http://ads.rediff.com/RealMedia/ads/adstream_nx.cgi/www.rediffmail.com/inbox.htm@Bottom" BORDER=0 VSPACE=0 HSPACE=0></a>