Loading...
Searching...
No Matches
io.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2#pragma once
3#include "mesh.hpp"
4#include <filesystem>
5#include <functional>
6#include <istream>
7
8namespace meshkit
9{
27struct IOOptions {
32 std::function<bool()> cancelled;
35 bool overwrite = false, durable = false, allowAttributeLoss = false;
43 bool legacy2dm =
44 false;
47};
48
52 std::uint64_t bytes = 0, ignoredRecords = 0, reorientedCells = 0;
57 std::vector<std::string> losses;
58};
59
66// Version-1 MKB is lossless for the generic model, with counted little-endian
67// records and a trailing content checksum. No host struct/padding is serialized.
68// Read failures expose no partial mesh. Writes use an exclusive same-directory
69// temporary and atomic publication; cancellation/failure preserves an old file.
82ReadResult readBinary(std::istream &, const IOOptions & = {});
90ReadResult readBinary(const std::filesystem::path &, const IOOptions & = {});
102IOReport writeBinary(const std::filesystem::path &, const Mesh &, const IOOptions & = {});
103// Bounded-record, two-pass seekable file reader: elements may precede nodes.
104// E3T/E4Q/ND/standard NS supported. Unsupported cards are never silently lost.
105// 2DM does not declare physical units; callers must supply them before meshing.
119ReadResult read2dm(const std::filesystem::path &, const IOOptions & = {});
132IOReport write2dm(const std::filesystem::path &, const Mesh &, const IOOptions & = {});
133}
The Qt-facing MeshKit API (meshkit::core_qt, meshkit::model_qt, meshkit::io_qt): mesh value types and...
The Qt-free MeshKit library: job events and progress (meshkit::runtime), the neutral mesh model,...
ReadResult read2dm(const std::filesystem::path &, const IOOptions &={})
Read an SMS 2DM file in two passes (nodes, then elements and node strings).
Definition smsio.cpp:248
UnknownRecords
How read2dm() treats a card other than MESH2D, ND, E3T, E4Q or NS.
Definition io.hpp:16
@ IgnoreWithReport
Skip the card, count it in IOReport::ignoredRecords, record a bounded ignored_card:<card> code in IOR...
Definition io.hpp:16
@ Reject
Fail the read with code unsupported_card (the default).
Definition io.hpp:16
ReadResult readBinary(std::istream &, const IOOptions &={})
Read a version-1 MeshKit binary (MKB) mesh from a stream.
Definition binaryio.cpp:99
IOReport write2dm(const std::filesystem::path &, const Mesh &, const IOOptions &={})
Validate a mesh and atomically publish it to a path as SMS 2DM.
Definition smsio.cpp:396
IOReport writeBinary(const std::filesystem::path &, const Mesh &, const IOOptions &={})
Validate a mesh and atomically publish it to a path as version-1 MKB.
Definition binaryio.cpp:11
Options shared by the MKB and 2DM readers and writers.
Definition io.hpp:27
bool allowAttributeLoss
write2dm() only.
Definition io.hpp:35
bool overwrite
Writes only.
Definition io.hpp:35
UnknownRecords unknownRecords
read2dm() only: handling of unsupported cards.
Definition io.hpp:46
Limits limits
Count, workspace-estimate, work, metadata-byte and 2DM line-length limits.
Definition io.hpp:29
bool legacy2dm
Compatibility ids/optional materials; still rejects malformed geometry.
Definition io.hpp:43
std::function< bool()> cancelled
Optional poll; returning true aborts with status Cancelled (code cancelled).
Definition io.hpp:32
bool durable
Writes only.
Definition io.hpp:35
Outcome of one read or write: status, code, message, counts, timing and byte total.
Definition io.hpp:49
std::uint64_t ignoredRecords
read2dm() only: cards skipped under UnknownRecords::IgnoreWithReport.
Definition io.hpp:52
std::vector< std::string > losses
Bounded codes, with total ignored-record count above.
Definition io.hpp:57
std::uint64_t bytes
Bytes written or read (MKB includes the checksum footer; a 2DM read reports the file size measured by...
Definition io.hpp:52
std::uint64_t reorientedCells
read2dm() only: clockwise cells whose corner order was reversed.
Definition io.hpp:52
Resource caps for jobs, validation and file I/O.
Definition mesh.hpp:198
Neutral owned mesh: XYZ vertices, triangle/quad cells, marked edges, paths, optional external ids and...
Definition mesh.hpp:159
Versioned outcome of a native operation: mesh validation, file I/O, or a job (as the base of JobRepor...
Definition mesh.hpp:232
Mesh and report returned by the readers.
Definition io.hpp:60
IOReport report
Status, code, message, counts and byte total of the read.
Definition io.hpp:64