Foxtrot is a fast viewer for STEP files, a standard interchange format for mechanical CAD

Overview

Foxtrot

Foxtrot is a fast viewer for STEP files, a standard interchange format for mechanical CAD. It is an experimental project built from the ground up, including new libraries for parsing and triangulation.

This repository includes a simple native GUI:

Motherboard example
(demo model source)

In addition, the same code can run in a browser (click to see the demo):

Browser example
(demo model source)

For more background on the project, check out this writeup by one of the main authors.

Quick start

(Prerequisite: install Rust and Cargo, and clone this repository)

cargo run --release -- examples/cube_hole.step

WebAssembly demo

(Prerequisite: install wasm-pack and clone this repository)

cd wasm
wasm-pack build --target no-modules
python3 -m http.server --directory deploy # or the simple server of your choice

Then, open the local server's URL (typically 127.0.0.1:8000) and select a sample file from the list.

Subsystems

  • cdt: Constrained Delaunay triangulation (standalone)
  • express: Parser for EXPRESS schemas files and a matching code generation system
  • experiments: Experiments with trait systems (unused)
  • step: Auto-generated STEP file parser. This take a very long time to compile, so it is isolated into this crate.
  • triangulate: Converts a file loaded by step into a triangle mesh, using cdt as its core
  • nurbs: A handful of NURBS / B-spline algorithms used by triangulate
  • gui: GUI for rendering STEP files, using WebGPU
  • wasm: Scaffolding to run in the browser using WebAssembly

Code generation

step/src/ap214.rs is automatically generated from 10303-214e3-aim-long.exp, which is available via CVS here (check out the APs folder).

To regenerate, run

cargo run --release --example gen_exp -- path/to/APs/10303-214e3-aim-long.exp step/src/ap214.rs

License

© 2021 Formlabs

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Disclaimer

Foxtrot is a proof-of-concept demo, not an industrial-strength CAD kernel. It may not work for your models! Even in the screenshots above, there are a handful of surfaces that it fails to triangulate; look in the console for details.

This isn't an official Formlabs project (experimental or otherwise), it is just code that happens to be owned by Formlabs.

No one at Formlabs is paid to maintain this, so set your expectations for support accordingly.

References

STEP Integrated Definitions

