Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Commit

Permalink
Merge pull request #32 from speckleworks/dev
Browse files Browse the repository at this point in the history
- 2D meshes are now consolidated to reduce duplicate vertices
- implemented new algorithm for determining the outer edge polyline for a mesh
- added LoadPlaneRef to 1D loads
- added StoreyRef to assemblies
- fixed bugs with 0D (node) and 1D loads and 2D load panels as part of planned re-implementation of conversion from Speckle to GSA objects
- fixed property reference bug for polylines
  • Loading branch information
nic-burgers-arup authored Dec 8, 2020
2 parents fee089b + 5a6f3a6 commit 3ba6d13
Show file tree
Hide file tree
Showing 110 changed files with 222,566 additions and 218,590 deletions.
Binary file modified Resource/SpeckleGSAInterfaces.dll
Binary file not shown.
Binary file modified Resource/SpeckleGSAProxy.dll
Binary file not shown.
39 changes: 38 additions & 1 deletion SpeckleStructuralClasses/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;

namespace SpeckleStructuralClasses
Expand All @@ -25,5 +26,41 @@ public static List<T> ValueAsTypedList<T> (this Dictionary<string, object> d, st
catch { }
return null;
}

public static List<double> ValueAsDoubleList(this Dictionary<string, object> d, string key)
{
if (!d.ContainsKey(key)) return null;

try
{
if (d[key] is List<double>)
{
return (List<double>)d[key];
}
else if (d[key] is List<object>)
{
//Note: this will return a new list instance, so calling Add() or AddRange() on the return value will not alter
//the structural properties dictionary.

var retList = new List<double>();
foreach (var dv in (List<object>)d[key])
{
try
{
var dblVal = Convert.ToDouble(dv);
retList.Add(dblVal);
}
catch
{
retList.Add(0);
}
}

return retList;
}
}
catch { }
return null;
}
}
}
10 changes: 5 additions & 5 deletions SpeckleStructuralClasses/Extensions/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SpeckleStructuralClasses
{
public partial class StructuralVectorThree
{
public StructuralVectorThree() { }

public StructuralVectorThree(double[] value, string applicationId = null, Dictionary<string, object> properties = null)
public StructuralVectorThree(IEnumerable<double> value, string applicationId = null, Dictionary<string, object> properties = null)
{
this.Value = value.ToList();
this.ApplicationId = applicationId;
Expand Down Expand Up @@ -86,7 +85,7 @@ public partial class StructuralVectorBoolThree
{
public StructuralVectorBoolThree() { }

public StructuralVectorBoolThree(bool[] value, string applicationId = null, Dictionary<string, object> properties = null)
public StructuralVectorBoolThree(IEnumerable<bool> value, string applicationId = null, Dictionary<string, object> properties = null)
{
this.Value = value.ToList();
this.ApplicationId = applicationId;
Expand Down Expand Up @@ -120,7 +119,7 @@ public partial class StructuralVectorSix
{
public StructuralVectorSix() { }

public StructuralVectorSix(double[] value, string applicationId = null, Dictionary<string, object> properties = null)
public StructuralVectorSix(IEnumerable<double> value, string applicationId = null, Dictionary<string, object> properties = null)
{
this.Value = value.ToList();
this.ApplicationId = applicationId;
Expand Down Expand Up @@ -187,7 +186,7 @@ public partial class StructuralVectorBoolSix
{
public StructuralVectorBoolSix() { }

public StructuralVectorBoolSix(bool[] value, string applicationId = null, Dictionary<string, object> properties = null)
public StructuralVectorBoolSix(IEnumerable<bool> value, string applicationId = null, Dictionary<string, object> properties = null)
{
this.Value = value.ToList();
this.ApplicationId = applicationId;
Expand Down Expand Up @@ -223,6 +222,7 @@ public StructuralAxis() { }

public StructuralAxis(StructuralVectorThree xdir, StructuralVectorThree ydir, StructuralVectorThree normal, string applicationId = null, Dictionary<string, object> properties = null)
{
//this.Origin = new SpecklePoint(0, 0, 0);
this.Normal = normal;
this.Xdir = xdir;
this.Ydir = ydir;
Expand Down
16 changes: 14 additions & 2 deletions SpeckleStructuralClasses/Extensions/Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ namespace SpeckleStructuralClasses
{
public static class Helper
{
public static double PointComparisonEpsilon = 0.0001;

public static void ScaleProperties(Dictionary<string, object> dict, double factor)
{
ScaleDictionary(ref dict, factor);
}

public static string CreateChildApplicationId(int elementGsaId, string parentMemberApplicationId)
public static string CreateChildApplicationId(int childId, string parentApplicationId)
{
return string.Join("_", new[] { parentApplicationId, childId.ToString() });
}

public static string CreateChildApplicationId(string childId, string parentApplicationId)
{
return string.Join("_", new[] { parentApplicationId, childId });
}

public static string ExtractParentApplicationId(string appId)
{
return string.Join("_", new[] { parentMemberApplicationId, elementGsaId.ToString() });
return appId.Split(new[] { '_' }).First();
}

private static void ScaleDictionary(ref Dictionary<string, object> dict, double factor)
Expand Down
Loading

0 comments on commit 3ba6d13

Please sign in to comment.