pub struct Model(/* private fields */);
Expand description
A reference counted, mutable Model
.
Implementations§
Source§impl Model
impl Model
Sourcepub fn new(inner: RcMut<ModelInner>) -> Self
pub fn new(inner: RcMut<ModelInner>) -> Self
Create new model from inner.
Sourcepub fn is_operation(&self) -> bool
pub fn is_operation(&self) -> bool
Check if a model contains an operation element.
Sourcepub fn make_deep_copy(&self) -> Self
pub fn make_deep_copy(&self) -> Self
Make a deep copy if this model. TODO: isn’t this a Clone?
Sourcepub fn is_same_as(&self, other: &Model) -> bool
pub fn is_same_as(&self, other: &Model) -> bool
Check if other
is and self
have the same address.
Sourcepub fn remove_child(&self, child: &Model)
pub fn remove_child(&self, child: &Model)
Remove child from this model.
Sourcepub fn append(&self, model: Model) -> Model
pub fn append(&self, model: Model) -> Model
Append a single model as child.
Also tries to set the output type if it has not been determined yet.
Sourcepub fn append_children(&self, models: Models) -> Self
pub fn append_children(&self, models: Models) -> Self
Append multiple models as children.
Return self.
Sourcepub fn boolean_op(self, op: BooleanOp, other: Model) -> Model
pub fn boolean_op(self, op: BooleanOp, other: Model) -> Model
Short cut to generate boolean operator as binary operation with two models.
Sourcepub fn replace_input_placeholders(&self, input_model: &Model) -> Self
pub fn replace_input_placeholders(&self, input_model: &Model) -> Self
Replace each input placeholder with copies of input_model
.
Sourcepub fn deduce_output_type(&self) -> OutputType
pub fn deduce_output_type(&self) -> OutputType
Deduce output type from children and set it and return it.
Sourcepub fn into_group(&self) -> Option<Model>
pub fn into_group(&self) -> Option<Model>
Return inner group if this model only contains a group as single child.
This function is used when we evaluate operations like subtract() {}
or hull() {}
.
When evaluating these operations, we want to iterate over the group’s children.
Source§impl Model
Iterator methods.
impl Model
Iterator methods.
Sourcepub fn descendants(&self) -> Descendants ⓘ
pub fn descendants(&self) -> Descendants ⓘ
Returns an iterator of models to this model and its unnamed descendants, in tree order.
Includes the current model.
Sourcepub fn source_file_descendants(&self) -> SourceFileDescendants ⓘ
pub fn source_file_descendants(&self) -> SourceFileDescendants ⓘ
Returns an iterator of models that belong to the same source file as this one
Sourcepub fn get_property(&self, id: &Identifier) -> Option<Value>
pub fn get_property(&self, id: &Identifier) -> Option<Value>
Get a property from this model.
Sourcepub fn set_property(&mut self, id: Identifier, value: Value) -> Option<Value>
pub fn set_property(&mut self, id: Identifier, value: Value) -> Option<Value>
Set a property in this model.
Sourcepub fn add_property(&self, id: Identifier, value: Value)
pub fn add_property(&self, id: Identifier, value: Value)
Add a new property to the model.
Source§impl Model
impl Model
Sourcepub fn prerender(&self, resolution: RenderResolution) -> RenderResult<()>
pub fn prerender(&self, resolution: RenderResolution) -> RenderResult<()>
Pre render the model.
Rendering the model means that all geometry is calculated and stored in the in the render cache.
Trait Implementations§
Source§impl AttributesAccess for Model
impl AttributesAccess for Model
Source§fn get_attributes_by_id(&self, id: &Identifier) -> Vec<Attribute>
fn get_attributes_by_id(&self, id: &Identifier) -> Vec<Attribute>
Source§fn get_single_attribute(&self, id: &Identifier) -> Option<Attribute>
fn get_single_attribute(&self, id: &Identifier) -> Option<Attribute>
Source§fn get_attribute_value(&self, id: &Identifier) -> Value
fn get_attribute_value(&self, id: &Identifier) -> Value
Source§fn get_resolution(&self) -> Option<ResolutionAttribute>
fn get_resolution(&self) -> Option<ResolutionAttribute>
Source§fn get_exports(&self) -> Vec<ExportCommand>
fn get_exports(&self) -> Vec<ExportCommand>
Source§fn get_measures(&self) -> Vec<MeasureCommand>
fn get_measures(&self) -> Vec<MeasureCommand>
Source§fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>
fn get_custom_attributes(&self, id: &Identifier) -> Vec<Tuple>
Source§impl CallMethod<Option<Model>> for Model
impl CallMethod<Option<Model>> for Model
Source§fn call_method(
&self,
name: &QualifiedName,
args: &ArgumentValueList,
context: &mut Context,
) -> EvalResult<Option<Model>>
fn call_method( &self, name: &QualifiedName, args: &ArgumentValueList, context: &mut Context, ) -> EvalResult<Option<Model>>
Source§impl Display for Model
Prints a Model
.
impl Display for Model
Prints a Model
.
A Model
signature has the form [id: ]ElementType[ = origin][ -> result_type]
.
The exemplary output will look like this:
id: Object:
Object = std::geo2d::Circle(radius = 3.0mm) -> Geometry2D:
Primitive = __builtin::geo2d::Circle(radius = 3.0) -> Geometry2D`
Source§impl FetchBounds2D for Model
impl FetchBounds2D for Model
Source§fn fetch_bounds_2d(&self) -> Bounds2D
fn fetch_bounds_2d(&self) -> Bounds2D
Source§impl FromIterator<Model> for Models
impl FromIterator<Model> for Models
Source§impl Render<Model> for Model
impl Render<Model> for Model
Source§fn render(&self, context: &mut RenderContext) -> RenderResult<Model>
fn render(&self, context: &mut RenderContext) -> RenderResult<Model>
Source§impl Render<Option<Rc<Geometry2D>>> for Model
This implementation renders a Geometry2D
out of a Model
.
impl Render<Option<Rc<Geometry2D>>> for Model
This implementation renders a Geometry2D
out of a Model
.
Notes:
- The impl attaches the output geometry to the model’s render output.
- It is assumed the model has been pre-rendered.
Source§fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry2DOutput>
fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry2DOutput>
Source§impl Render<Option<Rc<Geometry3D>>> for Model
This implementation renders a Geometry3D
out of a Model
.
impl Render<Option<Rc<Geometry3D>>> for Model
This implementation renders a Geometry3D
out of a Model
.
Notes:
- The impl attaches the output geometry to the model’s render output.
- It is assumed the model has been pre-rendered.
Source§fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry3DOutput>
fn render(&self, context: &mut RenderContext) -> RenderResult<Geometry3DOutput>
Source§impl SrcReferrer for Model
impl SrcReferrer for Model
Source§impl TreeDisplay for Model
impl TreeDisplay for Model
Source§impl WriteToFile for Model
impl WriteToFile for Model
Auto Trait Implementations§
impl Freeze for Model
impl !RefUnwindSafe for Model
impl !Send for Model
impl !Sync for Model
impl Unpin for Model
impl !UnwindSafe for Model
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read more