[vtkusers] filling in a sphere's intersection with a plane

The Merper msmerps at gmail.com
Fri Jan 11 23:30:10 EST 2019


Thank you David,
    I tried to do as you suggested with the following code:

                    // Use vtkCutter to derive the contour of the
intersection with the Z-plane
                    var Origin=_ZPlaneSource.GetOrigin();
                    var Normal= _ZPlaneSource.GetNormal();
                    var TempPlane = vtkPlane.New();
                    TempPlane.SetOrigin(Origin[0], Origin[1], Origin[2]);
                    TempPlane.SetNormal(Normal[0], Normal[1], Normal[2]);
                    var Cutter = vtkCutter.New();
                    Cutter.SetCutFunction(TempPlane);
                    Cutter.SetInputConnection(SphereSource.GetOutputPort());
                    Cutter.Update();
                    var CutterMapper = vtkPolyDataMapper.New();
                    CutterMapper.SetInputConnection(Cutter.GetOutputPort());

                    // Use vtkContourTriangulator to fill the polyline
contour with traingles
                    vtkContourTriangulator Poly =
vtkContourTriangulator.New();
                    Poly.SetInputConnection(Cutter.GetOutputPort());
                    var PolyMapper = vtkDataSetMapper.New();
                    PolyMapper.SetInputConnection(Poly.GetOutputPort());
                    PolyMapper.ScalarVisibilityOff();
                    var PolyActor = vtkActor.New();

PolyActor.GetProperty().SetColor(((double)_LandmarkColors[i].R)
/ 255,
                        ((double)_LandmarkColors[i].G) / 255,
((double)_LandmarkColors[i].B) / 255);
                    PolyActor.SetMapper(PolyMapper);
                    Ren.AddActor(PolyActor);

And it renders a circle in the slice that intersects the center of the
sphere (i.e., the attached slice91.png). However, when you go below or
above that slice, you just see the outline of the sphere (e.g.,
slice90.jpg). When you go down one or more slices further you see the
bottom of the sphere with 3D shading (e.g., slice89.jpg), until it goes out
of view.

Did I do something wrong? My PolyMapper instance of vtkDataSetMaper does
not have a method SetResolveCoincidentTopologyToPolygonOffset().
     thanks again,
        -M

On Fri, Jan 11, 2019 at 11:38 AM David Gobbi <david.gobbi at gmail.com> wrote:

> If you already have the spheres as polydata, and if they are already in
> your volume coord system, then the simplest approach is probably to use
> these two filters:
> - vtkCutter, to cut the sphere (this generates a polyline contour of the
> intersection)
> - vtkContourTriangulator to fill the polyline contour with triangles
>
> When rendering the result on the image, the polydata and your image slice
> will be coincident in the z-buffer.  It might be possible to fix this by
> calling SetResolveCoincidentTopologyToPolygonOffset() on the polydata
> mapper.
>
> Rendering the filled spheres with voxels would be more complicated.  The
> vtkPolyDataToImageStencil class works volumetrically, i.e. it would be used
> to fill the entire sphere and produce a binary volume.  Then the desired
> slice of that volume would be rendered as an overlay.
>
>    David
>
>
> On Fri, Jan 11, 2019 at 8:02 AM The Merper <msmerps at gmail.com> wrote:
>
>> Thanks for the speedy reply, David.
>> The application is a GUI that allows users to mark points in a 3D MRI
>> volume. The user browses the volume and marks the points in 2D slices of
>> the volume, which are rendered via a vtkImageViewer2. Once a point is
>> marked, I represent the location with a sphere. I use vtkSphereSource via
>> vtkPolyDataMapper to render the spheres.
>>
>> I'd be happy using polygons or voxels.
>>    thanks again,
>>       -Merps
>>
>>
>>
>>
>> On Thu, Jan 10, 2019 at 5:08 PM David Gobbi <david.gobbi at gmail.com>
>> wrote:
>>
>>> On Thu, Jan 10, 2019 at 12:13 PM The Merper <msmerps at gmail.com> wrote:
>>>
>>>>
>>>>   I have a set of spheres in a volume that I visualize in 2D slices.
>>>> When the plane of a 2D slice intersects a sphere, I want the interior of
>>>> the sphere to be filled.
>>>>
>>>
>>> How are the spheres defined?  Do you already have them as vtkPolyData
>>> objects, or do you just have a list of "center and radius" values to
>>> describe the spheres?
>>>
>>> When you say "visualize in 2D slices" do you mean that you are already
>>> visualizing slices of something (e.g. of an image) and you want to display
>>> the sphere cuts as an overlay on the image?  For your application, does it
>>> matter whether the sphere cuts are displayed as voxels (i.e. a
>>> vtkImageData) vs polygons?
>>>
>>> Also, for context, what is the general purpose of your application?
>>>
>>> Cheers,
>>>   David
>>>
>>>
>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190111/bc484c4c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slice90.png
Type: image/png
Size: 61829 bytes
Desc: not available
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190111/bc484c4c/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slice89.png
Type: image/png
Size: 61656 bytes
Desc: not available
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190111/bc484c4c/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: slice91.png
Type: image/png
Size: 61774 bytes
Desc: not available
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190111/bc484c4c/attachment-0005.png>


More information about the vtkusers mailing list