Comments
  • Incorrect CDT -- points not in the input added

    Incorrect CDT -- points not in the input added

    The following picture illustrates the issue:

    image

    All points except 4 in the corners were added as constraint edges (visualized with red color). The triangulation contains triangles (visualized with blue color) with vertices which do not correspond to any input point.

    This is fully zoomed out image (scaled to 0-1):

    image

    Note that I have removed some triangles from the zoomed-out image above (the white areas were correctly covered).

    Input points:

    [[-500., -1000.], [-500., 1000.], [500., 1000.], [500., -1000.]]
    

    Input edges (list of edges, each is list of a-b points):

    [[[-420.56, -920.56], [-379.44, -920.56]], [[-379.44, -920.56], [-379.53156, -840.588]], [[-379.53156, -840.588], [-420.65155, -840.588]], [[-420.65155, -840.588], [-424.31952, -897.4294]], [[-424.31952, -897.4294], [-424.31952, -904.1894]], [[-424.31952, -904.1894], [-420.56, -920.56]], [[-420.56, 920.56], [-420.56, 879.44]], [[-420.56, 879.44], [-379.44, 879.44]], [[-379.44, 879.44], [-379.44, 920.56]], [[-379.44, 920.56], [-420.56, 920.56]], [[379.44, 920.56], [379.44, 879.44]], [[379.44, 879.44], [420.56, 879.44]], [[420.56, 879.44], [420.56, 920.56]], [[420.56, 920.56], [379.44, 920.56]], [[379.44, -879.44], [379.44, -920.56]], [[379.44, -920.56], [420.56, -920.56]], [[420.56, -920.56], [420.56, -879.44]], [[420.56, -879.44], [379.44, -879.44]]]
    
    opened by Indy2222 2
  • 'Missing ref_direction' panic

    'Missing ref_direction' panic

    Attached step file causes:

    Loading mesh!
    Waiting for mesh
    thread '<unnamed>' panicked at 'Missing ref_direction', triangulate/src/triangulate.rs:324:54
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    thread 'main' panicked at 'Failed to load mesh: Any { .. }', gui/src/app.rs:202:18
    
    opened by virtualritz 0
  • Build fails on Macbook

    Build fails on Macbook

    Not sure what all information to provide. I am trying to build this cool-looking project, but I am getting an error. I am new to Rust so not sure how to proceed.

       Compiling autocfg v1.1.0
       Compiling libc v0.2.132
       Compiling bitflags v1.3.2
       Compiling cfg-if v1.0.0
       Compiling proc-macro2 v1.0.43
       Compiling quote v1.0.21
       Compiling unicode-ident v1.0.4
       Compiling syn v1.0.99
       Compiling log v0.4.17
       Compiling foreign-types-shared v0.1.1
       Compiling scopeguard v1.1.0
       Compiling core-foundation-sys v0.8.3
       Compiling thiserror v1.0.35
       Compiling memchr v2.5.0
       Compiling crossbeam-utils v0.8.11
       Compiling unicode-width v0.1.10
       Compiling cty v0.2.2
       Compiling arrayvec v0.5.2
       Compiling once_cell v1.14.0
       Compiling termcolor v1.1.3
       Compiling hashbrown v0.12.3
       Compiling bit-vec v0.6.3
       Compiling byteorder v1.4.3
       Compiling radium v0.5.3
       Compiling smallvec v1.9.0
       Compiling fixedbitset v0.2.0
       Compiling block v0.1.6
       Compiling typenum v1.15.0
       Compiling lexical-core v0.7.6
       Compiling core-foundation-sys v0.7.0
       Compiling parking_lot_core v0.8.5
       Compiling rayon-core v1.9.3
       Compiling version_check v0.9.4
       Compiling tap v1.0.1
       Compiling wyz v0.2.0
       Compiling ryu v1.0.11
       Compiling paste v1.0.9
       Compiling funty v1.1.0
       Compiling rawpointer v0.2.1
       Compiling static_assertions v1.1.0
       Compiling cfg_aliases v0.1.1
       Compiling ahash v0.4.7
       Compiling either v1.8.0
       Compiling copyless v0.1.5
       Compiling profiling v1.0.6
       Compiling range-alloc v0.1.2
       Compiling fast-float v0.2.0
       Compiling geometry-predicates v0.3.0
       Compiling regex-syntax v0.6.27
       Compiling arrayvec v0.7.2
       Compiling cfg-if v0.1.10
       Compiling humantime v2.1.0
       Compiling dispatch v0.2.0
       Compiling vec_map v0.8.2
       Compiling ansi_term v0.12.1
       Compiling strsim v0.8.0
       Compiling lazy_static v1.4.0
       Compiling pollster v0.2.5
       Compiling instant v0.1.12
       Compiling gpu-alloc-types v0.2.0
       Compiling gpu-descriptor-types v0.1.1
       Compiling wgpu-types v0.8.0
       Compiling num-traits v0.2.15
       Compiling indexmap v1.9.1
       Compiling memoffset v0.6.5
       Compiling crossbeam-epoch v0.9.10
       Compiling lock_api v0.4.8
       Compiling num-integer v0.1.45
       Compiling num-rational v0.4.1
       Compiling rayon v1.5.3
       Compiling foreign-types v0.3.2
       Compiling textwrap v0.11.0
       Compiling raw-window-handle v0.4.3
       Compiling codespan-reporting v0.11.1
       Compiling bit-set v0.5.3
       Compiling fxhash v0.2.1
       Compiling nom v6.1.2
       Compiling matrixmultiply v0.3.2
       Compiling wgpu-core v0.8.1
       Compiling itertools v0.10.4
       Compiling hashbrown v0.9.1
       Compiling gpu-alloc v0.4.7
       Compiling gpu-descriptor v0.1.1
       Compiling malloc_buf v0.0.6
       Compiling raw-window-handle v0.3.4
       Compiling num_cpus v1.13.1
       Compiling atty v0.2.14
       Compiling jobserver v0.1.24
       Compiling core-foundation v0.9.3
       Compiling crossbeam-channel v0.5.6
       Compiling aho-corasick v0.7.19
       Compiling bitvec v0.19.6
       Compiling core-foundation v0.7.0
       Compiling petgraph v0.5.1
       Compiling storage-map v0.3.0
       Compiling clap v2.34.0
       Compiling spirv_headers v1.5.0
       Compiling approx v0.5.1
       Compiling num-complex v0.4.2
       Compiling ordered-float v2.10.0
       Compiling parking_lot v0.11.2
       Compiling cc v1.0.73
       Compiling core-graphics-types v0.1.1
       Compiling core-graphics v0.19.2
       Compiling regex v1.6.0
       Compiling crossbeam-deque v0.8.2
       Compiling simba v0.5.1
       Compiling core-graphics v0.22.3
       Compiling objc_exception v0.1.2
       Compiling env_logger v0.8.4
       Compiling thiserror-impl v1.0.35
       Compiling bytemuck_derive v1.2.1
       Compiling express v0.1.0 (/Users/auser/working/github/foxtrot/express)
       Compiling nalgebra v0.27.1
       Compiling bytemuck v1.12.1
       Compiling naga v0.4.2
       Compiling cdt v0.1.0 (/Users/auser/working/github/foxtrot/cdt)
       Compiling step v0.1.0 (/Users/auser/working/github/foxtrot/step)
       Compiling gfx-hal v0.8.0
       Compiling nalgebra-glm v0.13.0
       Compiling gfx-backend-empty v0.8.0
       Compiling nurbs v0.1.0 (/Users/auser/working/github/foxtrot/nurbs)
    The following warnings were emitted during compilation:
    
    warning: /opt/local/bin/ranlib: object: /Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/libexception.a(exception.o) malformed object (unknown load command 1)
    warning: ar: internal ranlib command failed
    
    error: failed to run custom build command for `objc_exception v0.1.2`
    
    Caused by:
      process didn't exit successfully: `/Users/auser/working/github/foxtrot/target/release/build/objc_exception-9f776d584def1ad7/build-script-build` (exit status: 1)
      --- stdout
      TARGET = Some("x86_64-apple-darwin")
      OPT_LEVEL = Some("3")
      HOST = Some("x86_64-apple-darwin")
      CC_x86_64-apple-darwin = None
      CC_x86_64_apple_darwin = None
      HOST_CC = None
      CC = None
      CFLAGS_x86_64-apple-darwin = None
      CFLAGS_x86_64_apple_darwin = None
      HOST_CFLAGS = None
      CFLAGS = None
      CRATE_CC_NO_DEFAULTS = None
      DEBUG = Some("true")
      CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2,sse3,ssse3")
      running: "cc" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-g" "-fno-omit-frame-pointer" "-m64" "-arch" "x86_64" "-Wall" "-Wextra" "-o" "/Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/extern/exception.o" "-c" "extern/exception.m"
      exit status: 0
      AR_x86_64-apple-darwin = None
      AR_x86_64_apple_darwin = None
      HOST_AR = None
      AR = None
      running: "ar" "cq" "/Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/libexception.a" "/Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/extern/exception.o"
      cargo:warning=/opt/local/bin/ranlib: object: /Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/libexception.a(exception.o) malformed object (unknown load command 1)
      cargo:warning=ar: internal ranlib command failed
      exit status: 1
    
      --- stderr
    
    
      error occurred: Command "ar" "cq" "/Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/libexception.a" "/Users/auser/working/github/foxtrot/target/release/build/objc_exception-825c3e6ffd75bfbf/out/extern/exception.o" with args "ar" did not execute successfully (status code exit status: 1).
    
    
    warning: build failed, waiting for other jobs to finish...
    
    opened by yepher 1
  • FIX: Newton's method singularities causing failure to lower points to 2D in NURBS surfaces.

    FIX: Newton's method singularities causing failure to lower points to 2D in NURBS surfaces.

    Frequently BSpline surfaces failed to lower points to 2D because of the use of try_inverse() to compute the gradient delta_i - this is because using this method, if you arrive at a stationary point, J_i stops being invertible.

    The solution here uses the pseudo inverse, which basically resolves to [0 0; 0 0], making delta_i = 0 (as expected), rather than returning None.

    Another option would be to simply set delta_i = 0 when try_inverse is None, however the psuedo-inverse is preffered because it sets only the singular values below epsilon (chosen arbitrarily here to 1e-4) of the inverted matrix to 0. This typically results in the 0 matrix, maybe there are times when it doesn't and you'd stop prematurely, I couldn't tell you for certain if that ever happens, can't hurt though...

    opened by tom-ainc 0
  • Any plans to support Product Manufacturing Information (PMI)?

    Any plans to support Product Manufacturing Information (PMI)?

    Hi there, I wonder if you guys have any plans to support labeling PMI inside the viewer? Similar feature that can be found on https://www.nist.gov/services-resources/software/step-file-analyzer-and-viewer

    image Image adapted from NIST STEP File Analyzer and Viewer

    Thanks for the awesome project :)

    opened by billy1624 0
