Loading...
Searching...
No Matches
isolatedSubnetwork.h
Go to the documentation of this file.
1//
2// Copyright 2025 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_EXEC_VDF_ISOLATED_SUBNETWORK_H
8#define PXR_EXEC_VDF_ISOLATED_SUBNETWORK_H
9
11
12#include "pxr/pxr.h"
13
14#include "pxr/exec/vdf/api.h"
15#include "pxr/exec/vdf/types.h"
16
17#include "pxr/base/tf/functionRef.h"
18#include "pxr/base/tf/pxrTslRobinMap/robin_map.h"
19#include "pxr/base/tf/pxrTslRobinMap/robin_set.h"
20
21#include <vector>
22
23PXR_NAMESPACE_OPEN_SCOPE
24
25class VdfNetwork;
26class VdfNode;
27
49{
50public:
52 VdfIsolatedSubnetwork &operator=(const VdfIsolatedSubnetwork &) = delete;
53
54 VDF_API
56
59
62 using EditFilter = TfFunctionRef<bool(const VdfNode *)>;
63
77 VDF_API static
78 std::unique_ptr<VdfIsolatedSubnetwork> IsolateBranch(
79 VdfConnection *connection,
80 EditFilter canDelete);
81
96 VDF_API static
97 std::unique_ptr<VdfIsolatedSubnetwork> IsolateBranch(
98 VdfNode *node,
99 EditFilter canDelete);
100
106 VDF_API static
107 std::unique_ptr<VdfIsolatedSubnetwork> New(VdfNetwork *network);
108
121 VDF_API
123 VdfConnection *connection,
124 EditFilter canDelete);
125
141 VDF_API
143 VdfNode *node,
144 EditFilter canDelete);
145
150 VDF_API
152
154 const std::vector<VdfNode *> &GetIsolatedNodes() const {
155 return _nodes;
156 }
157
160 return _connections;
161 }
162
163private:
165
166 // Helper that checks if we can traverse past \p sourceNode.
167 bool _CanTraverse(
168 const VdfNode &sourceNode,
169 EditFilter canDelete);
170
171 // Helper that traverses a branch.
172 void _TraverseBranch(
173 VdfConnection *connection,
174 EditFilter canDelete);
175
176private:
177
178 // The network
179 VdfNetwork *_network;
180
181 // The set of isolated nodes.
182 std::vector<VdfNode *> _nodes;
183
184 // The set of isolated connections.
185 ConnectionSet _connections;
186
187 // Used to keep track of the number of remaining output connections for a
188 // given node that have not yet been determined to be part of the isolated
189 // subnetwork.
191 _unisolatedOutputConnections;
192
193 // Flag that indicates whether or not RemoveIsolatedObjectsFromNetwork has
194 // been called.
195 bool _removedIsolatedObjects = false;
196};
197
198PXR_NAMESPACE_CLOSE_SCOPE
199
200#endif
This class provides a non-owning reference to a type-erased callable object with a specified signatur...
Definition: functionRef.h:19
A class that fully represents a connection between two VdfNodes.
Definition: connection.h:30
A VdfIsolatedSubnetwork builds a collection of VdfNodes and VdfConnections that are disconnected from...
const ConnectionSet & GetIsolatedConnections() const
Returns the set of isolated nodes.
VDF_API bool AddIsolatedBranch(VdfNode *node, EditFilter canDelete)
Isolates all nodes and connections reachable via input connections from node that are not connected v...
VDF_API void RemoveIsolatedObjectsFromNetwork()
Removes all isolated objects from the network.
const std::vector< VdfNode * > & GetIsolatedNodes() const
Returns the set of isolated nodes.
static VDF_API std::unique_ptr< VdfIsolatedSubnetwork > IsolateBranch(VdfConnection *connection, EditFilter canDelete)
Isolates all nodes and connections reachable via input connections from connection that are not conne...
VDF_API bool AddIsolatedBranch(VdfConnection *connection, EditFilter canDelete)
Isolates all nodes and connections reachable via input connections from connection that are not conne...
pxr_tsl::robin_set< VdfConnection *, TfHash > ConnectionSet
A set of isolated connections.
static VDF_API std::unique_ptr< VdfIsolatedSubnetwork > New(VdfNetwork *network)
Creates an empty isolated subnetwork.
static VDF_API std::unique_ptr< VdfIsolatedSubnetwork > IsolateBranch(VdfNode *node, EditFilter canDelete)
Isolates all nodes and connections reachable via input connections from node that are not connected v...
TfFunctionRef< bool(const VdfNode *)> EditFilter
A function that returns true if the given node is allowed to be isolated and deleted.
A VdfNetwork is a collection of VdfNodes and their connections.
Definition: network.h:60
This is the base class for all nodes in a VdfNetwork.
Definition: node.h:53
Implementation of a hash map using open-addressing and the robin hood hashing algorithm with backward...
Definition: robin_map.h:96