mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-07 03:01:55 +00:00
- Schema programs draw on one step allowance per reading pass: MAX_SCHEMA_STEPS (2^22) moves into the BitReader's budget next to the decoded-element allowance, and the tree walk carries both from reader to reader. A per-call ceiling let a cheap entity repeated many times run ~2^22 steps each. - The vertex-colour pre-check charges the minimum encoding (one full colour, then one reuse bit each), so a run of reused colours may end a section. - placements() reports unreadable globals when an entity reference, not only an item, names a reference coordinate system. - chunks_exact -> as_chunks for clippy 1.99 (chunks_exact_to_as_chunks). Tests: programs_on_one_stream_share_the_step_allowance, one_step_allowance_covers_the_whole_walk, reused_vertex_colours_may_be_the_last_data, unreadable_globals_are_an_error_when_a_reference_names_a_coordinate_system; each fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SqmHYx8FiWM5PcsoiErgp9
38 lines
1.6 KiB
Rust
38 lines
1.6 KiB
Rust
//! A reader for PRC, the 3D model format a PDF `/3D` stream of `/Subtype /PRC` carries
|
|
//! (ISO 32000-2 §13.6.3, ISO 14739-1).
|
|
//!
|
|
//! Layer L0, standalone: this crate depends on no other PdfCraft crate. It reads the
|
|
//! uncompressed container, inflates each section, and decodes the bit-level primitives and
|
|
//! the schema a newer producer uses to describe fields this reader does not know; it decodes
|
|
//! tessellations and walks the product tree into placed, coloured meshes
|
|
//! ([`PrcFile::placements`], [`PrcFile::model_tree`]).
|
|
//!
|
|
//! Clause numbers in `[WD x.y]` refer to the PRC working draft, ISO/TC 171/SC 2 N570.
|
|
//!
|
|
//! Every read is bounded: inflation by [`MAX_INFLATED_BYTES`] (or a caller's limit), decoded
|
|
//! array elements by [`MAX_DECODED_ELEMENTS`] and schema-program steps by [`MAX_SCHEMA_STEPS`]
|
|
//! per reading pass, schema programs by a depth ceiling. Damaged data is an error, never a panic.
|
|
#![forbid(unsafe_code)]
|
|
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
|
|
|
|
mod acof;
|
|
mod arrays;
|
|
mod bits;
|
|
mod container;
|
|
mod entity;
|
|
mod error;
|
|
mod geometry;
|
|
mod schema;
|
|
mod tess;
|
|
#[cfg(test)]
|
|
mod testw;
|
|
mod tree;
|
|
|
|
pub use bits::{BitReader, MAX_DECODED_ELEMENTS, MAX_SCHEMA_STEPS};
|
|
pub use container::{FileStructure, MAX_FILE_STRUCTURES, MAX_INFLATED_BYTES, PRC_READER_VERSION, PrcFile, PrcHeader, SectionKind, UniqueId};
|
|
pub use error::PrcError;
|
|
pub use geometry::Matrix;
|
|
pub use schema::Schema;
|
|
pub use tess::{Tessellation, TriangleMesh, TriangleStyle};
|
|
pub use tree::{EntityOverrides, MAX_PLACEMENTS, ModelNode, NameSource, Placement, Rgba, StyleAlpha};
|