Blender  V3.3
abc_writer_mesh.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 #pragma once
3 
8 #include "abc_writer_abstract.h"
10 
11 #include <Alembic/AbcGeom/OPolyMesh.h>
12 #include <Alembic/AbcGeom/OSubD.h>
13 
14 struct ModifierData;
15 
16 namespace blender::io::alembic {
17 
18 /* Writer for Alembic geometry. Does not assume the object is a mesh object. */
20  private:
21  /* Either poly-mesh or subdivision-surface is used, depending on is_subd_.
22  * References to the schema must be kept, or Alembic will not properly write. */
23  Alembic::AbcGeom::OPolyMesh abc_poly_mesh_;
24  Alembic::AbcGeom::OPolyMeshSchema abc_poly_mesh_schema_;
25 
26  Alembic::AbcGeom::OSubD abc_subdiv_;
27  Alembic::AbcGeom::OSubDSchema abc_subdiv_schema_;
28 
29  /* Determines whether a poly mesh or a subdivision surface is exported.
30  * The value is set by an export option but only true if there is a subdivision modifier on the
31  * exported object. */
32  bool is_subd_;
33  ModifierData *subsurf_modifier_;
34 
35  CDStreamConfig m_custom_data_config;
36 
37  public:
38  explicit ABCGenericMeshWriter(const ABCWriterConstructorArgs &args);
39 
40  virtual void create_alembic_objects(const HierarchyContext *context) override;
41  virtual Alembic::Abc::OObject get_alembic_object() const override;
42  Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override;
43 
44  protected:
45  virtual bool is_supported(const HierarchyContext *context) const override;
46  virtual void do_write(HierarchyContext &context) override;
47 
48  virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) = 0;
49  virtual void free_export_mesh(Mesh *mesh);
50 
51  virtual bool export_as_subdivision_surface(Object *ob_eval) const;
52 
53  private:
54  void write_mesh(HierarchyContext &context, Mesh *mesh);
55  void write_subd(HierarchyContext &context, Mesh *mesh);
56  template<typename Schema> void write_face_sets(Object *object, Mesh *mesh, Schema &schema);
57 
58  void write_arb_geo_params(Mesh *me);
59  bool get_velocities(Mesh *mesh, std::vector<Imath::V3f> &vels);
60  void get_geo_groups(Object *object,
61  Mesh *mesh,
62  std::map<std::string, std::vector<int32_t>> &geo_groups);
63 };
64 
65 /* Writer for Alembic geometry of Blender Mesh objects. */
67  public:
69 
70  protected:
71  virtual Mesh *get_export_mesh(Object *object_eval, bool &r_needsfree) override;
72 };
73 
74 } // namespace blender::io::alembic
virtual void do_write(HierarchyContext &context) override
ABCGenericMeshWriter(const ABCWriterConstructorArgs &args)
virtual Alembic::Abc::OObject get_alembic_object() const override
virtual bool is_supported(const HierarchyContext *context) const override
virtual Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree)=0
Alembic::Abc::OCompoundProperty abc_prop_for_custom_props() override
virtual void create_alembic_objects(const HierarchyContext *context) override
virtual bool export_as_subdivision_surface(Object *ob_eval) const
virtual Mesh * get_export_mesh(Object *object_eval, bool &r_needsfree) override
ABCMeshWriter(const ABCWriterConstructorArgs &args)
SocketIndexByIdentifierMap * map