<div class="gmail_quote">On Tue, Aug 7, 2012 at 5:19 AM, ikatz <span dir="ltr">&lt;<a href="mailto:ikatzbilb@hotmail.com" target="_blank">ikatzbilb@hotmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I can&#39;t provide a self-contained example because the code is quite complex<br>
and uses another libraries for other purposes, it would be impossible to<br>
compile everything. Anyway, I will try to explain as best as possible.<br>
We are using what we call gfxPointClouds, an structure that holds all the<br>
poins of the point cloud, and after getting the number of points we use<br>
vtkPolyData structures to manage all the points. This point cloud element is<br>
treated as other elements like spheres or lines in our vtkRenderWindow, the<br>
problem is that when we want to &quot;refresh&quot; the whole Viewport (working with<br>
&gt;10 million point clouds) it takes a lot of time (sometimes 1 minute) or<br>
does not even load the point cloud and the program fails. I don&#39;t know if<br>
there is another way of managing this point clouds structures in VTK other<br>
than vtkPolyData or if it&#39;s normal to last so match...<br>
<br>
Here is the code:<br>
<br>
const gfxPointCloud3* cop = dynamic_cast&lt;const gfxPointCloud3*&gt;(pointCloud);<br>
        unsigned int iNumPoints = cop-&gt;GetNumElements();<br>
<br>
        //Reset to an empty state and free any memory.<br>
        m_PolyData-&gt;Initialize();<br>
<br>
        //No points, no work.<br>
        if( iNumPoints &gt; 0 )<br>
        {<br>
                vtkPoints* pointSet = vtkPoints::New();<br>
                pointSet-&gt;Allocate(iNumPoints);<br>
                vtkCellArray* cellSet = vtkCellArray::New();<br>
                vtkBitArray* selectSet = vtkBitArray::New();<br>
                vtkFloatArray* scalarSet = vtkFloatArray::New();<br>
<br>
                pointSet-&gt;SetNumberOfPoints( iNumPoints );<br>
                selectSet-&gt;SetNumberOfValues( iNumPoints );<br>
<br>
                switch( cop-&gt;GetAttributeSize() )<br>
                {<br>
                        case 1: //char (8 bits)<br>
                        case 2: //short (16 bits)<br>
                        case 4: //int (32 bits)<br>
                        case 8: //double (64 bits)<br>
                                m_AttributeSize = cop-&gt;GetAttributeSize();<br>
                                scalarSet-&gt;SetNumberOfValues( iNumPoints );<br>
                                bAttribute = true;<br>
                                break;<br>
                        default: //invalid size: disable the color map.<br>
                                m_AttributeSize = 0;<br>
                                m_Map-&gt;ScalarVisibilityOff();<br>
                }<br>
<br>
                gfxPoint3 point;<br>
                for( unsigned int i=0; i&lt;iNumPoints; i++ )<br>
                {<br>
                        //Add the point to the point list.<br>
                        point = cop-&gt;GetElement(i);<br>
                        pointSet-&gt;SetPoint(     i, point.x(), point.y(), point.z() );<br>
<br>
                        //Create a new cell and add the new point to it.<br>
                        cellSet-&gt;InsertNextCell( 1 );<br>
                        cellSet-&gt;InsertCellPoint( i );<br>
<br>
                        //Mark the new point as not selected.<br>
                        selectSet-&gt;SetValue( i, 0 );<br>
<br>
                        //IF{} just to speed-up when there is no attribute in the point cloud.<br>
                        if( bAttribute )<br>
                        {<br>
                                switch( m_AttributeSize )<br>
                                {<br>
                                        //All types are converted to float.<br>
                                        case 1: //char (8 bits)<br>
                                                scalarSet-&gt;SetValue( i, *((char*)(cop-&gt;GetAttribute(i))) );<br>
                                                break;<br>
                                        case 2: //short (16 bits)<br>
                                                scalarSet-&gt;SetValue( i, *((short*)(cop-&gt;GetAttribute(i))) );<br>
                                                break;<br>
                                        case 4: //int (32 bits)<br>
                                                scalarSet-&gt;SetValue( i, *((int*)(cop-&gt;GetAttribute(i))) );<br>
                                                break;<br>
                                        case 8: //double (64 bits)<br>
                                                scalarSet-&gt;SetValue( i, *((double*)(cop-&gt;GetAttribute(i))) );<br>
                                                break;<br>
                                }<br>
                        }<br>
                }<br>
<br>
                m_PolyData-&gt;SetPoints( pointSet );<br>
                m_PolyData-&gt;SetVerts( cellSet );<br>
<br>
                //Associate the selection scalar with the cells.<br>
                m_PolyData-&gt;GetCellData()-&gt;SetScalars( selectSet );<br>
<br>
                //Associate the attribute scalar with the points.<br>
                if( bAttribute )<br>
                        m_PolyData-&gt;GetPointData()-&gt;SetScalars( scalarSet );<br>
<br>
                m_PolyData-&gt;Modified();<br>
<br>
                m_Map-&gt;SetInput( m_PolyData );<br>
                m_SelectionMap-&gt;SetInput( m_PolyData );<br>
<br>
                scalarSet-&gt;Delete();<br>
                selectSet-&gt;Delete();<br>
                cellSet-&gt;Delete();<br>
                pointSet-&gt;Delete();<br>         }<br></blockquote><div><br></div>You should be able to turn that into a working demo without much trouble. It looks like you can just replace your custom data type with a  vtkPointSource (<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PointSource">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/PointSource</a> ) to produce some random data. Of course you&#39;ll also have to make the member variables defined in this demo scope, etc.</div>
<div class="gmail_quote"><br>David</div>