All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
alembicReader.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 USDABC_ALEMBICREADER_H
25 #define USDABC_ALEMBICREADER_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/sdf/abstractData.h"
31 #include "pxr/base/tf/token.h"
32 #include <boost/noncopyable.hpp>
33 #include <boost/scoped_ptr.hpp>
34 #include <stdint.h>
35 #include <string>
36 #include <vector>
37 
38 PXR_NAMESPACE_OPEN_SCOPE
39 
40 
41 // Note -- Even though this header is private we try to keep Alembic headers
42 // out of it anyway for simplicity's sake.
43 
48 class UsdAbc_AlembicDataReader : boost::noncopyable {
49 public:
50  typedef int64_t Index;
51 
52  UsdAbc_AlembicDataReader();
53  ~UsdAbc_AlembicDataReader();
54 
57  bool Open(const std::string& filePath);
58 
60  void Close();
61 
63  std::string GetErrors() const;
64 
66  void SetFlag(const TfToken&, bool set = true);
67 
69  bool HasSpec(const SdfPath& path) const;
70 
72  SdfSpecType GetSpecType(const SdfPath& path) const;
73 
76  bool HasField(const SdfPath& path,
77  const TfToken& fieldName,
78  SdfAbstractDataValue* value) const;
79 
82  bool HasField(const SdfPath& path,
83  const TfToken& fieldName,
84  VtValue* value) const;
85 
88  bool HasValue(const SdfPath& path, Index index,
89  SdfAbstractDataValue* value) const;
90 
93  bool HasValue(const SdfPath& path, Index index,
94  VtValue* value) const;
95 
97  void VisitSpecs(const SdfAbstractData& owner,
98  SdfAbstractDataSpecVisitor* visitor) const;
99 
101  TfTokenVector List(const SdfPath& path) const;
102 
105  class TimeSamples {
106  typedef std::vector<double> _UsdTimeCodes;
107  public:
108  typedef _UsdTimeCodes::const_iterator const_iterator;
109 
111  TimeSamples();
112 
115  TimeSamples(const std::vector<double>& times);
116 
118  void Swap(TimeSamples& other);
119 
121  bool IsEmpty() const;
122 
124  size_t GetSize() const;
125 
127  std::set<double> GetTimes() const;
128 
130  double operator[](size_t index) const;
131 
133  void AddTo(std::set<double>*) const;
134 
137  bool FindIndex(double usdTime, Index* index) const;
138 
140  bool Bracket(double usdTime, double* tLower, double* tUpper) const;
141 
143  template <class T>
144  static bool Bracket(const T&, double usdTime,
145  double* tLower, double* tUpper);
146 
147  private:
148  // The monotonically increasing Usd times.
149  _UsdTimeCodes _times;
150  };
151 
153  const std::set<double>& ListAllTimeSamples() const;
154 
156  const TimeSamples&
157  ListTimeSamplesForPath(const SdfPath& path) const;
158 
159 private:
160  boost::scoped_ptr<class UsdAbc_AlembicDataReaderImpl> _impl;
161  std::string _errorLog;
162 };
163 
164 
165 PXR_NAMESPACE_CLOSE_SCOPE
166 
167 #endif
Base class for objects used to visit specs in an SdfAbstractData object.
Definition: abstractData.h:561
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:394
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:287
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182
Interface for scene description data storage.
Definition: abstractData.h:73