Re: [osg-users] Visitor concept. No finalize?

2011-01-26 Thread Peter Amstutz
If it's so important it get called automatically, why can't you run your finalize code in the destructor? On 1/25/2011 3:36 PM, Sam Warns wrote: Hi, that is exactly the point. My RemoveXVisitor SHOULD remove nodes but since it is not possible to do that in apply and there is no finalize

Re: [osg-users] Visitor concept. No finalize?

2011-01-26 Thread Sam Warns
This would require the user to be aware of the fact that the Visitor has not finished its work after dtor is called. This is even more user unfriendly in my point of view. Sam -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=35988#35988

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Robert Osfield
Hi Sam, You can't remove an object from it's a parent in a apply() method as this would invalidate the iterators of the calling code (the traverse() method that calls the node-accept() which in turn calls the apply()). It's safe to remove the children of a node you are passed in a the apply

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Sam Warns
Hi Robert, the second half of my post is about the second option you was talking about. The apply only gathers the nodes in question and does nothing else then there is another method that performs the removal from parent. But the issue with that is, that if I do not call this method, no removal

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Robert Osfield
Hi Sam, You have complete control over what you do before and after traversal, there really isn't any need to have a finalize method as it would only restrict what users can do over what they can already do. If you wanted an finialize method in your visitor then just write a method like:

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Sam Warns
Hi Robert, I am aware of the possibility to define my own methods in the visitor but the point I was trying to explain is, that if I apply a visitor on a scene I would except that this visitor has finished its work after calling the node-accept(myVisitor) If I have a RemoveXVisitor and I as

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Robert Osfield
Hi Sam, I simply don't get why your are expecting things from the NodeVisitor that it isn't intended to provide, and what you can very simply provide yourself. There are many examples of NodeVisitor's in action in the OSG please do a search through the code base. Robert. On Tue, Jan 25, 2011

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Sam Warns
Hi Robert, I suppose I expect that because let's say a RemoveGroupsVisitor should remove Groups from a given graph, when I apply this visitor to a scene by Code: RemoveGroupsVisitor r; scene-accept(r); I personally would expect that now the groups are removed, which they are not by the

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Robert Osfield
Hi Sam, Your expectations are unreasonable, please them recalibrate otherwise you are going to constantly disappointed that everything in the world doesn't conform to you prior conceptions. In the case of the NodeVisitor where you are seeing a limitation, it's actually a positive and deliberate

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Paul Martz
On 1/25/2011 4:34 AM, Sam Warns wrote: Hi Robert, I am aware of the possibility to define my own methods in the visitor but the point I was trying to explain is, that if I apply a visitor on a scene I would except that this visitor has finished its work after calling the

Re: [osg-users] Visitor concept. No finalize?

2011-01-25 Thread Sam Warns
Hi, that is exactly the point. My RemoveXVisitor SHOULD remove nodes but since it is not possible to do that in apply and there is no finalize method that gets automatically called after accept has finished, it is only possible to remove nodes by providing a custom member which the user must