|
TrueReality
v0.1.1912
|
Visitor for type safe operations on trCore::Nodes. More...
#include <NodeVisitor.h>


Public Types | |
| enum | TraversalMode { TRAVERSE_NONE = 0, TRAVERSE_PARENTS = 1, TRAVERSE_ALL_CHILDREN = 2, TRAVERSE_ACTIVE_CHILDREN = 3 } |
| enum | VisitorType { NODE_VISITOR = 0, UPDATE_VISITOR = 1, EVENT_VISITOR = 2, COLLECT_OCCLUDER_VISITOR = 3, CULL_VISITOR = 4, INTERSECTION_VISITOR = 5 } |
| using | BaseClass = trBase::Base |
Public Types inherited from trBase::Base | |
| using | BaseClass = trBase::SmrtClass |
Public Types inherited from trBase::SmrtClass | |
| using | BaseClass = osg::Referenced |
Public Member Functions | |
| NodeVisitor (TraversalMode tm=TRAVERSE_NONE, const std::string name=CLASS_TYPE) | |
| Holds the class type name for efficient comparisons. More... | |
| NodeVisitor (VisitorType type, TraversalMode tm=TRAVERSE_NONE, const std::string name=CLASS_TYPE) | |
| Constructor. More... | |
| virtual const std::string & | GetType () const override |
| Returns the class type. More... | |
| virtual void | SetName (const std::string &name) |
| Sets this instances name. More... | |
| virtual osg::NodeVisitor * | AsOSGVisitor () |
| Returns a pointer to the internal OSG Node. More... | |
| virtual const osg::NodeVisitor * | AsOSGVisitor () const |
| Returns a constant pointer to the internal OSG Node. More... | |
| virtual void | Reset () |
| Method to call to reset visitor. More... | |
| void | SetVisitorType (VisitorType type) |
| Set the VisitorType, used to distinguish different visitors during traversal of the scene, typically used in the Node:Traverse() method to select which behavior to use for different types of traversal/visitors. More... | |
| VisitorType | GetVisitorType () const |
| Get the VisitorType. More... | |
| void | SetTraversalNumber (unsigned int fn) |
| Set the traversal number. More... | |
| unsigned int | GetTraversalNumber () const |
| Get the traversal number. More... | |
| void | SetFrameStamp (FrameStamp *fs) |
| Set the FrameStamp that this traversal is associated with. More... | |
| const FrameStamp * | GetFrameStamp () const |
| Get the FrameStamp that this traversal is associated with. More... | |
| void | SetTraversalMask (Node::NodeMask mask) |
| Set the TraversalMask of this NodeVisitor. More... | |
| Node::NodeMask | GetTraversalMask () const |
| Get the TraversalMask. More... | |
| void | SetNodeMaskOverride (Node::NodeMask mask) |
| Node::NodeMask | GetNodeMaskOverride () const |
| bool | ValidNodeMask (const Nodes::Node &node) const |
| Method to called by Node and its subclass' Node::Accept() method, if the result is true it is used to cull operations of nodes and their subgraphs. More... | |
| void | SetTraversalMode (TraversalMode mode) |
| Set the traversal mode for Node::Traverse() to use when deciding which children of a node to traverse. More... | |
| TraversalMode | GetTraversalMode () const |
| Get the traversal mode. More... | |
| void | Traverse (Node &node) |
| Method for handling traversal of a nodes. More... | |
| void | PushOntoNodePath (Node *node) |
| Method called by Node::Accept() method before a call to the NodeVisitor::Apply(..). More... | |
| void | PopFromNodePath () |
| Method called by Node::Accept() method after a call to NodeVisitor::Apply(..). More... | |
| NodePath * | GetNodePath () |
| Get the non const NodePath from the top most node applied down to the current Node being visited. More... | |
| const NodePath * | GetNodePath () const |
| Get the const NodePath from the top most node applied down to the current Node being visited. More... | |
| virtual trBase::Vec3 | GetEyePoint () const |
| Get the eye point in local coordinates. More... | |
| virtual trBase::Vec3 | GetViewPoint () const |
| Get the view point in local coordinates. More... | |
| virtual float | GetDistanceToEyePoint (const trBase::Vec3 &, bool) const |
| Get the distance from a point to the eye point, distance value in local coordinate system. More... | |
| virtual float | GetDistanceFromEyePoint (const trBase::Vec3 &, bool) const |
| Get the distance of a point from the eye point, distance value in the eye coordinate system. More... | |
| virtual float | GetDistanceToViewPoint (const trBase::Vec3 &, bool) const |
| Get the distance from a point to the view point, distance value in local coordinate system. More... | |
Public Member Functions inherited from trBase::Base | |
| Base (const std::string &name=CLASS_TYPE) | |
| Holds the class type name for efficient comparisons. More... | |
| virtual const std::string & | GetName () |
| Returns this instances name. More... | |
| virtual const std::string & | GetName () const |
| Returns this instances name. More... | |
| virtual void | SetUUID (const trBase::UniqueId &id) |
| Overwrites the default internal UUID with the passed in one. More... | |
| virtual const trBase::UniqueId & | GetUUID (void) |
| Returns the instances Universally Unique ID. More... | |
Public Member Functions inherited from trBase::SmrtClass | |
| SmrtClass () | |
| Adds an easy and swappable access to the base class. More... | |
| SmrtClass (bool threadSafeRefUnref) | |
| Constructor. More... | |
| SmrtClass (const SmrtClass &inst) | |
| Copy constructor. More... | |
| virtual bool | GetThreadSafeRefUnref () |
| Get whether a mutex is used to ensure Ref() and UnRef() are thread safe. More... | |
| OpenThreads::Mutex * | GetRefMutex () const |
| Get the mutex used to ensure thread safety of Ref()/UnRef(). More... | |
| int | Ref () const |
| Increment the reference count by one, indicating that this object has another pointer which is referencing it. More... | |
| int | Unref () const |
| Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More... | |
| int | UnRefNoDelete () const |
| Decrement the reference count by one, indicating that a pointer to this object is no longer referencing it. More... | |
| int | ReferenceCount () const |
| Return the number of pointers currently referencing this object. More... | |
Static Public Attributes | |
| static const trUtil::RefStr | CLASS_TYPE = trUtil::RefStr("trCore::Nodes::NodeVisitor") |
| Adds an easy and swappable access to the base class. More... | |
Static Public Attributes inherited from trBase::Base | |
| static const trUtil::RefStr | CLASS_TYPE = trUtil::RefStr("trBase::Base") |
| Adds an easy and swappable access to the base class. More... | |
Protected Member Functions | |
| ~NodeVisitor () | |
| Destructor. More... | |
Protected Member Functions inherited from trBase::Base | |
| ~Base () | |
| Base destructor. More... | |
Protected Member Functions inherited from trBase::SmrtClass | |
| ~SmrtClass () | |
Protected Attributes | |
| trBase::SmrtPtr< osg::NodeVisitor > | mNodeVisitor |
| The node visitor. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from trBase::SmrtClass | |
| static OpenThreads::Mutex * | GetGlobalReferencedMutex () |
| Get the optional global Referenced mutex, this can be shared between all trBase::SmrtClass. More... | |
Visitor for type safe operations on trCore::Nodes.
Based on GOF's Visitor pattern. The NodeVisitor is useful for developing type safe operations to nodes in the scene graph (as per Visitor pattern), and adds to this support for optional scene graph traversal to allow operations to be applied to whole scenes at once. The Visitor pattern uses a technique of double dispatch as a mechanism to call the appropriate Apply(..) method of the NodeVisitor. To use this feature one must use the Node::Accept(NodeVisitor) which is extended in each Node subclass, rather than the NodeVisitor apply directly. So use root->Accept(myVisitor); instead of myVisitor.Apply(*root). The later method will bypass the double dispatch and the appropriate NodeVisitor::Apply(..) method will not be called.
Definition at line 55 of file trCore/Nodes/NodeVisitor.h.
Definition at line 77 of file trCore/Nodes/NodeVisitor.h.
| Enumerator | |
|---|---|
| TRAVERSE_NONE | |
| TRAVERSE_PARENTS | |
| TRAVERSE_ALL_CHILDREN | |
| TRAVERSE_ACTIVE_CHILDREN | |
Definition at line 59 of file trCore/Nodes/NodeVisitor.h.
| Enumerator | |
|---|---|
| NODE_VISITOR | |
| UPDATE_VISITOR | |
| EVENT_VISITOR | |
| COLLECT_OCCLUDER_VISITOR | |
| CULL_VISITOR | |
| INTERSECTION_VISITOR | |
Definition at line 67 of file trCore/Nodes/NodeVisitor.h.
| trCore::Nodes::NodeVisitor::NodeVisitor | ( | TraversalMode | tm = TRAVERSE_NONE, |
| const std::string | name = CLASS_TYPE |
||
| ) |
Holds the class type name for efficient comparisons.
Constructor.
| tm | (Optional) The time. |
| name | (Optional) The name. |
Definition at line 168 of file trCore/Nodes/NodeVisitor.cpp.
| trCore::Nodes::NodeVisitor::NodeVisitor | ( | VisitorType | type, |
| TraversalMode | tm = TRAVERSE_NONE, |
||
| const std::string | name = CLASS_TYPE |
||
| ) |
Constructor.
| type | The type. |
| tm | (Optional) The time. |
| name | (Optional) The name. |
Definition at line 174 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trCore::Nodes::ToVisitorType().

