pub struct ScadObject { /* private fields */ }
Expand description
An scad object which is a single scad element and can have zero or more child objects
#How it works
An scad object is a single ScadElement
optionally followed by any number of child
objects. This represents the following scad code:
translate([1,2,3]) //parent
{
cube([3,5,1]); //Child
//...
}
Without using the scad!
macro, you would create an scad object by doing the
following.
//Create the parent
let mut obj = ScadObject::new(ScadElement::Union);
//add some children
obj.add_child(ScadObject::new(ScadElement::Cube(vec3(1., 1., 1.))));
//...
This would be quite tedious to type each time you want to create a new object
which is why the scad!
macro exists. This does mean that if you want to add
more children to an scad object created by the macro, you can simply use the
add_child
function on the result of the macro.
Implementations§
Source§impl ScadObject
impl ScadObject
pub fn new(element: ScadElement) -> ScadObject
pub fn add_child(&mut self, statement: ScadObject)
Sourcepub fn get_code(&self) -> String
pub fn get_code(&self) -> String
Returns the scad code for the object.
If there are no children, only the code for the ScadElement of the
object followed by a ;
is returned. If children exist, the code for
the element is returned first, followed by the code for each child surrounded
by {}
and indented 1 tab character.
Sourcepub fn is_important(&mut self)
pub fn is_important(&mut self)
Marks the object as important. This will prepend the object code with an ! which tells scad to only render that object and its children.
Sourcepub fn important(self) -> ScadObject
pub fn important(self) -> ScadObject
Takes ownership over the object, marks it as important and returns it. Usefull if you want to mark something as important without having to change the binding to mut
Trait Implementations§
Source§impl Clone for ScadObject
impl Clone for ScadObject
Source§fn clone(&self) -> ScadObject
fn clone(&self) -> ScadObject
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ScadObject
impl RefUnwindSafe for ScadObject
impl Send for ScadObject
impl Sync for ScadObject
impl Unpin for ScadObject
impl UnwindSafe for ScadObject
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,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§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).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.