This document is for a version of USD that is under development. See this page for the current release.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
20PXR_NAMESPACE_OPEN_SCOPE
21
22
29{
30public:
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
77private:
78 VtIntArray _parentIndices;
79};
80
81
82int
83UsdSkelTopology::GetParent(size_t index) const
84{
85 TF_DEV_AXIOM(index < _parentIndices.size());
86 return _parentIndices[index];
87}
88
89
90PXR_NAMESPACE_CLOSE_SCOPE
91
92#endif // PXR_USD_USD_SKEL_TOPOLOGY_H
Represents a range of contiguous elements.
Definition: span.h:71
Object holding information describing skeleton topology.
Definition: topology.h:29
bool IsRoot(size_t index) const
Returns true if the index'th joint is a root joint.
Definition: topology.h:69
UsdSkelTopology()=default
Construct an empty topology.
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
USDSKEL_API UsdSkelTopology(const VtIntArray &parentIndices)
Construct a skel topology from an array of parent indices.
USDSKEL_API bool Validate(std::string *reason=nullptr) const
Validate the topology.
USDSKEL_API UsdSkelTopology(TfSpan< const SdfPath > paths)
Construct a skel topology from paths, an array of joint paths.
USDSKEL_API UsdSkelTopology(TfSpan< const TfToken > paths)
Construct a skel topology from paths, an array holding ordered joint paths as tokens.
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
Definition: diagnostic.h:205
Basic Sdf data types.