Open CASCADE Technology Reference Manual 8.0.2
Loading...
Searching...
No Matches
BRepGraph_ParentExplorer Class Reference

Upward occurrence-aware parent traversal for BRepGraph. More...

#include <BRepGraph_ParentExplorer.hxx>

Data Structures

struct  Config
 Consolidated configuration for the explorer. More...

Public Types

enum class  LinkKind { None , Reference , Structural }
 Relationship kind between Current() and CurrentChild(). More...
enum class  TraversalMode { Recursive , DirectParents }
 Upward traversal strategy. More...

Public Member Functions

 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, const Config &theConfig)
 Preferred long-term constructor: all tuning knobs in Config.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode)
 Explore all parents of the starting node.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, TraversalMode theMode)
 Explore parents of the starting node using the given traversal mode.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, const std::optional< BRepGraph_NodeId::Kind > &theAvoidKind, bool theEmitAvoidKind, TraversalMode theMode=TraversalMode::Recursive)
 Explore all parents while pruning branches at the avoid kind.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, BRepGraph_NodeId::Kind theTargetKind)
 Explore only parents of the given kind.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, BRepGraph_NodeId::Kind theTargetKind, TraversalMode theMode)
 Explore only parents of the given kind using the given traversal mode.
 BRepGraph_ParentExplorer (const BRepGraph &theGraph, const BRepGraph_NodeId theNode, BRepGraph_NodeId::Kind theTargetKind, const std::optional< BRepGraph_NodeId::Kind > &theAvoidKind, bool theEmitAvoidKind, TraversalMode theMode=TraversalMode::Recursive)
 Explore parents of the given kind while pruning branches at the avoid kind.
const Config & GetConfig () const
 Returns the traversal configuration this explorer was constructed with. Read-only - configuration is fixed for the lifetime of the explorer.
bool More () const
 True if another matching parent is available.
void Next ()
 Advance to the next matching parent.
BRepGraphInc::NodeInstance Current () const
 Current matching ancestor node with accumulated location and orientation.
BRepGraph_NodeId CurrentChild () const
 Returns the immediate child of Current() on the currently emitted branch. Returns invalid NodeId when no current ancestor is available.
LinkKind CurrentLinkKind () const
 Returns how Current() is linked to CurrentChild().
BRepGraph_RefId CurrentRef () const
 Returns the exact parent-owned RefId linking Current() to CurrentChild(), when that branch step is represented by a reference entry.
const TopLoc_Location & LeafLocation () const
 Accumulated location at the starting node of the current branch.
TopAbs_Orientation LeafOrientation () const
 Accumulated orientation at the starting node of the current branch.
bool IsCurrentBranchRoot () const
 True if Current() is the explicit root node of the current branch.
NCollection_ForwardRangeIterator< BRepGraph_ParentExplorer > begin ()
 Returns an STL-compatible iterator for range-based for loops.
NCollection_ForwardRangeSentinel end () const
 Returns a sentinel marking the end of iteration.

Detailed Description

Upward occurrence-aware parent traversal for BRepGraph.

See also
BRepGraph class comment "Iterator guide" for choosing between iterator types.

Enumerates all ancestor nodes reachable from a starting node. Traversal is path-aware: when the same definition is reached through multiple occurrence paths, each path contributes its own parent sequence with its own accumulated location and orientation.

The traversal follows the actual graph structure transparently - every node kind is visited as a distinct entity (no hidden collapses): Vertex -> Edge, Edge -> CoEdge, CoEdge -> Wire, Wire -> Face, Face -> Shell, Shell -> Solid, Solid -> CompSolid/Compound, topology root -> Occurrence, Product child -> Occurrence, Occurrence -> parent Product.

Traversal modes

  • Recursive: walks the full ancestor chain to the graph roots. Without target kind, all ancestors are emitted. With target kind, only matching ancestors are emitted but intermediate levels are traversed to reach them.
  • DirectParents: yields only the immediate parents of the starting node. No ascent into grandparents. With target kind, only parents matching the kind are returned.

Member Enumeration Documentation

◆ LinkKind

Relationship kind between Current() and CurrentChild().

Enumerator
None 

No current branch step.

Reference 

Current() owns CurrentChild() through a RefId.

Structural 

Current() reaches CurrentChild() through a structural non-ref link.

◆ TraversalMode

Upward traversal strategy.

Enumerator
Recursive 

Walk the full ancestor chain to the graph roots.

DirectParents 

Yields only the immediate parents of the starting node.

Constructor & Destructor Documentation

◆ BRepGraph_ParentExplorer() [1/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
const Config & theConfig )

