forked from 1b-agent/opencadstudio-upstream
Finish Ramox edge and slice integration
This commit is contained in:
1 parent
d3f0d0ec42
commit
fd3ddc1608
26 files changed
+954
-67
No files matched your search
@@ -21,3 +21,54 @@ pub fn solid_to_sat(body: &Body) -> Option<SatDocument> {
|
||||
let binary = SabWriter::write(&document);
|
||||
valid(&SabReader::read(&binary).ok()?).then_some(document)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use cadkernel::geom2d::{Arc, Curve};
|
||||
use cadkernel::space::Plane;
|
||||
|
||||
fn circle_section(z: f64, radius: f64) -> (Plane, Vec<Curve>) {
|
||||
let curves = (0..4)
|
||||
.map(|part| {
|
||||
let start = std::f64::consts::FRAC_PI_2 * part as f64;
|
||||
Curve::Arc(Arc {
|
||||
centre: [0.0, 0.0],
|
||||
radius,
|
||||
start_angle: start,
|
||||
end_angle: start + std::f64::consts::FRAC_PI_2,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
(
|
||||
Plane::from_axes([0.0, 0.0, z], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]),
|
||||
curves,
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_curved_loft_round_trips_through_text_and_binary_acis() {
|
||||
let body = cadkernel::brep::loft(&[
|
||||
circle_section(0.0, 5.0),
|
||||
circle_section(10.0, 2.0),
|
||||
])
|
||||
.unwrap();
|
||||
assert!(body.validate().is_empty());
|
||||
|
||||
let mut document = SatDocument::new();
|
||||
cadkernel::acis::append(&body, &mut document).unwrap();
|
||||
let text = document.to_sat_string();
|
||||
let parsed = SatDocument::parse(&text).unwrap();
|
||||
let (restored, text_loss) = cadkernel::acis::lift(&parsed);
|
||||
assert!(text_loss.is_empty(), "{text_loss:?}");
|
||||
assert_eq!(restored.len(), 1);
|
||||
assert!(restored[0].validate().is_empty());
|
||||
|
||||
let binary = SabWriter::write(&parsed);
|
||||
let parsed_binary = SabReader::read(&binary).unwrap();
|
||||
let (restored, binary_loss) = cadkernel::acis::lift(&parsed_binary);
|
||||
assert!(binary_loss.is_empty(), "{binary_loss:?}");
|
||||
assert_eq!(restored.len(), 1);
|
||||
assert!(restored[0].validate().is_empty());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user