Skip to content

Commit

Permalink
refactor | s&t : export all through sal-3dlib
Browse files Browse the repository at this point in the history
  • Loading branch information
novartole committed Nov 19, 2024
1 parent 6921401 commit cae8656
Show file tree
Hide file tree
Showing 39 changed files with 108 additions and 53 deletions.
4 changes: 4 additions & 0 deletions crates/sal-3dlib-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "sal-3dlib-core"
version = "0.0.1"
edition = "2021"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions crates/sal-3dlib-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Abstact definition of objects and operations over the CAD kernel.
//! It is assumed that the kernel is universal, but it implements all the necessary traits.
//
pub mod bound;
pub mod gmath;
pub mod ops;
pub mod props;
pub mod topology;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 12 additions & 1 deletion crates/sal-3dlib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
[package]
name = "sal-3dlib"
version = "0.0.1"
version = "0.1.0"
edition = "2021"

[dependencies]
sal-3dlib-core = { path = "../sal-3dlib-core/" }
sal-occt-rs = { path = "../sal-occt-rs/" }

[dev-dependencies]
debugging.workspace = true
env_logger.workspace = true
log.workspace = true
testing.workspace = true
sal-sync.workspace = true
35 changes: 27 additions & 8 deletions crates/sal-3dlib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
//! This is a set of modules for interacting with the CAD kernel.
//! It is assumed that the kernel is universal,
//! but it implements all the necessary traits.
//! Set of modules for interacting with the CAD kernel.
//!
//! Main objects and operations are defined in the core module (see [sal_3dlib_core]).
//!
//! [sal_occt_rs] provides an implementation of the core.
//
pub mod bound;
pub mod gmath;
pub mod ops;
pub mod props;
pub mod topology;
pub use sal_3dlib_core::bound;
pub use sal_occt_rs::fs;
pub use sal_occt_rs::gmath;
///
/// Operations for creating, transforming, and modifying objects.
pub mod ops {
///
/// Create new objects from combinations of two groups of objects.
pub mod boolean {
///
/// Build an elementary volume from a set of objects.
pub mod volume {
pub use sal_3dlib_core::ops::boolean::volume::*;
pub use sal_occt_rs::ops::boolean::volume::VolumeConf;
}
pub use sal_3dlib_core::ops::boolean::*;
pub use sal_occt_rs::ops::boolean::OpConf;
}
pub use sal_3dlib_core::ops::{transform, Polygon};
}
pub use sal_3dlib_core::props;
pub use sal_occt_rs::export::topology;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
use debugging::session::debug_session::{Backtrace, DebugSession, LogLevel};
use sal_3dlib::{
fs::Reader,
gmath::Vector,
ops::{
boolean::{volume::Volume, Intersect},
boolean::{
volume::{Volume, VolumeConf},
Intersect, OpConf,
},
transform::{Rotate, Translate},
Polygon,
},
props::{Center, Metadata, Volume as _},
topology::Vertex,
topology::{
shape::{Face, Vertex, Wire},
Shape,
},
};
use sal_occt_rs::{fs::Reader, prelude::*};
use std::{
f64::consts::PI,
sync::Once,
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
anyhow = "1.0.93"
cxx = "1.0.130"
glam = { version = "0.24", features = ["bytemuck"] }
sal-3dlib = { path = "../sal-3dlib/" }
sal-3dlib-core = { path = "../sal-3dlib-core/" }
opencascade = { git = "https://github.com/novartole/opencascade-rs.git", branch = "dev" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
use crate::{prelude, topology::shape};
use opencascade::primitives::{self, ShapeType};
use sal_3dlib::props::Attributes;
use sal_3dlib_core::props::Attributes;
use std::path::Path;
///
/// Reader of various file format.
Expand Down
8 changes: 4 additions & 4 deletions crates/sal-occt-rs/src/gmath.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//! Implementation of [sal_3dlib::gmath].
//! Implementation of [sal_3dlib_core::gmath].
//
mod point;
mod vector;
//
use sal_3dlib::gmath;
use sal_3dlib_core::gmath;
///
/// Location in 3-dimensional space.
///
/// See [sal_3dlib::gmath::Point] for details.
/// See [sal_3dlib_core::gmath::Point] for details.
pub type Point = gmath::Point<3>;
///
/// Displacment in 3-dimensional space.
///
/// See [sal_3dlib::gmath::Vector] for details.
/// See [sal_3dlib_core::gmath::Vector] for details.
pub struct Vector(pub(crate) gmath::Vector<3>);
28 changes: 16 additions & 12 deletions crates/sal-occt-rs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,46 @@
//! Implementation of [sal_3dlib] taking [opencascade] as the CAD kernel.
//! Implementation of [sal_3dlib_core] taking [opencascade] as the CAD kernel.
//
pub mod fs;
pub mod gmath;
pub mod ops;
#[cfg(test)]
mod tests;
mod topology;
mod export {
pub mod export {
///
/// Implementation of [sal_3dlib_core::topology].
pub mod topology {
///
/// Implementation of [sal_3dlib_core::topology].
pub mod shape {
use sal_3dlib::topology;
use sal_3dlib_core::topology;
///
/// See [sal_3dlib::topology::Vertex] for details.
/// See [sal_3dlib_core::topology::Vertex] for details.
pub type Vertex<T> = topology::Vertex<3, super::Vertex, T>;
///
/// See [sal_3dlib::topology::Edge] for details.
/// See [sal_3dlib_core::topology::Edge] for details.
pub type Edge<T> = topology::Edge<3, super::Edge, T>;
///
/// See [sal_3dlib::topology::Wire] for details.
/// See [sal_3dlib_core::topology::Wire] for details.
pub type Wire<T> = topology::Wire<3, super::Wire, T>;
///
/// See [sal_3dlib::topology::Face] for details.
/// See [sal_3dlib_core::topology::Face] for details.
pub type Face<T> = topology::Face<3, super::Face, T>;
///
/// See [sal_3dlib::topology::Shell] for details.
/// See [sal_3dlib_core::topology::Shell] for details.
pub type Shell<T> = topology::Shell<3, super::Shell, T>;
///
/// See [sal_3dlib::topology::Solid] for details.
/// See [sal_3dlib_core::topology::Solid] for details.
pub type Solid<T> = topology::Solid<3, super::Solid, T>;
///
/// See [sal_3dlib::topology::Compound] for details.
/// See [sal_3dlib_core::topology::Compound] for details.
pub type Compound<T> = topology::Compound<3, super::Compound, T>;
}
//
use crate::topology::shape::*;
use sal_3dlib::topology;
use sal_3dlib_core::topology;
///
/// See [sal_3dlib::topology::Shape] for details.
/// See [sal_3dlib_core::topology::Shape] for details.
pub type Shape<T> = topology::Shape<3, Vertex, Edge, Wire, Face, Shell, Solid, Compound, T>;
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/ops.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//! Implementation of [sal_3dlib::ops].
//! Implementation of [sal_3dlib_core::ops].
//
pub mod boolean;
8 changes: 4 additions & 4 deletions crates/sal-occt-rs/src/ops/boolean.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Implementation of [sal_3dlib::ops::boolean].
//! Implementation of [sal_3dlib_core::ops::boolean].
//
pub mod volume;
//
use sal_3dlib::ops::boolean;
use sal_3dlib_core::ops::boolean;
///
/// See [sal_3dlib::ops::boolean::OpConf] for details.
/// See [sal_3dlib_core::ops::boolean::OpConf] for details.
#[derive(Clone, Copy)]
pub struct OpConf {
///
/// See [sal_3dlib::ops::boolean::OpConf::parallel] for details.
/// See [sal_3dlib_core::ops::boolean::OpConf::parallel] for details.
pub parallel: bool,
}
//
Expand Down
8 changes: 4 additions & 4 deletions crates/sal-occt-rs/src/ops/boolean/volume.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Implementation of [sal_3dlib::ops::boolean::volume].
//! Implementation of [sal_3dlib_core::ops::boolean::volume].
//
use super::*;
use sal_3dlib::ops::boolean::volume;
use sal_3dlib_core::ops::boolean::volume;
///
/// See [sal_3dlib::ops::boolean::volume::VolumeConf] for details.
/// See [sal_3dlib_core::ops::boolean::volume::VolumeConf] for details.
#[derive(Clone, Copy)]
pub struct VolumeConf {
///
/// See [sal_3dlib::ops::boolean::OpConf::parallel] for details.
/// See [sal_3dlib_core::ops::boolean::OpConf::parallel] for details.
pub parallel: bool,
}
//
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//! Implementation of [sal_3dlib::topology].
//! Inner structures used for [sal_3dlib_core::topology::Shape].
//
pub mod shape;
16 changes: 9 additions & 7 deletions crates/sal-occt-rs/src/topology/shape.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Inner structures used for [sal_3dlib_core::topology].
//
#![allow(dead_code)]
//
mod compound;
Expand All @@ -9,25 +11,25 @@ mod wire;
//
use opencascade::primitives;
///
/// Implementation of [sal_3dlib::topology::Vertex].
/// Implementation of [sal_3dlib_core::topology::Vertex].
pub struct Vertex(pub(crate) primitives::Vertex);
///
/// Implementation of [sal_3dlib::topology::Edge].
/// Implementation of [sal_3dlib_core::topology::Edge].
pub struct Edge(pub(crate) primitives::Edge);
///
/// Implementation of [sal_3dlib::topology::Wire].
/// Implementation of [sal_3dlib_core::topology::Wire].
pub struct Wire(pub(crate) primitives::Wire);
///
/// Implementation of [sal_3dlib::topology::Face].
/// Implementation of [sal_3dlib_core::topology::Face].
#[derive(Clone)]
pub struct Face(pub(crate) primitives::Face);
///
/// Implementation of [sal_3dlib::topology::Shell].
/// Implementation of [sal_3dlib_core::topology::Shell].
#[derive(Clone)]
pub struct Shell(pub(crate) primitives::Shell);
///
/// Implementation of [sal_3dlib::topology::Solid].
/// Implementation of [sal_3dlib_core::topology::Solid].
pub struct Solid(pub(crate) primitives::Solid);
///
/// Implementation of [sal_3dlib::topology::Compound].
/// Implementation of [sal_3dlib_core::topology::Compound].
pub struct Compound(pub(crate) primitives::Compound);
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/compound.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::*;
use sal_3dlib::props::Center;
use sal_3dlib_core::props::Center;
//
//
impl Center for Compound {
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/face.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::gmath::Vector;
use glam::DVec3;
use sal_3dlib::{
use sal_3dlib_core::{
ops::transform::{Rotate, Translate},
props::{Area, Center},
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/shell.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::ops::boolean::volume::VolumeConf;
use anyhow::Result;
use sal_3dlib::{ops::boolean::volume::Volume, props::Center};
use sal_3dlib_core::{ops::boolean::volume::Volume, props::Center};
//
//
impl Volume<Face, VolumeConf, Result<Solid>> for Shell {
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/solid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::ops::boolean::OpConf;
use primitives::IntoShape;
use sal_3dlib::{ops::boolean::Intersect, props::Volume};
use sal_3dlib_core::{ops::boolean::Intersect, props::Volume};
//
//
impl Volume for Solid {
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/vertex.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::gmath::Point;
use glam::DVec3;
use sal_3dlib::props::Dist;
use sal_3dlib_core::props::Dist;
//
//
impl From<Point> for Vertex {
Expand Down
2 changes: 1 addition & 1 deletion crates/sal-occt-rs/src/topology/shape/wire.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::*;
use crate::gmath::Point;
use glam::DVec3;
use sal_3dlib::ops::Polygon;
use sal_3dlib_core::ops::Polygon;
//
//
impl Polygon<Vertex> for Wire {
Expand Down

0 comments on commit cae8656

Please sign in to comment.