pub struct CsgFactory<T: Number> {
pub primitives: SlotMap<PrimitiveKey, PrimitiveMeta>,
pub faces: SlotMap<FaceKey, FaceMeta<T>>,
pub edges: SlotMap<EdgeKey, EdgeMeta<T>>,
}Expand description
A factory that creates CSG primitives while tracking face and edge metadata.
All metadata is owned by the factory. Polygons and CSGs store only
FaceKey references that can be looked up here.
§Example
use rscad_csg_bsp::CsgFactory;
let mut factory = CsgFactory::<f64>::new();
let csg = factory.cuboid(2.0, 1.0, 3.0);
// Pick a polygon and find all siblings sharing the same face.
let face_key = csg.polygons()[0].face_key().unwrap();
let siblings = factory.polygons_sharing_face(&csg, face_key);Fields§
§primitives: SlotMap<PrimitiveKey, PrimitiveMeta>§faces: SlotMap<FaceKey, FaceMeta<T>>§edges: SlotMap<EdgeKey, EdgeMeta<T>>Implementations§
Source§impl<T: Number> CsgFactory<T>
impl<T: Number> CsgFactory<T>
pub fn new() -> Self
Sourcepub fn absorb(&mut self, other: &Self) -> FaceKeyRemap
pub fn absorb(&mut self, other: &Self) -> FaceKeyRemap
Absorb all entries from other into self, remapping keys.
Returns a FaceKeyRemap so callers can update polygon face_keys.
Sourcepub fn cast<T2: Number>(self) -> (CsgFactory<T2>, FaceKeyRemap)where
T: AsPrimitive<T2>,
pub fn cast<T2: Number>(self) -> (CsgFactory<T2>, FaceKeyRemap)where
T: AsPrimitive<T2>,
Cast the factory’s numeric type from T to T2.
Returns the new factory and a face-key remap (needed to update polygons).
pub fn face(&self, key: FaceKey) -> Option<&FaceMeta<T>>
pub fn edge(&self, key: EdgeKey) -> Option<&EdgeMeta<T>>
pub fn primitive(&self, key: PrimitiveKey) -> Option<&PrimitiveMeta>
Sourcepub fn polygons_sharing_face(
&self,
csg: &Csg<T>,
face_key: FaceKey,
) -> Vec<usize>
pub fn polygons_sharing_face( &self, csg: &Csg<T>, face_key: FaceKey, ) -> Vec<usize>
Returns the indices of all polygons in csg that share the given face.
Sourcepub fn cube(&mut self, size: T) -> Csg<T>
pub fn cube(&mut self, size: T) -> Csg<T>
Create a cube (uniform cuboid) centered at the origin.
Sourcepub fn cuboid(&mut self, x: T, y: T, z: T) -> Csg<T>
pub fn cuboid(&mut self, x: T, y: T, z: T) -> Csg<T>
Create a cuboid centered at the origin with the given dimensions.
Sourcepub fn cylinder(&mut self, radius: T, height: T, segments: usize) -> Csg<T>
pub fn cylinder(&mut self, radius: T, height: T, segments: usize) -> Csg<T>
Create a cylinder centered at the origin, axis along Y.
Sourcepub fn cone(&mut self, radius: T, height: T, segments: usize) -> Csg<T>
pub fn cone(&mut self, radius: T, height: T, segments: usize) -> Csg<T>
Create a cone centered at the origin, axis along Y.
Sourcepub fn torus(
&mut self,
major_radius: T,
minor_radius: T,
major_segments: usize,
minor_segments: usize,
) -> Csg<T>
pub fn torus( &mut self, major_radius: T, minor_radius: T, major_segments: usize, minor_segments: usize, ) -> Csg<T>
Create a torus centered at the origin, lying in the XZ plane.
Trait Implementations§
Source§impl<T: Clone + Number> Clone for CsgFactory<T>
impl<T: Clone + Number> Clone for CsgFactory<T>
Source§fn clone(&self) -> CsgFactory<T>
fn clone(&self) -> CsgFactory<T>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<T> Freeze for CsgFactory<T>
impl<T> RefUnwindSafe for CsgFactory<T>where
T: RefUnwindSafe,
impl<T> Send for CsgFactory<T>
impl<T> Sync for CsgFactory<T>
impl<T> Unpin for CsgFactory<T>where
T: Unpin,
impl<T> UnsafeUnpin for CsgFactory<T>
impl<T> UnwindSafe for CsgFactory<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> FromTemplate for T
impl<T> FromTemplate for T
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.§impl<T> Template for T
impl<T> Template for T
§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
entity context to produce a [Template::Output].§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clone.