Blender V5.3
abc_util.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4#pragma once
5
9
10#include "abc_reader_object.h"
11
12#include "BLI_string_ref.hh"
13
14#include <Alembic/Abc/Foundation.h>
15#include <Alembic/Abc/ICompoundProperty.h>
16#include <Alembic/Abc/IObject.h>
17#include <Alembic/Abc/ISampleSelector.h>
18#include <Alembic/Abc/TypedArraySample.h>
19#include <Alembic/AbcCoreAbstract/Foundation.h>
20#include <Alembic/AbcCoreAbstract/TimeSampling.h>
21#include <Alembic/AbcGeom/IXform.h>
22
23#include <optional>
24#include <string>
25#include <vector>
26
27namespace blender {
28
29using Alembic::Abc::chrono_t;
30using Alembic::Abc::V3fArraySamplePtr;
31
32struct ID;
33struct Object;
34
35namespace io::alembic {
36
37class AbcObjectReader;
39
40static inline const std::string ABC_CURVE_RESOLUTION_U_PROPNAME = "blender:resolution";
41static inline const std::string ABC_ACTIVE_COLOR_ATTRIBUTE_PROPNAME =
42 "blender:active_color_attribute";
43static inline const std::string ABC_DEFAULT_COLOR_ATTRIBUTE_PROPNAME =
44 "blender:default_color_attribute";
45
46/* ORCO, Generated Coordinates, and Reference Points ("Pref") are all terms for the same thing.
47 * Other applications (Maya, Houdini) write these to a property called "Pref". */
48static inline const std::string propNameOriginalCoordinates = "Pref";
49
50/* This should only return true if the attribute (or property) is exported in .arbGeomParams. */
52
53std::string get_valid_abc_name(const char *name);
54
55/* Convert from float to Alembic matrix representations. Does NOT convert from Z-up to Y-up. */
56Imath::M44d convert_matrix_datatype(const float mat[4][4]);
57/* Convert from Alembic to float matrix representations. Does NOT convert from Y-up to Z-up. */
58void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4]);
59
60void split(const std::string &s, char delim, std::vector<std::string> &tokens);
61
62template<class TContainer> bool begins_with(const TContainer &input, const TContainer &match)
63{
64 return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
65}
66
67bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name);
68V3fArraySamplePtr get_velocity_prop(const Alembic::Abc::ICompoundProperty &schema,
69 const Alembic::AbcGeom::ISampleSelector &selector,
70 const std::string &name);
71
77 /* Index of the first ("floor") sample. */
78 Alembic::AbcGeom::index_t index;
79 /* Index of the second ("ceil") sample. */
80 Alembic::AbcGeom::index_t ceil_index;
81 /* Factor to interpolate between the `index` and `ceil_index`. */
82 double weight;
83};
84
91std::optional<SampleInterpolationSettings> get_sample_interpolation_settings(
92 const Alembic::AbcGeom::ISampleSelector &selector,
93 const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
94 size_t samples_number);
95
97
98/* Alembic does not have specific enumerations for FaceVaryingInterpolateBoundary and
99 * InterpolateBoundary, rather it uses the values from OpenSubDiv 2.x and RenderMan
100 * directly respectively.
101 *
102 * The identifiers used in the following enumerations are based on their USD equivalent
103 * as used in USD's Alembic writer.
104 */
105
106/* See https://opensubdiv.org/docs/compatibility.html for how to convert values from
107 * OpenSubDiv 2.x to 3.x. */
114
115/* See the RenderMan documentation for those values:
116 * https://rmanwiki-27.pixar.com/space/REN27/542213016/Subdivision+Surfaces#Boundary-Interpolation
117 */
123
124} // namespace io::alembic
125} // namespace blender
bool begins_with(const TContainer &input, const TContainer &match)
Definition abc_util.h:62
std::string get_valid_abc_name(const char *name)
Definition abc_util.cc:36
static const std::string ABC_ACTIVE_COLOR_ATTRIBUTE_PROPNAME
Definition abc_util.h:41
V3fArraySamplePtr get_velocity_prop(const Alembic::Abc::ICompoundProperty &schema, const Alembic::AbcGeom::ISampleSelector &selector, const std::string &name)
Definition abc_util.cc:91
AbcObjectReader * create_reader(const AbcReaderConstructorArgs &args)
Definition abc_util.cc:162
bool is_reserved_attribute_name(const StringRefNull name)
Definition abc_util.cc:31
static const std::string ABC_CURVE_RESOLUTION_U_PROPNAME
Definition abc_util.h:40
Imath::M44d convert_matrix_datatype(const float mat[4][4])
Definition abc_util.cc:46
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name)
Definition abc_util.cc:82
static const std::string ABC_DEFAULT_COLOR_ATTRIBUTE_PROPNAME
Definition abc_util.h:43
static const std::string propNameOriginalCoordinates
Definition abc_util.h:48
std::optional< SampleInterpolationSettings > get_sample_interpolation_settings(const Alembic::AbcGeom::ISampleSelector &selector, const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling, size_t samples_number)
Definition abc_util.cc:129
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
BMesh Iterators.