Hi Gib,<div><br></div><div>Even though a programmable source like that wiki example is probably the &quot;cleanest&quot; way to do things, there is a simpler way to build a dataset for vtkGlyph3D.</div><div><br></div><div>

The vtkGlyph3D filter needs two inputs: one input for the positions of each glyph (i.e. one point per glyph) and another input for the glyph shape (i.e. the square that you already made).</div><div><br></div><div>The first input is just a list of points, you can build it as a polydata just like you did with the squares, except that you want to use &quot;verts&quot; as your cells:</div>

<div><br></div><div><meta charset="utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">vtkSmartPointer&lt;vtkPoints&gt; positions = vtkSmartPointer&lt;vtkPoints&gt;::New();<br>

vtkSmartPointer&lt;vtkCellArray&gt; dummycells = vtkSmartPointer&lt;vtkCellArray&gt;::New();</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">positions-&gt;SetNumberOfPoints(npos); // number of squares</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">dummycells-&gt;InsertNextCell(npos); // size of dummy &quot;verts&quot; array</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">for (int ipos = 0; ipos &lt; npos; ipos++)</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">  {</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">  positions-&gt;SetPoint(ipos, x, y, z);  // square positions set here</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">  dummycells-&gt;InsertCellPoint(ipos);</span></div><div>  }</div><div><br><meta charset="utf-8"><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">vtkSmartPointer&lt;vtkPolyData&gt; input = vtkSmartPointer&lt;vtkPolyData&gt;::New();</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">input-&gt;SetPoints(positions);</span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">input-&gt;SetVerts(dummycells);</span></div>

<div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; "><meta charset="utf-8">vtkSmartPointer&lt;vtkGlyph3D&gt; glypher = vtkSmartPointer&lt;vtkGlyph3D&gt;::New();</span></div>

<div>glypher-&gt;SetInput(input);</div><div>glypher-&gt;SetSource(polygonPolyData);</div><div><br></div><div>Then feed the output of the glypher into the mapper, and it will automatically draw a square at each position.  To change the positions, you would do this:</div>

<div><br></div><div>positions-&gt;SetPoint(idx, x, y, z); // set point idx to (x,y,z)</div><div>glypher-&gt;Modified(); // tell glypher that the data has changed</div><div><br></div><div>Then re-render, and the squares will be at their new positions.  I have not tested the code above, but I&#39;ve done similar things in the past.</div>

<div><br></div><div>  David</div><div><br><div class="gmail_quote">On Wed, Nov 24, 2010 at 12:52 PM, Gib  Bogle <span dir="ltr">&lt;<a href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Seb, if this is what you are referring to:<br>
<a href="http://www.itk.org/Wiki/VTK/Java_Code_Samples" target="_blank">http://www.itk.org/Wiki/VTK/Java_Code_Samples</a><br>
it might require skills a bit beyond my rather primitive level of C++ expertise.<div><div></div><div class="h5"><br>
<br>
Gib<br>
<br>
Quoting Sebastien Jourdain &lt;<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>&gt;:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
You can use a single actor, you will need to have a programable source<br>
that update the output dataset that has the location of each center of<br>
the square.<br>
<br>
Pipeline: Actor(Mapper(Glyph(CustomSource, Square)))<br>
<br>
To change the position of a square, you can have something like that...<br>
<br>
customSource.SetSquarePosition( suquareId, xyz )<br>
<br>
Seb<br>
<br>
PS: I think I wrote a sample code in Java for programmable source on the wiki...<br>
<br>
<br>
On Wed, Nov 24, 2010 at 1:41 PM, Gib  Bogle &lt;<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Seb,<br>
<br>
Although I referred to a simplified case in which the squares don&#39;t change,<br>
in general I need to allow for their movement.  Therefore I don&#39;t think it<br>
will be possible for me to use a single actor.  If I&#39;m wrong, could you<br>
please provide a bit more  detail?<br>
<br>
Thanks<br>
Gib<br>
<br>
Quoting Sebastien Jourdain &lt;<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>&gt;:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Gib,<br>
<br>
My first question will be. Are you using one actor for each of your<br>
10000 flat squares ?<br>
If so, the performance limitation may come from the number of actors<br>
involved. One solution to that is to create only one dataset with all<br>
the squares that has only one mapper and actor. To do so, you can<br>
build it by hand or simply use the Glyph filter with your square as a<br>
glyph and another dataset that has the location of those squares.<br>
<br>
Seb<br>
<br>
<br>
On Wed, Nov 24, 2010 at 12:44 AM, Gib Bogle &lt;<a href="mailto:g.bogle@auckland.ac.nz" target="_blank">g.bogle@auckland.ac.nz</a>&gt;<br>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I asked about this before, but didn&#39;t attract any responses.  I have a<br>
better understanding of the issue now, so perhaps my questions will make<br>
more sense.<br>
<br>
At regular intervals as my simulation program executes, I am rendering a<br>
scene that contains mainly about 1000 small spheres (which move) and<br>
about<br>
10000 flat squares (which do not move).  I have discovered that the<br>
surprising slowness of the the rendering is caused by the squares, even<br>
though the spheres have ThetaResolution and PhiResolution both equal to<br>
12,<br>
which I guess means 144 faces per sphere, i.e. a total of 144,000 faces.<br>
 By<br>
