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_PLUGIN_USD_ABC_ALEMBIC_DATA_H 25 #define PXR_USD_PLUGIN_USD_ABC_ALEMBIC_DATA_H 26 27 #include "pxr/pxr.h" 28 #include "pxr/usd/sdf/data.h" 29 #include "pxr/usd/sdf/fileFormat.h" 30 #include "pxr/base/tf/declarePtrs.h" 31 #include <boost/shared_ptr.hpp> 32 33 PXR_NAMESPACE_OPEN_SCOPE 34 35 36 TF_DECLARE_WEAK_AND_REF_PTRS(UsdAbc_AlembicData); 37 38 /// \class UsdAbc_AlembicData 39 /// 40 /// Provides an SdfAbstractData interface to Alembic data. 41 /// 42 class UsdAbc_AlembicData : public SdfAbstractData { 43 public: 44 /// Returns a new \c UsdAbc_AlembicData object. Outside a successful 45 /// \c Open() and \c Close() pairing, the data acts as if it contains 46 /// a pseudo-root prim spec at the absolute root path. 47 static UsdAbc_AlembicDataRefPtr New( 48 SdfFileFormat::FileFormatArguments = {}); 49 50 /// Opens the Alembic file at \p filePath read-only (closing any open 51 /// file). Alembic is not meant to be used as an in-memory store for 52 /// editing so methods that modify the file are not supported. 53 /// \sa Write(). 54 bool Open(const std::string& filePath); 55 56 /// Closes the Alembic file. This does nothing if already closed. 57 /// After the call it's as if the object was just created by New(). 58 void Close(); 59 60 /// Write the contents of \p data to a new or truncated Alembic file at 61 /// \p filePath with the comment \p comment. \p data is not modified. 62 static bool Write(const SdfAbstractDataConstPtr& data, 63 const std::string& filePath, 64 const std::string& comment); 65 66 // SdfAbstractData overrides 67 virtual bool StreamsData() const; 68 virtual void CreateSpec(const SdfPath&, SdfSpecType specType); 69 virtual bool HasSpec(const SdfPath&) const; 70 virtual void EraseSpec(const SdfPath&); 71 virtual void MoveSpec(const SdfPath& oldPath, const SdfPath& newPath); 72 virtual SdfSpecType GetSpecType(const SdfPath&) const; 73 virtual bool Has(const SdfPath&, const TfToken& fieldName, 74 SdfAbstractDataValue* value) const; 75 virtual bool Has(const SdfPath&, const TfToken& fieldName, 76 VtValue* value = NULL) const; 77 virtual VtValue Get(const SdfPath&, const TfToken& fieldName) const; 78 virtual void Set(const SdfPath&, const TfToken& fieldName, 79 const VtValue& value); 80 virtual void Set(const SdfPath&, const TfToken& fieldName, 81 const SdfAbstractDataConstValue& value); 82 virtual void Erase(const SdfPath&, const TfToken& fieldName); 83 virtual std::vector<TfToken> List(const SdfPath&) const; 84 virtual std::set<double> 85 ListAllTimeSamples() const; 86 virtual std::set<double> 87 ListTimeSamplesForPath(const SdfPath&) const; 88 virtual bool 89 GetBracketingTimeSamples(double time, double* tLower, double* tUpper) const; 90 virtual size_t 91 GetNumTimeSamplesForPath(const SdfPath& path) const; 92 virtual bool 93 GetBracketingTimeSamplesForPath(const SdfPath&, 94 double time, 95 double* tLower, double* tUpper) const; 96 virtual bool 97 QueryTimeSample(const SdfPath&, double time, 98 SdfAbstractDataValue* value) const; 99 virtual bool 100 QueryTimeSample(const SdfPath&, double time, 101 VtValue* value) const; 102 virtual void 103 SetTimeSample(const SdfPath&, double, const VtValue&); 104 virtual void 105 EraseTimeSample(const SdfPath&, double); 106 107 protected: 108 UsdAbc_AlembicData(SdfFileFormat::FileFormatArguments); 109 virtual ~UsdAbc_AlembicData(); 110 111 // SdfAbstractData overrides 112 virtual void _VisitSpecs(SdfAbstractDataSpecVisitor* visitor) const; 113 114 private: 115 boost::shared_ptr<class UsdAbc_AlembicDataReader> _reader; 116 const SdfFileFormat::FileFormatArguments _arguments; 117 }; 118 119 120 PXR_NAMESPACE_CLOSE_SCOPE 121 122 #endif // PXR_USD_PLUGIN_USD_ABC_ALEMBIC_DATA_H 123