Alembic: remove support for HDF5 archive format

Alembic is not a single file format, it can be stored in two different
ways: Ogawa and HDF5. Ogawa replaced HDF5 and is smaller and much faster
(4-25x) to read ([source](http://exocortex.com/blog/alembic_is_about_to_get_really_fast)).

As long as Blender has had Alembic support, it has never supported the
HDF5 format in any release. There is a build option `WITH_ALEMBIC_HDF5`
that can be used to enable HDF5 support in your own build. This commit
removes this build option and the code that it manages.

In the years that I have been maintainer of Blender's Alembic code, I
only remember getting a request to support HDF5 once, and that was to
support very old software that has likely since then been updated to
support Ogawa. Ubuntu and Fedora also seem to bundle Blender without
HDF5 support.

This decision was discussed on
[DevTalk](https://devtalk.blender.org/t/alembic-hdf5-support-completely-remove)
where someone also mentioned that there is a tool available that can
convert HDF5 files to the Ogawa format.
This commit is contained in:
Sybren A. Stüvel 2020-06-15 11:06:46 +02:00
parent ece7ebb3a8
commit 0c38436227
Notes: blender-bot 2023-02-14 08:40:26 +01:00
Referenced by commit f5866f484f, Remove patch for HDF5 library
Referenced by commit 0102b9d47e, Alembic: remove HDF5 support from CMake files
13 changed files with 13 additions and 142 deletions

View File

@ -66,10 +66,6 @@ if(WITH_ALEMBIC)
bf_alembic
)
add_definitions(-DWITH_ALEMBIC)
if(WITH_ALEMBIC_HDF5)
add_definitions(-DWITH_ALEMBIC_HDF5)
endif()
endif()
if(WITH_USD)

View File

@ -133,7 +133,6 @@ static int wm_alembic_export_exec(bContext *C, wmOperator *op)
.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
.export_hair = RNA_boolean_get(op->ptr, "export_hair"),
.export_particles = RNA_boolean_get(op->ptr, "export_particles"),
.compression_type = RNA_enum_get(op->ptr, "compression_type"),
.packuv = RNA_boolean_get(op->ptr, "packuv"),
.triangulate = RNA_boolean_get(op->ptr, "triangulate"),
.quad_method = RNA_enum_get(op->ptr, "quad_method"),
@ -163,15 +162,6 @@ static void ui_alembic_export_settings(uiLayout *layout, PointerRNA *imfptr)
uiLayout *row;
uiLayout *col;
# ifdef WITH_ALEMBIC_HDF5
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Archive Options:"), ICON_NONE);
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "compression_type", 0, NULL, ICON_NONE);
# endif
box = uiLayoutBox(layout);
row = uiLayoutRow(box, false);
uiItemL(row, IFACE_("Manual Transform:"), ICON_NONE);
@ -429,13 +419,6 @@ void WM_OT_alembic_export(wmOperatorType *ot)
"Curves as Mesh",
"Export curves and NURBS surfaces as meshes");
RNA_def_enum(ot->srna,
"compression_type",
rna_enum_abc_compression_items,
ABC_ARCHIVE_OGAWA,
"Compression",
"");
RNA_def_float(
ot->srna,
"global_scale",

View File

@ -35,11 +35,6 @@ struct bContext;
typedef struct AbcArchiveHandle AbcArchiveHandle;
enum {
ABC_ARCHIVE_OGAWA = 0,
ABC_ARCHIVE_HDF5 = 1,
};
int ABC_get_version(void);
struct AlembicExportParams {
@ -68,8 +63,6 @@ struct AlembicExportParams {
bool export_hair;
bool export_particles;
unsigned int compression_type : 1;
/* See MOD_TRIANGULATE_NGON_xxx and MOD_TRIANGULATE_QUAD_xxx
* in DNA_modifier_types.h */
int quad_method;

View File

@ -36,7 +36,6 @@ set(INC
set(INC_SYS
${ALEMBIC_INCLUDE_DIRS}
${BOOST_INCLUDE_DIR}
${HDF5_INCLUDE_DIRS}
${OPENEXR_INCLUDE_DIRS}
)
@ -98,13 +97,6 @@ set(LIB
${OPENEXR_LIBRARIES}
)
if(WITH_ALEMBIC_HDF5)
add_definitions(-DWITH_ALEMBIC_HDF5)
list(APPEND LIB
${HDF5_LIBRARIES}
)
endif()
list(APPEND LIB
${BOOST_LIBRARIES}
)

View File

@ -93,7 +93,6 @@ ExportSettings::ExportSettings()
apply_subdiv(false),
use_subdiv_schema(false),
export_child_hairs(true),
export_ogawa(true),
pack_uv(false),
triangulate(false),
quad_method(0),
@ -276,8 +275,7 @@ void AbcExporter::operator()(short *do_update, float *progress, bool *was_cancel
abc_scene_name = "untitled";
}
m_writer = new ArchiveWriter(
m_filename, abc_scene_name, m_settings.scene, m_settings.export_ogawa);
m_writer = new ArchiveWriter(m_filename, abc_scene_name, m_settings.scene);
/* Create time samplings for transforms and shapes. */

View File

@ -73,7 +73,6 @@ struct ExportSettings {
bool curves_as_mesh;
bool use_subdiv_schema;
bool export_child_hairs;
bool export_ogawa;
bool pack_uv;
bool triangulate;

View File

@ -40,11 +40,8 @@ using Alembic::Abc::IArchive;
using Alembic::Abc::kWrapExisting;
static IArchive open_archive(const std::string &filename,
const std::vector<std::istream *> &input_streams,
bool &is_hdf5)
const std::vector<std::istream *> &input_streams)
{
is_hdf5 = false;
try {
Alembic::AbcCoreOgawa::ReadArchive archive_reader(input_streams);
@ -53,22 +50,7 @@ static IArchive open_archive(const std::string &filename,
catch (const Exception &e) {
std::cerr << e.what() << '\n';
#ifdef WITH_ALEMBIC_HDF5
try {
is_hdf5 = true;
Alembic::AbcCoreAbstract::ReadArraySampleCachePtr cache_ptr;
return IArchive(Alembic::AbcCoreHDF5::ReadArchive(),
filename.c_str(),
ErrorHandler::kThrowPolicy,
cache_ptr);
}
catch (const Exception &) {
std::cerr << e.what() << '\n';
return IArchive();
}
#else
/* Inspect the file to see whether it's really a HDF5 file. */
/* Inspect the file to see whether it's actually a HDF5 file. */
char header[4]; /* char(0x89) + "HDF" */
std::ifstream the_file(filename.c_str(), std::ios::in | std::ios::binary);
if (!the_file) {
@ -81,16 +63,12 @@ static IArchive open_archive(const std::string &filename,
std::cerr << filename << " has an unknown file format, unable to read." << std::endl;
}
else {
is_hdf5 = true;
std::cerr << filename << " is in the obsolete HDF5 format, unable to read." << std::endl;
}
if (the_file.is_open()) {
the_file.close();
}
return IArchive();
#endif
}
return IArchive();
@ -113,18 +91,7 @@ ArchiveReader::ArchiveReader(struct Main *bmain, const char *filename)
m_streams.push_back(&m_infile);
m_archive = open_archive(abs_filename, m_streams, m_is_hdf5);
/* We can't open an HDF5 file from a stream, so close it. */
if (m_is_hdf5) {
m_infile.close();
m_streams.clear();
}
}
bool ArchiveReader::is_hdf5() const
{
return m_is_hdf5;
m_archive = open_archive(abs_filename, m_streams);
}
bool ArchiveReader::valid() const

View File

@ -25,11 +25,6 @@
#define __ABC_READER_ARCHIVE_H__
#include <Alembic/Abc/All.h>
#ifdef WITH_ALEMBIC_HDF5
# include <Alembic/AbcCoreHDF5/All.h>
#endif
#include <Alembic/AbcCoreOgawa/All.h>
#include <fstream>
@ -46,21 +41,12 @@ class ArchiveReader {
Alembic::Abc::IArchive m_archive;
std::ifstream m_infile;
std::vector<std::istream *> m_streams;
bool m_is_hdf5;
public:
ArchiveReader(struct Main *bmain, const char *filename);
bool valid() const;
/**
* Returns true when either Blender is compiled with HDF5 support and
* the archive was successfully opened (valid() will also return true),
* or when Blender was built without HDF5 support but a HDF5 file was
* detected (valid() will return false).
*/
bool is_hdf5() const;
Alembic::Abc::IObject getTop();
};

View File

@ -43,10 +43,8 @@ using Alembic::Abc::OArchive;
/* This kinda duplicates CreateArchiveWithInfo, but Alembic does not seem to
* have a version supporting streams. */
static OArchive create_archive(std::ostream *ostream,
const std::string &filename,
const std::string &scene_name,
double scene_fps,
bool ogawa)
double scene_fps)
{
Alembic::Abc::MetaData abc_metadata;
@ -73,38 +71,25 @@ static OArchive create_archive(std::ostream *ostream,
abc_metadata.set(Alembic::Abc::kDateWrittenKey, buffer);
ErrorHandler::Policy policy = ErrorHandler::kThrowPolicy;
#ifdef WITH_ALEMBIC_HDF5
if (!ogawa) {
return OArchive(Alembic::AbcCoreHDF5::WriteArchive(), filename, abc_metadata, policy);
}
#else
static_cast<void>(filename);
static_cast<void>(ogawa);
#endif
Alembic::AbcCoreOgawa::WriteArchive archive_writer;
return OArchive(archive_writer(ostream, abc_metadata), kWrapExisting, policy);
}
ArchiveWriter::ArchiveWriter(const char *filename,
const std::string &abc_scene_name,
const Scene *scene,
bool do_ogawa)
const Scene *scene)
{
/* Use stream to support unicode character paths on Windows. */
if (do_ogawa) {
#ifdef WIN32
UTF16_ENCODE(filename);
std::wstring wstr(filename_16);
m_outfile.open(wstr.c_str(), std::ios::out | std::ios::binary);
UTF16_UN_ENCODE(filename);
UTF16_ENCODE(filename);
std::wstring wstr(filename_16);
m_outfile.open(wstr.c_str(), std::ios::out | std::ios::binary);
UTF16_UN_ENCODE(filename);
#else
m_outfile.open(filename, std::ios::out | std::ios::binary);
m_outfile.open(filename, std::ios::out | std::ios::binary);
#endif
}
m_archive = create_archive(&m_outfile, filename, abc_scene_name, FPS, do_ogawa);
m_archive = create_archive(&m_outfile, abc_scene_name, FPS);
}
OArchive &ArchiveWriter::archive()

View File

@ -25,11 +25,6 @@
#define __ABC_WRITER_ARCHIVE_H__
#include <Alembic/Abc/All.h>
#ifdef WITH_ALEMBIC_HDF5
# include <Alembic/AbcCoreHDF5/All.h>
#endif
#include <Alembic/AbcCoreOgawa/All.h>
#include <fstream>
@ -47,10 +42,7 @@ class ArchiveWriter {
Alembic::Abc::OArchive m_archive;
public:
ArchiveWriter(const char *filename,
const std::string &abc_scene_name,
const Scene *scene,
bool do_ogawa);
ArchiveWriter(const char *filename, const std::string &abc_scene_name, const Scene *scene);
Alembic::Abc::OArchive &archive();
};

View File

@ -373,7 +373,6 @@ bool ABC_export(Scene *scene,
job->settings.renderable_only = params->renderable_only;
job->settings.use_subdiv_schema = params->use_subdiv_schema;
job->settings.export_ogawa = (params->compression_type == ABC_ARCHIVE_OGAWA);
job->settings.pack_uv = params->packuv;
job->settings.global_scale = params->global_scale;
job->settings.triangulate = params->triangulate;
@ -620,7 +619,6 @@ static std::pair<bool, AbcObjectReader *> visit_object(
enum {
ABC_NO_ERROR = 0,
ABC_ARCHIVE_FAIL,
ABC_UNSUPPORTED_HDF5,
};
struct ImportJobData {
@ -659,11 +657,7 @@ static void import_startjob(void *user_data, short *stop, short *do_update, floa
ArchiveReader *archive = new ArchiveReader(data->bmain, data->filename);
if (!archive->valid()) {
#ifndef WITH_ALEMBIC_HDF5
data->error_code = archive->is_hdf5() ? ABC_UNSUPPORTED_HDF5 : ABC_ARCHIVE_FAIL;
#else
data->error_code = ABC_ARCHIVE_FAIL;
#endif
delete archive;
return;
}
@ -850,9 +844,6 @@ static void import_endjob(void *user_data)
case ABC_ARCHIVE_FAIL:
WM_report(RPT_ERROR, "Could not open Alembic archive for reading! See console for detail.");
break;
case ABC_UNSUPPORTED_HDF5:
WM_report(RPT_ERROR, "Alembic archive in obsolete HDF5 format is not supported.");
break;
}
WM_main_add_notifier(NC_SCENE | ND_FRAME, data->scene);

View File

@ -225,7 +225,6 @@ extern const EnumPropertyItem rna_enum_dt_mix_mode_items[];
extern const EnumPropertyItem rna_enum_dt_layers_select_src_items[];
extern const EnumPropertyItem rna_enum_dt_layers_select_dst_items[];
extern const EnumPropertyItem rna_enum_abc_compression_items[];
extern const EnumPropertyItem rna_enum_context_mode_items[];
extern const EnumPropertyItem rna_enum_curveprofile_preset_items[];

View File

@ -41,13 +41,6 @@
# include "ABC_alembic.h"
#endif
const EnumPropertyItem rna_enum_abc_compression_items[] = {
#ifdef WITH_ALEMBIC
{ABC_ARCHIVE_OGAWA, "OGAWA", 0, "Ogawa", ""},
{ABC_ARCHIVE_HDF5, "HDF5", 0, "HDF5", ""},
#endif
{0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
# include "BKE_editmesh.h"
@ -222,7 +215,6 @@ static void rna_Scene_alembic_export(Scene *scene,
bool use_subdiv_schema,
bool export_hair,
bool export_particles,
int compression_type,
bool packuv,
float scale,
bool triangulate,
@ -257,7 +249,6 @@ static void rna_Scene_alembic_export(Scene *scene,
.use_subdiv_schema = use_subdiv_schema,
.export_hair = export_hair,
.export_particles = export_particles,
.compression_type = compression_type,
.packuv = packuv,
.triangulate = triangulate,
.quad_method = quad_method,
@ -410,7 +401,6 @@ void RNA_api_scene(StructRNA *srna)
func, "export_hair", 1, "Export Hair", "Exports hair particle systems as animated curves");
RNA_def_boolean(
func, "export_particles", 1, "Export Particles", "Exports non-hair particle systems");
RNA_def_enum(func, "compression_type", rna_enum_abc_compression_items, 0, "Compression", "");
RNA_def_boolean(
func, "packuv", 0, "Export with packed UV islands", "Export with packed UV islands");
RNA_def_float(