Skip to main content

CsgFactory

Struct CsgFactory 

Source
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>

Source

pub fn new() -> Self

Source

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.

Source

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).

Source

pub fn face(&self, key: FaceKey) -> Option<&FaceMeta<T>>

Source

pub fn edge(&self, key: EdgeKey) -> Option<&EdgeMeta<T>>

Source

pub fn primitive(&self, key: PrimitiveKey) -> Option<&PrimitiveMeta>

Source

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.

Source

pub fn cube(&mut self, size: T) -> Csg<T>

Create a cube (uniform cuboid) centered at the origin.

Source

pub fn cuboid(&mut self, x: T, y: T, z: T) -> Csg<T>

Create a cuboid centered at the origin with the given dimensions.

Source

pub fn cylinder(&mut self, radius: T, height: T, segments: usize) -> Csg<T>

Create a cylinder centered at the origin, axis along Y.

Source

pub fn cone(&mut self, radius: T, height: T, segments: usize) -> Csg<T>

Create a cone centered at the origin, axis along Y.

Source

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.

Source

pub fn rhomboid( &mut self, a: Vector3<T>, b: Vector3<T>, c: Vector3<T>, ) -> Csg<T>

Create a parallelepiped (rhomboid) centered at the origin.

Source

pub fn sphere(&mut self, radius: T, segments: usize, stacks: usize) -> Csg<T>

Create a UV sphere centered at the origin.

Trait Implementations§

Source§

impl<T: Clone + Number> Clone for CsgFactory<T>

Source§

fn clone(&self) -> CsgFactory<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + Number> Debug for CsgFactory<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Number> Default for CsgFactory<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromTemplate for T
where T: Clone + Default + Unpin,

§

type Template = T

The [Template] for this type.
§

impl<T> FromWorld for T
where T: Default,

§

fn from_world(_world: &mut World) -> T

Creates Self using default().

§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

impl<T> Identity for T
where T: ?Sized,

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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

§

fn into_result(self) -> Result<T, RunSystemError>

Converts this type into the system output type.
§

impl<A> Is for A
where A: Any,

§

fn is<T>() -> bool
where T: Any,

Checks if the current type “is” another type, using a TypeId equality comparison. This is most useful in the context of generic logic. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
§

impl<T> Template for T
where T: Clone + Default + Unpin,

§

type Output = T

The type of value produced by this [Template].
§

fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>

Uses this template and the given entity context to produce a [Template::Output].
§

fn clone_template(&self) -> T

Clones this template. See Clone.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TypeData for T
where T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData>

Creates a type-erased clone of this value.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ConditionalSend for T
where T: Send,

§

impl<T> OpaqueAttachment for T
where T: Send + Sync + 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> Settings for T
where T: 'static + Send + Sync,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,