Owner
null
A cross platform reloading image viewer combined with a command executor

Watchout A cross platform reloading image viewer combined with a command executor. Watchout will do any of the following: Run a command when any file

Benedikt Terhechte 6 Oct 7, 2022
A Rust encoder/decoder for Dominic Szablewski's QOI format for fast, lossless image compression.

QOI - The “Quite OK Image” format This is a Rust encoder and decoder for Dominic Szablewski's QOI format for fast, lossless image compression. See the

Chevy Ray Johnston 62 Nov 29, 2022
Fast encoder/decoder for the lossless DTM 16 bit image format

DTM Image Format Fast encoder/decoder for the DTM image format. The DTM image format is a 16-bit lossless image format supporting one to four channels

Kurt Kühnert 4 Oct 15, 2022
Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format.

RDR2 Screenshot converter Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format. QuickStart Just download the executable fi

Timofey Gelazoniya 12 Sep 29, 2022
Camera RAW to DNG file format converter

DNGLab - A camera RAW to DNG file format converter Command line tool to convert camera RAW files to Digital Negative Format (DNG). It is currently in

null 92 Jan 6, 2023
Rust port of the Quite Okay Image format

qoi_rs What is this? A pretty boring Rust translation of qoi. Status What's there Encode & Decode works Results agree with the C implementation for al

