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 has_no_output(&self) -> bool
pub fn has_no_output(&self) -> bool
Return true, if model wont produce any output
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 render_output_type(&self) -> OutputType
pub fn render_output_type(&self) -> OutputType
Get render output type. Expects a render output.
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.
Sourcepub fn set_id(&self, id: Identifier)
pub fn set_id(&self, id: Identifier)
Set the id of a model. This happens if the model was created by an assignment.
For example, the assignment statement a = Circle(4mm) will result in a model with id a.
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 multiplicity_descendants(&self) -> MultiplicityDescendants ⓘ
pub fn multiplicity_descendants(&self) -> MultiplicityDescendants ⓘ
An iterator that descends to multiplicity nodes.
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<usize>
pub fn prerender(&self, resolution: RenderResolution) -> RenderResult<usize>
Pre-render the model.
Pre-rendering create as render output and calculates the matrices, resolutions and hashes of a model.
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 CalcBounds2D for Model
impl CalcBounds2D for Model
Source§fn calc_bounds_2d(&self) -> Bounds2D
fn calc_bounds_2d(&self) -> Bounds2D
Source§impl CallMethod<Option<Model>> for Model
impl CallMethod<Option<Model>> for Model
Source§fn call_method(
&self,
name: &QualifiedName,
args: &ArgumentValueList,
context: &mut EvalContext,
) -> EvalResult<Option<Model>>
fn call_method( &self, name: &QualifiedName, args: &ArgumentValueList, context: &mut EvalContext, ) -> EvalResult<Option<Model>>
Source§impl ComputedHash for Model
impl ComputedHash for Model
Source§fn computed_hash(&self) -> HashId
fn computed_hash(&self) -> HashId
Source§impl Eval<Model> for Rc<SourceFile>
impl Eval<Model> for Rc<SourceFile>
Source§fn eval(&self, context: &mut EvalContext) -> EvalResult<Model>
fn eval(&self, context: &mut EvalContext) -> EvalResult<Model>
T.Source§impl From<&Model> for RenderAttributes
impl From<&Model> for RenderAttributes
Source§impl FromIterator<Model> for Models
impl FromIterator<Model> for Models
Source§impl RenderWithContext<Model> for Model
impl RenderWithContext<Model> for Model
Source§fn render_with_context(
&self,
context: &mut RenderContext,
) -> RenderResult<Model>
fn render_with_context( &self, context: &mut RenderContext, ) -> RenderResult<Model>
Source§impl RenderWithContext<Rc<WithBounds2D<Geometry2D>>> for Model
This implementation renders a Geometry2D out of a Model.
impl RenderWithContext<Rc<WithBounds2D<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_with_context(
&self,
context: &mut RenderContext,
) -> RenderResult<Geometry2DOutput>
fn render_with_context( &self, context: &mut RenderContext, ) -> RenderResult<Geometry2DOutput>
Source§impl RenderWithContext<Rc<WithBounds3D<Geometry3D>>> for Model
This implementation renders a Geometry3D out of a Model.
impl RenderWithContext<Rc<WithBounds3D<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_with_context(
&self,
context: &mut RenderContext,
) -> RenderResult<Geometry3DOutput>
fn render_with_context( &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§fn tree_print(&self, f: &mut Formatter<'_>, tree_state: TreeState) -> Result
fn tree_print(&self, f: &mut Formatter<'_>, tree_state: TreeState) -> Result
f and use {:depth$} syntax in front of your single line
output to get proper indention.Source§fn display_tree(&self, f: &mut Formatter<'_>) -> Result
fn display_tree(&self, f: &mut Formatter<'_>) -> Result
0.Source§fn debug_tree(&self, f: &mut Formatter<'_>) -> Result
fn debug_tree(&self, f: &mut Formatter<'_>) -> Result
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