#![allow(clippy::missing_errors_doc)]
use crate::error::WasmError;
use crate::kernel::BrepKernel;
impl BrepKernel {
pub fn resolve_face(&self, handle: u32) -> Result<brepkit_topology::face::FaceId, WasmError> {
let index = handle as usize;
self.topo
.face_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "face",
index,
})
}
pub fn resolve_vertex(
&self,
handle: u32,
) -> Result<brepkit_topology::vertex::VertexId, WasmError> {
let index = handle as usize;
self.topo
.vertex_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "vertex",
index,
})
}
pub fn resolve_edge(&self, handle: u32) -> Result<brepkit_topology::edge::EdgeId, WasmError> {
let index = handle as usize;
self.topo
.edge_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "edge",
index,
})
}
pub fn resolve_solid(
&self,
handle: u32,
) -> Result<brepkit_topology::solid::SolidId, WasmError> {
let index = handle as usize;
self.topo
.solid_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "solid",
index,
})
}
pub fn resolve_wire(&self, handle: u32) -> Result<brepkit_topology::wire::WireId, WasmError> {
let index = handle as usize;
self.topo
.wire_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "wire",
index,
})
}
pub fn resolve_shell(
&self,
handle: u32,
) -> Result<brepkit_topology::shell::ShellId, WasmError> {
let index = handle as usize;
self.topo
.shell_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "shell",
index,
})
}
pub fn resolve_compound(
&self,
handle: u32,
) -> Result<brepkit_topology::compound::CompoundId, WasmError> {
let index = handle as usize;
self.topo
.compound_id_from_index(index)
.ok_or(WasmError::InvalidHandle {
entity: "compound",
index,
})
}
}
#[allow(clippy::cast_possible_truncation)]
pub const fn face_id_to_u32(id: brepkit_topology::face::FaceId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn solid_id_to_u32(id: brepkit_topology::solid::SolidId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn vertex_id_to_u32(id: brepkit_topology::vertex::VertexId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn edge_id_to_u32(id: brepkit_topology::edge::EdgeId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn wire_id_to_u32(id: brepkit_topology::wire::WireId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn shell_id_to_u32(id: brepkit_topology::shell::ShellId) -> u32 {
id.index() as u32
}
#[allow(clippy::cast_possible_truncation)]
pub const fn compound_id_to_u32(id: brepkit_topology::compound::CompoundId) -> u32 {
id.index() as u32
}