null 9 Dec 9, 2021
Rust library to get image size and format without loading/decoding

imageinfo-rs Rust library to get image size and format without loading/decoding. The imageinfo don't get image format by file ext name, but infer by f

xiaozhuai, Weihang Ding 47 Dec 30, 2022
An intel PT trace converter from `perf.data` to Fuchsia trace format.

Introduction Recent Intel processors feature the "Intel Processor Trace" feature, which can be used to capture the full execution trace of a program.

Michał Chojnowski 14 Nov 9, 2022
mico (minimalistic config file format) encoder and decoder

mico This library implements a parser and emitter for mico (minimalistic config file format). Format example: Name: mico Description: minimalistic con

null 1 Jan 30, 2022
Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Phil Spindler 3 Nov 2, 2021
Convert UFO .glif files to SVG, whether they're part of a font or not

Convert UFO glyph files (.glif) to SVG There exists already an svg2glif, but for some reason not the opposite operation. My MFEKglif editor treats .gl

Modular Font Editor K 3 Apr 26, 2022
Thumbnailer - This crate can be used to create thumbnails for all kinds of files.

Thumbnailer This crate can be used to create thumbnails for all kinds of files. Usage use thumbnailer::{create_thumbnails, Thumbnail, ThumbnailSize};

Julius Riegel 4 Oct 30, 2022
Generates preview thumbnails for 3D model files

Generates preview thumbnails for 3D model files. Provide a Windows Explorer extensions that adds preview thumbnails for 3D model files.

EYHN 244 Dec 27, 2022
CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console)

CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console). Supports most standard image formats, and some video formats.

Michael 30 Jan 1, 2023
😱 Dead fast thumbnail library for browser and NodeJs! Built with Rust 🦀 and WebAssembly 🕸

thumbo-core ?? Dead fast thumbnail library for browser and NodeJs Built with Rust ?? & WebAssembly ?? ?? About thumbo-core is a thubnail library for b

Victor Aremu 12 Dec 2, 2022
Rust library for fast image resizing with using of SIMD instructions.

fast_image_resize Rust library for fast image resizing with using of SIMD instructions. CHANGELOG Supported pixel formats and available optimisations:

Kirill Kuzminykh 115 Jan 5, 2023
A fast wordlist to nthash converter

nthasher A fast wordlist to nthash converter Usage Pass it a UTF8 encoded wordlist, and write the output to a file. ./nthasher <wordlist> > wordlist.n

Dominic White 18 Nov 3, 2022
A lightning-fast Sixel serializer/deserializer

sixel-image This is a (pretty fast!) sixel serializer/deserializer with cropping support. It accepts a sixel serialized string byte-by-byte, deseriali

null 12 Oct 27, 2022
Tutorial for rCore OS step by step (2nd edition)

rCore_tutorial WARNING This project is no longer maintained, please try Tutorial v3.5. Documentations Please read https://rcore-os.github.io/rCore_tut

rCore OS 135 Nov 7, 2022
Tutorial for rCore OS step by step (3rd edition)

rCore-Tutorial V3(开发中) 本教学仓库是继 rCore_tutorial V2 后重构的 V3 版本。 本文档的目标主要针对「做实验的同学」,我们会对每章结束后提供完成的代码,你的练习题只需要基于我们给出的版本上增量实现即可,不需要重新按照教程写一遍。 而对想完整实现一个 rCor

rCore OS 419 Dec 30, 2022