mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-27 01:25:52 +00:00
Merge pull request #376 from hannobraun/debug
Extract `fj-debug` from `fj-app`
This commit is contained in:
commit
1c2d086639
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -631,6 +631,7 @@ dependencies = [
|
||||
"clap",
|
||||
"figment",
|
||||
"fj",
|
||||
"fj-debug",
|
||||
"fj-math",
|
||||
"futures",
|
||||
"libloading",
|
||||
@ -651,6 +652,13 @@ dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fj-debug"
|
||||
version = "0.5.0"
|
||||
dependencies = [
|
||||
"parry3d-f64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fj-math"
|
||||
version = "0.5.0"
|
||||
|
@ -3,6 +3,7 @@ resolver = "2"
|
||||
members = [
|
||||
"fj",
|
||||
"fj-app",
|
||||
"fj-debug",
|
||||
"fj-math",
|
||||
|
||||
"models/cuboid",
|
||||
@ -14,5 +15,6 @@ members = [
|
||||
]
|
||||
default-members = [
|
||||
"fj-app",
|
||||
"fj-debug",
|
||||
"fj-math",
|
||||
]
|
||||
|
@ -43,6 +43,10 @@ features = ["env", "toml"]
|
||||
version = "0.5.0"
|
||||
path = "../fj"
|
||||
|
||||
[dependencies.fj-debug]
|
||||
version = "0.5.0"
|
||||
path = "../fj-debug"
|
||||
|
||||
[dependencies.fj-math]
|
||||
version = "0.5.0"
|
||||
path = "../fj-math"
|
||||
|
@ -1,36 +0,0 @@
|
||||
use parry3d_f64::query::Ray;
|
||||
|
||||
/// Debug info from the CAD kernel that can be visualized
|
||||
///
|
||||
/// At this point, this is a placeholder that will be filled with life later.
|
||||
pub struct DebugInfo {
|
||||
/// Rays being used during face triangulation
|
||||
pub triangle_edge_checks: Vec<TriangleEdgeCheck>,
|
||||
}
|
||||
|
||||
impl DebugInfo {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
triangle_edge_checks: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.triangle_edge_checks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Record of a check to determine if a triangle edge is within a face
|
||||
pub struct TriangleEdgeCheck {
|
||||
pub ray: Ray,
|
||||
pub hits: Vec<f64>,
|
||||
}
|
||||
|
||||
impl TriangleEdgeCheck {
|
||||
pub fn new(ray: Ray) -> Self {
|
||||
Self {
|
||||
ray,
|
||||
hits: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,9 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::Triangle;
|
||||
use nalgebra::{vector, Point};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
mesh::{Index, MeshMaker},
|
||||
};
|
||||
use crate::mesh::{Index, MeshMaker};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Vertices {
|
||||
|
@ -1,17 +1,15 @@
|
||||
use std::collections::HashSet;
|
||||
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Point, Scalar, Triangle, Vector};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{
|
||||
use crate::kernel::{
|
||||
geometry::{Circle, Curve, Line},
|
||||
topology::{
|
||||
edges::{Cycle, Edge},
|
||||
faces::Face,
|
||||
vertices::Vertex,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
@ -1,12 +1,10 @@
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Point, Scalar};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{
|
||||
use crate::kernel::{
|
||||
geometry::Surface,
|
||||
shape::Shape,
|
||||
topology::{edges::Cycle, faces::Face},
|
||||
},
|
||||
};
|
||||
|
||||
use super::ToShape;
|
||||
|
@ -1,17 +1,15 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Scalar};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{
|
||||
use crate::kernel::{
|
||||
shape::Shape,
|
||||
topology::{
|
||||
edges::{Cycle, Edge},
|
||||
faces::Face,
|
||||
vertices::Vertex,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
use super::ToShape;
|
||||
|
@ -1,17 +1,15 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Scalar};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{
|
||||
use crate::kernel::{
|
||||
shape::Shape,
|
||||
topology::{
|
||||
edges::{Cycle, Edge},
|
||||
faces::Face,
|
||||
vertices::Vertex,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
use super::ToShape;
|
||||
|
@ -5,10 +5,9 @@ pub mod sketch;
|
||||
pub mod sweep;
|
||||
pub mod transform;
|
||||
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Scalar};
|
||||
|
||||
use crate::debug::DebugInfo;
|
||||
|
||||
use super::shape::Shape;
|
||||
|
||||
/// Implemented by all shapes
|
||||
|
@ -1,12 +1,10 @@
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Point, Scalar};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{
|
||||
use crate::kernel::{
|
||||
geometry::Surface,
|
||||
shape::Shape,
|
||||
topology::{edges::Cycle, faces::Face, vertices::Vertex},
|
||||
},
|
||||
};
|
||||
|
||||
use super::ToShape;
|
||||
|
@ -1,9 +1,7 @@
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Scalar, Vector};
|
||||
|
||||
use crate::{
|
||||
debug::DebugInfo,
|
||||
kernel::{algorithms::sweep::sweep_shape, shape::Shape},
|
||||
};
|
||||
use crate::kernel::{algorithms::sweep::sweep_shape, shape::Shape};
|
||||
|
||||
use super::ToShape;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::{Aabb, Scalar, Transform};
|
||||
use parry3d_f64::math::Isometry;
|
||||
|
||||
use crate::{debug::DebugInfo, kernel::shape::Shape};
|
||||
use crate::kernel::shape::Shape;
|
||||
|
||||
use super::ToShape;
|
||||
|
||||
|
@ -3,19 +3,15 @@ use std::{
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
use fj_debug::{DebugInfo, TriangleEdgeCheck};
|
||||
use fj_math::{Aabb, Scalar, Segment, Triangle};
|
||||
use parry2d_f64::query::{Ray as Ray2, RayCast as _};
|
||||
use parry3d_f64::query::Ray as Ray3;
|
||||
|
||||
use crate::{
|
||||
debug::{DebugInfo, TriangleEdgeCheck},
|
||||
kernel::{
|
||||
algorithms::{
|
||||
approximation::Approximation, triangulation::triangulate,
|
||||
},
|
||||
use crate::kernel::{
|
||||
algorithms::{approximation::Approximation, triangulation::triangulate},
|
||||
geometry::Surface,
|
||||
shape::Handle,
|
||||
},
|
||||
};
|
||||
|
||||
use super::edges::Cycle;
|
||||
|
@ -1,7 +1,6 @@
|
||||
mod args;
|
||||
mod camera;
|
||||
mod config;
|
||||
mod debug;
|
||||
mod graphics;
|
||||
mod input;
|
||||
mod kernel;
|
||||
@ -14,6 +13,7 @@ use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
use std::{collections::HashMap, sync::mpsc, time::Instant};
|
||||
|
||||
use fj_debug::DebugInfo;
|
||||
use fj_math::Scalar;
|
||||
use futures::executor::block_on;
|
||||
use notify::Watcher as _;
|
||||
@ -29,7 +29,6 @@ use crate::{
|
||||
args::Args,
|
||||
camera::Camera,
|
||||
config::Config,
|
||||
debug::DebugInfo,
|
||||
graphics::{DrawConfig, Renderer},
|
||||
kernel::shapes::ToShape as _,
|
||||
mesh::MeshMaker,
|
||||
|
14
fj-debug/Cargo.toml
Normal file
14
fj-debug/Cargo.toml
Normal file
@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "fj-debug"
|
||||
version = "0.5.0"
|
||||
edition = "2021"
|
||||
|
||||
description = "The world needs another CAD program."
|
||||
readme = "../README.md"
|
||||
repository = "https://github.com/hannobraun/fornjot"
|
||||
license = "0BSD"
|
||||
keywords = ["cad", "programmatic", "code-cad"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
parry3d-f64 = "0.8.0"
|
54
fj-debug/src/lib.rs
Normal file
54
fj-debug/src/lib.rs
Normal file
@ -0,0 +1,54 @@
|
||||
//! Debug information definitions for the Fornjot ecosystem
|
||||
//!
|
||||
//! This crate contains debug information that is used by other crates within
|
||||
//! the Fornjot ecosystem. The types in here aren't very useful in themselves,
|
||||
//! but they define an interface that other crates use to communicate between
|
||||
//! each other.
|
||||
|
||||
#![deny(missing_docs)]
|
||||
|
||||
use parry3d_f64::query::Ray;
|
||||
|
||||
/// Debug info from the CAD kernel that can be visualized
|
||||
///
|
||||
/// At this point, this is a placeholder that will be filled with life later.
|
||||
#[derive(Default)]
|
||||
pub struct DebugInfo {
|
||||
/// Rays being used during face triangulation
|
||||
pub triangle_edge_checks: Vec<TriangleEdgeCheck>,
|
||||
}
|
||||
|
||||
impl DebugInfo {
|
||||
/// Construct an empty instance of `DebugInfo`
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Clear all information within this instance
|
||||
///
|
||||
/// The resulting instance is the same, as if created by [`DebugInfo::new`],
|
||||
/// but calling `clear` might be more efficient in regard to heap
|
||||
/// allocations.
|
||||
pub fn clear(&mut self) {
|
||||
self.triangle_edge_checks.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// Record of a check to determine if a triangle edge is within a face
|
||||
pub struct TriangleEdgeCheck {
|
||||
/// The ray used to perform the check
|
||||
pub ray: Ray,
|
||||
|
||||
/// Where the ray hit any edges of the face
|
||||
pub hits: Vec<f64>,
|
||||
}
|
||||
|
||||
impl TriangleEdgeCheck {
|
||||
/// Construct a new instance
|
||||
pub fn new(ray: Ray) -> Self {
|
||||
Self {
|
||||
ray,
|
||||
hits: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user