topology.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 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_USD_USD_SKEL_TOPOLOGY_H
8 #define PXR_USD_USD_SKEL_TOPOLOGY_H
9 
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usdSkel/api.h"
14 
15 #include "pxr/base/tf/span.h"
16 #include "pxr/usd/sdf/path.h"
17 #include "pxr/usd/sdf/types.h"
18 
19 
20 PXR_NAMESPACE_OPEN_SCOPE
21 
22 
29 {
30 public:
32  UsdSkelTopology() = default;
33 
39  USDSKEL_API
41 
43  USDSKEL_API
45 
49  USDSKEL_API
50  UsdSkelTopology(const VtIntArray& parentIndices);
51 
55  USDSKEL_API
56  bool Validate(std::string* reason=nullptr) const;
57 
58  const VtIntArray& GetParentIndices() const { return _parentIndices; }
59 
60  size_t GetNumJoints() const { return size(); }
61 
62  size_t size() const { return _parentIndices.size(); }
63 
66  inline int GetParent(size_t index) const;
67 
69  bool IsRoot(size_t index) const { return GetParent(index) < 0; }
70 
71  bool operator==(const UsdSkelTopology& o) const;
72 
73  bool operator!=(const UsdSkelTopology& o) const {
74  return !(*this == o);
75  }
76 
77 private:
78  VtIntArray _parentIndices;
79 };
80 
81 
82 int
83 UsdSkelTopology::GetParent(size_t index) const
84 {
85  TF_DEV_AXIOM(index < _parentIndices.size());
86  return _parentIndices[index];
87 }
88 
89 
90 PXR_NAMESPACE_CLOSE_SCOPE
91 
92 #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:206
int GetParent(size_t index) const
Returns the parent joint of the index'th joint, Returns -1 for joints with no parent (roots).
Definition: topology.h:83
UsdSkelTopology()=default
Construct an empty topology.
Object holding information describing skeleton topology.
Definition: topology.h:28
Basic Sdf data types.
Represents a range of contiguous elements.
Definition: span.h:70
USDSKEL_API bool Validate(std::string *reason=nullptr) const
Validate the topology.
bool IsRoot(size_t index) const
Returns true if the index'th joint is a root joint.
Definition: topology.h:69