All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
topology.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 PXR_USD_USD_SKEL_TOPOLOGY_H
25 #define PXR_USD_USD_SKEL_TOPOLOGY_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usdSkel/api.h"
31 
32 #include "pxr/base/tf/span.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/usd/sdf/types.h"
35 
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 
46 {
47 public:
49  UsdSkelTopology() = default;
50 
56  USDSKEL_API
58 
60  USDSKEL_API
62 
66  USDSKEL_API
67  UsdSkelTopology(const VtIntArray& parentIndices);
68 
72  USDSKEL_API
73  bool Validate(std::string* reason=nullptr) const;
74 
75  const VtIntArray& GetParentIndices() const { return _parentIndices; }
76 
77  size_t GetNumJoints() const { return size(); }
78 
79  size_t size() const { return _parentIndices.size(); }
80 
83  inline int GetParent(size_t index) const;
84 
86  bool IsRoot(size_t index) const { return GetParent(index) < 0; }
87 
88  bool operator==(const UsdSkelTopology& o) const;
89 
90  bool operator!=(const UsdSkelTopology& o) const {
91  return !(*this == o);
92  }
93 
94 private:
95  VtIntArray _parentIndices;
96 };
97 
98 
99 int
100 UsdSkelTopology::GetParent(size_t index) const
101 {
102  TF_DEV_AXIOM(index < _parentIndices.size());
103  return _parentIndices[index];
104 }
105 
106 
107 PXR_NAMESPACE_CLOSE_SCOPE
108 
109 #endif // PXR_USD_USD_SKEL_TOPOLOGY_H
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
Definition: diagnostic.h:222
UsdSkelTopology()=default
Construct an empty topology.
Object holding information describing skeleton topology.
Definition: topology.h:45
Basic Sdf data types.
bool IsRoot(size_t index) const
Returns true if the index&#39;th joint is a root joint.
Definition: topology.h:86
Represents a range of contiguous elements.
Definition: span.h:87
int GetParent(size_t index) const
Returns the parent joint of the index&#39;th joint, Returns -1 for joints with no parent (roots)...
Definition: topology.h:100
USDSKEL_API bool Validate(std::string *reason=nullptr) const
Validate the topology.