Class Model
A container for elements.
Inheritance
Inherited Members
Namespace: Elements
Assembly: Hypar.Elements.dll
Syntax
public class Model
Constructors
Model()
Construct an empty model.
Declaration
public Model()
Model(Position, Transform, IDictionary<Guid, Element>)
Construct a model.
Declaration
[JsonConstructor]
public Model(Position origin, Transform transform, IDictionary<Guid, Element> elements)
Parameters
| Type | Name | Description |
|---|---|---|
| Position | origin | The origin of the model. |
| Transform | transform | The transform of the model. |
| System.Collections.Generic.IDictionary<System.Guid, Element> | elements | A collection of elements. |
Model(Transform, IDictionary<Guid, Element>)
Construct a model.
Declaration
public Model(Transform transform, IDictionary<Guid, Element> elements)
Parameters
| Type | Name | Description |
|---|---|---|
| Transform | transform | The model's transform. |
| System.Collections.Generic.IDictionary<System.Guid, Element> | elements | The model's elements. |
Model(IEnumerable<Element>, Transform)
Construct a model with the given elements.
Declaration
public Model(IEnumerable<Element> elements, Transform transform = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<Element> | elements | The model's elements. |
| Transform | transform | The models' transform. |
Properties
Elements
A collection of Elements keyed by their identifiers.
Declaration
[JsonProperty("Elements", Required = Required.Always)]
[Required]
public IDictionary<Guid, Element> Elements { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.IDictionary<System.Guid, Element> |
Origin
The origin of the model.
Declaration
[JsonProperty("Origin", Required = Required.Default, NullValueHandling = NullValueHandling.Ignore)]
[Obsolete("Use Transform instead.")]
public Position Origin { get; set; }
Property Value
| Type | Description |
|---|---|
| Position |
Transform
The transform of the model.
Declaration
[JsonProperty("Transform", Required = Required.AllowNull)]
public Transform Transform { get; set; }
Property Value
| Type | Description |
|---|---|
| Transform |
Methods
AddElement(Element, Boolean)
Declaration
public void AddElement(Element element, bool gatherSubElements = true)
Parameters
| Type | Name | Description |
|---|---|---|
| Element | element | |
| System.Boolean | gatherSubElements |
AddElements(Element[])
Add elements to the model.
Declaration
public void AddElements(params Element[] elements)
Parameters
| Type | Name | Description |
|---|---|---|
| Element[] | elements | The elements to add to the model. |
AddElements(IEnumerable<Element>, Boolean)
Add a collection of elements to the model.
Declaration
public void AddElements(IEnumerable<Element> elements, bool gatherSubElements = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<Element> | elements | The elements to add to the model. |
| System.Boolean | gatherSubElements | Should sub-elements in properties be added to the model's elements collection? |
AllElementsAssignableFromType<T>()
Get all elements assignable from type T. This will include types which derive from T and types which implement T if T is an interface.
Declaration
public IEnumerable<T> AllElementsAssignableFromType<T>()
where T : Element
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> | A collection of elements derived from the specified type. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the element from which returned elements derive. |
AllElementsOfType<T>()
Get all elements of the type T.
Declaration
public IEnumerable<T> AllElementsOfType<T>()
where T : Element
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.IEnumerable<T> | A collection of elements of the specified type. |
Type Parameters
| Name | Description |
|---|---|
| T | The type of element to return. |
FromJson(String, Boolean)
Declaration
public static Model FromJson(string json, bool forceTypeReload = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | json | |
| System.Boolean | forceTypeReload |
Returns
| Type | Description |
|---|---|
| Model |
FromJson(String, out List<String>, Boolean)
Deserialize a model from JSON.
Declaration
public static Model FromJson(string json, out List<string> errors, bool forceTypeReload = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | json | The JSON representing the model. |
| System.Collections.Generic.List<System.String> | errors | A collection of deserialization errors. |
| System.Boolean | forceTypeReload | Option to force reloading the inernal type cache. Use if you add types dynamically in your code. |
Returns
| Type | Description |
|---|---|
| Model |
GetElementByName<T>(String)
Get the first entity with the specified name.
Declaration
public T GetElementByName<T>(string name)
where T : Element
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Returns
| Type | Description |
|---|---|
| T | An entity or null if no entity can be found with the provided name. |
Type Parameters
| Name | Description |
|---|---|
| T |
GetElementOfType<T>(Guid)
Get an entity by id from the Model.
Declaration
public T GetElementOfType<T>(Guid id)
where T : Element
Parameters
| Type | Name | Description |
|---|---|---|
| System.Guid | id | The identifier of the element. |
Returns
| Type | Description |
|---|---|
| T | An entity or null if no entity can be found with the provided id. |
Type Parameters
| Name | Description |
|---|---|
| T |
Intersect(Plane, out Dictionary<Guid, List<Polygon>>, out Dictionary<Guid, List<Polygon>>, out Dictionary<Guid, List<Line>>)
Intersect the model with the provided plane.
Declaration
public void Intersect(Plane plane, out Dictionary<Guid, List<Polygon>> intersectionPolygons, out Dictionary<Guid, List<Polygon>> beyondPolygons, out Dictionary<Guid, List<Line>> lines)
Parameters
| Type | Name | Description |
|---|---|---|
| Plane | plane | The intersection plane. |
| System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<Polygon>> | intersectionPolygons | A collection of polygons resulting from the intersection of the plane with all elements in the model. |
| System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<Polygon>> | beyondPolygons | A collection of polygons resulting from intersection of the beyond plane with all elements in the model. |
| System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<Line>> | lines | A collection of line segments resulting from intersection of the plane with all elements in the model. |
ToJson()
Serialize the model to JSON using default arguments.
Declaration
public string ToJson()
Returns
| Type | Description |
|---|---|
| System.String |
ToJson(Boolean)
Serialize the model to JSON to match default arguments. TODO this method can be removed after Hypar.Functions release 0.9.11 occurs.
Declaration
public string ToJson(bool indent = false)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | indent |
Returns
| Type | Description |
|---|---|
| System.String |
ToJson(Boolean, Boolean)
Serialize the model to JSON.
Declaration
public string ToJson(bool indent = false, bool gatherSubElements = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | indent | |
| System.Boolean | gatherSubElements |
Returns
| Type | Description |
|---|---|
| System.String |
ToJson(String, Boolean)
Serialize the model to a JSON file.
Declaration
public void ToJson(string path, bool gatherSubElements = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | The path of the file on disk. |
| System.Boolean | gatherSubElements |
UpdateBoundsAndComputedSolids()
Update the bounds and computed solids of all geometric elements in the model.
Declaration
public void UpdateBoundsAndComputedSolids()
UpdateRepresentations()
Update the representations of all geometric elements in the model.
Declaration
public void UpdateRepresentations()