Loading...
Searching...
No Matches
binary.h
1//
2// Copyright 2024 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_BASE_TS_BINARY_H
9#define PXR_BASE_TS_BINARY_H
10
11#include "pxr/pxr.h"
12#include "pxr/base/ts/api.h"
13#include "pxr/base/ts/spline.h"
14#include "pxr/base/ts/types.h"
16
17#include <vector>
18#include <unordered_map>
19#include <cstdint>
20
21PXR_NAMESPACE_OPEN_SCOPE
22
23
24// For writing splines to, and reading them from, binary files.
25//
26struct Ts_BinaryDataAccess
27{
28public:
29 // Get spline data version that is needed to write the given spline.
30 // 1: initial version.
31 // 2: added tangent algorithms None and AutoEase
32 // 3: added loopBoundaryTime to delimit spline extrapolation loop regions,
33 // and repurposed the time-valued header bit to denote a GfTimeCode
34 // value type
35 // 4: added GfDuration valued splines.
36 TS_API
37 static uint8_t GetBinaryFormatVersion(const TsSpline& spline);
38
39 // Write a spline to binary data. There are two outputs: a blob, and a
40 // customData map-of-dictionaries that consists of standard types.
41 TS_API
42 static void GetBinaryData(
43 const TsSpline &spline,
44 std::vector<uint8_t> *buf,
45 const std::unordered_map<TsTime, VtDictionary> **customDataOut);
46
47 // Read a spline out of binary data.
48 TS_API
49 static TsSpline CreateSplineFromBinaryData(
50 const std::vector<uint8_t> &buf,
51 std::unordered_map<TsTime, VtDictionary> &&customData);
52
53private:
54 static TsSpline _ParseV1_4(
55 uint8_t version,
56 const std::vector<uint8_t> &buf,
57 std::unordered_map<TsTime, VtDictionary> &&customData);
58};
59
60
61PXR_NAMESPACE_CLOSE_SCOPE
62
63#endif
A mathematical description of a curved function from time to value.
Definition spline.h:60