|
protected |
Destructor.
Definition at line 340 of file trCore/Nodes/NodeVisitor.cpp.
|
virtual |
Returns a pointer to the internal OSG Node.
Definition at line 194 of file trCore/Nodes/NodeVisitor.cpp.
References trBase::SmrtPtr< T >::Get(), and mNodeVisitor.

|
virtual |
Returns a constant pointer to the internal OSG Node.
Definition at line 200 of file trCore/Nodes/NodeVisitor.cpp.
References trBase::SmrtPtr< T >::Get(), and mNodeVisitor.

|
inlinevirtual |
Get the distance of a point from the eye point, distance value in the eye coordinate system.
Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the GetDistanceFromEyePoint(pos) is not implemented than a default value of 0.0 is returned.*.
| parameter1 | The first parameter. |
| parameter2 | True to parameter 2. |
Definition at line 391 of file trCore/Nodes/NodeVisitor.h.
|
inlinevirtual |
Get the distance from a point to the eye point, distance value in local coordinate system.
Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the GetDistanceFromEyePoint(pos) is not implemented then a default value of 0.0 is returned.
| parameter1 | The first parameter. |
| parameter2 | True to parameter 2. |
Definition at line 376 of file trCore/Nodes/NodeVisitor.h.
|
inlinevirtual |
Get the distance from a point to the view point, distance value in local coordinate system.
Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement. If the GetDistanceToViewPoint(pos) is not implemented then a default value of 0.0 is returned.*.
| parameter1 | The first parameter. |
| parameter2 | True to parameter 2. |
Definition at line 406 of file trCore/Nodes/NodeVisitor.h.
|
inlinevirtual |
Get the eye point in local coordinates.
Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
Definition at line 351 of file trCore/Nodes/NodeVisitor.h.
|
inline |
Get the FrameStamp that this traversal is associated with.
NOTE: The user must handle the destruction of the returned pointer
Definition at line 242 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Definition at line 266 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
| NodePath * trCore::Nodes::NodeVisitor::GetNodePath | ( | ) |
Get the non const NodePath from the top most node applied down to the current Node being visited.
Definition at line 308 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
| const NodePath * trCore::Nodes::NodeVisitor::GetNodePath | ( | ) | const |
Get the const NodePath from the top most node applied down to the current Node being visited.
Definition at line 324 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Get the TraversalMask.
Definition at line 254 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Get the traversal mode.
Definition at line 284 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trCore::Nodes::ToTraversalMode().

