Skip to content

Commit

Permalink
Add component to define sections
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Oscarsson committed Dec 9, 2020
1 parent cbe593f commit 3802e6f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 45 deletions.
4 changes: 2 additions & 2 deletions componentsGrasshopper/Sections/SectionDefine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class SectionDefine: GH_Component
}
protected override void RegisterInputParams(GH_InputParamManager pManager)
{
pManager.AddSurfaceParameter("Surfaces", "Srfs", "Item or list of surfaces of section.", GH_ParamAccess.list);
pManager.AddSurfaceParameter("Surfaces", "Srfs", "Item or list of surfaces of section. Surfaces must lie in the XY-plane at z=0.", GH_ParamAccess.list);
pManager.AddTextParameter("Name", "Name", "Name of section", GH_ParamAccess.item);
pManager.AddTextParameter("MaterialType", "MatType", "Material type.", GH_ParamAccess.item);
pManager.AddTextParameter("MaterialType", "MatType", "Material type. Choice: SteelRolled/SteelColdWorked/SteelWelded/Concrete/Timber", GH_ParamAccess.item);
pManager.AddTextParameter("GroupName","GroupName","Name of section group", GH_ParamAccess.item);
pManager.AddTextParameter("TypeName","TypeName","Name of section type", GH_ParamAccess.item);
pManager.AddTextParameter("SizeName","SizeName","Name of section size", GH_ParamAccess.item);
Expand Down
14 changes: 1 addition & 13 deletions src/Geometry/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Region
internal Geometry.FdCoordinateSystem CoordinateSystem { get; set; }

/// <summary>
/// Used for panels only
/// Used for panels and sections
/// </summary>
[XmlIgnore]
public FdVector3d LocalZ
Expand Down Expand Up @@ -52,18 +52,6 @@ public FdVector3d LocalZ
}
}

public Rhino.Geometry.Vector3d Normal
{
get
{
return this.LocalZ.ToRhino();
}
set
{
this.LocalZ = Geometry.FdVector3d.FromRhino(value);
}
}

[XmlElement("contour")]
public List<Contour> Contours = new List<Contour>(); // sequence: contour_type

Expand Down
21 changes: 7 additions & 14 deletions src/Materials/MaterialTypeEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@ namespace FemDesign.Materials
{
public enum MaterialTypeEnum
{
[XmlEnum(Name = "0")]
SteelRolled,
[XmlEnum(Name = "1")]
SteelColdWorked,
[XmlEnum(Name = "2")]
SteelWelded,
[XmlEnum(Name = "3")]
Concrete,
[XmlEnum(Name = "4")]
Timber,
[XmlEnum(Name = "65535")]
Unknown,
[XmlEnum(Name = "-1")]
Undefined
SteelRolled = 0,
SteelColdWorked = 1,
SteelWelded = 2,
Concrete = 3,
Timber = 4,
Unknown = 65535,
Undefined = -1
}
}
71 changes: 55 additions & 16 deletions src/Sections/Section.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,46 @@ namespace FemDesign.Sections
public class Section: EntityBase
{
[XmlElement("region_group", Order = 1)]
public Geometry.RegionGroup RegionGroup { get; set; } // region_group_type
public Geometry.RegionGroup _regionGroup;

[XmlIgnore]
public Geometry.RegionGroup RegionGroup
{
set
{

Geometry.FdVector3d unitZ = Geometry.FdVector3d.UnitZ();
foreach(Geometry.Region region in value.Regions)
{
// check normal
int par = region.LocalZ.Parallel(unitZ);
if (par == 1)
{
// pass
}
else if (par == -1)
{
region.LocalZ = unitZ;
}
else
{
throw new System.ArgumentException("Normal of region must be parallell with z-axis");
}

// check if z of any point is not 0
if (region.Contours[0].Edges[0].Points[0].Z != 0)
{
throw new System.ArgumentException("Region must lie in the XY-plane with z=0");
}
}

this._regionGroup = value;
}
get
{
return this._regionGroup;
}
}

[XmlElement("end", Order = 2)]
public string _end { get; set; } // enpty_type
Expand Down Expand Up @@ -47,21 +86,21 @@ private Section()

}

// /// <summary>
// /// Construct a new section
// /// <summary>
// public Section(Geometry.RegionGroup regionGroup, string name, string type, Materials.MaterialTypeEnum materialTypeEnum, string groupName, string typeName, string sizeName)
// {
// this.EntityCreated();
// this.RegionGroup = regionGroup;
// this.Name = name;
// this.Type = type;
// this.MaterialType = materialTypeEnum;
// this.GroupName = groupName;
// this.TypeName = typeName;
// this.SizeName = sizeName;
// this._end = "";
// }
/// <summary>
/// Construct a new section
/// <summary>
public Section(Geometry.RegionGroup regionGroup, string name, string type, Materials.MaterialTypeEnum materialTypeEnum, string groupName, string typeName, string sizeName)
{
this.EntityCreated();
this.RegionGroup = regionGroup;
this.Name = name;
this.Type = type;
this.MaterialType = ((int)materialTypeEnum).ToString();
this.GroupName = groupName;
this.TypeName = typeName;
this.SizeName = sizeName;
this._end = "";
}

/// <summary>
/// Get a Section from a SectionDatabase by name.
Expand Down

0 comments on commit 3802e6f

Please sign in to comment.