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",
|
"clap",
|
||||||
"figment",
|
"figment",
|
||||||
"fj",
|
"fj",
|
||||||
|
"fj-debug",
|
||||||
"fj-math",
|
"fj-math",
|
||||||
"futures",
|
"futures",
|
||||||
"libloading",
|
"libloading",
|
||||||
@ -651,6 +652,13 @@ dependencies = [
|
|||||||
"winit",
|
"winit",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fj-debug"
|
||||||
|
version = "0.5.0"
|
||||||
|
dependencies = [
|
||||||
|
"parry3d-f64",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fj-math"
|
name = "fj-math"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
|
@ -3,6 +3,7 @@ resolver = "2"
|
|||||||
members = [
|
members = [
|
||||||
"fj",
|
"fj",
|
||||||
"fj-app",
|
"fj-app",
|
||||||
|
"fj-debug",
|
||||||
"fj-math",
|
"fj-math",
|
||||||
|
|
||||||
"models/cuboid",
|
"models/cuboid",
|
||||||
@ -14,5 +15,6 @@ members = [
|
|||||||
]
|
]
|
||||||
default-members = [
|
default-members = [
|
||||||
"fj-app",
|
"fj-app",
|
||||||
|
"fj-debug",
|
||||||
"fj-math",
|
"fj-math",
|
||||||
]
|
]
|
||||||
|
@ -43,6 +43,10 @@ features = ["env", "toml"]
|
|||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
path = "../fj"
|
path = "../fj"
|
||||||
|
|
||||||
|
[dependencies.fj-debug]
|
||||||
|
version = "0.5.0"
|
||||||
|
path = "../fj-debug"
|
||||||
|
|
||||||
[dependencies.fj-math]
|
[dependencies.fj-math]
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
path = "../fj-math"
|
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 bytemuck::{Pod, Zeroable};
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::Triangle;
|
use fj_math::Triangle;
|
||||||
use nalgebra::{vector, Point};
|
use nalgebra::{vector, Point};
|
||||||
|
|
||||||
use crate::{
|
use crate::mesh::{Index, MeshMaker};
|
||||||
debug::DebugInfo,
|
|
||||||
mesh::{Index, MeshMaker},
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Vertices {
|
pub struct Vertices {
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Point, Scalar, Triangle, Vector};
|
use fj_math::{Point, Scalar, Triangle, Vector};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::DebugInfo,
|
geometry::{Circle, Curve, Line},
|
||||||
kernel::{
|
topology::{
|
||||||
geometry::{Circle, Curve, Line},
|
edges::{Cycle, Edge},
|
||||||
topology::{
|
faces::Face,
|
||||||
edges::{Cycle, Edge},
|
vertices::Vertex,
|
||||||
faces::Face,
|
|
||||||
vertices::Vertex,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Point, Scalar};
|
use fj_math::{Aabb, Point, Scalar};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::DebugInfo,
|
geometry::Surface,
|
||||||
kernel::{
|
shape::Shape,
|
||||||
geometry::Surface,
|
topology::{edges::Cycle, faces::Face},
|
||||||
shape::Shape,
|
|
||||||
topology::{edges::Cycle, faces::Face},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ToShape;
|
use super::ToShape;
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Scalar};
|
use fj_math::{Aabb, Scalar};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::DebugInfo,
|
shape::Shape,
|
||||||
kernel::{
|
topology::{
|
||||||
shape::Shape,
|
edges::{Cycle, Edge},
|
||||||
topology::{
|
faces::Face,
|
||||||
edges::{Cycle, Edge},
|
vertices::Vertex,
|
||||||
faces::Face,
|
|
||||||
vertices::Vertex,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Scalar};
|
use fj_math::{Aabb, Scalar};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::DebugInfo,
|
shape::Shape,
|
||||||
kernel::{
|
topology::{
|
||||||
shape::Shape,
|
edges::{Cycle, Edge},
|
||||||
topology::{
|
faces::Face,
|
||||||
edges::{Cycle, Edge},
|
vertices::Vertex,
|
||||||
faces::Face,
|
|
||||||
vertices::Vertex,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,10 +5,9 @@ pub mod sketch;
|
|||||||
pub mod sweep;
|
pub mod sweep;
|
||||||
pub mod transform;
|
pub mod transform;
|
||||||
|
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Scalar};
|
use fj_math::{Aabb, Scalar};
|
||||||
|
|
||||||
use crate::debug::DebugInfo;
|
|
||||||
|
|
||||||
use super::shape::Shape;
|
use super::shape::Shape;
|
||||||
|
|
||||||
/// Implemented by all shapes
|
/// Implemented by all shapes
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Point, Scalar};
|
use fj_math::{Aabb, Point, Scalar};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::DebugInfo,
|
geometry::Surface,
|
||||||
kernel::{
|
shape::Shape,
|
||||||
geometry::Surface,
|
topology::{edges::Cycle, faces::Face, vertices::Vertex},
|
||||||
shape::Shape,
|
|
||||||
topology::{edges::Cycle, faces::Face, vertices::Vertex},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::ToShape;
|
use super::ToShape;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Scalar, Vector};
|
use fj_math::{Aabb, Scalar, Vector};
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{algorithms::sweep::sweep_shape, shape::Shape};
|
||||||
debug::DebugInfo,
|
|
||||||
kernel::{algorithms::sweep::sweep_shape, shape::Shape},
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::ToShape;
|
use super::ToShape;
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::{Aabb, Scalar, Transform};
|
use fj_math::{Aabb, Scalar, Transform};
|
||||||
use parry3d_f64::math::Isometry;
|
use parry3d_f64::math::Isometry;
|
||||||
|
|
||||||
use crate::{debug::DebugInfo, kernel::shape::Shape};
|
use crate::kernel::shape::Shape;
|
||||||
|
|
||||||
use super::ToShape;
|
use super::ToShape;
|
||||||
|
|
||||||
|
@ -3,19 +3,15 @@ use std::{
|
|||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use fj_debug::{DebugInfo, TriangleEdgeCheck};
|
||||||
use fj_math::{Aabb, Scalar, Segment, Triangle};
|
use fj_math::{Aabb, Scalar, Segment, Triangle};
|
||||||
use parry2d_f64::query::{Ray as Ray2, RayCast as _};
|
use parry2d_f64::query::{Ray as Ray2, RayCast as _};
|
||||||
use parry3d_f64::query::Ray as Ray3;
|
use parry3d_f64::query::Ray as Ray3;
|
||||||
|
|
||||||
use crate::{
|
use crate::kernel::{
|
||||||
debug::{DebugInfo, TriangleEdgeCheck},
|
algorithms::{approximation::Approximation, triangulation::triangulate},
|
||||||
kernel::{
|
geometry::Surface,
|
||||||
algorithms::{
|
shape::Handle,
|
||||||
approximation::Approximation, triangulation::triangulate,
|
|
||||||
},
|
|
||||||
geometry::Surface,
|
|
||||||
shape::Handle,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::edges::Cycle;
|
use super::edges::Cycle;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
mod args;
|
mod args;
|
||||||
mod camera;
|
mod camera;
|
||||||
mod config;
|
mod config;
|
||||||
mod debug;
|
|
||||||
mod graphics;
|
mod graphics;
|
||||||
mod input;
|
mod input;
|
||||||
mod kernel;
|
mod kernel;
|
||||||
@ -14,6 +13,7 @@ use std::ffi::OsStr;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::{collections::HashMap, sync::mpsc, time::Instant};
|
use std::{collections::HashMap, sync::mpsc, time::Instant};
|
||||||
|
|
||||||
|
use fj_debug::DebugInfo;
|
||||||
use fj_math::Scalar;
|
use fj_math::Scalar;
|
||||||
use futures::executor::block_on;
|
use futures::executor::block_on;
|
||||||
use notify::Watcher as _;
|
use notify::Watcher as _;
|
||||||
@ -29,7 +29,6 @@ use crate::{
|
|||||||
args::Args,
|
args::Args,
|
||||||
camera::Camera,
|
camera::Camera,
|
||||||
config::Config,
|
config::Config,
|
||||||
debug::DebugInfo,
|
|
||||||
graphics::{DrawConfig, Renderer},
|
graphics::{DrawConfig, Renderer},
|
||||||
kernel::shapes::ToShape as _,
|
kernel::shapes::ToShape as _,
|
||||||
mesh::MeshMaker,
|
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