All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
modelKindProcessor.h
Go to the documentation of this file.
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 PXRUSDMAYA_MODEL_KIND_PROCESSOR_H
25 #define PXRUSDMAYA_MODEL_KIND_PROCESSOR_H
26 
28 
29 #include "usdMaya/jobArgs.h"
30 #include "usdMaya/primWriter.h"
31 
32 #include "pxr/pxr.h"
33 
34 #include "pxr/usd/usd/prim.h"
35 #include "pxr/usd/usd/stage.h"
36 
37 #include <unordered_map>
38 #include <unordered_set>
39 #include <vector>
40 
41 PXR_NAMESPACE_OPEN_SCOPE
42 
43 
49 {
50 public:
51  UsdMaya_ModelKindProcessor(const UsdMayaJobExportArgs& args);
52 
58  void OnWritePrim(
59  const UsdPrim& prim,
60  const UsdMayaPrimWriterSharedPtr& primWriter);
61 
70 
71 private:
72  typedef std::unordered_map<SdfPath, std::vector<SdfPath>, SdfPath::Hash>
73  _PathVectorMap;
74  typedef std::unordered_map<SdfPath, bool, SdfPath::Hash> _PathBoolMap;
75  typedef std::unordered_set<SdfPath, SdfPath::Hash> _PathSet;
76 
77  UsdMayaJobExportArgs _args;
78 
79  // Precomputes whether _args.rootKind IsA assembly.
80  bool _rootIsAssembly;
81 
82  // Paths on at which we added USD references or authored kind.
83  std::vector<SdfPath> _pathsThatMayHaveKind;
84 
85  // Maps root paths to list of exported gprims under the root path.
86  // The keys in this map are only root prim paths that are assemblies
87  // (either because _args.rootKind=assembly or kind=assembly was previously
88  // authored).
89  // These are just used for error messages.
90  _PathVectorMap _pathsToExportedGprimsMap;
91 
92  // Set of all root paths that contain exported gprims.
93  _PathSet _pathsWithExportedGprims;
94 
95  bool _AuthorRootPrimKinds(
96  UsdStageRefPtr& stage,
97  _PathBoolMap& rootPrimIsComponent);
98 
99  bool _FixUpPrimKinds(
100  UsdStageRefPtr& stage,
101  const _PathBoolMap& rootPrimIsComponent);
102 };
103 
104 
105 PXR_NAMESPACE_CLOSE_SCOPE
106 
107 #endif
bool MakeModelHierarchy(UsdStageRefPtr &stage)
Writes model hierarchy for the given stage based on the information collected by OnWritePrim.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:131
void OnWritePrim(const UsdPrim &prim, const UsdMayaPrimWriterSharedPtr &primWriter)
Processes the given prim in order to collect model hierarchy data.
This class encapsulates all of the logic for writing model kinds from UsdMaya_WriteJob.