|
inline |
Get the traversal number.
Typically used to denote the frame count.
Definition at line 230 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
overridevirtual |
Returns the class type.
Implements trBase::Base.
Definition at line 181 of file trCore/Nodes/NodeVisitor.cpp.
References CLASS_TYPE.
|
inlinevirtual |
Get the view point in local coordinates.
Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
Definition at line 361 of file trCore/Nodes/NodeVisitor.h.
|
inline |
Get the VisitorType.
Definition at line 218 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trCore::Nodes::ToVisitorType().

|
inline |
Method called by Node::Accept() method after a call to NodeVisitor::Apply(..).
Note, the user does not typically call PopFromNodePath() as it will be called automatically by the Node::Accept() method.
Definition at line 302 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Method called by Node::Accept() method before a call to the NodeVisitor::Apply(..).
The back of the list will, therefore, be the current node being visited inside the Apply(..), and the rest of the list will be the parental sequence of nodes from the top most node applied down the graph to the current node. Note, the user does not typically call PushNodeOnPath() as it will be called automatically by the Node::Accept() method.
| [in,out] | node | If non-null, the node. |
Definition at line 296 of file trCore/Nodes/NodeVisitor.cpp.
References trCore::Nodes::Node::AsOSGNode(), and mNodeVisitor.

|
virtual |
Method to call to reset visitor.
Useful if your visitor accumulates state during a traversal, and you plan to reuse the visitor. To flush that state for the next traversal: call reset() prior to each traversal.
Definition at line 206 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Set the FrameStamp that this traversal is associated with.
| [in,out] | fs | If non-null, the file system. |
Definition at line 236 of file trCore/Nodes/NodeVisitor.cpp.
References trCore::Nodes::FrameStamp::AsOSGClass(), and mNodeVisitor.

