Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical struct naming, bump deps, removed unused deps #40

Merged
merged 7 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[workspace]
resolver = "2"
members = [
"example-pages-generator",
"readme-generator",
"truck-base",
"truck-geoderive",
"truck-geotrait",
"truck-geometry",
"truck-modeling",
"truck-geotrait",
"truck-js",
"truck-meshalgo",
"truck-modeling",
"truck-platform",
"truck-polymesh",
"truck-rendimpl",
"truck-shapeops",
"truck-topology",
"truck-js",
"truck-stepio",
"readme-generator",
"example-pages-generator",
"truck-topology",
]

[profile.release.package.truck-js]
Expand Down
126 changes: 74 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
# truck - Truck is a rust CAD kernel
# `truck` ‒ A Rust CAD Kernel

## Overview
`truck` is an open-source [B-rep](https://en.wikipedia.org/wiki/Boundary_representation)
[geometric modeling kernel](https://en.wikipedia.org/wiki/Geometric_modeling_kernel)
written in Rust.

Truck is an open-source shape processing kernel by Rust.
The broad concept consists of the following three elements.
![A bottle modeled with truck](example.gif)

- Trendy Tools
- Traditional Arts
- Theseus' ship
*This bottle is based on [this tutorial](https://dev.opencascade.org/doc/overview/html/occt__tutorial.html)
by Open CASCADE Technology (OCCT), a great senior of truck.
The OCCT tutorial properly models the fillets and the threading.
This shows that truck is still in its infancy in terms of functionality.
Our immediate goal for truck is to be able to model this bottle perfectly.*

### Trendy Tools
## Overview

- We are targeting the next generation of market share using developmental tools: Rust and WebGPU.
- Advanced optimizations using Rust and WebGPU maximize the performance of each crate.
The guiding principles are:

### Traditional Arts
### Modern Tools

- We will break away from the legacy by re-implementing the B-rep with NURBS in the above trendy tools.
- Safe implementation using Rust to eliminate core dumped for CPU-derived processes.
- Cargo's extensive maintenance features ensure thorough continuous integration.
- We are using Rust. We pay special attention to make everything work with
WebGPU (`wgpu`).
- We use Cargo's extensive maintenance features to ensure thorough continuous
integration.

### Theseus' ship
### Mindful Choices

- We are modularizing into smaller crates that can be replaced, like [the Ship of Theseus](https://en.wikipedia.org/wiki/Ship_of_Theseus).
- Based on the many lessons learned in the past, we have given up on overall optimization as a single application, and design as a collection of individual optimized crates.
- Since unexpected expansions are bound to occur, we deal with uncontrolled expansions in the form of small modules.
- Instead of creating another binding to one of the existing geometry kernels
we are writing a new B-rep NURBS kernel.
- We use safe Rust (although we give you the choice of using `unsafe` methods
in some instances).
- Speed is a priority and that includes the `wgpu` backend.

## License
### Modular Architecture

Apache License 2.0
- Functionality is modularized into smaller crates that can be replaced, like
the parts in [the Ship of Theseus](https://en.wikipedia.org/wiki/Ship_of_Theseus).
- Based on the many lessons we learned in the past, we have given up on overall
optimizations that a single library/crate would afford. A collection of
individual, optimized crates carries less risk and can be made just as
efficient.
- Feature creep usually happens over time. While we don't believe to be immune
from it, bundling stuff in smaller crates will help us deal with it.

## Usage

### How to Run Examples
### Examples

All examples are located under the examples directory in each crates.
These examples use the default syntax for running examples, as found in the [Cargo](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#examples) documentation.
All examples are located under the `examples` folder of each crate.
These examples use the default syntax for running examples, as found in the
[resp. Cargo documentation](https://doc.rust-lang.org/cargo/reference/cargo-targets.html#examples) .

At first, let's run the following example!

Expand All @@ -44,58 +57,67 @@ git submodule update --init
cargo run --example rotate-objects
```

## crates
## Tutorials

### truck-base [![Crates.io](https://img.shields.io/crates/v/truck-base.svg)](https://crates.io/crates/truck-base) [![Docs.rs](https://docs.rs/truck-base/badge.svg)](https://docs.rs/truck-base)
There are some learning resources for using `truck` v0.1.x series.

basic structs and traits: importing cgmath, curve and surface traits, tolerance, etc...
- [`truck-tutorial`](https://ricos.gitlab.io/truck-tutorial/v0.1/)
- [`truck-tutorial-ja`](https://ricos.gitlab.io/truck-tutorial-ja/v0.1/)
(Japanese version)
- [`truck-tutorial-code`](https://github.com/ricosjp/truck-tutorial-code/tree/v0.1)
(sample code for the tutorial)

### truck-geotrait [![Crates.io](https://img.shields.io/crates/v/truck-geotrait.svg)](https://crates.io/crates/truck-geotrait) [![Docs.rs](https://docs.rs/truck-geotrait/badge.svg)](https://docs.rs/truck-geotrait)

Defines geometric traits: `ParametricCurve`, `ParametricSurface`, and so on.
## Crates

### truck-geometry [![Crates.io](https://img.shields.io/crates/v/truck-geometry.svg)](https://crates.io/crates/truck-geometry) [![Docs.rs](https://docs.rs/truck-geometry/badge.svg)](https://docs.rs/truck-geometry)
### `truck-base` [![Crates.io](https://img.shields.io/crates/v/truck-base.svg)](https://crates.io/crates/truck-base) [![Docs.rs](https://docs.rs/truck-base/badge.svg)](https://docs.rs/truck-base)

geometrical structs: knot vector, B-spline and NURBS
Basic structs and traits: imports `cgmath`, curve and surface traits,
tolerance, etc.

### truck-topology [![Crates.io](https://img.shields.io/crates/v/truck-topology.svg)](https://crates.io/crates/truck-topology) [![Docs.rs](https://docs.rs/truck-topology/badge.svg)](https://docs.rs/truck-topology)
### `truck-geotrait` [![Crates.io](https://img.shields.io/crates/v/truck-geotrait.svg)](https://crates.io/crates/truck-geotrait) [![Docs.rs](https://docs.rs/truck-geotrait/badge.svg)](https://docs.rs/truck-geotrait)

topological structs: vertex, edge, wire, face, shell, and solid
Geometric traits: `ParametricCurve`, `ParametricSurface`, etc.

### truck-polymesh [![Crates.io](https://img.shields.io/crates/v/truck-polymesh.svg)](https://crates.io/crates/truck-polymesh) [![Docs.rs](https://docs.rs/truck-polymesh/badge.svg)](https://docs.rs/truck-polymesh)
### `truck-geometry` [![Crates.io](https://img.shields.io/crates/v/truck-geometry.svg)](https://crates.io/crates/truck-geometry) [![Docs.rs](https://docs.rs/truck-geometry/badge.svg)](https://docs.rs/truck-geometry)

defines polygon data structure and some algorithms handling mesh, including meshing the shapes
Geometric structs: knot vector, B-spline and NURBS

### truck-meshalgo [![Crates.io](https://img.shields.io/crates/v/truck-meshalgo.svg)](https://crates.io/crates/truck-meshalgo) [![Docs.rs](https://docs.rs/truck-meshalgo/badge.svg)](https://docs.rs/truck-meshalgo)
### `truck-topology` [![Crates.io](https://img.shields.io/crates/v/truck-topology.svg)](https://crates.io/crates/truck-topology) [![Docs.rs](https://docs.rs/truck-topology/badge.svg)](https://docs.rs/truck-topology)

Mesh algorighms, include tessellations of the shape.
Topological structs: vertex, edge, wire, face, shell, and solid.

### truck-modeling [![Crates.io](https://img.shields.io/crates/v/truck-modeling.svg)](https://crates.io/crates/truck-modeling) [![Docs.rs](https://docs.rs/truck-modeling/badge.svg)](https://docs.rs/truck-modeling)
### `truck-polymesh` [![Crates.io](https://img.shields.io/crates/v/truck-polymesh.svg)](https://crates.io/crates/truck-polymesh) [![Docs.rs](https://docs.rs/truck-polymesh/badge.svg)](https://docs.rs/truck-polymesh)

integrated modeling algorithms by geometry and topology
Polygon data structures and algorithms for handling meshes, including meshing
of shapes.

### truck-shapeops [![Crates.io](https://img.shields.io/crates/v/truck-shapeops.svg)](https://crates.io/crates/truck-shapeops) [![Docs.rs](https://docs.rs/truck-shapeops/badge.svg)](https://docs.rs/truck-shapeops)
### `truck-meshalgo` [![Crates.io](https://img.shields.io/crates/v/truck-meshalgo.svg)](https://crates.io/crates/truck-meshalgo) [![Docs.rs](https://docs.rs/truck-meshalgo/badge.svg)](https://docs.rs/truck-meshalgo)

Provides boolean operations to Solid
Meshing algorighms, i.e. tessellations of shapes.

### truck-platform [![Crates.io](https://img.shields.io/crates/v/truck-platform.svg)](https://crates.io/crates/truck-platform) [![Docs.rs](https://docs.rs/truck-platform/badge.svg)](https://docs.rs/truck-platform)
### `truck-modeling` [![Crates.io](https://img.shields.io/crates/v/truck-modeling.svg)](https://crates.io/crates/truck-modeling) [![Docs.rs](https://docs.rs/truck-modeling/badge.svg)](https://docs.rs/truck-modeling)

graphic utility library based on wgpu
Integrated modeling algorithms for geometry and topology.

### truck-rendimpl [![Crates.io](https://img.shields.io/crates/v/truck-rendimpl.svg)](https://crates.io/crates/truck-rendimpl) [![Docs.rs](https://docs.rs/truck-rendimpl/badge.svg)](https://docs.rs/truck-rendimpl)
### `truck-shapeops` [![Crates.io](https://img.shields.io/crates/v/truck-shapeops.svg)](https://crates.io/crates/truck-shapeops) [![Docs.rs](https://docs.rs/truck-shapeops/badge.svg)](https://docs.rs/truck-shapeops)

visualization of shape and polygon mesh based on platform
Boolean operations on solids.

### truck-js
### `truck-platform` [![Crates.io](https://img.shields.io/crates/v/truck-platform.svg)](https://crates.io/crates/truck-platform) [![Docs.rs](https://docs.rs/truck-platform/badge.svg)](https://docs.rs/truck-platform)

Javascript wrapper of truck.
Graphic utility library based on `wgpu`.

![dependencies](./dependencies.svg)
### `truck-rendimpl` [![Crates.io](https://img.shields.io/crates/v/truck-rendimpl.svg)](https://crates.io/crates/truck-rendimpl) [![Docs.rs](https://docs.rs/truck-rendimpl/badge.svg)](https://docs.rs/truck-rendimpl)

## Tutorials
Visualization of shapes and polygon meshes for various platforms.

There are some learning resources for using truck v0.1.x series.
### `truck-js`

Javascript bindings for `truck`.

![dependencies](./dependencies.svg)

## License

- [truck-tutorial](https://ricos.gitlab.io/truck-tutorial/v0.1/)
- [truck-tutorial-ja](https://ricos.gitlab.io/truck-tutorial-ja/v0.1/) (Japanese version)
- [truck-tutorial-code](https://github.com/ricosjp/truck-tutorial-code/tree/v0.1) (pre-created sample code)
Apache License 2.0.
Binary file added example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion truck-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ categories = ["graphics"]
[dependencies]
cgmath = { version = "0.18.0", features = ["serde"] }
matext4cgmath = "0.1.0"
serde = { version = "1.0.151", features = ["derive"] }
serde = { version = "1.0.152", features = ["derive"] }
rustc-hash = "1.1.0"
4 changes: 2 additions & 2 deletions truck-geoderive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ proc-macro = true

[dependencies]
quote = "1.0.23"
proc-macro2 = "1.0.49"
syn = { version = "1.0.107", features = ["derive", "printing"] }
proc-macro2 = "1.0.51"
syn = { version = "1.0.108", features = ["derive", "printing"] }
proc-macro-error = "1.0.4"
5 changes: 1 addition & 4 deletions truck-geometry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ license = "Apache-2.0"

keywords = ["truck", "graphics"]
categories = ["graphics"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
derive_more = "0.99.17"
num = "0.4.0"
serde = { version = "1.0.151", features = ["derive"] }
serde = { version = "1.0.152", features = ["derive"] }
thiserror = "1.0.38"
truck-base = { version = "0.4.0", path = "../truck-base" }
truck-geotrait = { version = "0.3.0", path = "../truck-geotrait" }
Expand Down
2 changes: 1 addition & 1 deletion truck-geometry/src/decorators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::ops::{Deref, DerefMut, Mul};
/// Vector4::new(-1.0, 0.0, 0.0, 1.0),
/// ];
/// // upper half circle on xy-plane
/// let uhcircle = NURBSCurve::new(BSplineCurve::new(knot_vec, control_points));
/// let uhcircle = NurbsCurve::new(BSplineCurve::new(knot_vec, control_points));
/// // sphere constructed by revolute circle
/// let sphere = RevolutedCurve::by_revolution(
/// uhcircle, Point3::origin(), Vector3::unit_x(),
Expand Down
22 changes: 11 additions & 11 deletions truck-geometry/src/decorators/revolved_curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,48 +321,48 @@ impl IncludeCurve<BSplineCurve<Point3>> for RevolutedCurve<BSplineCurve<Point3>>
}
}

impl<'a> IncludeCurve<BSplineCurve<Point3>> for RevolutedCurve<&'a NURBSCurve<Vector4>> {
impl<'a> IncludeCurve<BSplineCurve<Point3>> for RevolutedCurve<&'a NurbsCurve<Vector4>> {
fn include(&self, curve: &BSplineCurve<Point3>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
}
}

impl IncludeCurve<BSplineCurve<Point3>> for RevolutedCurve<NURBSCurve<Vector4>> {
impl IncludeCurve<BSplineCurve<Point3>> for RevolutedCurve<NurbsCurve<Vector4>> {
fn include(&self, curve: &BSplineCurve<Point3>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
}
}

impl<'a> IncludeCurve<NURBSCurve<Vector4>> for RevolutedCurve<&'a BSplineCurve<Point3>> {
fn include(&self, curve: &NURBSCurve<Vector4>) -> bool {
impl<'a> IncludeCurve<NurbsCurve<Vector4>> for RevolutedCurve<&'a BSplineCurve<Point3>> {
fn include(&self, curve: &NurbsCurve<Vector4>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
}
}

impl IncludeCurve<NURBSCurve<Vector4>> for RevolutedCurve<BSplineCurve<Point3>> {
fn include(&self, curve: &NURBSCurve<Vector4>) -> bool {
impl IncludeCurve<NurbsCurve<Vector4>> for RevolutedCurve<BSplineCurve<Point3>> {
fn include(&self, curve: &NurbsCurve<Vector4>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
}
}

impl<'a> IncludeCurve<NURBSCurve<Vector4>> for RevolutedCurve<&'a NURBSCurve<Vector4>> {
fn include(&self, curve: &NURBSCurve<Vector4>) -> bool {
impl<'a> IncludeCurve<NurbsCurve<Vector4>> for RevolutedCurve<&'a NurbsCurve<Vector4>> {
fn include(&self, curve: &NurbsCurve<Vector4>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
}
}

impl IncludeCurve<NURBSCurve<Vector4>> for RevolutedCurve<NURBSCurve<Vector4>> {
fn include(&self, curve: &NURBSCurve<Vector4>) -> bool {
impl IncludeCurve<NurbsCurve<Vector4>> for RevolutedCurve<NurbsCurve<Vector4>> {
fn include(&self, curve: &NurbsCurve<Vector4>) -> bool {
let knots = curve.knot_vec().to_single_multi().0;
let degree = curve.degree() + usize::max(2, self.curve.degree());
sub_include(self, curve, &knots, degree)
Expand Down Expand Up @@ -555,7 +555,7 @@ fn include_curve_abnormal0() {

#[test]
fn include_curve_abnormal1() {
let curve = NURBSCurve::new(BSplineCurve::new(
let curve = NurbsCurve::new(BSplineCurve::new(
KnotVec::bezier_knot(3),
vec![
Vector4::new(0.0, 3.0, 0.0, 1.0),
Expand Down
2 changes: 1 addition & 1 deletion truck-geometry/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ the number of control points: {1}"
/// let weights = vec![1.0, 2.0]; // less than control points
///
/// assert!(matches!(
/// NURBSCurve::<Vector3>::try_from_bspline_and_weights(bspcurve, weights),
/// NurbsCurve::<Vector3>::try_from_bspline_and_weights(bspcurve, weights),
/// Err(Error::DifferentLength),
/// ));
/// ```
Expand Down
1 change: 0 additions & 1 deletion truck-geometry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
unused_import_braces,
unused_qualifications
)]
#![allow(clippy::many_single_char_names)]

use serde::{Deserialize, Serialize};
use std::fmt::Debug;
Expand Down
Loading