[vtkusers] vtkAssembly::SetVisiblity(int)
Barth, Sebastian
sebastian.barth at iosb.fraunhofer.de
Mon Jul 12 08:37:18 EDT 2010
I have opened a bug report for the assembly visibility problem:
http://www.vtk.org/Bug/view.php?id=10979
Will you create one for your two issues, too?
I don't have enough time to try your code, sorry!
Regards,
Sebastian Barth
-----Ursprüngliche Nachricht-----
Von: Eric E. Monson [mailto:emonson at cs.duke.edu]
Gesendet: Freitag, 9. Juli 2010 15:50
An: Barth, Sebastian
Cc: VTK Mailing List
Betreff: Re: [vtkusers] vtkAssembly::SetVisiblity(int)
Yeah, I think there are some bugs lurking...
If I run this code (which uses vtkPropAssembly) the ResetCamera call centers the window on the cube, as if the sphere wasn't there, but in fact it's still visible:
import vtk
sphere = vtk.vtkSphereSource()
sphMapper = vtk.vtkPolyDataMapper()
sphMapper.SetInputConnection(sphere.GetOutputPort())
sphActor = vtk.vtkActor()
sphActor.SetMapper(sphMapper)
cube = vtk.vtkCubeSource()
cubeMapper = vtk.vtkPolyDataMapper()
cubeMapper.SetInputConnection(cube.GetOutputPort())
cubeActor = vtk.vtkActor()
cubeActor.SetMapper(cubeMapper)
cubeActor.SetPosition(1,1,1)
sphAssemb = vtk.vtkPropAssembly()
sphAssemb.AddPart(sphActor)
mothAssemb = vtk.vtkPropAssembly()
mothAssemb.AddPart(cubeActor)
mothAssemb.AddPart(sphAssemb)
sphAssemb.SetVisibility(0)
mothAssemb.SetVisibility(1)
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddViewProp(mothAssemb)
ren.ResetCamera()
renWin.Render()
iren.Start()
And, I can't seem to add one vtkPropAssembly to another vtkPropAssembly without getting a Segmentation Fault, when it sounds from the documentation that you should be able to build a hierarchy out of these.
I don't know if this and what you've found can be filed under the same bug report since they deal with different, although related, classes...
Talk to you later,
-Eric
On Jul 9, 2010, at 9:27 AM, Eric E. Monson wrote:
> 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
>
> _______________________________________________
> 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