|
virtual |
Sets this instances name.
| name | The name. |
Reimplemented from trBase::Base.
Definition at line 187 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trBase::Base::SetName().

|
inline |
Definition at line 260 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Set the TraversalMask of this NodeVisitor.
The TraversalMask is used by the NodeVisitor::ValidNodeMask() method to determine whether to operate on a node and its subgraph. ValidNodeMask() is called automatically in the Node::Accept() method before any call to NodeVisitor::Apply(), Apply() is only ever called if ValidNodeMask returns true. Note, if NodeVisitor::_traversalMask is 0 then all operations will be switched off for all nodes. Whereas setting both _traversalMask and _nodeMaskOverride to 0xffffffff will allow a visitor to work on all nodes regardless of their own Node::_nodeMask state.
| mask | The mask. |
Definition at line 248 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Set the traversal mode for Node::Traverse() to use when deciding which children of a node to traverse.
If a NodeVisitor has been attached via SetTraverseVisitor() and the new mode is not TRAVERSE_VISITOR then the attached visitor is detached. Default mode is TRAVERSE_NONE.
| mode | The mode. |
Definition at line 278 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trCore::Nodes::ToTraversalMode().

|
inline |
Set the traversal number.
Typically used to denote the frame count.
| fn | The function. |
Definition at line 224 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor.
|
inline |
Set the VisitorType, used to distinguish different visitors during traversal of the scene, typically used in the Node:Traverse() method to select which behavior to use for different types of traversal/visitors.
| type | The type. |
Definition at line 212 of file trCore/Nodes/NodeVisitor.cpp.
References mNodeVisitor, and trCore::Nodes::ToVisitorType().

|
inline |
Method for handling traversal of a nodes.
If you intend to use the visitor for actively traversing the scene graph then make sure the Accept() methods call this method unless they handle traversal directly.
| [in,out] | node | The node. |
Definition at line 290 of file trCore/Nodes/NodeVisitor.cpp.
References trCore::Nodes::Node::AsOSGNode(), and mNodeVisitor.

|
inline |
Method to called by Node and its subclass' Node::Accept() method, if the result is true it is used to cull operations of nodes and their subgraphs.
Return true if the result of a bit wise and of the NodeVisitor::_traversalMask with the bit or between NodeVistor::_nodeMaskOverride and the Node::_nodeMask. Default values for _traversalMask is 0xffffffff, _nodeMaskOverride is 0x0, and osg::Node::_nodeMask is 0xffffffff.
| node | The node. |
Definition at line 272 of file trCore/Nodes/NodeVisitor.cpp.
References trCore::Nodes::Node::AsOSGNode(), and mNodeVisitor.

|
static |
Adds an easy and swappable access to the base class.
Definition at line 79 of file trCore/Nodes/NodeVisitor.h.
Referenced by GetType(), and trCore::Nodes::ToTraversalMode().
|
protected |
The node visitor.
Definition at line 411 of file trCore/Nodes/NodeVisitor.h.
Referenced by AsOSGVisitor(), GetFrameStamp(), GetNodeMaskOverride(), GetNodePath(), GetTraversalMask(), GetTraversalMode(), GetTraversalNumber(), GetVisitorType(), NodeVisitor(), PopFromNodePath(), PushOntoNodePath(), Reset(), SetFrameStamp(), SetName(), SetNodeMaskOverride(), SetTraversalMask(), SetTraversalMode(), SetTraversalNumber(), SetVisitorType(), Traverse(), and ValidNodeMask().