<html><body>
<p><tt>&quot;Steve Chall&quot; &lt;stevec@renci.org&gt; wrote on 09/10/2007 06:35:29:<br>
<br>
&gt; David,</tt><br>
<tt>&gt; I just ran into a problem with your approach that I’m hoping you can<br>
&gt; help me with. &nbsp;Each of the spheres needs to have a different color <br>
&gt; assigned to it. &nbsp;If I add each vtkSphereSource to a <br>
&gt; vtkAppendPolyData object, is there any way I maintain the <br>
&gt; association between each sphere and its assigned color? The only way<br>
&gt; I know of to do that is with vtkActor::GetProperty()::SetColor(…) <br>
&gt; and with the vtkAppendPolyData approach, the whole vtkAppendPolyData<br>
&gt; object is associated with a single actor, which means it gets just <br>
&gt; one color assignment. &nbsp;Is that correct? &nbsp;If so, can you suggest a <br>
&gt; workaround? &nbsp;I can still display all the spheres individually with <br>
&gt; their colors, I think,, but I can’t figure out how to keep the color<br>
&gt; associations in the 2D slice. &nbsp;Thanks.</tt><br>
<tt>&gt; &nbsp;</tt><br>
<tt>&gt; -Steve</tt><br>
<tt>&gt; &nbsp;</tt><br>
<br>
<tt>Hi Steve, this is getting a bit outside my experience, ie I always use vtk to represent point scalar data and have never had to 'manually' assign colours. Typical work with vtk is to use point (or sometimes cell) scalar data to control colour or to assign actor colours, you are in between these cases. </tt><br>
<br>
<tt>You could create a data set of just points with scalars and use glyphs (vtkGlyph3D) scaled and coloured according to scalar values, then cut them... But what are your ultimate goals here? there may be a way to do what you are asking now: spheres of differing sizes and colours but that might be a dead end when you move to the next step (you mentioned more complex shapes for particles). </tt><br>
<br>
<tt>What kinds of particle shapes are you considering? How do you want colours to be assigned? Any other requirements? Are shapes, sizes and colours all independent? </tt><a href="http://www.vtk.org/doc/release/5.0/html/c2_vtk_t_9.html#c2_vtk_t_vtkProgrammableGlyphFilter"><u><font size="4" color="#0000FF">vtkProgrammableGlyphFilter</font></u></a><font size="4"> </font><tt>&nbsp;could be worth a look (I've never used it) but it sounds like you could create points with one or more attribute values associated, then use those attributes to generate glyphs for your particles with desired features: size, colour... You might need to find a way to associate (new?) scalars with each glyph so when it is cut it will have the desired colour....</tt><br>
<br>
<tt>&nbsp; regards, Dave P</tt><br>
<br>
<tt>&gt; <br>
&gt; From: Steve Chall [<a href="mailto:steve.chall@earthlink.net">mailto:steve.chall@earthlink.net</a>] <br>
&gt; Sent: Monday, October 08, 2007 12:12 AM<br>
&gt; To: David.Pont@ensisjv.com; Steve Chall<br>
&gt; Cc: 'Theresa-Marie Rhyne'; vtkusers@vtk.org<br>
&gt; Subject: Re: [vtkusers] Displaying the intersection of a plane with <br>
&gt; a bunch of spheres</tt><br>
<tt>&gt; &nbsp;</tt><br>
<tt>&gt; Thanks, David, &nbsp;This looks eminently doable and makes plenty of <br>
&gt; sense. &nbsp;I'm going to try it today.<br>
&gt; <br>
&gt; -Steve</tt><br>
<tt>&gt; -----Original Message----- <br>
&gt; From: David.Pont@ensisjv.com <br>
&gt; Sent: Oct 7, 2007 4:32 PM <br>
&gt; To: Steve Chall <br>
&gt; Cc: 'Theresa-Marie Rhyne' , vtkusers@vtk.org <br>
&gt; Subject: Re: [vtkusers] Displaying the intersection of a plane with <br>
&gt; a bunch of spheres <br>
&gt; <br>
</tt><br>
<tt>&gt; &quot;Steve Chall&quot; &lt;stevec@renci.org&gt; wrote on 06/10/2007 07:35:07:<br>
&gt; <br>
&gt; &gt; I want to generate a 3D rectangular volume of ~38,000 closely packed,<br>
&gt; &gt; sometimes overlapping &quot;particles&quot; - initially spheres simply defined as a<br>
&gt; &gt; list of centroids and a parallel list of radii, more complex objects later<br>
&gt; &gt; on - and interactively look at arbitrary slices through the volume, with the<br>
&gt; &gt; particle intersections represented as disks or circles in the 2D slice (down<br>
&gt; &gt; to a single pixel, of course, if the slice is tangent to the surface of a<br>
&gt; &gt; &quot;particle&quot;). &nbsp;Due to the number of &quot;particles&quot; I think performance scaling<br>
&gt; &gt; issues might also be a concern at some point.<br>
&gt; &gt; <br>
&gt; &gt; I’ve been working with VTK now for some time in pursuit of a solution and<br>
&gt; &gt; haven’t really come to a satisfactory conclusion. &nbsp;I’ve tried the following<br>
&gt; &gt; two approaches thus far:<br>
&gt; &gt; <br>
&gt; &gt; 1) Implicit booleans: &nbsp;I read in the sphere positions and radii and<br>
&gt; &gt; construct a vtkSphere for each one. &nbsp;As I do that I add each to a<br>
&gt; &gt; vtkImplicitBoolean object “sphereUnion” with the operation type set to<br>
&gt; &gt; union. &nbsp;I then create a vtkPlane object (right now I’m not worrying about<br>
&gt; &gt; interactively moving the plane around: &nbsp;I’ve just got it set through the<br>
&gt; &gt; middle of the cluster of spheres so that I know, because I can see it, that<br>
&gt; &gt; there’s a non-empty intersection between the plane and some of the<br>
&gt; &gt; spheres). &nbsp;Then I create another vtkImplicitBoolean called “slice” and add<br>
&gt; &gt; to it the sphereUnion and the plane with operation type set to<br>
&gt; &gt; intersection. &nbsp;I run slice into a vtkSampleFunction, that into a<br>
&gt; &gt; vtkContourFilter into a vtkPolyDataMapper into a vtkActor and into a<br>
&gt; &gt; vtkRenderer (the standard textbook sequence). &nbsp;I’ve tried looking at various<br>
&gt; &gt; subsets – just the sphereUnion, just the plane, etc. – and I see what I<br>
&gt; &gt; expect. &nbsp;But I’d think that the intersection of a bunch of spheres and a<br>
&gt; &gt; plane would look like calamari or sausage slices: a cluster of rings or<br>
&gt; &gt; disks on a 2D surface. &nbsp;However, what I’m seeing is a strange cluster of<br>
&gt; &gt; lumpy, irregular 3D objects scattered through the 3D sample space that<br>
&gt; &gt; perhaps roughly correspond to some or all of the original spheres. Thus far<br>
&gt; &gt; I haven't made any sense of it. &nbsp;So on to the second approach:<br>
&gt; &gt; <br>
&gt; &gt; 2) Polygons: &nbsp;I create the vtkSpheres, but this time convert each into a<br>
&gt; &gt; vtkPolyData object (vtkSphere -&gt; vtkSampleFunction -&gt; vtkContourFilter) and<br>
&gt; &gt; add the resulting polygonal sphere to a vtkAppendPolyData object. &nbsp;I create<br>
&gt; &gt; a vtkPlaneSource object (the polygonal equivalent to the vtkPlane implicit<br>
&gt; &gt; surface object in approach 1 above) and a vtkProbeFilter. &nbsp;I set the probe’s<br>
&gt; &gt; input connection to the vtkPlaneSource and its source connection to the<br>
&gt; &gt; vtkAppendPolydata object (the spheres) and then from there into the usual<br>
&gt; &gt; pipeline to the renderer. &nbsp;Once again I think the subunits are ok – I can<br>
&gt; &gt; display them and they look like I’d expect – but I don’t see any probe’d<br>
&gt; &gt; data at all. &nbsp;<br>
&gt; &gt; <br>
&gt; &gt; Does either of these approaches look promising, or is there an entirely<br>
&gt; &gt; different direction that’s more likely to produce useful results? &nbsp;I’d<br>
&gt; &gt; appreciate any insights you might have. &nbsp;I can provide source code if it<br>
&gt; &gt; would make it any clearer. &nbsp;Thanks for any help you can provide.<br>
&gt; <br>
&gt; You should try this: create your spheres as polydata objects with <br>
&gt; vtkSphereSource (instead of implicit spheres with vtkSphere) and <br>
&gt; merge into one data set with vtkAppendPolyData. Create an implicit <br>
&gt; plane with vtkPlane (as before) and use vtkCutter to generate the 2D<br>
&gt; slice through your polydata spheres. You should get 'circular' <br>
&gt; polylines (and/or points), increase the resolution in <br>
&gt; vtkSphereSource to get better approximation to circles (better calamari ;-).<br>
&gt; <br>
&gt; You can also cut more complex shapes this way, so long as you can <br>
&gt; represent them as polydata. Performance with this approach should be<br>
&gt; OK, unlike an approach based on vtkSampleFunction -&gt; <br>
&gt; vtkContourFilter which typically requires high sampling density to <br>
&gt; get acceptable resolution. 38K particles is quite a few so vtkCutter<br>
&gt; will be busy but using vtkSampleFunction on this problem would be an<br>
&gt; order of magnitude (or 2) slower.<br>
&gt; If you really need to specify the particles as implicit functions <br>
&gt; you would use vtkSampleFunction -&gt; vtkContour to turn them into <br>
&gt; polydata and then apply vtkCutter on the polydata, that way if you <br>
&gt; want to move the cutting plane around you will not have to re-<br>
&gt; execute vtkSampleFunction. <br>
&gt; <br>
&gt; &nbsp; HTH, Dave P<br>
&gt; <br>
&gt; &gt; <br>
&gt; &gt; Steve<br>
&gt; &gt; <br>
&gt; &gt; -Steve Chall<br>
&gt; &gt; &nbsp;Senior Research Software Developer<br>
&gt; &gt; &nbsp;Renaissance Computing Institute<br>
&gt; &gt; &nbsp;Phone: 919-515-0051<br>
&gt; &gt; &nbsp;Email: stevec@renci.org<br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; <br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; This is the private VTK discussion list. <br>
&gt; &gt; Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk">http://www.vtk</a>.<br>
&gt; &gt; org/Wiki/VTK_FAQ<br>
&gt; &gt; Follow this link to subscribe/unsubscribe:<br>
&gt; &gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a></tt></body></html>