ifc_lite_geometry_runtime/
worker_empty.rs1use super::{BrepHandle, SmlibWorker, TessellatedMesh, WorkerError};
5use crate::protocol::KernelCommand;
6
7const SEMANTIC_EMPTY: u32 = 32;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum NumericalOutcome {
15 NonEmpty,
16 Empty,
17}
18
19impl SmlibWorker {
20 pub fn is_empty(&mut self, solid: BrepHandle) -> Result<bool, WorkerError> {
23 if self.capabilities()? & SEMANTIC_EMPTY == 0 {
24 return Err(self.poison("semantic empty query unavailable"));
25 }
26 let solid = self.wire(solid)?;
27 let bytes = self.call(KernelCommand::IsEmpty {
28 session: self.session,
29 solid,
30 })?;
31 match u32::from_le_bytes(self.fixed(bytes)?) {
32 0 => Ok(false),
33 1 => Ok(true),
34 _ => Err(self.poison("invalid semantic empty result")),
35 }
36 }
37
38 pub(super) fn certify_empty(
41 &mut self,
42 solid: BrepHandle,
43 ) -> Result<TessellatedMesh, WorkerError> {
44 if !self.is_empty(solid)? {
45 return Err(self.poison("zero tessellation of a nonempty solid"));
46 }
47 Ok(TessellatedMesh::empty())
48 }
49}