[vtkusers] vtkAssembly::SetVisiblity(int)

Eric E. Monson emonson at cs.duke.edu
Fri Jul 9 09:27:19 EDT 2010


Hey Sebastian,

Yes that shows it very clearly -- interesting...

Since the SetVisibility() method on vtkAssembly is just the one inherited from vtkProp, my guess would be that what you're wanting is not exactly a bug, but just something that's never been implemented...? I think you're right that the logical implementation would be to have the higher levels in the assembly tree set the visibility for all members below, just like the transformations. 

I think you should file a bug report about it.

Also, while writing this I just started looking at vtkPropAssembly since it explicitly says in the doxygen that "The props can then be treated as a group (e.g., turning visibility on and off)." I'm getting some crashes, though, on some of my tests, so I'm not sure if it's working for what you want, or not. (I'm also not sure whether you can get away with an assembly of vtkProp rather than of vtkProp3D for your application.) Maybe you can start testing that, too, and see if it will work for you. (It's SetVisibility also comes from vtkProp, so you would think that it would work the same, for better or worse...)

Talk to you later,
-Eric


On Jul 9, 2010, at 7:26 AM, Barth, Sebastian wrote:

> Hello Eric,
> 
> I've worked out the problem. I've used the following example for testing.
> The problem is, that the motherAssembly ignores the visibility of the line2Assembly and decides directly on the visibility of the line2 actor if it should render the line.
> 
> In the following example the line2 (green) should not be rendered because of the visibility, which is set to false, of the line2Assembly. But the line2 is rendered anyway.
> 
> Is this a bug?
> 
> 
>    vtkLineSource * source = vtkLineSource::New();
>    source->SetPoint1(0,  0, 0);
>    source->SetPoint2(20, 0, 0);
> 
>    vtkPolyDataMapper * mapper = vtkPolyDataMapper::New();
>    mapper->SetInputConnection(source->GetOutputPort());
> 
>    vtkActor * line1 = vtkActor::New();
>    line1->SetMapper(mapper);
>    line1->GetProperty()->SetColor(1,0,0);
> 
>    vtkActor * line2 = vtkActor::New();
>    line2->SetMapper(mapper);
>    line2->GetProperty()->SetColor(0,1,0);
>    line2->SetPosition(0, 2, 0);
> 
>    vtkAssembly * line2Assembly = vtkAssembly::New();
>    line2Assembly->AddPart(line2);
> 
> 
>    vtkAssembly * motherAssembly = vtkAssembly::New();
>    motherAssembly->AddPart(line1);
>    motherAssembly->AddPart(line2Assembly);
> 
> 
>    line1->SetVisibility(true);
>    line2->SetVisibility(true);
>    line2Assembly->SetVisibility(false);
>    motherAssembly->SetVisibility(true);
> 
> 
>    vtkRenderer * ren = vtkRenderer::New();
>    vtkRenderWindow * renWin = vtkRenderWindow::New();
>    renWin->AddRenderer(ren);
>    vtkRenderWindowInteractor * iren = vtkRenderWindowInteractor::New();
>    iren->SetRenderWindow(renWin);
> 
>    ren->AddActor(motherAssembly);
>    ren->ResetCamera();
>    renWin->Render();
>    iren->Start();
> 
> 
> Thanks a lot for your help!
> 
> Best Regards,
> 
> Sebastian Barth
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Eric E. Monson [mailto:emonson at cs.duke.edu] 
> Gesendet: Donnerstag, 8. Juli 2010 16:02
> An: Barth, Sebastian
> Cc: vtkusers at vtk.org
> Betreff: Re: [vtkusers] vtkAssembly::SetVisiblity(int)
> 
> Hey Sebastian,
> 
> Well, it works for me. Here's a Python example where setting visibility to False gives a blank window, but setting it to True gives a cube and a sphere:
> 
> # -------------------------------
> import vtk
> 
> sphere = vtk.vtkSphereSource()
> mapper1 = vtk.vtkPolyDataMapper()
> mapper1.SetInputConnection(sphere.GetOutputPort())
> actor1 = vtk.vtkActor()
> actor1.SetMapper(mapper1)
> 
> cube = vtk.vtkCubeSource()
> mapper2 = vtk.vtkPolyDataMapper()
> mapper2.SetInputConnection(cube.GetOutputPort())
> actor2 = vtk.vtkActor()
> actor2.SetMapper(mapper2)
> actor2.SetPosition(1,1,1)
> 
> assemb = vtk.vtkAssembly()
> assemb.AddPart(actor1)
> assemb.AddPart(actor2)
> assemb.SetVisibility(True)
> 
> ren = vtk.vtkRenderer()
> renWin = vtk.vtkRenderWindow()
> renWin.AddRenderer(ren)
> iren = vtk.vtkRenderWindowInteractor()
> iren.SetRenderWindow(renWin)
> 
> ren.AddActor(assemb)
> ren.ResetCamera()
> renWin.Render()
> iren.Start()
> # -------------------------------
> 
> Maybe there's something else happening with yours? What version of VTK and platform are your using?
> 
> Talk to you later,
> -Eric
> 
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
> 
> 
> On Jul 8, 2010, at 9:26 AM, Barth, Sebastian wrote:
> 
>> Hello vtkusers,
>> 
>> I have a vtkAssembly that controls some vtkActors. Everything works fine with rotating and translating the vtkActors with the vtkAssembly.
>> If I want to use vtkAssembly::SetVisibility(false) or vtkAssembly::SetVisibilityOff() nothing happens. The actors ignore the visibility of its assembly.
>> 
>> Is this a bug or a wanted behavior?
>> How can I set all of the props added to the assembly set invisible or visible?
>> 
>> Thanks a lot!
>> 
>> Best Regards,
>> Sebastian Barth
>> _______________________________________________
>> 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




More information about the vtkusers mailing list