my calculations rendering the scene 288 times with spheres alone takes<br>
about<br>
4 sec, with the squares alone takes about 20 sec, and with both spheres<br>
and<br>
squares about 24 sec.  That is, 10,000 squares take 5 times as long as<br>
1000<br>
spheres with 144,000 faces.<br>
<br>
Apparently there&#39;s something very inefficient about the way I am<br>
rendering<br>
the squares.  Here is the code for tileMapper (which makes squares):<br>
<br>
// Create the square<br>
// Setup points to draw a unit square in the XY plane, at y=0<br>
vtkSmartPointer&lt;vtkPoints&gt; points = vtkSmartPointer&lt;vtkPoints&gt;::New();<br>
vtkSmartPointer&lt;vtkCellArray&gt; vertices =<br>
vtkSmartPointer&lt;vtkCellArray&gt;::New();<br>
points-&gt;InsertNextPoint(-0.5, 0.0, -0.5);<br>
points-&gt;InsertNextPoint( 0.5, 0.0, -0.5);<br>
points-&gt;InsertNextPoint( 0.5, 0.0,  0.5);<br>
points-&gt;InsertNextPoint(-0.5, 0.0,  0.5);<br>
<br>
vtkSmartPointer&lt;vtkPolygon&gt; polygon = vtkSmartPointer&lt;vtkPolygon&gt;::New();<br>
polygon-&gt;GetPointIds()-&gt;SetNumberOfIds(4); //make a quad<br>
polygon-&gt;GetPointIds()-&gt;SetId(0, 0);<br>
polygon-&gt;GetPointIds()-&gt;SetId(1, 1);<br>
polygon-&gt;GetPointIds()-&gt;SetId(2, 2);<br>
polygon-&gt;GetPointIds()-&gt;SetId(3, 3);<br>
<br>
//Add the polygon to a list of polygons<br>
vtkSmartPointer&lt;vtkCellArray&gt; polygons =<br>
vtkSmartPointer&lt;vtkCellArray&gt;::New();<br>
polygons-&gt;InsertNextCell(polygon);<br>
<br>
//Create a PolyData<br>
vtkSmartPointer&lt;vtkPolyData&gt; polygonPolyData =<br>
vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
polygonPolyData-&gt;SetPoints(points);<br>
polygonPolyData-&gt;SetPolys(polygons);<br>
<br>
//Create a mapper and actor<br>
tileMapper = vtkPolyDataMapper::New();<br>
tileMapper-&gt;SetInput(polygonPolyData);<br>
tileMapper-&gt;ScalarVisibilityOff();<br>
<br>
The square actors are made like this:<br>
<br>
actor = vtkActor::New();<br>
actor-&gt;SetMapper(tileMapper);<br>
actor-&gt;GetProperty()-&gt;SetColor(boneColor);<br>
actor-&gt;GetProperty()-&gt;SetAmbient(0.5);<br>
actor-&gt;GetProperty()-&gt;SetDiffuse(0.2);<br>
actor-&gt;GetProperty()-&gt;SetSpecular(0.5);<br>
actor-&gt;SetPosition(pos);<br>
ren-&gt;AddActor(actor);<br>
<br>
then not touched again (in the simulations I report times for.)<br>
<br>
I&#39;d be very grateful if someone could give me a clue as to what I&#39;m doing<br>
wrong to make the rendering so slow.<br>
<br>
Thanks<br>
Gib<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
<br>
</blockquote>
<br>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br></div>