public static object AppendMesh(sSystem sghSystem, string meshName, List <double> verticeNineNumbers, int colorA, int colorR, int colorG, int colorB) { sDynamoConverter dycon = new sDynamoConverter("Feet", "Meters"); List <string> meshNames = new List <string>(); for (int i = 0; i < sghSystem.meshes.Count; ++i) { if (sghSystem.meshes[i].meshName == meshName) { sghSystem.meshes.RemoveAt(i); } } sMesh sm = dycon.TosMesh(dycon.EnsureUnit(verticeNineNumbers), new sColor(colorA, colorR, colorG, colorB)); sm.meshName = meshName; sghSystem.meshes.Add(sm); foreach (sMesh mm in sghSystem.meshes) { meshNames.Add(mm.meshName); } return(new Dictionary <string, object> { { "sSystem", sghSystem }, { "AppendedMeshNames", meshNames } }); }
internal void ToDynamoToolKitMeshData(sSystem ssys, eColorMode colorMode, out List <List <Dyn.Point> > vpts, out List <List <int> > findice, out List <List <int> > colorsR, out List <List <int> > colorsG, out List <List <int> > colorsB, double du = 0.0, sRange th = null) { List <sMesh> sms = new List <sMesh>(); sRange dataRange; ssys.ConstructBeamResultMesh(colorMode, ref sms, out dataRange, th, du); List <List <Dyn.Point> > ppp = new List <List <Dyn.Point> >(); List <List <int> > iii = new List <List <int> >(); List <List <int> > rrr = new List <List <int> >(); List <List <int> > ggg = new List <List <int> >(); List <List <int> > bbb = new List <List <int> >(); foreach (sMesh sm in sms) { List <int> ii = new List <int>(); List <int> rr = new List <int>(); List <int> gg = new List <int>(); List <int> bb = new List <int>(); List <Dyn.Point> pp = new List <Autodesk.DesignScript.Geometry.Point>(); ToDynamoToolKitMeshData(sm, ref pp, ref ii, ref rr, ref gg, ref bb); ppp.Add(pp); iii.Add(ii); rrr.Add(rr); ggg.Add(gg); bbb.Add(bb); } vpts = ppp; findice = iii; colorsR = rrr; colorsG = ggg; colorsB = bbb; }
public static object To_DynamoMeshData(sSystem sghSystem, double colorThreshold = 0.0, double deformation = 0.0) { List <List <Dyn.Point> > vertice = null; List <List <int> > faceIndice = null; List <List <int> > Rs = null; List <List <int> > Gs = null; List <List <int> > Bs = null; if (sghSystem != null) { sDynamoConverter dyncon = new sDynamoConverter(); sRange th = null; if (colorThreshold > 0.0) { th = new sRange(0.0, colorThreshold); } dyncon.ToDynamoToolKitMeshData(sghSystem, eColorMode.Stress_Combined_Absolute, out vertice, out faceIndice, out Rs, out Gs, out Bs, deformation, th); } return(new Dictionary <string, object> { { "vertice", vertice }, { "indice", faceIndice }, { "R", Rs }, { "G", Gs }, { "B", Bs } }); }
public static object Upload_sSystem(string hostURL, bool upload, sSystem sghSystem) { string url = hostURL + "sWebSystemServer.asmx/ReceiveFromClient"; string mmes = ""; if (sghSystem != null) { sSystem ssys = sghSystem as sSystem; string jsonData = ssys.Jsonify(); if (upload) { try { var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url); request.ContentType = "application/json"; request.Method = "POST"; request.Expect = "application/json"; using (var streamWriter = new StreamWriter(request.GetRequestStream())) { streamWriter.Write("{'sysFromClient':'" + jsonData + "'}"); streamWriter.Close(); } var httpResponse = (System.Net.HttpWebResponse)request.GetResponse(); StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()); string resp = streamReader.ReadToEnd(); sJsonReceiver jj = Newtonsoft.Json.JsonConvert.DeserializeObject <sJsonReceiver>(resp); mmes = jj.d; } catch (System.Net.WebException e) { mmes = "Couldn't Find The Server"; string pageContent = new StreamReader(e.Response.GetResponseStream()).ReadToEnd().ToString(); //Error = pageContent; } } else { mmes = ""; } } else { mmes = "Please provide sghSystem"; } return(new Dictionary <string, object> { { "status", mmes } }); }
public static object To_sElements(sSystem sghSystem) { List <object> obj0 = new List <object>(); List <object> obj1 = new List <object>(); List <object> obj2 = new List <object>(); List <object> obj3 = new List <object>(); List <object> obj4 = new List <object>(); if (sghSystem != null) { //?????????? //?????????? //?????????? //?????????? foreach (sFrameSet b in sghSystem.frameSets) { obj1.Add(b); } foreach (sNode n in sghSystem.nodes) { if (n.boundaryCondition != null) { obj3.Add(n.boundaryCondition); } if (n.pointLoads != null && n.pointLoads.Count > 0) { foreach (sPointLoad spl in n.pointLoads) { obj2.Add(spl); } } } if (sghSystem.loadCombinations != null && sghSystem.loadCombinations.Count > 0) { foreach (sLoadCombination com in sghSystem.loadCombinations) { obj4.Add(com); } } } return(new Dictionary <string, object> { { "areaElements", obj0 }, { "beamElements", obj1 }, { "pointLoads", obj2 }, { "pointSupports", obj3 }, { "loadCombos", obj4 } }); }
internal List <Dyn.Mesh> ToDynamoMesh(sSystem ssys, eColorMode colorMode, out List <List <Color> > verticeColor, double du = 0.0, sRange th = null) { List <sMesh> sms = new List <sMesh>(); sRange dataRange; ssys.ConstructBeamResultMesh(colorMode, ref sms, out dataRange, th, du); List <List <Color> > allcols = new List <List <Color> >(); List <Dyn.Mesh> dms = new List <Autodesk.DesignScript.Geometry.Mesh>(); foreach (sMesh sm in sms) { List <Color> cols; dms.Add(ToDynamoMesh(sm, out cols)); allcols.Add(cols); } verticeColor = allcols; return(dms); }
public static object To_DynamoMesh_Appendix(sSystem sghSystem) { List <Dyn.Mesh> emesh = new List <Dyn.Mesh>(); List <List <Color> > verticeColor = null; if (sghSystem != null) { sDynamoConverter dyncon = new sDynamoConverter("Meters", "Feet"); foreach (sMesh sm in sghSystem.meshes) { List <Color> vcols; emesh.Add(dyncon.ToDynamoMesh(sm, out vcols)); verticeColor.Add(vcols); } } return(new Dictionary <string, object> { { "dynamoMesh", emesh } }); }
public static object Build_sSystem(List <object> sElements, object systemSettings = null) { sSystemSetting sysSet = null; if (systemSettings == null) { sysSet = new sSystemSetting(); sysSet.systemOriUnit = "Feet"; sysSet.systemName = "DefaultSetting"; sysSet.currentCase = "DEAD"; sysSet.currentCheckType = eSystemCheckType.StrengthCheck; sysSet.currentStressThreshold_pascal = 25 * 6894757.28; sysSet.currentDeflectionThreshold_mm = 100; sysSet.mergeTolerance_m = 0.005; sysSet.meshDensity_m = 0.5; } else { sysSet = systemSettings as sSystemSetting; } sSystem jsys = new sSystem(); jsys.systemSettings = sysSet; List <IsObject> sobjs = new List <IsObject>(); sDynamoConverter dycon = new sDynamoConverter(); jsys.loadPatterns.Add("DEAD"); int supCount = 0; int nodeID = 0; foreach (object so in sElements) { sFrameSet sb = so as sFrameSet; if (sb != null) { jsys.frameSets.Add(sb); sobjs.Add(sb); if (sb.lineLoads != null) { foreach (sLineLoad ll in sb.lineLoads) { jsys.AwarePatternNames(ll.loadPatternName); } } continue; } sPointSupport psup = so as sPointSupport; if (psup != null) { if (jsys.UpdateNodeFromPointElement(psup, nodeID)) { nodeID++; } supCount++; continue; } sPointLoad pl = so as sPointLoad; if (pl != null) { if (jsys.UpdateNodeFromPointElement(pl, nodeID)) { nodeID++; jsys.AwarePatternNames(pl.loadPatternName); } continue; } sLoadCombination com = so as sLoadCombination; if (com != null) { jsys.SetLoadCombination(com); } } if (supCount > 0) { //jsys.geometrySettings.systemBoundingBox = dycon.TosBoundingBox(sobjs); //jsys.SystemName = sysSet.systemName; return(new Dictionary <string, object> { { "sSystem", jsys } }); } else { return(new Dictionary <string, object> { { "sSystem", null } }); } }
protected override void SolveInstance(IGH_DataAccess DA) { sSystem ssys = null; string meshName = ""; List <Mesh> ms = new List <Mesh>(); System.Drawing.Color col = System.Drawing.Color.Empty; if (!DA.GetData(0, ref ssys)) { return; } if (!DA.GetData(1, ref meshName)) { return; } if (!DA.GetDataList(2, ms)) { return; } if (!DA.GetData(3, ref col)) { return; } string modelUnit = Rhino.RhinoDoc.ActiveDoc.ModelUnitSystem.ToString(); sRhinoConverter rhcon = new sRhinoConverter(modelUnit, "Meters"); Mesh bm = new Mesh(); foreach (Mesh m in ms) { Mesh ensuredM = rhcon.EnsureUnit(m) as Mesh; bm.Append(ensuredM); } bm.Vertices.CombineIdentical(false, false); for (int i = 0; i < bm.Vertices.Count; ++i) { bm.VertexColors.SetColor(i, col); } int count = 0; List <string> meshNames = new List <string>(); foreach (sMesh sm in ssys.meshes) { if (sm.meshName == meshName) { count++; } meshNames.Add(sm.meshName); } string mms = "Appended Meshes"; if (count == 0) { sMesh sm = rhcon.TosMesh(bm); sm.opacity = (double)(col.A) / (255.0); sm.meshName = meshName; ssys.meshes.Add(sm); } foreach (string mn in meshNames) { mms += "\n" + mn; } this.Message = mms; DA.SetData(0, ssys); }