brep_kernel/offset/
offset_shell.rs1use crate::boolean::{assemble_open_fragments, edge_interior_lies_on, finalize_assembled_solid};
2use crate::classification::{parameter_point_in_face, PolygonClass};
3use crate::face_merge::merge_same_surface_faces_open;
4use crate::fragment::{fragment_solid, FaceFragmentRecord, FragmentEdgeSource};
5use crate::imprint::{
6 EdgeSplitRecord, FaceImprints, FaceKey, FacePcurve, ImprintOptions, ImprintPieceRecord,
7 ImprintResultRecord, ImprintVertex,
8};
9use crate::mass_properties::parameter_space_area;
10use crate::project_point_to_surface;
11use crate::topology::{
12 BrepSolid, CoedgeRecord, EdgeRecord, FaceRecord, LoopRecord, ShellRecord, VertexRecord,
13};
14use crate::{
15 apply_edge_splits, build_imprints, classify_point, offset_face_carrier, DiagnosticSeverity,
16 KernelDiagnostics, KernelOutcome, KernelStage, KernelTolerances, PointClass, Vec2, Vec3,
17};
18use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};
19use serde::Serialize;
20
21const SOURCE_OPERAND: u8 = 250;
22
23fn debug_enabled() -> bool {
24 std::env::var("BREP_OS_DEBUG").is_ok_and(|value| !value.is_empty() && value != "0")
25}
26
27macro_rules! os_debug {
28 ($($arg:tt)*) => {
29 if debug_enabled() {
30 eprintln!($($arg)*);
31 }
32 };
33}
34
35#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize)]
36#[serde(rename_all = "lowercase")]
37pub enum OffsetFaceRole {
38 Source,
39 Offset,
40 Wall,
41}
42
43#[derive(Clone, Debug, Serialize)]
44pub struct OffsetShellResultRecord {
45 pub solid: BrepSolid,
46 pub face_images: Vec<OffsetShellFaceImageRecord>,
47}
48
49#[derive(Clone, Debug, Serialize)]
50pub struct OffsetShellFaceImageRecord {
51 pub role: OffsetFaceRole,
52 pub source_face_id: u64,
53}
54
55#[derive(Clone)]
56struct Carrier {
57 solid: BrepSolid,
58 source_face_id: u64,
59 kind: OffsetFaceRole,
60}
61
62#[path = "offset_shell/carriers.rs"]
86mod carriers;
87#[path = "offset_shell/smooth_sync.rs"]
88mod smooth_sync;
89#[path = "offset_shell/carrier_rebuild.rs"]
90mod carrier_rebuild;
91#[path = "offset_shell/connectors.rs"]
92mod connectors;
93#[path = "offset_shell/orientation.rs"]
94mod orientation;
95#[path = "offset_shell/rim_welds.rs"]
96mod rim_welds;
97#[path = "offset_shell/pipeline.rs"]
98mod pipeline;
99#[cfg(test)]
100#[path = "offset_shell/tests.rs"]
101mod tests;
102
103use carrier_rebuild::*;
104use carriers::*;
105use connectors::*;
106use orientation::*;
107use rim_welds::*;
108use smooth_sync::*;
109
110pub use pipeline::{offset_shell, offset_shell_with_diagnostics};
111pub(crate) use orientation::{flip_all_faces, flip_shell_faces, orient_open_solid_faces};