All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
repr.h
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 HD_REPR_H
25 #define HD_REPR_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/imaging/hd/api.h"
29 #include "pxr/imaging/hd/drawItem.h"
30 #include "pxr/imaging/hd/tokens.h"
31 #include <vector>
32 
33 PXR_NAMESPACE_OPEN_SCOPE
34 
35 
49 public:
50  explicit HdReprSelector()
51  : refinedToken()
52  , unrefinedToken()
53  , pointsToken() { }
54 
55  explicit HdReprSelector(TfToken const &token)
56  : refinedToken(token)
57  , unrefinedToken()
58  , pointsToken() { }
59 
60  explicit HdReprSelector(
61  TfToken const &refined,
62  TfToken const &unrefined)
63  : refinedToken(refined)
64  , unrefinedToken(unrefined)
65  , pointsToken() { }
66 
67  explicit HdReprSelector(
68  TfToken const &refined,
69  TfToken const &unrefined,
70  TfToken const &points)
71  : refinedToken(refined)
72  , unrefinedToken(unrefined)
73  , pointsToken(points) { }
74 
76  static const size_t MAX_TOPOLOGY_REPRS = 3;
77 
80  HD_API
81  bool Contains(const TfToken &reprToken) const;
82 
85  HD_API
86  bool IsActiveRepr(size_t topologyIndex) const;
87 
90  HD_API
91  bool AnyActiveRepr() const;
92 
99  HD_API
100  HdReprSelector CompositeOver(const HdReprSelector &under) const;
101 
102  HD_API
103  bool operator==(const HdReprSelector &rhs) const;
104 
105  HD_API
106  bool operator!=(const HdReprSelector &rhs) const;
107 
108  HD_API
109  bool operator<(const HdReprSelector &rhs) const;
110 
111  HD_API
112  size_t Hash() const;
113 
114  HD_API
115  char const* GetText() const;
116 
117  HD_API
118  friend std::ostream &operator <<(std::ostream &stream,
119  HdReprSelector const& t);
120 
121 
122  HD_API
123  TfToken const &operator[](size_t topologyIndex) const;
124 
125 private:
126  TfToken refinedToken;
127  TfToken unrefinedToken;
128  TfToken pointsToken;
129 };
130 
147 class HdRepr {
148 public:
149  typedef std::vector<HdDrawItem*> DrawItems;
150 
151  HD_API
152  HdRepr();
153  HD_API
154  virtual ~HdRepr();
155 
157  const DrawItems& GetDrawItems() {
158  return _drawItems;
159  }
160 
162  void AddDrawItem(HdDrawItem *item) {
163  _drawItems.push_back(item);
164  }
165 
170  HdDrawItem* GetDrawItem(size_t index) {
171  return _drawItems[index];
172  }
173 
174 private:
175  // Noncopyable
176  HdRepr(const HdRepr&) = delete;
177  HdRepr& operator=(const HdRepr&) = delete;
178 
179 private:
180  DrawItems _drawItems;
181 };
182 
183 
184 PXR_NAMESPACE_CLOSE_SCOPE
185 
186 #endif //HD_REPR_H
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
HD_API bool AnyActiveRepr() const
Returns true if any of the topology tokens is valid, i.e., neither empty nor disabled.
A draw item is a light-weight representation of an HdRprim&#39;s resources and material to be used for re...
Definition: drawItem.h:66
HD_API bool IsActiveRepr(size_t topologyIndex) const
Returns true if the topology token at an index is active, i.e., neither empty nor disabled...
Describes one or more authored display representations for an rprim.
Definition: repr.h:48
static const size_t MAX_TOPOLOGY_REPRS
Currenly support upto 3 topology tokens.
Definition: repr.h:76
HD_API bool Contains(const TfToken &reprToken) const
Returns true if the passed in reprToken is in the set of tokens for any topology index.
HdDrawItem * GetDrawItem(size_t index)
Returns the draw item at the requested index.
Definition: repr.h:170
HD_API HdReprSelector CompositeOver(const HdReprSelector &under) const
Returns a selector that is the composite of this selector &#39;over&#39; the passed in selector.
An HdRepr refers to a (single) topological representation of an rprim, and owns the draw item(s) that...
Definition: repr.h:147
const DrawItems & GetDrawItems()
Returns the draw items for this representation.
Definition: repr.h:157
void AddDrawItem(HdDrawItem *item)
Transfers ownership of a draw item to this repr.
Definition: repr.h:162