Blender  V3.3
abc_util.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
8 #include <Alembic/Abc/All.h>
9 #include <Alembic/AbcGeom/All.h>
10 
11 using Alembic::Abc::chrono_t;
12 
13 struct ID;
14 struct Object;
15 
16 namespace blender::io::alembic {
17 
18 class AbcObjectReader;
19 struct ImportSettings;
20 
21 std::string get_id_name(const ID *const id);
22 std::string get_id_name(const Object *const ob);
23 std::string get_valid_abc_name(const char *name);
33 std::string get_object_dag_path_name(const Object *const ob, Object *dupli_parent);
34 
35 /* Convert from float to Alembic matrix representations. Does NOT convert from Z-up to Y-up. */
36 Imath::M44d convert_matrix_datatype(float mat[4][4]);
37 /* Convert from Alembic to float matrix representations. Does NOT convert from Y-up to Z-up. */
38 void convert_matrix_datatype(const Imath::M44d &xform, float r_mat[4][4]);
39 
40 void split(const std::string &s, char delim, std::vector<std::string> &tokens);
41 
42 template<class TContainer> bool begins_with(const TContainer &input, const TContainer &match)
43 {
44  return input.size() >= match.size() && std::equal(match.begin(), match.end(), input.begin());
45 }
46 
47 template<typename Schema>
48 void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max)
49 {
50  const Alembic::Abc::TimeSamplingPtr &time_samp = schema.getTimeSampling();
51 
52  if (!schema.isConstant()) {
53  const size_t num_samps = schema.getNumSamples();
54 
55  if (num_samps > 0) {
56  const chrono_t min_time = time_samp->getSampleTime(0);
57  min = std::min(min, min_time);
58 
59  const chrono_t max_time = time_samp->getSampleTime(num_samps - 1);
60  max = std::max(max, max_time);
61  }
62  }
63 }
64 
65 template<typename Schema>
66 void get_min_max_time(const Alembic::AbcGeom::IObject &object,
67  const Schema &schema,
68  chrono_t &min,
69  chrono_t &max)
70 {
71  get_min_max_time_ex(schema, min, max);
72 
73  const Alembic::AbcGeom::IObject &parent = object.getParent();
74  if (parent.valid() && Alembic::AbcGeom::IXform::matches(parent.getMetaData())) {
75  Alembic::AbcGeom::IXform xform(parent, Alembic::AbcGeom::kWrapExisting);
76  get_min_max_time_ex(xform.getSchema(), min, max);
77  }
78 }
79 
80 bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name);
81 
82 double get_weight_and_index(Alembic::AbcCoreAbstract::chrono_t time,
83  const Alembic::AbcCoreAbstract::TimeSamplingPtr &time_sampling,
84  int samples_number,
85  Alembic::AbcGeom::index_t &i0,
86  Alembic::AbcGeom::index_t &i1);
87 
88 AbcObjectReader *create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings);
89 
90 /* *************************** */
91 
92 #undef ABC_DEBUG_TIME
93 
94 class ScopeTimer {
95  const char *m_message;
96  double m_start;
97 
98  public:
99  ScopeTimer(const char *message);
100  ~ScopeTimer();
101 };
102 
103 #ifdef ABC_DEBUG_TIME
104 # define SCOPE_TIMER(message) ScopeTimer prof(message)
105 #else
106 # define SCOPE_TIMER(message)
107 #endif
108 
109 /* *************************** */
110 
121  std::ostringstream m_stream;
122 
123  public:
127  std::string str() const;
128 
132  void clear();
133 
138  std::ostringstream &stream();
139 };
140 
141 #define ABC_LOG(logger) logger.stream()
142 
146 std::ostream &operator<<(std::ostream &os, const SimpleLogger &logger);
147 
148 } // namespace blender::io::alembic
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
ScopeTimer(const char *message)
Definition: abc_util.cc:205
std::ostringstream & stream()
Definition: abc_util.cc:228
double time
ccl_global KernelShaderEvalInput * input
static void get_weight_and_index(CDStreamConfig &config, Alembic::AbcCoreAbstract::TimeSamplingPtr time_sampling, size_t samples_number)
bool begins_with(const TContainer &input, const TContainer &match)
Definition: abc_util.h:42
void get_min_max_time(const Alembic::AbcGeom::IObject &object, const Schema &schema, chrono_t &min, chrono_t &max)
Definition: abc_util.h:66
std::string get_valid_abc_name(const char *name)
Definition: abc_util.cc:43
std::ostream & operator<<(std::ostream &os, const SimpleLogger &logger)
Definition: abc_util.cc:233
std::string get_object_dag_path_name(const Object *const ob, Object *dupli_parent)
get_object_dag_path_name returns the name under which the object will be exported in the Alembic file...
Definition: abc_util.cc:52
std::string get_id_name(const Object *const ob)
Definition: abc_util.cc:29
Imath::M44d convert_matrix_datatype(float mat[4][4])
Definition: abc_util.cc:70
bool has_property(const Alembic::Abc::ICompoundProperty &prop, const std::string &name)
Definition: abc_util.cc:106
void get_min_max_time_ex(const Schema &schema, chrono_t &min, chrono_t &max)
Definition: abc_util.h:48
AbcObjectReader * create_reader(const Alembic::AbcGeom::IObject &object, ImportSettings &settings)
Definition: abc_util.cc:151
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition: abc_util.cc:92
#define min(a, b)
Definition: sort.c:35
Definition: DNA_ID.h:368
float max