[vtk-developers] vtkMutableTree?

Wylie, Brian bnwylie at sandia.gov
Tue Mar 30 15:59:57 EDT 2010


Well I was being shy... but since Ken chimed in... I send out what I had in my drafts folder... reflecting some of the same observations that Ken made...


Making vtkTree mutable is a darned if you do darned if you don't proposition....



1) Make the 'treeness' of the class enforced at all times, so every insert or delete revalidates the structure as a valid tree.

      Pros: You know you always have a valid tree

      Cons: insertion and deletion become more expensive or not possible at all*



* If I hit a flat file or a database I may get edges in arbitrary order, so I would have to store all the edges in an auxiliary data structure and then carefully traverse and construct the tree (this use case happens a lot for us).





2) Don't enforce validation, have a function like CheckValidTree() that you call after construction/modification.

      Pros: you get a mutable tree

      Cons: Can the toolkit enforce this to be called? When? How? What if a filter upstream is still naughty? What if this check fails and the filter doesn't gracefully handle that failure? Defensive programming necessitates that everyone call this on the tree before beginning processing of the tree (expensive).



But going off the suggestion (which I think) was to have both vtkTree (non-mutable) and vtkMutableTree (that looks a lot like vtkMutableDirectedGraph but allows shallow copies back and forth from a vtkTree)... I'm going to have to think about whether this makes sense... perhaps after a peanut butter and cheetos sandwich it will become clear...


  Brian Wylie - Org 1424
  Sandia National Laboratories
  MS 1323 - Building CSRI/242
  (505)844-2238 FAX(505)284-2518
       _______ __
      /_  __(_) /_____ _____
       / / / / __/ __ `/ __ \
      / / / / /_/ /_/ / / / /
     /_/ /_/\__/\__,_/_/ /_/
            Informatics Toolkit

From: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org] On Behalf Of Moreland, Kenneth
Sent: Tuesday, March 30, 2010 1:28 PM
To: Nasztanovics Ferenc; VTK Developers; David Doria
Subject: Re: [vtk-developers] vtkMutableTree?

I am perhaps not the best person to speak to this, but I can assure you that the graph storage objects were not created without a great deal of deliberation and revision.  At one point in an early version of Titan we did have a mutable tree.  That turned out to be very difficult to work with because unless you happened to be building the tree in a very specific way, you would end up with intermediate structures that technically were not trees, which the class did not allow.  That meant that most filters that created a tree would have to build their own auxiliary structures and then copy the final version into the VTK tree structure.  This is why to create a tree you now have to first build it in a mutable graph and then copy it into a tree structure, at which time the tree will be validated.

I think the real problem is that you have to manually copy the vtkTree.  Does it not work to call DeepCopy on vtkMutableDirectedGraph with the vtkTree?  If not, then that is probably a bug that you should submit a bug report for.

-Ken


On 3/30/10 8:58 AM, "Nasztanovics Ferenc" <naszta at naszta.hu> wrote:
I think it would be nice. :)

Thanks,

Naszta
________________________________________
Feladó: vtk-developers-bounces at vtk.org [vtk-developers-bounces at vtk.org], meghatalmazó: David Doria [daviddoria+vtk at gmail.com]
Küldve: 2010. március 30. 23:50
Címzett: VTK Developers
Tárgy: [vtk-developers] vtkMutableTree?

Is there a reason you can't add to a vtkTree? I always have to convert
a vtkTree manually (copy every vertex and edge) to a
vtkMutableDirectedGraph, make my changes, then convert back with
CheckedShallowCopy. Could we create a vtkMutableTree?

Thanks,

David
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtk-developers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtk-developers




   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20100330/e7041f9d/attachment.html>


More information about the vtk-developers mailing list