[vtkusers] Combining resliced images and polygons

Jothybasu K Selvaraj jothybasu at gmail.com
Fri Mar 26 12:38:14 EDT 2010


Sorry, earlier mail was incomplete. here is the full code

cutPlane=vtk.vtkPlane()
         cutPlane.SetOrigin(0,0,SliceNo)
         cutPlane.SetNormal(0,0,1)
         cutter=vtk.vtkCutter()
         cutter.SetCutFunction(cutPlane)
         cutter.GenerateCutScalarsOff()
         Color=Object.GetProperty().GetColor()
         cutter.SetInput(Object.GetMapper().GetInput())
         cutter.Update()

cutMapper=vtk.vtkPolyDataMapper()
         #cutMapper.ScalarVisibilityOn()
         cutMapper.SetInputConnection( cutter.GetOutputPort())
         color=Object.GetProperty().GetColor()
         planeActor=vtk.vtkActor()
         planeActor.GetProperty().SetOpacity(0.5)
         planeActor.GetProperty().SetColor(color)
         planeActor.GetProperty().SetLineWidth(0.1)
         planeActor.GetProperty().SetAmbient(1)
         planeActor.GetProperty().SetSpecularColor(1, 1, 1)
         planeActor.GetProperty().SetDiffuseColor(color)
         planeActor.GetProperty().SetDiffuse(0.8)
         planeActor.GetProperty().SetSpecular(0.3)
         planeActor.GetProperty().SetSpecularPower(20)
         planeActor.GetProperty().SetRepresentationToSurface()
    planeActor.SetMapper(cutMapper)
         return planeActor

Jothy

On Fri, Mar 26, 2010 at 4:36 PM, Jothybasu K Selvaraj
<jothybasu at gmail.com>wrote:

> I am wondering, I too uses a simialr function to cut the sphere and adding
> it to the imageviewer2 and able to display it properly after adding those
> lines. Initially I too had this problem. I am sending you the entire cuttin
> code of mine verify with that.
>
> cutPlane=vtk.vtkPlane()
>          cutPlane.SetOrigin(0,0,SliceNo)
>          cutPlane.SetNormal(0,0,1)
>          cutter=vtk.vtkCutter()
>          cutter.SetCutFunction(cutPlane)
>          cutter.GenerateCutScalarsOff()
>          Color=Object.GetProperty().GetColor()
>          cutter.SetInput(Object.GetMapper().GetInput())
>          cutter.Update()
>
>
> On Fri, Mar 26, 2010 at 4:34 PM, Scott Johnson <Scott.Johnson at neuwave.com>wrote:
>
>>  I had tried it earlier and it made no difference.  I tried it again,
>> just to be sure.  Still no difference.
>>
>>
>>
>> Thanks
>>
>>
>>
>>                                 -- Scott
>>
>>
>>
>> *From:* Jothybasu K Selvaraj [mailto:jothybasu at gmail.com]
>> *Sent:* Friday, March 26, 2010 11:32 AM
>>
>> *To:* Scott Johnson
>> *Cc:* vtkusers at vtk.org
>> *Subject:* Re: [vtkusers] Combining resliced images and polygons
>>
>>
>>
>> Did you add Cutter.Update()
>>
>> Jothy
>>
>> On Fri, Mar 26, 2010 at 4:30 PM, Scott Johnson <Scott.Johnson at neuwave.com>
>> wrote:
>>
>> Yes.
>>
>>
>>
>> clippedROI = vtk.vtkCutter()
>>
>> clippedROI.SetCutFunction(plane)
>>
>> clippedROI.GenerateCutScalarsOff()
>>
>> clippedROI.SetInputConnection(targetSphere.GetOutputPort())
>>
>>
>>
>>                                 -- Scott
>>
>>
>>
>> *From:* Jothybasu K Selvaraj [mailto:jothybasu at gmail.com]
>> *Sent:* Friday, March 26, 2010 11:29 AM
>>
>>
>> *To:* Scott Johnson
>> *Cc:* vtkusers at vtk.org
>> *Subject:* Re: [vtkusers] Combining resliced images and polygons
>>
>>
>>
>> Did you set the generateCutScalarsOff() in cutter?
>>
>> That is the most important point.
>>
>> Jothy
>>
>> On Fri, Mar 26, 2010 at 4:27 PM, Scott Johnson <Scott.Johnson at neuwave.com>
>> wrote:
>>
>> Thanks again Jothy, but it didn’t make any difference.
>>
>>
>>
>> My actor definition code now looks like:
>>
>>
>>
>> clipActor = vtk.vtkActor()
>>
>> clipActor.SetMapper(clipMapper)
>>
>> clipActor.GetProperty().SetLineWidth(10)
>>
>> clipActor.GetProperty().SetOpacity(1.0)
>>
>> clipActor.GetProperty().SetColor(1.0, 0.0, 0.0)
>>
>> clipActor.GetProperty().SetDiffuseColor(1.0, 0.0, 0.0)
>>
>> clipActor.GetProperty().SetEdgeColor(1.0, 0.0, 0.0)
>>
>> clipActor.GetProperty().SetDiffuse(0.8)
>>
>> clipActor.GetProperty().SetSpecular(0.3)
>>
>> clipActor.GetProperty().SetSpecularPower(20)
>>
>> clipActor.GetProperty().SetRepresentationToSurface()
>>
>>
>>
>> Could it be something in the image viewer?  That code is:
>>
>> imageViewer = vtk.vtkImageViewer2()
>>
>> imageViewer.SetupInteractor(interactor)
>>
>> imageViewer.SetInputConnection(reslice.GetOutputPort())
>>
>> imageViewer.SetSlice((zMax - zMin) / 2)
>>
>> imageViewer.GetRenderer().AddActor(clipActor)
>>
>> imageViewer.GetRenderer().AddActor(annotation)
>>
>> imageViewer.SetSize(winWidth, winHeight)
>>
>> imageViewer.SetColorWindow(defaultWindowValue)
>>
>> imageViewer.SetColorLevel(defaultWindowValue / 2)
>>
>>
>>
>> I’ll attach a picture of what I’m seeing.  The confusing part to me is
>> that the ‘annotation’ does show up colored as expected.
>>
>>
>>
>> Thanks
>>
>>
>>
>>                                 -- Scott
>>
>>
>>
>> *From:* Jothybasu K Selvaraj [mailto:jothybasu at gmail.com]
>> *Sent:* Friday, March 26, 2010 10:22 AM
>> *To:* Scott Johnson
>> *Cc:* vtkusers at vtk.org
>>
>>
>> *Subject:* Re: [vtkusers] Combining resliced images and polygons
>>
>>
>>
>> Set cutter.GenerateCutScalarsOff()
>>
>>
>>
>> and
>>
>> Actor.GetProperty().SetDiffuseColor(color)
>> Actor.GetProperty().SetDiffuse(0.8) Actor.GetProperty().SetSpecular(0.3)
>>        Actor.GetProperty().SetSpecularPower(20)
>>       Actor.GetProperty().SetRepresentationToSurface()
>>
>> Jothy
>>
>> On Fri, Mar 26, 2010 at 10:32 AM, Jothybasu K Selvaraj <
>> jothybasu at gmail.com> wrote:
>>
>> Instead of using Clipper use vtkCutter, that will give you a contour not
>> half sphere.
>>
>> Jothy
>>
>> On Thu, Mar 25, 2010 at 10:14 PM, Scott Johnson <
>> Scott.Johnson at neuwave.com> wrote:
>>
>> Hi Folks,
>>
>>
>>
>> I’m looking for a pointer.
>>
>>
>>
>> I’m trying to display a resliced image, either axial, coronal, or sagital
>> and then display a contour representing the same plane cutting through a
>> polygonal shape.  In my current example I have created a sphere which
>> intersects some of the image slices.  As I scroll through the slices I
>> expect to see circles where the slice intersects the sphere.
>>
>>
>>
>> Right now I have created a SphereSource -> ClipPolyData -> PolyDataMapper
>> -> Actor.  The ClipPolyData has a plane as the clip function.
>>
>>
>>
>> For the images I have ImageReslice -> ImageMapToWindowLevelColors ->
>> ImageActor
>>
>>
>>
>> Both of these actors are connected to a Renderer and added to a
>> RenderWindow.
>>
>>
>>
>> What I get is a slice and half of a sphere floating over it.  I can’t get
>> the circle to be reflected on the image.  I’ve also tried to use an
>> ImageViewer2 for the display to no avail.
>>
>>
>>
>> My original plan was to sync the plane definitions in the ImageReslice and
>> the clipping plane, but I can’t get past this point.
>>
>>
>>
>> This seems much more difficult than it needs to be.  Is there a simpler
>> way?
>>
>>
>>
>> Thanks
>>
>>
>>
>>                                 -- Scott
>>
>>
>>
>>
>> _______________________________________________
>> 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
>>
>> 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/20100326/afac6d0b/attachment.htm>


More information about the vtkusers mailing list