<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 &quot;vtkUnstructuredGrid.h&quot;<BR>
 <BR>
#include &quot;vtkPolyDataMapper.h&quot;<BR>
#include &quot;vtkActor.h&quot;<BR>
#include &quot;vtkRenderer.h&quot;<BR>
#include &quot;vtkRenderWindow.h&quot;<BR>
#include &quot;vtkRenderWindowInteractor.h&quot;<BR>
#include &quot;vtkIdType.h&quot;<BR>
#include &quot;vtkCellArray.h&quot;<BR>
#include &quot;vtkPoints.h&quot;<BR>
#include &quot;vtkDoubleArray.h&quot;<BR>
#include &quot;vtkProperty.h&quot;<BR>
 <BR>
#include &quot;vtkButterflySubdivisionFilter.h&quot;<BR>
#include &quot;vtkReverseSense.h&quot;<BR>
#include &quot;vtkSurfaceReconstructionFilter.h&quot;<BR>
#include &quot;vtkContourFilter.h&quot;<BR>
 <BR>
 <BR>
 <BR>
#include &quot;stdio.h&quot;<BR>
 <BR>
 <BR>
 <BR>
void main()<BR>
{<BR>
&nbsp; vtkRenderer *ren=vtkRenderer::New();<BR>
&nbsp; vtkRenderWindow *win=vtkRenderWindow::New();<BR>
&nbsp; win-&gt;AddRenderer(ren);<BR>
&nbsp; vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();<BR>
&nbsp; win-&gt;SetInteractor(iren);<BR>
&nbsp; iren-&gt;Initialize();<BR>
&nbsp; <BR>
&nbsp; FILE *fp;<BR>
&nbsp; fp=fopen(&quot;data.set&quot;,&quot;r&quot;);<BR>
&nbsp; int npts=25;<BR>
 <BR>
&nbsp; double *data=new double[npts*3];<BR>
&nbsp; int i,counter;<BR>
&nbsp; double temp;<BR>
&nbsp; for (i=0;i&lt;npts;i++)<BR>
&nbsp; {<BR>
&nbsp; &nbsp; fscanf(fp,&quot;%lf&quot;,&amp;temp);<BR>
&nbsp; &nbsp; data[i*3]=temp;//works if i do temp/100000000.0;<BR>
&nbsp; &nbsp; <BR>
&nbsp; &nbsp; fscanf(fp,&quot;%lf&quot;,&amp;temp);<BR>
&nbsp; &nbsp; data[i*3+1]=temp;<BR>
 <BR>
&nbsp; &nbsp; fscanf(fp,&quot;%lf&quot;,&amp;temp);<BR>
&nbsp; &nbsp; data[i*3+2]=temp;<BR>
 <BR>
&nbsp; &nbsp; fscanf(fp,&quot;%lf&quot;,&amp;temp);<BR>
&nbsp; }<BR>
 <BR>
&nbsp; vtkIdType *m_saCellArray=new vtkIdType[npts];<BR>
&nbsp; for (counter=0;counter&lt;npts;counter++)<BR>
&nbsp; {<BR>
&nbsp;  m_saCellArray[counter]=counter;<BR>
&nbsp; }<BR>
&nbsp; vtkCellArray *m_spCells=vtkCellArray::New();<BR>
&nbsp; m_spCells-&gt;Allocate(m_spCells-&gt;EstimateSize(npts,1));<BR>
&nbsp; m_spCells-&gt;InsertNextCell(npts);<BR>
&nbsp; m_spCells-&gt;ReplaceCell(0,npts,m_saCellArray);<BR>
&nbsp; vtkDoubleArray *m_spPointSet=vtkDoubleArray::New(); <BR>
&nbsp; m_spPointSet-&gt;SetNumberOfComponents(3);<BR>
&nbsp; m_spPointSet-&gt;SetNumberOfTuples(npts);<BR>
&nbsp; m_spPointSet-&gt;SetArray(data,npts*3,1);&nbsp; <BR>
&nbsp; m_spPointSet-&gt;Modified();<BR>
&nbsp; vtkPoints *m_spPoints=vtkPoints::New();<BR>
&nbsp; m_spPoints-&gt;Allocate(npts*3);<BR>
&nbsp; m_spPoints-&gt;SetData(m_spPointSet);<BR>
&nbsp; vtkUnstructuredGrid *m_spData=vtkUnstructuredGrid::New();<BR>
&nbsp; m_spData-&gt;Allocate(npts*3);<BR>
&nbsp; m_spData-&gt;SetPoints(m_spPoints);<BR>
&nbsp; int *cell_type=new int[npts];<BR>
&nbsp; memset(cell_type,1,sizeof(int)*npts);<BR>
&nbsp; m_spData-&gt;SetCells(cell_type,m_spCells); <BR>
&nbsp; m_spData-&gt;Modified();<BR>
&nbsp; m_spData-&gt;Update();<BR>
&nbsp; vtkSurfaceReconstructionFilter *reconst=vtkSurfaceReconstructionFilter::New();<BR>
&nbsp; reconst-&gt;SetInput(m_spData);<BR>
&nbsp; vtkContourFilter *filter=vtkContourFilter::New();<BR>
&nbsp; filter-&gt;SetInput((vtkDataSet*)reconst-&gt;GetOutput());<BR>
&nbsp; filter-&gt;SetValue(0,0.0);<BR>
&nbsp; vtkButterflySubdivisionFilter *butr=vtkButterflySubdivisionFilter::New();<BR>
&nbsp; butr-&gt;SetInput(filter-&gt;GetOutput());<BR>
&nbsp; butr-&gt;SetNumberOfSubdivisions(3);<BR>
&nbsp; vtkReverseSense *rev=vtkReverseSense::New();<BR>
&nbsp; rev-&gt;SetInput(butr-&gt;GetOutput());<BR>
&nbsp; rev-&gt;ReverseCellsOn();<BR>
&nbsp; rev-&gt;ReverseNormalsOn();<BR>
&nbsp; vtkPolyDataMapper *mapper=vtkPolyDataMapper::New();<BR>
&nbsp; mapper-&gt;SetInput(rev-&gt;GetOutput());<BR>
&nbsp; vtkActor *surface=vtkActor::New();<BR>
&nbsp; surface-&gt;SetMapper(mapper);<BR>
&nbsp; ren-&gt;AddActor(surface);<BR>
&nbsp; iren-&gt;Start();<BR>
}<BR>
/* these data must be put in a file called data.set<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 2.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 7.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 8.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 0.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 2.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 7.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.450000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.450000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.450000&nbsp; &nbsp; &nbsp; &nbsp; 0.500000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.450000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
150000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.450000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
200000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000<BR>
200000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 2.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 0.500000<BR>
200000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 7.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
200000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 8.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.350000&nbsp; &nbsp; &nbsp; &nbsp; 1.500000<BR>
200000000.000000&nbsp; &nbsp; &nbsp; &nbsp; 1.000000&nbsp; &nbsp; &nbsp; &nbsp; 0.400000&nbsp; &nbsp; &nbsp; &nbsp; 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>