All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
primIndex_StackFrame.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PCP_PRIM_INDEX_STACK_FRAME_H
25 #define PCP_PRIM_INDEX_STACK_FRAME_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/arc.h"
29 #include "pxr/usd/pcp/node.h"
30 #include "pxr/usd/pcp/site.h"
31 
32 PXR_NAMESPACE_OPEN_SCOPE
33 
34 class PcpPrimIndex;
35 
41 class PcpPrimIndex_StackFrame
42 {
43 public:
44  PcpPrimIndex_StackFrame(PcpLayerStackSite const &requestedSite,
45  PcpNodeRef const &parentNode,
46  PcpArc *arcToParent,
47  PcpPrimIndex_StackFrame *previousFrame,
48  PcpPrimIndex const *originatingIndex,
49  bool skipDuplicateNodes)
50  : previousFrame(previousFrame)
51  , requestedSite(requestedSite)
52  , parentNode(parentNode)
53  , arcToParent(arcToParent)
54  , originatingIndex(originatingIndex)
55  , skipDuplicateNodes(skipDuplicateNodes) {}
56 
58  PcpPrimIndex_StackFrame* previousFrame;
59 
62  PcpLayerStackSite requestedSite;
63 
66  PcpNodeRef parentNode;
67 
70  PcpArc* arcToParent;
71 
74  PcpPrimIndex const *originatingIndex;
75 
78  bool skipDuplicateNodes;
79 };
80 
86 class PcpPrimIndex_StackFrameIterator
87 {
88 public:
89  PcpNodeRef node;
90  PcpPrimIndex_StackFrame* previousFrame;
91 
92  PcpPrimIndex_StackFrameIterator(
93  const PcpNodeRef& n, PcpPrimIndex_StackFrame* f)
94  : node(n)
95  , previousFrame(f)
96  {
97  }
98 
100  void Next()
101  {
102  if (node.GetArcType() != PcpArcTypeRoot) {
103  // Step to the next parent within this graph.
104  node = node.GetParentNode();
105  } else if (previousFrame) {
106  // No more parents in this graph, but there is an outer
107  // prim index that this node will become part of.
108  // Step to the (eventual) parent in that graph.
109  node = previousFrame->parentNode;
110  previousFrame = previousFrame->previousFrame;
111  } else {
112  // No more parents.
113  node = PcpNodeRef();
114  }
115  }
116 
118  void NextFrame()
119  {
120  if (previousFrame) {
121  node = previousFrame->parentNode;
122  previousFrame = previousFrame->previousFrame;
123  }
124  else {
125  node = PcpNodeRef();
126  }
127  }
128 
130  PcpArcType GetArcType()
131  {
132  if (node.GetArcType() != PcpArcTypeRoot) {
133  // Use the current node's arc type.
134  return node.GetArcType();
135  } else if (previousFrame) {
136  // No more parents in this graph, but there is an outer
137  // prim index, so consult arcToParent.
138  return previousFrame->arcToParent->type;
139  } else {
140  // No more parents; this must be the absolute final root.
141  return PcpArcTypeRoot;
142  }
143  }
144 };
145 
146 PXR_NAMESPACE_CLOSE_SCOPE
147 
148 #endif // PCP_PRIM_INDEX_STACK_FRAME_H
Represents an arc connecting two nodes in the prim index.
Definition: arc.h:44
A site specifies a path in a layer stack of scene description.
Definition: site.h:117
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:77
PcpNode represents a node in an expression tree for compositing scene description.
Definition: node.h:65
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
Definition: types.h:46