GithubHelp home page GithubHelp logo

djeedai / weldr Goto Github PK

View Code? Open in Web Editor NEW
9.0 9.0 3.0 154 KB

A Rust library and command-line tool to manage LDraw files (.ldr)

Home Page: https://crates.io/crates/weldr

License: Apache License 2.0

Rust 100.00%
command-line-tool ldraw lego parser rust rust-library

weldr's People

Contributors

djeedai avatar scanmountgoat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

weldr's Issues

multi-part document (MPD) support

Ldraw has an MPD extension for embedding multiple files in the same file. The extension is documented here: https://www.ldraw.org/article/47.html.

While files using the MPD extension typically use the .mpd extension, it's also common to see .ldr files containing multiple embedded files. This seems to be the standard way to define submodels in a single ldraw file or embed custom parts.

The current parsing implementation assumes all subfile commands come from the resolver like DiskResolver, which won't be the case for embedded files. This causes resolve errors. The spec doesn't make any requirements on how to handle embedded filenames "masking" the filenames of actual parts on disk. This could theoretically be handled by just parsing and adding all the embedded files to the source map before recursing into the subfiles themselves. This would ensure the embedded submodel file gets loaded before we try and resolve the command 1 ... submodel.

This may also require changes to the return type of the parse commands. Returning a single SourceFile may not adequately capture that the file could have embedded files. This depends on whether a SourceFile should represent the list of commands in a single ldraw file or the file "blocks" as represented in the MPD extension. It still makes sense for parse_raw to return the SourceFile. The recursive version parse could return all commands in a single SourceFile, return a collection of SourceFile, or not return a SourceFile at all.

I'm currently working on reworking the file loading to try and support this extension as described above. Let me know if you have any suggestions or concerns.

Consider using `bytemuck` instead of manual `as_u8_slice()`

It would be safer to let bytemuck handle those conversions, the maintainers have put a lot of thinking into making sure their implementation is safe.

See what Rust version bytemuck supports; they say 1.34 for base without feature, but do we need any feature?

README issues

Logging to remember:

  • wrong LICENSE-APACHE(2) link
  • wrong Cargo.toml snippet version

CHANGELOG also missing reference to fix of #21

Utf8Error when trying to parse 2902.dat

I was looking for robust and efficient ldraw parsers in Rust and found this crate. From my initial experience, the library has been very well documented and easy to use. I noticed in #2 that the code likely hasn't been run against the entire parts library yet. I've already found some panics.

I'm getting the error Utf8Error { valid_up_to: 10, error_len: Some(1) } at this section of code. Rust doesn't seem to complain about the formatting when I trying and convert the file to utf8 with std::fs::read_to_string. This happens on the recently downloaded ldraw as well as bricklink studio parts libraries. I can upload the dat file if needed.

weldr/lib/src/lib.rs

Lines 414 to 420 in aae1bff

named!(
comment<Command>,
do_parse!(
content: take_not_cr_or_lf
>> (Command::Comment(CommentCmd::new(std::str::from_utf8(content).unwrap())))
)
);

Roadmap 1.0

weldr

  • Implement all basic LDraw commands (1 to 5) (aae85ec)
  • Implement sub-file resolution and recursive parsing (7cc74c6)
  • Add error handling (5758d20)
  • Expose iterators (1d5eac6):
    • for all non-sub-file commands (default behavior; iter()), transparently descending into sub-files
    • for all commands local to a file (local_iter()) including sub-file commands, without dereferencing
  • Implement common meta command extensions
    • !HISTORY - File Changes History
    • !COLOUR - Colour Definition (372ef24)
    • BFC - Back Face Culling
    • !TEXMAP - Texture Mapping
    • !CATEGORY (afe45eb)
    • !KEYWORDS (afe45eb)
    • Multi-Part Document (#26)
  • Add basic filesystem-based resolver (possibly in examples/ only)
  • Add source map cache to avoid re-loading and re-parsing the same sub-files
  • Benchmark : entire LDraw official catalog (speed + correctness)

weldr-bin

  • Handle parts catalog location configuration (5db56b9)
  • Fix bug with some round parts looking truncated (e.g. 6143.dat) (94fd91f)
  • Merge duplicate vertices
  • Handle various primitives : line, triangle, quad (instead of current all-triangle discard-lines) (lines: efaa14a)
  • convert gltf: Output glTF buffer inline inside JSON to allow stdout output

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.