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: 9.9.13.0 (9.9.13.0)
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

(Overrides SoActionEnableElements.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodForwardTraversal

Traverse a node 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
(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
(Inherited from SoAction.)
Public methodGetOriginalPathListAppliedTo
(Inherited from SoAction.)
Public methodGetPath

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

Public methodGetPathAppliedTo
(Inherited from SoAction.)
Public methodGetPathCode(SbNativeArrayInt32)

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 methodGetPathCode(SbNativeInt32Array) Obsolete.

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
(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 SoSceneManager associated with this action.

(Inherited from SoAction.)
Public methodGetState
(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
(Inherited from SoAction.)
Public methodHasTerminated
(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
(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
(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
(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 (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 (setName()), then reuse the same SoSearchAction object to do a search by type (setType()), the action will actually search for a node that satisfies both criteria. To avoid this problem, call reset() before reusing the action object.

By default SoSearchAction only searches nodes that are actually traversed. For example it would not search all the children of an 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 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 SoPath method getTail() does not return the found node. This is also because nodekits try to keep their children hidden. To avoid this problem cast the returned SoPath to SoFullPath. Hidden references:

    SoSearchAction creates one or more SoPath objects when applied to the scene graph. The 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 SoPath object exists. These SoPath objects are stored internally in the action and exist until the action object itself is reclaimed or reset.

    Efficiency:

    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 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 SoCallbackAction instead.

    For example, if you want to count all the shape nodes in the scene graph, you could use an 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 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 );
 SoFullPath path = (SoFullPath)sa.GetPath();
 if (path) {
   SoNode node = path.GetTail();
 }

Example 2: Find all the 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 (SoFullPath path in pathList)
 {
   SoFont fontNode = (SoFont)path.GetTail();
   . . .
 }

See Also