HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
XUSD_FindPrimsTask.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Side Effects Software Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 
18 #include "HUSD_API.h"
19 #include "XUSD_PathSet.h"
20 #include "XUSD_Utils.h"
21 #include <UT/UT_PathPattern.h>
22 #include <UT/UT_Task.h>
24 #include <pxr/usd/usd/stage.h>
25 #include <pxr/usd/usd/primRange.h>
26 #include <pxr/usd/sdf/path.h>
27 #include <pxr/base/tf/token.h>
28 
30 
32 
33 // Generic base class for gathering per-prim information during a multithreaded
34 // traversal of a stage using an XUSD_PathPatthern to restrict the traversal.
36 {
37 public:
38  virtual ~XUSD_FindPrimsTaskData();
39  virtual void addToThreadData(UsdPrim &prim) = 0;
40 };
41 
42 // Subclass of XUSD_FindPrimsTaskData that specifically collects the SdfPaths
43 // of all USD prims found in the traversal into an XUSD_PathSet.
45 {
46 public:
47  ~XUSD_FindPrimPathsTaskData() override;
48  void addToThreadData(UsdPrim &prim) override;
49 
50  void gatherPathsFromThreads(XUSD_PathSet &paths);
51 
52 private:
53  class FindPrimPathsTaskThreadData
54  {
55  public:
56  SdfPathVector myPaths;
57  };
60 
61  FindPrimPathsTaskThreadDataTLS myThreadData;
62 };
63 
64 // Subclass of XUSD_FindPrimsTaskData that specifically collects the UsdPrims
65 // of all USD prims found in the traversal into a UT_Array<UsdPrim>.
67 {
68 public:
69  ~XUSD_FindUsdPrimsTaskData() override;
70  void addToThreadData(UsdPrim &prim) override;
71 
72  void gatherPrimsFromThreads(UT_Array<UsdPrim> &prims);
73  void gatherPrimsFromThreads(std::vector<UsdPrim> &prims);
74 
75 private:
76  class FindUsdPrimsTaskThreadData
77  {
78  public:
79  UT_Array<UsdPrim> myPrims;
80  };
83 
84  FindUsdPrimsTaskThreadDataTLS myThreadData;
85 };
86 
87 // Class for performing a multithreaded traversal of a stage guided by a
88 // UT_PathPattern. Data is collected into an XUSD_FindPrimsTaskData object
89 // by calling its addToThreadData method with all matching prims.
91 {
92 public:
93  XUSD_FindPrimsTask(const UsdPrim& prim,
95  const Usd_PrimFlagsPredicate &predicate,
96  const UT_PathPattern *pattern,
97  const XUSD_SimpleAutoCollection *autocollection);
98 
99  UT_Task *run() override;
100 
101 private:
102  UsdPrim myPrim;
103  XUSD_FindPrimsTaskData &myData;
104  const Usd_PrimFlagsPredicate &myPredicate;
105  const UT_PathPattern *myPattern;
106  const XUSD_SimpleAutoCollection *myAutoCollection;
107  bool myVisited;
108 };
109 
111 
#define HUSD_API
Definition: HUSD_API.h:32
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
Definition: prim.h:132
virtual UT_Task * run()=0
std::vector< class SdfPath > SdfPathVector
A vector of SdfPaths.
Definition: path.h:209
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1346
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
virtual void addToThreadData(UsdPrim &prim)=0
GLubyte * pattern
Definition: glew.h:5711
GLenum const void * paths
Definition: glew.h:13589