forked from 1b-agent/opencadstudio-upstream
feat(model): add exact solid modelling tools
This commit is contained in:
1 parent
fb2ea1e831
commit
06cd0ec6a9
51 files changed
+1487
-574
No files matched your search
@@ -3,12 +3,21 @@
|
||||
//! Analytic surfaces remain analytic instead of becoming facets.
|
||||
|
||||
use cadkernel::acis::append;
|
||||
use acadrust::entities::acis::SatDocument;
|
||||
use acadrust::entities::acis::{SabReader, SabWriter, SatDocument};
|
||||
use cadkernel::brep::Body;
|
||||
|
||||
/// Returns `None` when the body contains an unsupported record form.
|
||||
pub fn planar_solid_to_sat(body: &Body) -> Option<SatDocument> {
|
||||
pub fn solid_to_sat(body: &Body) -> Option<SatDocument> {
|
||||
let mut document = SatDocument::new();
|
||||
append(body, &mut document).ok()?;
|
||||
Some(document)
|
||||
let document = SatDocument::parse(&document.to_sat_string()).ok()?;
|
||||
let valid = |candidate: &SatDocument| {
|
||||
let (restored, loss) = cadkernel::acis::lift(candidate);
|
||||
loss.is_empty() && restored.len() == 1 && restored[0].validate().is_empty()
|
||||
};
|
||||
if !valid(&document) {
|
||||
return None;
|
||||
}
|
||||
let binary = SabWriter::write(&document);
|
||||
valid(&SabReader::read(&binary).ok()?).then_some(document)
|
||||
}
|
||||
Reference in new issue
Block a user