Preferred long-term constructor: all tuning knobs in Config.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theConfigtraversal configuration

◆ BRepGraph_ParentExplorer() [2/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode )

Explore all parents of the starting node.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored

◆ BRepGraph_ParentExplorer() [3/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
TraversalMode theMode )

Explore parents of the starting node using the given traversal mode.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theModetraversal strategy (recursive or direct parents)

◆ BRepGraph_ParentExplorer() [4/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
const std::optional< BRepGraph_NodeId::Kind > & theAvoidKind,
bool theEmitAvoidKind,
TraversalMode theMode = TraversalMode::Recursive )

Explore all parents while pruning branches at the avoid kind.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theAvoidKindnode kind to avoid ascending through
[in]theEmitAvoidKindif true, emit matching avoid-kind ancestors once
[in]theModetraversal strategy

◆ BRepGraph_ParentExplorer() [5/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
BRepGraph_NodeId::Kind theTargetKind )

Explore only parents of the given kind.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theTargetKindkind of nodes to emit

◆ BRepGraph_ParentExplorer() [6/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
BRepGraph_NodeId::Kind theTargetKind,
TraversalMode theMode )

Explore only parents of the given kind using the given traversal mode.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theTargetKindkind of nodes to emit
[in]theModetraversal strategy

◆ BRepGraph_ParentExplorer() [7/7]

BRepGraph_ParentExplorer::BRepGraph_ParentExplorer ( const BRepGraph & theGraph,
const BRepGraph_NodeId theNode,
BRepGraph_NodeId::Kind theTargetKind,
const std::optional< BRepGraph_NodeId::Kind > & theAvoidKind,
bool theEmitAvoidKind,
TraversalMode theMode = TraversalMode::Recursive )

Explore parents of the given kind while pruning branches at the avoid kind.

Parameters
[in]theGraphgraph to walk
[in]theNodestarting node whose ancestors are explored
[in]theTargetKindkind of nodes to emit
[in]theAvoidKindnode kind to avoid ascending through
[in]theEmitAvoidKindif true, emit matching avoid-kind ancestors once
[in]theModetraversal strategy

Member Function Documentation

◆ begin()

NCollection_ForwardRangeIterator< BRepGraph_ParentExplorer > BRepGraph_ParentExplorer::begin ( )
inline

Returns an STL-compatible iterator for range-based for loops.

◆ Current()

BRepGraphInc::NodeInstance BRepGraph_ParentExplorer::Current ( ) const
inlinenodiscard

Current matching ancestor node with accumulated location and orientation.

◆ CurrentChild()

BRepGraph_NodeId BRepGraph_ParentExplorer::CurrentChild ( ) const
nodiscard

Returns the immediate child of Current() on the currently emitted branch. Returns invalid NodeId when no current ancestor is available.

◆ CurrentLinkKind()

LinkKind BRepGraph_ParentExplorer::CurrentLinkKind ( ) const
nodiscard

Returns how Current() is linked to CurrentChild().

◆ CurrentRef()

BRepGraph_RefId BRepGraph_ParentExplorer::CurrentRef ( ) const
nodiscard

Returns the exact parent-owned RefId linking Current() to CurrentChild(), when that branch step is represented by a reference entry.

Some upward steps are structural and therefore have no parent-owned ref entry even though the parent itself is still emitted by the explorer. In those cases this method returns an invalid RefId, for example for CoEdge->Edge and Occurrence->Product/topology-root.

◆ end()

NCollection_ForwardRangeSentinel BRepGraph_ParentExplorer::end ( ) const
inline

Returns a sentinel marking the end of iteration.

◆ GetConfig()

const Config & BRepGraph_ParentExplorer::GetConfig ( ) const
inlinenodiscard

Returns the traversal configuration this explorer was constructed with. Read-only - configuration is fixed for the lifetime of the explorer.

◆ IsCurrentBranchRoot()

bool BRepGraph_ParentExplorer::IsCurrentBranchRoot ( ) const
nodiscard

True if Current() is the explicit root node of the current branch.

◆ LeafLocation()

const TopLoc_Location & BRepGraph_ParentExplorer::LeafLocation ( ) const
nodiscard

Accumulated location at the starting node of the current branch.

◆ LeafOrientation()

TopAbs_Orientation BRepGraph_ParentExplorer::LeafOrientation ( ) const
nodiscard

Accumulated orientation at the starting node of the current branch.

◆ More()

bool BRepGraph_ParentExplorer::More ( ) const
inlinenodiscard

True if another matching parent is available.

◆ Next()

void BRepGraph_ParentExplorer::Next ( )

Advance to the next matching parent.


The documentation for this class was generated from the following file: