Click or drag to resize
SoSearchAction Class

Searches for nodes in a scene graph.

Inheritance Hierarchy

Namespace: OIV.Inventor.Actions
Assembly: OIV.Inventor (in OIV.Inventor.dll) Version: 2024.1.2.0 (2024.1.2)
Syntax
public class SoSearchAction : SoAction

The SoSearchAction type exposes the following members.

Constructors
  NameDescription
Public methodSoSearchAction

Constructor.

Top
Methods
  NameDescription
Public methodAddPath
Public methodApply(SoNode)

Initiates an action on the graph defined by a node.

(Inherited from SoAction.)
Public methodApply(SoPath)

Initiates an action on the graph defined by a path.

(Inherited from SoAction.)
Public methodApply(SoPathList)
Calls Apply(pathList, false).
(Inherited from SoAction.)
Public methodApply(SoPathList, Boolean)

Initiates an action on the graph defined by a list of paths.

(Inherited from SoAction.)
Public methodClearApplyResult

When applied, an action may reference nodes or create objects (e.g.

(Overrides SoActionClearApplyResult.)
Public methodStatic memberEnableElement
Public methodEnableElements Obsolete.
Returns the list of enabled elements for a given action subclass.
(Inherited from SoAction.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodForwardTraversal(SoNode)

Traverse a node that is not part of the current scenegraph.

(Inherited from SoAction.)
Public methodForwardTraversal(SoPath)

Traverse a path that is not part of the current scenegraph.

(Inherited from SoAction.)
Public methodGetContinueActionInBranchFlag

This function indicates if the action must stop in the current branch.

(Inherited from SoAction.)
Public methodGetCurPath

Returns the path accumulated during traversal, i.e., the chain of nodes from the root of the traversed graph to the current node being traversed.

(Inherited from SoAction.)
Public methodGetDistribMode

Returns the distribution mode of this action across a cluster (ScaleViz-Cluster only).

(Inherited from SoAction.)
Public methodGetFind

Returns what to look for.

Public methodGetHashCode
Overrides GetHashCode().
(Inherited from SoNetBase.)
Public methodGetInterest

Returns which paths to return.

Public methodGetName

Returns the name of the node to search for.

Public methodGetNode

Returns the node to search for.

Public methodGetNodeAppliedTo

Returns the node the action is being applied to.

(Inherited from SoAction.)
Public methodGetOriginalPathListAppliedTo

Returns the original path list the action is being applied to.

(Inherited from SoAction.)
Public methodGetPath

Returns resulting path, or NULL if no path was found.

Public methodGetPathAppliedTo

Returns the path the action is being applied to.

(Inherited from SoAction.)
Public methodGetPathCode

Returns path code based on where current node (the node at the end of the current path) lies with respect to the path(s) the action is being applied to.

(Inherited from SoAction.)
Public methodGetPathListAppliedTo

Returns the path list the action is being applied to.

(Inherited from SoAction.)
Public methodGetPaths

Returns resulting path list.

Public methodGetPipeId

Gets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.

(Inherited from SoAction.)
Public methodGetSceneManager

Return the OIV.Inventor.SoSceneManager associated with this action.

(Inherited from SoAction.)
Public methodGetState

Gets the state from the action.

(Inherited from SoAction.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetType(Boolean)

Returns the node type to search for.

Public methodGetWhatAppliedTo

Returns code indicating what action is being applied to.

(Inherited from SoAction.)
Public methodHasTerminated

Returns true if the traversal has reached a termination condition.

(Inherited from SoAction.)
Public methodInvalidateState

Invalidates the current traversal state in the action, forcing it to be recreated when the action is next applied.

(Inherited from SoAction.)
Public methodIsBeingApplied

Returns true if this action is currently being applied.

(Inherited from SoAction.)
Public methodIsFound
Public methodIsLastPathListAppliedTo

Returns true if the current list is the last one from the original.

(Inherited from SoAction.)
Public methodIsSearchingAll

Returns false if searching uses regular traversal, true if it traverses every single node.

Public methodIsUsingAlternateRep

Returns true if current action is using alternate representations.

(Inherited from SoAction.)
Public methodPostDelayedTraversal

Method called by SoMultiPassManager after delayed pass traversals.

(Inherited from SoAction.)
Public methodPreDelayedTraversal

Method called by SoMultiPassManager before delayed pass traversals.

(Inherited from SoAction.)
Public methodReset

Resets options back to default values; clears list of returned paths.

Public methodResetContinueActionInBranchFlag

This function resets the continue action flag.

(Inherited from SoAction.)
Public methodSetFind

Sets what to look for; what is a bitmask of LookFor enum values.

Public methodSetFound
Public methodSetInterest

Sets which paths to return.

Public methodSetName

Sets the name of the node to search for.

Public methodSetNode

Sets the node to search for.

Public methodSetPipeId

Sets pipe identifier in the range [1..N] associated to this render action while running a ScaleViz Multipipe configuration.

(Inherited from SoAction.)
Public methodSetSceneManager

Set the scene manager associated with this action (if any ).

(Inherited from SoAction.)
Public methodSetSearchingAll

Sets whether searching uses regular traversal or whether it traverses every single node.

Public methodSetType(Type)
Calls SetType(t, true).
Public methodSetType(Type, Boolean)

Sets the node type to search for.

Public methodSetUpState

Creates state if it is NULL or it is no longer valid because new elements have been enabled since it was created.

(Inherited from SoAction.)
Public methodStopActionInBranch

This function stops the action in the current Scene Graph branch.

(Inherited from SoAction.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTraverse

Does traversal of a graph rooted by a node.

(Inherited from SoAction.)
Public methodUseAlternateRep

Tell the action to use alternate representations during traversal when available.

(Inherited from SoAction.)
Top
Remarks

This class is used to search scene graphs for specific nodes, nodes of a specific type, nodes with a specific name, or any combination of these. It can search for just the first or last node satisfying the criteria or for all such nodes. The action returns a path (OIV.Inventor.SoPath) to each node found. The searched for node is the "tail" of each path.

Note that the search criteria are cumulative. For example, if you do a search by name (OIV.Inventor.Actions.SoSearchAction.SetName(System.String)), then reuse the same OIV.Inventor.Actions.SoSearchAction object to do a search by type (OIV.Inventor.Actions.SoSearchAction.SetType(System.Type, System.Boolean)), the action will actually search for a node that satisfies both criteria. To avoid this problem, call OIV.Inventor.Actions.SoSearchAction.Reset() before reusing the action object.

By default OIV.Inventor.Actions.SoSearchAction only searches nodes that are actually traversed. For example it would not search all the children of an OIV.Inventor.Nodes.SoSwitch node unless the whichChild field is set to SO_SWITCH_ALL. To search all nodes in the scene graph (except nodekits - see next paragraph) call setSearchingAll(true).

Nodekits:

  • By default OIV.Inventor.Actions.SoSearchAction will not search inside nodekits even when setSearchingAll is true. This is because nodekits try to keep their children hidden. To allow searching inside nodekits call the static method SoBaseKit.setSearchingChildren(true).

  • A common problem is that when the searched for node is found inside a nodekit, the OIV.Inventor.SoPath method getTail() does not return the found node. This is also because nodekits try to keep their children hidden. To avoid this problem use FullPath.GetTail() instead.

Hidden references:

OIV.Inventor.Actions.SoSearchAction creates one or more OIV.Inventor.SoPath objects when applied to the scene graph. The OIV.Inventor.SoPath object references each node in the path. This reference will prevent the node and its associated memory from being reclaimed for as long as the OIV.Inventor.SoPath object exists. These OIV.Inventor.SoPath objects are stored internally in the action and exist until the action object itself is reclaimed or reset.

Efficiency:

OIV.Inventor.Actions.SoSearchAction is convenient for finding one or many nodes in the scene graph. However it may be an inefficient solution for finding a large number of nodes because it uses CPU time and memory to create an OIV.Inventor.SoPath for every node found. If you expect to find many nodes, especially if you just need the node object and not a path, then you should consider using OIV.Inventor.Actions.SoCallbackAction instead.

For example, if you want to count all the shape nodes in the scene graph, you could use an OIV.Inventor.Actions.SoSearchAction similar to the second example below. The number of shapes would conveniently be the number of paths created by the action, but you wouldn't actually make any use of the path information. Using OIV.Inventor.Actions.SoCallbackAction would be a little more work, because you have to implement a counter in a delegate method. But it would be much more efficient because the action simply calls your delegatewhen each shape node is visited during the traversal.

EXAMPLE

Example 1: Given an instance of a node, create a path to the location of that node in the scene graph:

SoSearchAction sa = new SoSearchAction();
 sa.SetNode( coneNode );
 sa.SetSearchingAll( true );              // Optional: Search all nodes
 SoBaseKit.SetSearchingChildren( true );  // Optional: Search inside nodekits
 sa.Apply( root );
 SoPath path = sa.GetPath();
 if (path != null) {
   SoNode node = path.FullPath.GetTail();
 }

Example 2: Find all the OIV.Inventor.Nodes.SoFont nodes in the scene graph:

SoSearchAction sa = new SoSearchAction();
 sa.SetType( typeof(SoFont) );
 sa.SetInterest( SoSearchAction.Interests.ALL );   // Find ALL instances
 sa.SetSearchingAll( true );              // Optional: Search all nodes
 SoBaseKit.SetSearchingChildren( true );  // Optional: Search inside nodekits
 sa.Apply( rootNode );
 SoPathList pathList = sa.GetPaths();     // Get list of paths
 foreach (SoPath path in pathList)
 {
   SoFont fontNode = (SoFont)path.FullPath.GetTail();
   . . .
 }

See Also