Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions main/opengeometry/src/brep/builder/boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn dimensions(values: &[f64]) -> Result<(), GeometryError> {
Ok(())
}

pub(crate) fn plane_boundary(
pub fn plane_boundary(
builder: &Builder,
frame: Frame3,
edge: u32,
Expand Down Expand Up @@ -50,16 +50,10 @@ pub(crate) fn plane_boundary(
Ok(boundary(edge, from, to, sense, pcurve))
}

pub(crate) fn uv_line(origin: [f64; 2], direction: [f64; 2]) -> PcurveGeometry {
pub fn uv_line(origin: [f64; 2], direction: [f64; 2]) -> PcurveGeometry {
PcurveGeometry::Line2 { origin, direction }
}
pub(crate) fn boundary(
edge: u32,
from: u32,
to: u32,
sense: Orientation,
pcurve: PcurveGeometry,
) -> Use {
pub fn boundary(edge: u32, from: u32, to: u32, sense: Orientation, pcurve: PcurveGeometry) -> Use {
Use {
edge,
from,
Expand Down
35 changes: 25 additions & 10 deletions main/opengeometry/src/brep/builder/brep_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ use crate::brep::topology::{
};
use crate::math::{Interval, Point3};

pub(crate) struct Use {
pub struct Use {
pub(super) edge: u32,
pub(super) from: u32,
pub(super) to: u32,
pub(super) sense: Orientation,
pub(super) pcurve: PcurveGeometry,
}

pub(crate) struct Builder {
pub struct Builder {
pub(crate) brep: BrepEnvelope,
}
impl Builder {
pub(crate) fn new(id: String, accuracy: Accuracy) -> Result<Self, GeometryError> {
pub fn new(id: String, accuracy: Accuracy) -> Result<Self, GeometryError> {
Ok(Self {
brep: BrepEnvelope::new(id, accuracy)?,
})
}
pub(crate) fn vertex(&mut self, p: Point3) -> u32 {
pub fn brep(&self) -> &BrepEnvelope {
&self.brep
}
pub fn vertex(&mut self, p: Point3) -> u32 {
let id = self.brep.topology.vertices.len() as u32;
self.brep.topology.vertices.push(Vertex {
id,
Expand All @@ -35,7 +38,7 @@ impl Builder {
});
id
}
pub(crate) fn edge(&mut self, curve: CurveGeometry, range: Interval, seam: bool) -> u32 {
pub fn edge(&mut self, curve: CurveGeometry, range: Interval, seam: bool) -> u32 {
let curve_id = self.brep.geometry.curves.len() as u32;
self.brep.geometry.curves.push(curve);
self.edge_geometry(
Expand Down Expand Up @@ -129,23 +132,23 @@ impl Builder {
});
Ok(loop_id)
}
pub(crate) fn face(
pub fn face(
&mut self,
key: &str,
surface: SurfaceGeometry,
bounds: [[f64; 2]; 2],
uses: Vec<Use>,
) -> Result<(), GeometryError> {
) -> Result<u32, GeometryError> {
self.face_with_holes(key, surface, bounds, uses, Vec::new())
}
pub(crate) fn face_with_holes(
pub fn face_with_holes(
&mut self,
key: &str,
surface: SurfaceGeometry,
bounds: [[f64; 2]; 2],
outer_uses: Vec<Use>,
hole_uses: Vec<Vec<Use>>,
) -> Result<(), GeometryError> {
) -> Result<u32, GeometryError> {
let surface_id = self.brep.geometry.surfaces.len() as u32;
self.brep.geometry.surfaces.push(surface);
let face = self.brep.topology.faces.len() as u32;
Expand Down Expand Up @@ -180,9 +183,21 @@ impl Builder {
reversed: false,
},
});
Ok(face)
}
pub fn set_face_sense(&mut self, face: u32, sense: Orientation) -> Result<(), GeometryError> {
self.brep
.topology
.faces
.get_mut(face as usize)
.ok_or(GeometryError::MissingReference {
kind: "face".into(),
index: face,
})?
.sense = sense;
Ok(())
}
pub(crate) fn finish_solid(mut self) -> Result<BrepEnvelope, GeometryError> {
pub fn finish_solid(mut self) -> Result<BrepEnvelope, GeometryError> {
let faces = (0..self.brep.topology.faces.len() as u32).collect();
self.brep.topology.shells.push(Shell {
id: 0,
Expand Down
5 changes: 3 additions & 2 deletions main/opengeometry/src/brep/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod brep_builder;
mod tests;
mod wire;

pub(crate) use boundary::{boundary, dimensions, padded_uv_bounds, plane_boundary, uv_line};
pub(crate) use brep_builder::{Builder, Use};
pub use boundary::{boundary, plane_boundary, uv_line};
pub(crate) use boundary::{dimensions, padded_uv_bounds};
pub use brep_builder::{Builder, Use};
pub(crate) use wire::WireUse;
14 changes: 7 additions & 7 deletions main/opengeometry/src/brep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ mod validate;
pub use accuracy::Accuracy;
pub use body_type::BodyType;
pub use bounds::PatchBounds;
pub(super) use builder::{
boundary, dimensions, padded_uv_bounds, plane_boundary, uv_line, Builder, Use, WireUse,
};
pub use builder::{boundary, plane_boundary, uv_line, Builder, Use};
pub(super) use builder::{dimensions, padded_uv_bounds, WireUse};
pub(super) use error::coverage_gap;
pub use error::GeometryError;
pub use frame::Frame3;
Expand All @@ -33,15 +32,16 @@ pub use geometry::{
CurveGeometry, GeometryStore, IntersectionPoint, Surface, SurfaceChart, SurfaceGeometry,
SurfaceJet2,
};
pub(super) use pcurve::{period_lifted_uv, IntersectionSide, PcurveGeometry};
pub(super) use pcurve::period_lifted_uv;
pub use pcurve::{IntersectionSide, PcurveGeometry};
pub use placement::{mirror::mirrored, placed};
pub use similarity::Similarity3;
#[cfg(test)]
pub(super) use topology::{circular_face, coarse_accuracy, fine_accuracy};
pub use topology::{
BrepEnvelope, Edge, Face, FaceProvenance, FaceRole, FaceSource, HalfEdge, Topology, Vertex,
BrepEnvelope, Edge, Face, FaceProvenance, FaceRole, FaceSource, HalfEdge, Orientation,
Topology, Vertex,
};
pub(super) use topology::{
EdgeGeometry, GeometryQuality, HalfEdgeGeometryUse, Loop, Orientation, Shell, SolidRegion,
TrimRegion, Wire,
EdgeGeometry, GeometryQuality, HalfEdgeGeometryUse, Loop, Shell, SolidRegion, TrimRegion, Wire,
};
4 changes: 2 additions & 2 deletions main/opengeometry/src/brep/pcurve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(tag = "kind", deny_unknown_fields)]
pub(crate) enum PcurveGeometry {
pub enum PcurveGeometry {
Line2 {
origin: UV,
direction: UV,
Expand All @@ -27,7 +27,7 @@ pub(crate) enum PcurveGeometry {
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub(crate) enum IntersectionSide {
pub enum IntersectionSide {
A,
B,
}
Expand Down
2 changes: 1 addition & 1 deletion main/opengeometry/src/brep/topology/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ pub(crate) use envelope::GeometryQuality;
pub(super) use envelope::SCHEMA_VERSION;
#[cfg(test)]
pub(crate) use fixtures::{circular_face, coarse_accuracy, fine_accuracy};
pub(crate) use orientation::Orientation;
pub use orientation::Orientation;
pub use provenance::{FaceProvenance, FaceRole, FaceSource};
2 changes: 1 addition & 1 deletion main/opengeometry/src/brep/topology/orientation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize};

#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub(crate) enum Orientation {
pub enum Orientation {
Forward,
Reverse,
}
Expand Down
2 changes: 1 addition & 1 deletion main/opengeometry/src/math/interval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn next_down(x: f64) -> f64 {
}

impl Interval {
pub(crate) fn new(lo: f64, hi: f64) -> Result<Self, MathError> {
pub fn new(lo: f64, hi: f64) -> Result<Self, MathError> {
finite(lo)?;
finite(hi)?;
if lo > hi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ fn add_two_arc_plane_face(
SurfaceGeometry::Plane { frame },
two_arc_plane_bounds(frame, arcs, tolerance),
uses,
)
)?;
Ok(())
}

fn set_embedded_provenance(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ fn add_parallel_caps(
SurfaceGeometry::Plane { frame: upper_frame },
planar_bounds,
upper_uses,
)
)?;
Ok(())
}

fn parallel_cap_bounds(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ pub(super) fn add_host_lateral_face(
),
],
host_holes,
)
)?;
Ok(())
}

pub(super) fn add_host_caps(
Expand Down Expand Up @@ -167,5 +168,6 @@ pub(super) fn add_host_caps(
axis_b: [0.0, host.radius],
},
)],
)
)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ fn add_cap_faces(
[bounds[0], [-bounds[1][1], -bounds[1][0]]],
bottom_outer,
bottom_holes,
)
)?;
Ok(())
}

fn cap_uses(
Expand Down
9 changes: 6 additions & 3 deletions main/opengeometry/src/primitives/internal/cylinder_sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ fn add_lateral_face(
uv_line([lo, 0.0], [0.0, 1.0]),
),
],
)
)?;
Ok(())
}

fn add_sector_caps(
Expand Down Expand Up @@ -258,7 +259,8 @@ fn add_sector_caps(
SurfaceGeometry::Plane { frame: top_frame },
[[-radius, radius]; 2],
top_uses,
)
)?;
Ok(())
}

fn add_radial_faces(
Expand Down Expand Up @@ -328,7 +330,8 @@ fn add_radial_faces(
SurfaceGeometry::Plane { frame: end_frame },
[[0.0, height], [0.0, radius]],
end_uses,
)
)?;
Ok(())
}

fn tangent(frame: Frame3, angle: f64) -> Point3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,5 +282,6 @@ fn add_annulus_caps(
[[-outer_radius, outer_radius]; 2],
outer_upper,
vec![inner_upper],
)
)?;
Ok(())
}
3 changes: 2 additions & 1 deletion main/opengeometry/src/primitives/internal/extruded_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ pub(super) fn add_plane_side(
SurfaceGeometry::Plane { frame: side_frame },
[[-g, norm(sub(destination, origin)) + g], [-g, height + g]],
uses,
)
)?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ fn add_cap_faces(
bottom_bounds,
bottom_outer,
bottom_holes,
)
)?;
Ok(())
}

fn cap_uses(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ fn add_plane_face(
[[-radius, radius]; 2],
vec![outer],
inner.into_iter().map(|hole| vec![hole]).collect(),
)
)?;
Ok(())
}

fn add_lateral_face(
Expand Down
6 changes: 4 additions & 2 deletions main/opengeometry/src/primitives/revolved_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ fn add_lower_cap(
axis_b: [0.0, -r0],
},
)],
)
)?;
Ok(())
}

fn add_upper_cap(
Expand All @@ -188,5 +189,6 @@ fn add_upper_cap(
axis_b: [0.0, r1],
},
)],
)
)?;
Ok(())
}
Loading