diff --git a/project/Morpho/Morpho25/Geometry/Building.cs b/project/Morpho/Morpho25/Geometry/Building.cs
index d980150..66306f6 100644
--- a/project/Morpho/Morpho25/Geometry/Building.cs
+++ b/project/Morpho/Morpho25/Geometry/Building.cs
@@ -3,23 +3,30 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Morpho25.Geometry
{
+ [DisplayName("Building")]
///
/// Building class.
///
public class Building : Entity, IEquatable
{
- [JsonProperty("observeBPS")]
+ [DisplayName("Name")]
+ [Description("Name of the building group")]
+ [JsonProperty("name")]
///
- /// Enable Building BPS output
+ /// Name of the building.
///
- public bool ObserveBPS { get; }
+ public override string Name { get; }
- [JsonProperty("geometry")]
+ [DisplayName("Geometry")]
+ [Description("Solid geometry")]
+ [JsonProperty("geometry", Required = Required.Always)]
///
/// Geometry of the building.
///
@@ -56,6 +63,8 @@ public class Building : Entity, IEquatable
///
public List BuildingGreenWallRows { get; private set; }
+ [DisplayName("Material")]
+ [Description("Facade and roof materials")]
[JsonProperty("material")]
///
/// Material of the building.
@@ -74,11 +83,13 @@ protected set
}
- [JsonProperty("name")]
+ [DisplayName("Observe BPS")]
+ [Description("Export BPS output")]
+ [JsonProperty("observeBPS")]
///
- /// Name of the building.
+ /// Enable Building BPS output
///
- public override string Name { get; }
+ public bool ObserveBPS { get; }
[JsonConstructor]
///
diff --git a/project/Morpho/Morpho25/Geometry/Entity.cs b/project/Morpho/Morpho25/Geometry/Entity.cs
index 9579465..3c04639 100644
--- a/project/Morpho/Morpho25/Geometry/Entity.cs
+++ b/project/Morpho/Morpho25/Geometry/Entity.cs
@@ -3,6 +3,7 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
namespace Morpho25.Geometry
{
@@ -25,6 +26,8 @@ public abstract class Entity
///
public abstract string Name { get; }
+ [DisplayName("ID")]
+ [Description("Numeric ID of the entity")]
[JsonProperty("id")]
///
/// ID of the entity.
diff --git a/project/Morpho/Morpho25/Geometry/Grid.cs b/project/Morpho/Morpho25/Geometry/Grid.cs
index d51bed5..8949acc 100644
--- a/project/Morpho/Morpho25/Geometry/Grid.cs
+++ b/project/Morpho/Morpho25/Geometry/Grid.cs
@@ -8,6 +8,7 @@
namespace Morpho25.Geometry
{
+ [DisplayName("Grid")]
///
/// Grid class.
///
diff --git a/project/Morpho/Morpho25/Geometry/Material.cs b/project/Morpho/Morpho25/Geometry/Material.cs
index f2ee9ad..25274a9 100644
--- a/project/Morpho/Morpho25/Geometry/Material.cs
+++ b/project/Morpho/Morpho25/Geometry/Material.cs
@@ -1,5 +1,8 @@
-using Newtonsoft.Json;
+using Morpho25.Utility;
+using Newtonsoft.Json;
using System;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace Morpho25.Geometry
@@ -50,6 +53,8 @@ public class Material : IEquatable
///
public const string DEFAULT_PLANT_3D = "0000C2";
+ [MinLength(1)]
+ [MaxLength(4)]
[JsonProperty("ids", Required = Required.Always)]
///
/// Material array of ID.
diff --git a/project/Morpho/Morpho25/Geometry/Plant2d.cs b/project/Morpho/Morpho25/Geometry/Plant2d.cs
index 92a0b7f..b629d25 100644
--- a/project/Morpho/Morpho25/Geometry/Plant2d.cs
+++ b/project/Morpho/Morpho25/Geometry/Plant2d.cs
@@ -1,27 +1,43 @@
using Morpho25.Utility;
using MorphoGeometry;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
namespace Morpho25.Geometry
{
+ [DisplayName("Simple Plant")]
///
/// Plant 2D class.
///
- public class Plant2d : Entity
+ public class Plant2d : Entity, IEquatable
{
- ///
- /// Geometry of the plant 2D.
- ///
- public FaceGroup Geometry { get; }
+ [DisplayName("Name")]
+ [Description("Name of the simple plant group")]
+ [JsonProperty("name")]
///
/// Name of the plant 2D.
///
public override string Name { get; }
+
+ [DisplayName("Geometry")]
+ [Description("Flat or solid geometry")]
+ [JsonProperty("geometry", Required = Required.Always)]
+ ///
+ /// Geometry of the plant 2D.
+ ///
+ public FaceGroup Geometry { get; }
+
+ [JsonIgnore]
///
/// Matrix 2D of the plant 2D.
///
public Matrix2d IDmatrix { get; private set; }
+
+ [DisplayName("Material")]
+ [Description("Simple plant type")]
+ [JsonProperty("material")]
///
/// Material of the plant 2D.
///
@@ -38,15 +54,16 @@ protected set
}
}
+
+ [JsonConstructor]
///
/// Create a new plant 2D.
///
- /// Grid object.
/// Geometry of the plant 2D.
/// Numerical ID.
/// Code of the material.
/// Name of the plant 2D.
- public Plant2d(Grid grid, FaceGroup geometry,
+ public Plant2d(FaceGroup geometry,
int id, string code = null, string name = null)
{
ID = id;
@@ -55,11 +72,9 @@ public Plant2d(Grid grid, FaceGroup geometry,
? CreateMaterial(Material.DEFAULT_PLANT_2D, code)
: CreateMaterial(Material.DEFAULT_PLANT_2D);
Name = name ?? "PlantGroup";
-
- SetMatrix(grid);
}
- private void SetMatrix(Grid grid)
+ public void SetMatrix(Grid grid)
{
Matrix2d matrix = new Matrix2d(grid.Size.NumX, grid.Size.NumY, "");
@@ -81,5 +96,74 @@ public override string ToString()
Name, ID, Material.IDs[0]);
}
+ public string Serialize()
+ {
+ return JsonConvert.SerializeObject(this);
+ }
+
+ public static Plant2d Deserialize(string json)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ public bool Equals(Plant2d other)
+ {
+ if (other == null)
+ return false;
+
+ if (other != null
+ && other.ID == this.ID
+ && other.Name == this.Name
+ && other.Material == this.Material
+ && other.Geometry == this.Geometry)
+ return true;
+ else
+ return false;
+ }
+
+ public override bool Equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ var plantObj = obj as Plant2d;
+ if (plantObj == null)
+ return false;
+ else
+ return Equals(plantObj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 17;
+ hash = hash * 23 + ID.GetHashCode();
+ hash = hash * 23 + Name.GetHashCode();
+ hash = hash * 23 + Material.GetHashCode();
+ hash = hash * 23 + Geometry.GetHashCode();
+ return hash;
+ }
+ }
+
+ public static bool operator ==(Plant2d plant1, Plant2d plant2)
+ {
+ if (((object)plant1) == null || ((object)plant2) == null)
+ return Object.Equals(plant1, plant2);
+
+ return plant1.Equals(plant2);
+ }
+
+ public static bool operator !=(Plant2d plant1, Plant2d plant2)
+ {
+ return !(plant1 == plant2);
+ }
}
}
diff --git a/project/Morpho/Morpho25/Geometry/Plant3d.cs b/project/Morpho/Morpho25/Geometry/Plant3d.cs
index c8914e0..3986743 100644
--- a/project/Morpho/Morpho25/Geometry/Plant3d.cs
+++ b/project/Morpho/Morpho25/Geometry/Plant3d.cs
@@ -1,21 +1,38 @@
using Morpho25.Utility;
using MorphoGeometry;
+using Newtonsoft.Json;
using System;
+using System.ComponentModel;
namespace Morpho25.Geometry
{
+ [DisplayName("Plant3D")]
///
/// Plant 3D class.
///
- public class Plant3d : Entity
+ public class Plant3d : Entity, IEquatable
{
private const int SHIFT = 1;
+ [DisplayName("Name")]
+ [Description("Name of the plant3D group")]
+ [JsonProperty("name")]
+ ///
+ /// Name of the plant 3D.
+ ///
+ public override string Name { get; }
+
+ [DisplayName("Geometry")]
+ [Description("Point geometry")]
+ [JsonProperty("geometry", Required = Required.Always)]
///
/// Geometry of the plant 3D.
///
public Vector Geometry { get; }
+ [DisplayName("Material")]
+ [Description("Plant3D type")]
+ [JsonProperty("material")]
///
/// Material of the plant 3D.
///
@@ -32,10 +49,8 @@ protected set
}
}
- ///
- /// Name of the plant 3D.
- ///
- public override string Name { get; }
+
+ [JsonIgnore]
///
/// Location of the plant 3D in the grid.
///
@@ -43,11 +58,10 @@ protected set
///
/// Create a new plant 3D.
///
- /// Grid object.
/// Geometry of the plant 3D.
/// Code of the material.
/// Name of the plant 3D.
- public Plant3d(Grid grid, Vector geometry,
+ public Plant3d(Vector geometry,
string code = null, string name = null)
{
Geometry = geometry;
@@ -55,11 +69,9 @@ public Plant3d(Grid grid, Vector geometry,
? CreateMaterial(Material.DEFAULT_PLANT_3D, code)
: CreateMaterial(Material.DEFAULT_PLANT_3D);
Name = name ?? "PlantGroup";
-
- SetPixel(grid);
}
- private void SetPixel(Grid grid)
+ public void SetPixel(Grid grid)
{
Pixel = new Pixel
{
@@ -79,5 +91,72 @@ public override string ToString()
Pixel.I, Pixel.J, Pixel.K));
}
+ public string Serialize()
+ {
+ return JsonConvert.SerializeObject(this);
+ }
+
+ public static Plant3d Deserialize(string json)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ public bool Equals(Plant3d other)
+ {
+ if (other == null)
+ return false;
+
+ if (other != null
+ && other.Name == this.Name
+ && other.Material == this.Material
+ && other.Geometry == this.Geometry)
+ return true;
+ else
+ return false;
+ }
+
+ public override bool Equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ var plantObj = obj as Plant3d;
+ if (plantObj == null)
+ return false;
+ else
+ return Equals(plantObj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 17;
+ hash = hash * 23 + Name.GetHashCode();
+ hash = hash * 23 + Material.GetHashCode();
+ hash = hash * 23 + Geometry.GetHashCode();
+ return hash;
+ }
+ }
+
+ public static bool operator ==(Plant3d plant1, Plant3d plant2)
+ {
+ if (((object)plant1) == null || ((object)plant2) == null)
+ return Object.Equals(plant1, plant2);
+
+ return plant1.Equals(plant2);
+ }
+
+ public static bool operator !=(Plant3d plant1, Plant3d plant2)
+ {
+ return !(plant1 == plant2);
+ }
}
}
diff --git a/project/Morpho/Morpho25/Geometry/Receptor.cs b/project/Morpho/Morpho25/Geometry/Receptor.cs
index c03be04..4ad14ad 100644
--- a/project/Morpho/Morpho25/Geometry/Receptor.cs
+++ b/project/Morpho/Morpho25/Geometry/Receptor.cs
@@ -1,27 +1,40 @@
using Morpho25.Utility;
using MorphoGeometry;
+using Newtonsoft.Json;
using System;
-
+using System.ComponentModel;
namespace Morpho25.Geometry
{
+ [DisplayName("Receptor")]
///
/// Receptor class.
///
- public class Receptor : Entity
+ public class Receptor : Entity, IEquatable
{
- ///
- /// Geometry of the receptor.
- ///
- public Vector Geometry { get; }
+ [DisplayName("Name")]
+ [Description("Name of the receptor")]
+ [JsonProperty("name", Required = Required.Always)]
///
/// Name of the receptor.
///
public override string Name { get; }
+
+ [DisplayName("Geometry")]
+ [Description("Point geometry")]
+ [JsonProperty("geometry", Required = Required.Always)]
+ ///
+ /// Geometry of the receptor.
+ ///
+ public Vector Geometry { get; }
+
+ [JsonIgnore]
///
/// Location of the receptor in the grid.
///
public Pixel Pixel { get; private set; }
+
+ [JsonIgnore]
///
/// Material of the receptor.
///
@@ -33,21 +46,15 @@ public override Material Material
///
/// Create a new receptor.
///
- /// Grid object.
/// Geometry of the receptor.
/// Name of the receptor.
- public Receptor(Grid grid,
- Vector geometry, string name = null)
+ public Receptor(Vector geometry, string name)
{
Geometry = geometry;
- SetPixel(grid);
- string text = name ?? "R_";
-
- Name = text + String.Join("_", Pixel.I,
- Pixel.J, Pixel.K);
+ Name = name;
}
- private void SetPixel(Grid grid)
+ public void SetPixel(Grid grid)
{
Pixel = new Pixel
{
@@ -64,5 +71,71 @@ public override string ToString()
{
return String.Format("Receptor::{0}", Name);
}
+
+ public string Serialize()
+ {
+ return JsonConvert.SerializeObject(this);
+ }
+
+ public static Receptor Deserialize(string json)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ public bool Equals(Receptor other)
+ {
+ if (other == null)
+ return false;
+
+ if (other != null
+ && other.Name == this.Name
+ && other.Geometry == this.Geometry)
+ return true;
+ else
+ return false;
+ }
+
+ public override bool Equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ var receptorObj = obj as Receptor;
+ if (receptorObj == null)
+ return false;
+ else
+ return Equals(receptorObj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 17;
+ hash = hash * 23 + Name.GetHashCode();
+ hash = hash * 23 + Geometry.GetHashCode();
+ return hash;
+ }
+ }
+
+ public static bool operator ==(Receptor receptor1, Receptor receptor2)
+ {
+ if (((object)receptor1) == null || ((object)receptor2) == null)
+ return Object.Equals(receptor1, receptor2);
+
+ return receptor1.Equals(receptor2);
+ }
+
+ public static bool operator !=(Receptor receptor1, Receptor receptor2)
+ {
+ return !(receptor1 == receptor2);
+ }
}
}
diff --git a/project/Morpho/Morpho25/Geometry/Soil.cs b/project/Morpho/Morpho25/Geometry/Soil.cs
index 822c6c2..660db2c 100644
--- a/project/Morpho/Morpho25/Geometry/Soil.cs
+++ b/project/Morpho/Morpho25/Geometry/Soil.cs
@@ -1,27 +1,43 @@
using Morpho25.Utility;
using MorphoGeometry;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
namespace Morpho25.Geometry
{
+ [DisplayName("Soil")]
///
/// Soil class.
///
- public class Soil : Entity
+ public class Soil : Entity, IEquatable
{
- ///
- /// Geometry of the soil.
- ///
- public FaceGroup Geometry { get; }
+ [DisplayName("Name")]
+ [Description("Name of the soil group")]
+ [JsonProperty("name")]
///
/// Name of the soil.
///
public override string Name { get; }
+
+ [DisplayName("Geometry")]
+ [Description("Flat or solid geometry")]
+ [JsonProperty("geometry", Required = Required.Always)]
+ ///
+ /// Geometry of the soil.
+ ///
+ public FaceGroup Geometry { get; }
+
+ [JsonIgnore]
///
/// Matrix 2D of the soil.
///
public Matrix2d IDmatrix { get; private set; }
+
+ [DisplayName("Material")]
+ [Description("Profile of the soil")]
+ [JsonProperty("material")]
///
/// Material of the soil.
///
@@ -36,17 +52,17 @@ protected set
_material = value;
}
-
}
+
+ [JsonConstructor]
///
/// Create a new soil.
///
- /// Grid object.
/// Geometry of the soil.
/// Numerical ID.
/// Code of the material.
/// Name of the soil.
- public Soil(Grid grid, FaceGroup geometry,
+ public Soil(FaceGroup geometry,
int id, string code = null,
string name = null)
{
@@ -56,11 +72,9 @@ public Soil(Grid grid, FaceGroup geometry,
? CreateMaterial(Material.DEFAULT_SOIL, code)
: CreateMaterial(Material.DEFAULT_SOIL);
Name = name ?? "SoilGroup";
-
- SetMatrix(grid);
}
- private void SetMatrix(Grid grid)
+ public void SetMatrix(Grid grid)
{
Matrix2d matrix = new Matrix2d(grid.Size.NumX, grid.Size.NumY, Material.DEFAULT_SOIL);
@@ -80,5 +94,73 @@ public override string ToString()
return String.Format("Soil::{0}::{1}::{2}",
Name, ID, Material.IDs[0]);
}
+
+ public string Serialize()
+ {
+ return JsonConvert.SerializeObject(this);
+ }
+
+ public static Soil Deserialize(string json)
+ {
+ try
+ {
+ return JsonConvert.DeserializeObject(json);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(e.Message);
+ }
+ }
+
+ public bool Equals(Soil other)
+ {
+ if (other == null)
+ return false;
+
+ if (other != null
+ && other.ID == this.ID
+ && other.Material == this.Material
+ && other.Geometry == this.Geometry)
+ return true;
+ else
+ return false;
+ }
+
+ public override bool Equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+
+ var soilObj = obj as Soil;
+ if (soilObj == null)
+ return false;
+ else
+ return Equals(soilObj);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ int hash = 17;
+ hash = hash * 23 + ID.GetHashCode();
+ hash = hash * 23 + Material.GetHashCode();
+ hash = hash * 23 + Geometry.GetHashCode();
+ return hash;
+ }
+ }
+
+ public static bool operator ==(Soil soil1, Soil soil2)
+ {
+ if (((object)soil1) == null || ((object)soil2) == null)
+ return Object.Equals(soil1, soil2);
+
+ return soil1.Equals(soil2);
+ }
+
+ public static bool operator !=(Soil soil1, Soil soil2)
+ {
+ return !(soil1 == soil2);
+ }
}
}
diff --git a/project/Morpho/Morpho25/Geometry/Source.cs b/project/Morpho/Morpho25/Geometry/Source.cs
index 41fa894..271adfa 100644
--- a/project/Morpho/Morpho25/Geometry/Source.cs
+++ b/project/Morpho/Morpho25/Geometry/Source.cs
@@ -1,27 +1,43 @@
using Morpho25.Utility;
using MorphoGeometry;
+using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.ComponentModel;
namespace Morpho25.Geometry
{
+ [DisplayName("Source")]
///
/// Source class.
///
- public class Source : Entity
+ public class Source : Entity, IEquatable