87 [[nodiscard]]
virtual bool can_write(
const std::string& filepath)
const = 0;
97 const std::string& filepath,
136 const std::vector<std::string>& extensions,
139 for (
const auto& ext : extensions) {
140 m_factories[ext] = factory;
144 [[nodiscard]] std::unique_ptr<VolumeWriter>
create_writer(
const std::string& filepath)
const
146 auto ext = std::filesystem::path(filepath).extension().string();
147 if (!ext.empty() && ext[0] ==
'.') {
151 auto it = m_factories.find(ext);
152 if (it != m_factories.end()) {
160 std::vector<std::string> exts;
161 exts.reserve(m_factories.size());
162 for (
const auto& [ext, _] : m_factories) {
std::unordered_map< std::string, VolumeWriterFactory > m_factories
std::vector< std::string > get_registered_extensions() const
void register_writer(const std::vector< std::string > &extensions, const VolumeWriterFactory &factory)
std::unique_ptr< VolumeWriter > create_writer(const std::string &filepath) const
static VolumeWriterRegistry & instance()
Singleton registry dispatching volume writes by file extension.
virtual bool can_write(const std::string &filepath) const =0
Check whether this writer handles the given filepath.
virtual ~VolumeWriter()=default
virtual std::vector< std::string > get_supported_extensions() const =0
File extensions handled by this writer (without dot).
virtual bool write(const std::string &filepath, const Kakshya::VolumeData &data, const VolumeWriteOptions &options={})=0
Write volume data to disk.
virtual std::string get_last_error() const =0
Last error message or empty string.
Abstract base for volumetric format writers.
std::function< std::unique_ptr< VolumeWriter >()> VolumeWriterFactory
float activity_threshold
Magnitude below which a cell is written as inactive.
bool half_float
Store values at half precision where the format supports it.
int compression
Format-specific compression code, or -1 for the writer's default.
float background
Value assumed by every inactive cell.
std::unordered_map< std::string, float > field_thresholds
Per-field overrides of activity_threshold, keyed by field name.
Configuration for volume writing.
A lattice and every field sampled over it, held in host memory.