Skip to content

Commit

Permalink
add prototype of OpLog + EvolutionLog
Browse files Browse the repository at this point in the history
  • Loading branch information
MattFerraro committed May 29, 2024
1 parent d032c1e commit 77a46e9
Show file tree
Hide file tree
Showing 11 changed files with 1,643 additions and 64 deletions.
66 changes: 66 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cadmium/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ svg = "0.13.1"
geo = "0.26.0"
serde_with = "3.4.0"
crc32fast = "1.3.2"
sha2 = "0.10.8"
indexmap = "2.1.0"
anyhow = { version = "1.0.86", features = ["backtrace"] }
thiserror = "1.0.61"
Expand Down
17 changes: 15 additions & 2 deletions packages/cadmium/src/archetypes.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use tsify::Tsify;
use serde::{Deserialize, Serialize};
use truck_modeling::Plane as TruckPlane;
use truck_modeling::InnerSpace;
use truck_modeling::Plane as TruckPlane;
use tsify::Tsify;

use crate::sketch::Point2;

#[derive(Tsify, Debug, Serialize, Deserialize)]
#[tsify(into_wasm_abi, from_wasm_abi)]
pub enum PlaneDescription {
None,
PlaneId(String),
SolidFace { solid_id: String, normal: Vector3 },
}
Expand Down Expand Up @@ -87,6 +88,18 @@ impl Plane {
}
}

pub fn from_truck_face(tf: truck_modeling::Face) -> Self {
let os = tf.oriented_surface();
match os {
truck_modeling::geometry::Surface::Plane(p) => {
return Plane::from_truck(p);
}
_ => {
panic!("I only know how to put sketches on planes");
}
}
}

pub fn project(&self, point: &Point3) -> Point2 {
let minus_origin = point.minus(&self.origin);
let x = minus_origin.dot(&self.primary);
Expand Down
5 changes: 2 additions & 3 deletions packages/cadmium/src/extrusion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::archetypes::{Point3, Vector3};
use crate::project::{RealPlane, RealSketch};
use crate::sketch::{arc_to_points, Face, Sketch};

use truck_modeling::{Point3 as TruckPoint3, Surface, Plane};
use truck_modeling::{Plane, Point3 as TruckPoint3, Surface};

use truck_topology::Solid as TruckSolid;

Expand Down Expand Up @@ -384,8 +384,8 @@ fn are_coplanar(p0: Plane, p1: Plane) -> bool {

#[cfg(test)]
mod tests {
use crate::project::Project;
use crate::project::tests::create_test_project;
use crate::project::Project;

#[allow(unused_imports)]
use super::*;
Expand Down Expand Up @@ -443,5 +443,4 @@ mod tests {
realization.save_solid_as_step_file(keys[0], "pkg/test.step");
realization.save_solid_as_obj_file(keys[0], "pkg/test.obj", 0.001);
}

}
3 changes: 2 additions & 1 deletion packages/cadmium/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ pub mod archetypes;
pub mod error;
pub mod extrusion;
pub mod message;
pub mod oplog;
pub mod project;
pub mod realization;
pub mod solid;
pub mod sketch;
pub mod solid;
pub mod step;
pub mod workbench;

Expand Down
Loading

0 comments on commit 77a46e9

Please sign in to comment.