Re: filling in a sphere's intersection with a plane
The Merper <[email protected]> Fri, 11 Jan 2019 23:30:10 -0500
| Newsgroups | gmane.comp.lib.vtk.user |
|---|---|
| Message-ID | <CALbMNizb1SqueQk40hyYqrKq=Xq2YDGeyo=LjTEuoQ40uCJXsQ@mail.gmail.com> |
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 <[email protected]> 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 <[email protected]> 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 <[email protected]>
>> wrote:
>>
>>> On Thu, Jan 10, 2019 at 12:13 PM The Merper <[email protected]> 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
>>>
>>>
>>>
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers
slice90.png
(image/png, 60.4 KB) - not displayed
slice89.png
(image/png, 60.2 KB) - not displayed
slice91.png
(image/png, 60.3 KB) - not displayed