[vtkusers] Displaying the intersection of a plane with a bunch of spheres

David.Pont at ensisjv.com David.Pont at ensisjv.com
Mon Oct 8 16:40:22 EDT 2007


"Steve Chall" <stevec at renci.org> wrote on 09/10/2007 06:35:29:

> David,
> I just ran into a problem with your approach that I’m hoping you can
> help me with.  Each of the spheres needs to have a different color
> assigned to it.  If I add each vtkSphereSource to a
> vtkAppendPolyData object, is there any way I maintain the
> association between each sphere and its assigned color? The only way
> I know of to do that is with vtkActor::GetProperty()::SetColor(…)
> and with the vtkAppendPolyData approach, the whole vtkAppendPolyData
> object is associated with a single actor, which means it gets just
> one color assignment.  Is that correct?  If so, can you suggest a
> workaround?  I can still display all the spheres individually with
> their colors, I think,, but I can’t figure out how to keep the color
> associations in the 2D slice.  Thanks.
>
> -Steve
>

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.

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).

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? vtkProgrammableGlyphFilter  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....

  regards, Dave P

>
> From: Steve Chall [mailto:steve.chall at earthlink.net]
> Sent: Monday, October 08, 2007 12:12 AM
> To: David.Pont at ensisjv.com; Steve Chall
> Cc: 'Theresa-Marie Rhyne'; vtkusers at vtk.org
> Subject: Re: [vtkusers] Displaying the intersection of a plane with
> a bunch of spheres
>
> Thanks, David,  This looks eminently doable and makes plenty of
> sense.  I'm going to try it today.
>
> -Steve
> -----Original Message-----
> From: David.Pont at ensisjv.com
> Sent: Oct 7, 2007 4:32 PM
> To: Steve Chall
> Cc: 'Theresa-Marie Rhyne' , vtkusers at vtk.org
> Subject: Re: [vtkusers] Displaying the intersection of a plane with
> a bunch of spheres
>

> "Steve Chall" <stevec at renci.org> wrote on 06/10/2007 07:35:07:
>
> > I want to generate a 3D rectangular volume of ~38,000 closely packed,
> > sometimes overlapping "particles" - initially spheres simply defined as
a
> > list of centroids and a parallel list of radii, more complex objects
later
> > on - and interactively look at arbitrary slices through the volume,
with the
> > particle intersections represented as disks or circles in the 2D slice
(down
> > to a single pixel, of course, if the slice is tangent to the surface of
a
> > "particle").  Due to the number of "particles" I think performance
scaling
> > issues might also be a concern at some point.
> >
> > I’ve been working with VTK now for some time in pursuit of a solution
and
> > haven’t really come to a satisfactory conclusion.  I’ve tried the
following
> > two approaches thus far:
> >
> > 1) Implicit booleans:  I read in the sphere positions and radii and
> > construct a vtkSphere for each one.  As I do that I add each to a
> > vtkImplicitBoolean object “sphereUnion” with the operation type set to
> > union.  I then create a vtkPlane object (right now I’m not worrying
about
> > interactively moving the plane around:  I’ve just got it set through
the
> > middle of the cluster of spheres so that I know, because I can see it,
that
> > there’s a non-empty intersection between the plane and some of the
> > spheres).  Then I create another vtkImplicitBoolean called “slice” and
add
> > to it the sphereUnion and the plane with operation type set to
> > intersection.  I run slice into a vtkSampleFunction, that into a
> > vtkContourFilter into a vtkPolyDataMapper into a vtkActor and into a
> > vtkRenderer (the standard textbook sequence).  I’ve tried looking at
various
> > subsets – just the sphereUnion, just the plane, etc. – and I see what I
> > expect.  But I’d think that the intersection of a bunch of spheres and
a
> > plane would look like calamari or sausage slices: a cluster of rings or
> > disks on a 2D surface.  However, what I’m seeing is a strange cluster
of
> > lumpy, irregular 3D objects scattered through the 3D sample space that
> > perhaps roughly correspond to some or all of the original spheres. Thus
far
> > I haven't made any sense of it.  So on to the second approach:
> >
> > 2) Polygons:  I create the vtkSpheres, but this time convert each into
a
> > vtkPolyData object (vtkSphere -> vtkSampleFunction -> vtkContourFilter)
and
> > add the resulting polygonal sphere to a vtkAppendPolyData object.  I
create
> > a vtkPlaneSource object (the polygonal equivalent to the vtkPlane
implicit
> > surface object in approach 1 above) and a vtkProbeFilter.  I set the
probe’s
> > input connection to the vtkPlaneSource and its source connection to the
> > vtkAppendPolydata object (the spheres) and then from there into the
usual
> > pipeline to the renderer.  Once again I think the subunits are ok – I
can
> > display them and they look like I’d expect – but I don’t see any
probe’d
> > data at all.
> >
> > Does either of these approaches look promising, or is there an entirely
> > different direction that’s more likely to produce useful results?  I’d
> > appreciate any insights you might have.  I can provide source code if
it
> > would make it any clearer.  Thanks for any help you can provide.
>
> You should try this: create your spheres as polydata objects with
> vtkSphereSource (instead of implicit spheres with vtkSphere) and
> merge into one data set with vtkAppendPolyData. Create an implicit
> plane with vtkPlane (as before) and use vtkCutter to generate the 2D
> slice through your polydata spheres. You should get 'circular'
> polylines (and/or points), increase the resolution in
> vtkSphereSource to get better approximation to circles (better calamari
;-).
>
> You can also cut more complex shapes this way, so long as you can
> represent them as polydata. Performance with this approach should be
> OK, unlike an approach based on vtkSampleFunction ->
> vtkContourFilter which typically requires high sampling density to
> get acceptable resolution. 38K particles is quite a few so vtkCutter
> will be busy but using vtkSampleFunction on this problem would be an
> order of magnitude (or 2) slower.
> If you really need to specify the particles as implicit functions
> you would use vtkSampleFunction -> vtkContour to turn them into
> polydata and then apply vtkCutter on the polydata, that way if you
> want to move the cutting plane around you will not have to re-
> execute vtkSampleFunction.
>
>   HTH, Dave P
>
> >
> > Steve
> >
> > -Steve Chall
> >  Senior Research Software Developer
> >  Renaissance Computing Institute
> >  Phone: 919-515-0051
> >  Email: stevec at renci.org
> >
> >
> >
> > _______________________________________________
> > This is the private VTK discussion list.
> > Please keep messages on-topic. Check the FAQ at: http://www.vtk.
> > org/Wiki/VTK_FAQ
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071009/25b0b659/attachment.htm>


More information about the vtkusers mailing list