1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License 4 * as published by the Free Software Foundation; either version 2 5 * of the License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * GNU General Public License for more details. 11 * 12 * You should have received a copy of the GNU General Public License 13 * along with this program; if not, write to the Free Software Foundation, 14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 * 16 * The Original Code is Copyright (C) 2020 Blender Foundation. 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup Alembic 22 */ 23 24 #pragma once 25 26 #include "ABC_alembic.h" 27 #include "IO_abstract_hierarchy_iterator.h" 28 29 #include <Alembic/Abc/OArchive.h> 30 #include <Alembic/Abc/OTypedScalarProperty.h> 31 32 #include <fstream> 33 #include <set> 34 #include <string> 35 36 struct Main; 37 struct Scene; 38 39 namespace blender::io::alembic { 40 41 /* Container for an Alembic archive and time sampling info. 42 * 43 * Constructor arguments are used to create the correct output stream and to set the archive's 44 * metadata. */ 45 class ABCArchive { 46 public: 47 typedef std::set<double> Frames; 48 49 Alembic::Abc::OArchive *archive; 50 51 ABCArchive(const Main *bmain, 52 const Scene *scene, 53 AlembicExportParams params, 54 std::string filename); 55 ~ABCArchive(); 56 57 uint32_t time_sampling_index_transforms() const; 58 uint32_t time_sampling_index_shapes() const; 59 60 Frames::const_iterator frames_begin() const; 61 Frames::const_iterator frames_end() const; 62 size_t total_frame_count() const; 63 64 bool is_xform_frame(double frame) const; 65 bool is_shape_frame(double frame) const; 66 67 ExportSubset export_subset_for_frame(double frame) const; 68 69 void update_bounding_box(const Imath::Box3d &bounds); 70 71 private: 72 std::ofstream abc_ostream_; 73 uint32_t time_sampling_index_transforms_; 74 uint32_t time_sampling_index_shapes_; 75 76 Frames xform_frames_; 77 Frames shape_frames_; 78 Frames export_frames_; 79 80 Alembic::Abc::OBox3dProperty abc_archive_bbox_; 81 }; 82 83 } // namespace blender::io::alembic 84