Esempio n. 1
0
        private void SetValues(ArchivableDictionary dictionary)
        {
            if (null == dictionary)
            {
                return;
            }

            m_integer_value++;
            m_double_value *= 1.57;

            dictionary.Set(INTEGER_VALUE, m_integer_value);
            dictionary.Set(DOUBLE_VALUE, m_double_value);
        }
        public static ArchivableDictionary ToNative(this Dictionary <string, object> dict)
        {
            ArchivableDictionary myDictionary = new ArchivableDictionary();

            if (dict == null)
            {
                return(myDictionary);
            }

            foreach (var key in dict.Keys)
            {
                if (dict[key] is Dictionary <string, object> )
                {
                    myDictionary.Set(key, ((Dictionary <string, object>)dict[key]).ToNative());
                }
                else if (dict[key] is SpeckleObject)
                {
                    var converted = SpeckleCore.Converter.Deserialise(( SpeckleObject )dict[key]);

                    if (converted is GeometryBase)
                    {
                        myDictionary.Set(key, ( GeometryBase )converted);
                    }
                    else if (converted is Interval)
                    {
                        myDictionary.Set(key, ( Interval )converted);
                    }
                    else if (converted is Vector3d)
                    {
                        myDictionary.Set(key, ( Vector3d )converted);
                    }
                    else if (converted is Plane)
                    {
                        myDictionary.Set(key, ( Plane )converted);
                    }
                }
                else if (dict[key] is int)
                {
                    myDictionary.Set(key, Convert.ToInt32(dict[key]));
                }
                else if (dict[key] is double)
                {
                    myDictionary.Set(key, ( double )dict[key]);
                }
                else if (dict[key] is bool)
                {
                    myDictionary.Set(key, ( bool )dict[key]);
                }
                else if (dict[key] is string)
                {
                    myDictionary.Set(key, ( string )dict[key]);
                }
            }
            return(myDictionary);
        }
Esempio n. 3
0
        public virtual ArchivableDictionary DeserializeToDictionary()
        {
            var dict = new ArchivableDictionary();

            // Set Component Plane
            dict.Set("Plane", Plane);

            return(dict);
        }
        private protected virtual ArchivableDictionary Serialize()
        {
            var dic = new ArchivableDictionary();

            if (HostObjRef != null)
            {
                //Subsurfaces have no host ObjRef object
                dic.Set(nameof(HostObjRef), HostObjRef);
            }

            if (HostRoomObjRef != null)
            {
                dic.Set(nameof(HostRoomObjRef), HostRoomObjRef);
            }


            return(dic);
        }
 /// <summary>
 /// Command.EndCommand event handler
 /// </summary>
 private void OnEndCommand(object sender, CommandEventArgs e)
 {
     if (CommandTrackingEnabled && e.CommandResult == Result.Success)
     {
         string key = e.CommandEnglishName;
         m_dictionary.TryGetInteger(key, out int value);
         m_dictionary.Set(key, ++value);
     }
 }
        private static ArchivableDictionary getArchivableDict(ExpandoObject dict)
        {
            var myDictionary = new ArchivableDictionary();

            foreach (var kvp in dict)
            {
                if (kvp.Value is ExpandoObject)
                {
                    myDictionary.Set(kvp.Key, getArchivableDict(kvp.Value as ExpandoObject));
                }
                else
                {
                    try
                    {
                        myDictionary.Set((string)kvp.Key, Convert.ToInt32(kvp.Value));
                    }
                    catch { }

                    try
                    {
                        myDictionary.Set((string)kvp.Key, (double)kvp.Value);
                    }
                    catch { }

                    try
                    {
                        myDictionary.Set((string)kvp.Key, (bool)kvp.Value);
                    }
                    catch { }

                    try
                    {
                        myDictionary.Set((string)kvp.Key, (string)kvp.Value);
                    }
                    catch { }
                }
            }
            return(myDictionary);
        }
Esempio n. 7
0
        /// <summary>
        /// Builds the cell mesh in a clean way.
        /// This lends the cell mesh to being referenced for PolyFrame use.
        /// This needs the face meshes stored in the faces
        /// </summary>
        public Mesh CreateCellMesh()
        {
            // create a dict for quick find of the vertices
            // take the faces from each faceMesh and reconstruct them in the cell
            var cellMesh = new Mesh();
            ArchivableDictionary vertDict = new ArchivableDictionary();

            for (int i = 0; i < Vertices.Count; i++)
            {
                vertDict.Set(i.ToString(), Vertices[i].Id);
            }
            cellMesh.UserDictionary.Set("VertexIds", vertDict);
            cellMesh.UserDictionary.Set("Id", Id);
            var cellVerts = new Dictionary <int, int>();

            foreach (var vert in Vertices)
            {
                cellVerts.Add(vert.Id, cellMesh.Vertices.Add(vert.Point)); // vert id : index in cell
            }

            foreach (var face in Faces)
            {
                //cellMesh.Ngons.AddNgon(new MeshNgon(new List<MeshFace>()));
                var mFaceList = new List <int>();
                foreach (var mFace in face.FMesh.Faces)
                {
                    var cellMFace = new MeshFace(
                        cellVerts[face.Vertices[mFace.A].Id],
                        cellVerts[face.Vertices[mFace.B].Id],
                        cellVerts[face.Vertices[mFace.C].Id]
                        );

                    mFaceList.Add(cellMesh.Faces.AddFace(cellMFace));
                }
                cellMesh.Ngons.AddNgon(MeshNgon.Create(face.Vertices.Select(x => cellVerts[x.Id]).ToList(), mFaceList));
            }



            cellMesh.UnifyNormals();

            cellMesh.Normals.ComputeNormals();
            cellMesh.Normals.UnitizeNormals();



            cellMesh.Flip(true, true, true);


            return(cellMesh);
        }
        private ArchivableDictionary Serialize()
        {
            var dic = new ArchivableDictionary();

            dic.Set(nameof(HBObject), HBObject.ToJson());
            dic.Set(nameof(Rooms), RoomEntitiesWithoutHistory);
            dic.Set(nameof(OrphanedApertures), OrphanedAperturesWithoutHistory);
            dic.Set(nameof(OrphanedDoors), OrphanedDoorsWithoutHistory);
            dic.Set(nameof(OrphanedFaces), OrphanedFacesWithoutHistory);
            dic.Set(nameof(OrphanedShades), OrphanedShadesWithoutHistory);
            return(dic);
        }
Esempio n. 9
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            //动态绑定
            List <dynamic> Inputs = new List <dynamic>();

            if (!DA.GetDataList(0, Inputs))
            {
                return;
            }
            ArchivableDictionary Archives = new ArchivableDictionary();

            for (int Index = 0; Index < Inputs.Count; Index++)
            {
                string Key = Guid.NewGuid().ToString();
                Archives.Set(Key, Inputs[Index].Value);
            }
            DA.SetData(0, Archives);
        }
Esempio n. 10
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var props = new ArchivableDictionary();

            for (int i = 0; i < Params.Input.Count; i++)
            {
                var key = Params.Input[i].NickName;

                object value = null;
                DA.GetData(i, ref value);

                if (value != null)
                {
                    GH_Number nmb = value as GH_Number;
                    if (nmb != null)
                    {
                        props.Set(key, nmb.Value);
                    }

                    if (value is double)
                    {
                        props.Set(key, (double)value);
                    }

                    if (value is int)
                    {
                        props.Set(key, (double)value);
                    }

                    GH_String str = value as GH_String;
                    if (str != null)
                    {
                        props.Set(key, str.Value);
                    }

                    if (value is string)
                    {
                        props.Set(key, (string)value);
                    }

                    GH_Boolean bol = value as GH_Boolean;
                    if (bol != null)
                    {
                        props.Set(key, bol.Value);
                    }

                    GH_ObjectWrapper temp = value as GH_ObjectWrapper;
                    if (temp != null)
                    {
                        ArchivableDictionary dict = ((GH_ObjectWrapper)value).Value as ArchivableDictionary;
                        if (dict != null)
                        {
                            props.Set(key, dict);
                        }
                    }

                    if (!props.ContainsKey(key))
                    {
                        this.AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, key + " could not be set. Strings, numbers, booleans and ArchivableDictionary are the only supported types.");
                    }
                }
            }

            DA.SetData(0, props);
        }
Esempio n. 11
0
        public ArchivableDictionary GlulamPropertiesToArchivableDictionary(Glulam g)
        {
            ArchivableDictionary ad = new ArchivableDictionary();

            var gd = g.GetProperties();

            //ad.Set("id", g.ID);
            ad.Set("centreline", g.Centreline);
            ad.Set("width", g.Width);
            ad.Set("height", g.Height);
            ad.Set("lamella_width", g.Data.LamWidth);
            ad.Set("lamella_height", g.Data.LamHeight);
            ad.Set("lamella_count_width", g.Data.NumWidth);
            ad.Set("lamella_count_height", g.Data.NumHeight);
            ad.Set("volume", g.GetVolume());
            ad.Set("samples", g.Data.Samples);

            /*
             * var planes = g.GetAllPlanes();
             * ArchivableDictionary pd = new ArchivableDictionary();
             *
             * for (int i = 0; i < planes.Length; ++i)
             * {
             *  pd.Set(string.Format("Frame_{0}", i), planes[i]);
             * }
             * ad.Set("frames", pd);
             *
             */
            double max_kw = 0.0, max_kh = 0.0;

            ad.Set("max_curvature", g.GetMaxCurvature(ref max_kw, ref max_kh));
            ad.Set("max_curvature_width", max_kw);
            ad.Set("max_curvature_height", max_kh);
            ad.Set("type", g.ToString());
            ad.Set("type_id", (int)g.Type());

            return(ad);
        }
Esempio n. 12
0
        /// <summary>
        /// creates a mesh patch corresponding to the cell
        /// also sets the area of the polygon
        /// </summary>
        public void FaceMesh()
        {
            // pick one vertex and create triangles with all the other pairs
            double area     = 0;
            Mesh   faceMesh = new Mesh();

            faceMesh.Vertices.AddVertices(Vertices.Select(x => x.Point));
            ArchivableDictionary vertDict = new ArchivableDictionary();

            for (int i = 0; i < Vertices.Count; i++)
            {
                vertDict.Set(i.ToString(), Vertices[i].Id);
            }
            faceMesh.UserDictionary.Set("VertexIds", vertDict);
            faceMesh.UserDictionary.Set("Id", Id);
            //this.FMesh.Vertices.Add(Centroid);
            for (int v = 1; v < faceMesh.Vertices.Count - 1; v++)
            {
                // create faces..
                faceMesh.Faces.AddFace(0, v, v + 1);
                Vector3d v1       = Vertices[v].Point - Vertices[0].Point;
                Vector3d v2       = Vertices[v + 1].Point - Vertices[0].Point;
                double   faceArea = System.Math.Abs(Vector3d.CrossProduct(v1, v2).Length / 2);
                area = area + faceArea;
            }


            if (Vertices.Count > 3)
            {
                faceMesh.Ngons.AddNgon(MeshNgon.Create
                                           (Enumerable.Range(0, Vertices.Count).ToList(),
                                           Enumerable.Range(0, faceMesh.Faces.Count).ToList()));
            }


            FMesh = faceMesh.DuplicateMesh();

            //FMesh.Normals.ComputeNormals();
            //FMesh.FaceNormals.ComputeFaceNormals();

            /*
             * for (int n=0; n<FMesh.Vertices.Count; n++)
             * {
             *  FMesh.Normals.SetNormal(n, Normal);
             * }
             * for (int fn = 0; fn < FMesh.FaceNormals.Count; fn++)
             * {
             *  FMesh.FaceNormals.SetFaceNormal(fn, Normal);
             * }
             */


            // check face normal against the PFFace normal and reverse if necessary

            /*
             * for (int i=0; i<FMesh.FaceNormals.Count; i++)
             * {
             *  if ((FMesh.FaceNormals[i] - Normal).Length > FMesh.FaceNormals[i].Length)
             *  {
             *      Vector3f reverse = FMesh.FaceNormals[i];
             *      reverse.Reverse();
             *      FMesh.FaceNormals.SetFaceNormal(i, reverse);
             *
             *  }
             * }
             * if ((FMesh.FaceNormals[0] - Normal).Length > FMesh.FaceNormals[0].Length)
             * {
             *  FMesh.Flip(true, true, true);
             *
             * }
             */
            Area = area;
        }
Esempio n. 13
0
        protected override void WriteDocument(RhinoDoc doc, BinaryArchiveWriter archive, FileWriteOptions options)
        {
            ArchivableDictionary dict = new ArchivableDictionary();
            int i = 1;

            dict.Set("BeamCount", Beams.Count);
            dict.Set("CountableUserData", CountableUserData.getCounter());
            foreach (Beam beam in Beams)
            {
                if (beam.GetType() == typeof(Column))
                {
                    Column col = beam as Column;
                    dict.Set("BeamType" + i, "Column");
                    dict.Set("ky" + i, col.Ky);
                    dict.Set("kz" + i, col.Kz);
                    dict.Set("ColLength" + i, col.Length);

                    dict.Set("CliConcreteStrenghtClass" + i, beam.CrossSec.ConcreteMaterial.StrengthClass ?? null);
                    dict.Set("ColumnCalculationSettings1" + i,
                             col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature1]);
                    dict.Set("ColumnCalculationSettings2" + i,
                             col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature2]);
                    dict.Set("ColumnCalculationSettings3" + i,
                             col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness1]);
                    dict.Set("ColumnCalculationSettings4" + i,
                             col.ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness2]);
                }
                else
                {
                    dict.Set("BeamType" + i, "Other");
                }


                dict.Set("Rh" + i, beam.ClimateCond.RH);
                dict.Set("T0" + i, beam.ClimateCond.T0);
                dict.Set("T" + i, beam.ClimateCond.T);


                dict.Set("BeamName" + i, beam.Name);


                dict.Set("Gammac" + i, beam.Gammac);
                dict.Set("Gammas" + i, beam.Gammas);
                dict.Set("Gammar" + i, beam.Gammar);
                dict.Set("Acc" + i, beam.Acc);

                dict.Set("CrossSecName" + i, beam.CrossSec.Name);
                dict.Set("ConcreteStrenghtClass" + i, beam.CrossSec.ConcreteMaterial.StrengthClass ?? null);
                dict.Set("BeamId" + i, beam.CrossSec.Id);
                dict.Set("geomLarges" + i, beam.CrossSec.GeometryLargeIds);
                dict.Set("reinf" + i, beam.CrossSec.ReinforementIds);


                if (beam.CrossSec.GetType() == typeof(RectangleCrossSection))
                {
                    RectangleCrossSection crossSectionTemp = beam.CrossSec as RectangleCrossSection;
                    dict.Set("CrossSectionType" + i, "Rect");
                    dict.Set("NoReinfH" + i, crossSectionTemp.NoReinfH);
                    dict.Set("NoReinfW" + i, crossSectionTemp.NoReinfW);
                    dict.Set("ConcreteCover" + i, crossSectionTemp.ConcreteCover);
                    dict.Set("ConcreteWidth" + i, crossSectionTemp.ConcreteWidth);
                    dict.Set("ConcreteHeight" + i, crossSectionTemp.ConcreteHeight);
                    dict.Set("HasSteelShell" + i, crossSectionTemp.HasSteelShell);
                    dict.Set("SteelThickness" + i, crossSectionTemp.SteelThickness);
                    dict.Set("MainDiameter" + i, crossSectionTemp.MainD);
                    dict.Set("StirrupDiameter" + i, crossSectionTemp.StirrupD);
                    dict.Set("SteelMaterialName" + i, crossSectionTemp.SteelMaterial.StrengthClass ?? null);
                    dict.Set("ReinforcementMaterialName" + i, crossSectionTemp.ReinfMaterial.StrengthClass ?? null);
                    dict.Set("Rotation" + i, crossSectionTemp.Rotation);
                }
                else if (beam.CrossSec.GetType() == typeof(CrossSection))
                {
                    dict.Set("CrossSectionType" + i, "Basic");
                }
                else if (beam.CrossSec.GetType() == typeof(CircleCrossSection))
                {
                    CircleCrossSection crossSectionTemp = beam.CrossSec as CircleCrossSection;
                    dict.Set("CrossSectionType" + i, "Rect");
                    dict.Set("NoReinf" + i, crossSectionTemp.NoReinf);
                    dict.Set("ConcreteCover" + i, crossSectionTemp.ConcreteCover);
                    dict.Set("ConcreteDiameter" + i, crossSectionTemp.ConcreteDiameter);
                    dict.Set("HasSteelShell" + i, crossSectionTemp.HasSteelShell);
                    dict.Set("SteelThickness" + i, crossSectionTemp.SteelThickness);
                    dict.Set("MainDiameter" + i, crossSectionTemp.MainD);
                    dict.Set("StirrupDiameter" + i, crossSectionTemp.StirrupD);
                    dict.Set("SteelMaterialName" + i, crossSectionTemp.SteelMaterial.StrengthClass ?? null);
                    dict.Set("ReinforcementMaterialName" + i, crossSectionTemp.ReinfMaterial.StrengthClass ?? null);
                }

                int k = 1;
                dict.Set("NumberOfLoadCases" + i, beam.LoadCases.Count);

                foreach (LoadCase loadCase in beam.LoadCases)
                {
                    if (loadCase.GetType() == typeof(ColLoadCase))
                    {
                        ColLoadCase clc = (ColLoadCase)loadCase;
                        dict.Set("LoadCaseType" + i + "s" + k, "ColLoadCase");
                        dict.Set("N_Ed" + i + "s" + k, clc.N_Ed);
                        dict.Set("M_EzTop" + i + "s" + k, clc.M_EzTop);
                        dict.Set("M_EzBottom" + i + "s" + k, clc.M_EzBottom);
                        dict.Set("M_EyTop" + i + "s" + k, clc.M_EyTop);
                        dict.Set("M_EyBottom" + i + "s" + k, clc.M_EyBottom);
                        dict.Set("Ratio" + i + "s" + k, clc.Ratio);
                        dict.Set("CCurve" + i + "s" + k, clc.Ccurve);
                    }
                    else if (loadCase.GetType() == typeof(SimpleLoadCase))
                    {
                        SimpleLoadCase slc = (SimpleLoadCase)loadCase;
                        dict.Set("LoadCaseType" + i + "s" + k, "SimpleLoadCase");
                        dict.Set("N_Ed" + i + "s" + k, slc.N_Ed);
                        dict.Set("M_Edy" + i + "s" + k, slc.M_Edy);
                        dict.Set("M_Edz" + i + "s" + k, slc.M_Edz);
                    }
                    dict.Set("LoadCaseName" + i + "s" + k, loadCase.Name);
                    switch (loadCase.Ls)
                    {
                    case LimitState.Ultimate:
                        dict.Set("LimitState" + i + "s" + k, 0); break;

                    case LimitState.Service_CH:
                        dict.Set("LimitState" + i + "s" + k, 1); break;

                    case LimitState.Service_FR:
                        dict.Set("LimitState" + i + "s" + k, 2); break;

                    case LimitState.Service_QP:
                        dict.Set("LimitState" + i + "s" + k, 3); break;

                    default:
                        break;
                    }

                    k++;
                }
                i++;
            }
            if (CurrentBeam != null)
            {
                dict.Set("currentBeamId", CurrentBeam.Id);
            }
            else
            {
                dict.Set("currentBeamId", -1);
            }

            archive.WriteDictionary(dict);
        }
Esempio n. 14
0
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            Beams.Clear();
            CurrentBeam = null;

            if (unitfactors.ContainsKey(RhinoDoc.ActiveDoc.ModelUnitSystem))
            {
                Unitfactor = unitfactors[RhinoDoc.ActiveDoc.ModelUnitSystem];
            }
            else
            {
                MessageBox.Show("Cross section design tool does not support the chosen" +
                                "unit system. Unit system will be changed to millimeters.");
                RhinoDoc.ActiveDoc.ModelUnitSystem = UnitSystem.Millimeters;
                Unitfactor = unitfactors[RhinoDoc.ActiveDoc.ModelUnitSystem];
            }



            try
            {
                ArchivableDictionary dict = archive.ReadDictionary();

                int i     = 1;
                int count = 0;
                if (dict["BeamCount"] != null)
                {
                    count = (int)dict["BeamCount"];
                }

                dict.Set("CountUserData", CountableUserData.getCounter());
                while (i < count + 1)
                {
                    Beam   bTemp;
                    string beamName = (string)dict["BeamName" + i];

                    if ((string)dict["BeamType" + i] == "Column")
                    {
                        bTemp = new Column(beamName, dict.GetDouble("Gammas" + i),
                                           dict.GetDouble("Gammac" + i),
                                           dict.GetDouble("Gammar" + i),
                                           dict.GetDouble("Acc" + i))
                        {
                            Length = (double)dict["ColLength" + i],
                            Ky     = (double)dict["ky" + i],
                            Kz     = (double)dict["kz" + i],
                        };
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature1] =
                            dict.GetBool("ColumnCalculationSettings1" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalCurvature2] =
                            dict.GetBool("ColumnCalculationSettings2" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness1] =
                            dict.GetBool("ColumnCalculationSettings3" + i);
                        ((Column)bTemp).ColumnCalcSettings.ColumnCalMethod[ColumnCalculationMethod.NominalStiffness2] =
                            dict.GetBool("ColumnCalculationSettings4" + i);
                    }
                    else
                    {
                        bTemp = new Beam(beamName, dict.GetDouble("Gammas" + i),
                                         dict.GetDouble("Gammac" + i),
                                         dict.GetDouble("Gammar" + i),
                                         dict.GetDouble("Acc" + i))
                        {
                        };
                    }

                    bTemp.ClimateCond = new ClimateCondition(
                        (int)dict["Rh" + i],
                        (int)dict["T0" + i],
                        (int)dict["T" + i],
                        bTemp);

                    string       crossSecName = (string)dict["CrossSecName" + i];
                    CrossSection cTemp;
                    if ((string)dict["CrossSectionType" + i] == "Basic")
                    {
                        cTemp =
                            new CrossSection(crossSecName, bTemp)
                        {
                        };
                    }

                    else if (dict.GetString("CrossSectionType" + i) == "Rect")
                    {
                        cTemp =
                            new RectangleCrossSection(crossSecName, bTemp)
                        {
                            NoReinfH       = (int)dict["NoReinfH" + i],
                            NoReinfW       = (int)dict["NoReinfW" + i],
                            ConcreteCover  = (int)dict["ConcreteCover" + i],
                            ConcreteWidth  = dict.GetInteger("ConcreteWidth" + i),
                            ConcreteHeight = dict.GetInteger("ConcreteHeight" + i),
                            HasSteelShell  = dict.GetBool("HasSteelShell" + i),
                            SteelThickness = dict.GetDouble("SteelThickness" + i),
                            MainD          = dict.GetInteger("MainDiameter" + i),
                            StirrupD       = dict.GetInteger("StirrupDiameter" + i),
                            SteelMaterial  = new SteelMaterial(dict.GetString("SteelMaterialName" + i) ?? "S355", SteelType.StructuralSteel, bTemp),
                            ReinfMaterial  = new SteelMaterial(dict.GetString("ReinforcementMaterialName" + i ?? "B500B"), SteelType.Reinforcement, bTemp),
                            Rotation       = dict.GetInteger("Rotation" + i),
                        };
                    }
                    else
                    {
                        cTemp =
                            new CircleCrossSection(crossSecName, bTemp)
                        {
                            NoReinf          = (int)dict["NoReinf"],
                            ConcreteCover    = (int)dict["ConcreteCover" + i],
                            ConcreteDiameter = dict.GetInteger("ConcreteDiameter" + i),
                            HasSteelShell    = dict.GetBool("HasSteelShell" + i),
                            SteelThickness   = dict.GetDouble("SteelThickness" + i),
                            MainD            = dict.GetInteger("MainDiameter" + i),
                            StirrupD         = dict.GetInteger("StirrupDiameter" + i),
                            SteelMaterial    = new SteelMaterial(dict.GetString("SteelMaterialName" + i) ?? "S355", SteelType.StructuralSteel, bTemp),
                            ReinfMaterial    = new SteelMaterial(dict.GetString("ReinforcementMaterialName" + i) ?? "B500B", SteelType.Reinforcement, bTemp),
                        };
                    }


                    //Sets a link between reinforcements and the beam
                    List <int> reinforcements = ((int[])dict["reinf" + i]).ToList();

                    List <Reinforcement> temp = GetReinforcements(reinforcements);
                    temp.ForEach(o => o.Material.Bm = bTemp);



                    //Sets a link between geometry larges and the beam
                    List <int> geometryLarges = ((int[])dict["geomLarges" + i]).ToList();

                    List <GeometryLarge> gls = GetGeometryLarges(geometryLarges);
                    gls.ForEach(o => o.Material.Bm = bTemp);


                    cTemp.ConcreteMaterial = new ConcreteMaterial((string)dict["ConcreteStrenghtClass" + i], bTemp);
                    bTemp.CrossSec         = cTemp;
                    geometryLarges.ForEach(id => cTemp.GeometryLargeIds.Add(id));
                    reinforcements.ForEach(id => cTemp.ReinforementIds.Add(id));
                    bTemp.Id = dict.GetInteger("BeamId" + i);
                    Beams.Add(bTemp);



                    //Set loadCases
                    int lc_n = dict.GetInteger("NumberOfLoadCases" + i);
                    int k    = 1;
                    while (k <= lc_n)
                    {
                        string name           = dict.GetString("LoadCaseName" + i + "s" + k);
                        int    limitStatenumb = dict.GetInteger("LimitState" + i + "s" + k);

                        LimitState ls;
                        switch (limitStatenumb)
                        {
                        case 0:
                            ls = LimitState.Ultimate; break;

                        case 1:
                            ls = LimitState.Service_CH; break;

                        case 2:
                            ls = LimitState.Service_FR; break;

                        case 3:
                            ls = LimitState.Service_QP; break;

                        default:
                            ls = LimitState.Ultimate; break;
                        }
                        ;

                        if (dict.GetString("LoadCaseType" + i + "s" + k) == "ColLoadCase")
                        {
                            ColLoadCase clc = new ColLoadCase(
                                dict.GetDouble("N_Ed" + i + "s" + k),
                                dict.GetDouble("M_EzTop" + i + "s" + k),
                                dict.GetDouble("M_EzBottom" + i + "s" + k),
                                dict.GetDouble("M_EyTop" + i + "s" + k),
                                dict.GetDouble("M_EyBottom" + i + "s" + k),
                                (Column)bTemp,
                                dict.GetDouble("Ratio" + i + "s" + k),
                                name,
                                dict.GetDouble("CCurve" + i + "s" + k),
                                ls);
                        }
                        else if (dict.GetString("LoadCaseType" + i + "s" + k) == "SimpleLoadCase")
                        {
                            SimpleLoadCase slc = new SimpleLoadCase(
                                dict.GetDouble("N_Ed" + i + "s" + k),
                                dict.GetDouble("M_Edz" + i + "s" + k),
                                dict.GetDouble("M_Edy" + i + "s" + k),
                                bTemp,
                                name,
                                ls);
                            bTemp.LoadCases.Add(slc);
                        }
                        k++;
                    }


                    i++;
                }
                Countable.SetCounter(i - 2);
                if (Beams.Count != 0)
                {
                    int currentID = (int)dict["currentBeamId"];
                    if (currentID != -1)
                    {
                        CurrentBeam = Beams.FirstOrDefault(beam => beam.Id == currentID);
                    }
                }

                CountableUserData.setCounter((int)dict["CountableUserData"]);

                if (MainForm != null)
                {
                    MainForm.ChangeToStartView();
                }

                //If there is previous display results, clear them
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                base.ReadDocument(doc, archive, options);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var props = new ArchivableDictionary();

            for (int i = 0; i < Params.Input.Count; i++)
            {
                var key = Params.Input[i].NickName;

                object ghInputProperty = null;
                DA.GetData(i, ref ghInputProperty);

                if (ghInputProperty == null)
                {
                    props.Set(key, "undefined");
                    continue;
                }

                object valueExtract = ghInputProperty.GetType().GetProperty("Value").GetValue(ghInputProperty, null);

                Debug.WriteLine(key + ": " + valueExtract.GetType().ToString());

                GeometryBase geometry = getGeometryBase(valueExtract);

                if (geometry != null)
                {
                    props.Set(key, geometry);
                    continue;
                }

                if (valueExtract is double)
                {
                    props.Set(key, (double)valueExtract);
                }

                if (valueExtract is Int32 || valueExtract is Int64 || valueExtract is Int16 || valueExtract is int)
                {
                    props.Set(key, (int)valueExtract);
                }

                if (valueExtract is string)
                {
                    props.Set(key, (string)valueExtract);
                }

                if (valueExtract is bool)
                {
                    props.Set(key, (bool)valueExtract);
                }

                if (valueExtract is Vector3d)
                {
                    props.Set(key, (Vector3d)valueExtract);
                }

                if (valueExtract is Point3d)
                {
                    props.Set(key, (Point3d)valueExtract);
                }

                if (valueExtract is Line)
                {
                    props.Set(key, (Line)valueExtract);
                }

                if ((valueExtract is Circle))
                {
                    props.Set(key, new ArcCurve((Circle)valueExtract));
                }

                if (valueExtract is Interval)
                {
                    props.Set(key, (Interval)valueExtract);
                }

                if (valueExtract is UVInterval)
                {
                    props.Set(key, "UV Interval not supported.");
                }

                if (valueExtract is Plane)
                {
                    props.Set(key, (Plane)valueExtract);
                }

                if (valueExtract is ArchivableDictionary)
                {
                    props.Set(key, (ArchivableDictionary)valueExtract);
                }
            }

            DA.SetData(0, props);
        }
Esempio n. 16
0
        public ArchivableDictionary GetArchivableDictionary()
        {
            ArchivableDictionary ad = new ArchivableDictionary();

            ad.Set("id", ID);
            ad.Set("centreline", Centreline);
            ad.Set("width", Width);
            ad.Set("height", Height);
            ad.Set("length", Centreline.GetLength());
            ad.Set("lamella_width", Data.LamWidth);
            ad.Set("lamella_height", Data.LamHeight);
            ad.Set("lamella_count_width", Data.NumWidth);
            ad.Set("lamella_count_height", Data.NumHeight);
            ad.Set("volume", GetVolume());
            ad.Set("samples", Data.Samples);

            //var planes = GetAllPlanes();
            //ArchivableDictionary pd = new ArchivableDictionary();

            //for (int i = 0; i < planes.Length; ++i)
            //{
            //    pd.Set(string.Format("Frame_{0}", i), planes[i]);
            //}
            //ad.Set("frames", pd);

            double max_kw = 0.0, max_kh = 0.0;

            ad.Set("max_curvature", GetMaxCurvature(ref max_kw, ref max_kh));
            ad.Set("max_curvature_width", max_kw);
            ad.Set("max_curvature_height", max_kh);
            ad.Set("type", ToString());
            ad.Set("type_id", (int)Type());

            return(ad);
        }
        public static ArchivableDictionary ToNative(this Dictionary <string, object> dict)
        {
            ArchivableDictionary myDictionary = new ArchivableDictionary();

            if (dict == null)
            {
                return(myDictionary);
            }

            foreach (var key in dict.Keys)
            {
                if (dict[key] is Dictionary <string, object> )
                {
                    myDictionary.Set(key, ((Dictionary <string, object>)dict[key]).ToNative());
                }
                else if (dict[key] is IEnumerable <object> && !(dict[key] is string))
                {
                    //var temp = new List<object>();
                    // TODO: Quick hack to output lists
                    // NOTE: Archivable Dictionaries only support IEnumberables of one declared type, so here we are ToString()-finyg everything. For the sake of whatever.
                    var temp = ((IEnumerable <object>)dict[key]).Select(obj => obj.ToString());
                    myDictionary.Set(key, temp);
                }
                else if (dict[key] is SpeckleObject)
                {
                    var converted = SpeckleCore.Converter.Deserialise(( SpeckleObject )dict[key]);

                    if (converted is GeometryBase)
                    {
                        myDictionary.Set(key, ( GeometryBase )converted);
                    }
                    else if (converted is Interval)
                    {
                        myDictionary.Set(key, ( Interval )converted);
                    }
                    else if (converted is Vector3d)
                    {
                        myDictionary.Set(key, ( Vector3d )converted);
                    }
                    else if (converted is Plane)
                    {
                        myDictionary.Set(key, ( Plane )converted);
                    }
                }
                else if (dict[key] is int)
                {
                    myDictionary.Set(key, Convert.ToInt32(dict[key]));
                }
                else if (dict[key] is double)
                {
                    myDictionary.Set(key, ( double )dict[key]);
                }
                else if (dict[key] is bool)
                {
                    myDictionary.Set(key, ( bool )dict[key]);
                }
                else if (dict[key] is string)
                {
                    myDictionary.Set(key, ( string )dict[key]);
                }
            }
            return(myDictionary);
        }
Esempio n. 18
0
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            var props = new ArchivableDictionary();

            List <string> m_key_list   = new List <string>();
            List <object> m_value_list = new List <object>();

            if (!DA.GetDataList("Keys", m_key_list))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No keys supplied.");
                return;
            }
            if (!DA.GetDataList("Values", m_value_list))
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "No values supplied.");
                return;
            }

            int N = Math.Min(m_key_list.Count, m_value_list.Count);

            for (int i = 0; i < N; ++i)
            {
                var key = m_key_list[i];

                object ghInputProperty = m_value_list[i];

                if (ghInputProperty == null)
                {
                    props.Set(key, "undefined");
                    continue;
                }

                object valueExtract = ghInputProperty.GetType().GetProperty("Value").GetValue(ghInputProperty, null);

                Debug.WriteLine(key + ": " + valueExtract.GetType().ToString());

                GeometryBase geometry = getGeometryBase(valueExtract);

                if (geometry != null)
                {
                    props.Set(key, geometry);
                    continue;
                }

                if (valueExtract is double)
                {
                    props.Set(key, (double)valueExtract);
                }

                if (valueExtract is Int32 || valueExtract is Int64 || valueExtract is Int16 || valueExtract is int)
                {
                    props.Set(key, (int)valueExtract);
                }

                if (valueExtract is string)
                {
                    props.Set(key, (string)valueExtract);
                }

                if (valueExtract is bool)
                {
                    props.Set(key, (bool)valueExtract);
                }

                if (valueExtract is Vector3d)
                {
                    props.Set(key, (Vector3d)valueExtract);
                }

                if (valueExtract is Point3d)
                {
                    props.Set(key, (Point3d)valueExtract);
                }

                if (valueExtract is Line)
                {
                    props.Set(key, (Line)valueExtract);
                }

                if ((valueExtract is Circle))
                {
                    props.Set(key, new ArcCurve((Circle)valueExtract));
                }

                if (valueExtract is Interval)
                {
                    props.Set(key, (Interval)valueExtract);
                }

                if (valueExtract is UVInterval)
                {
                    props.Set(key, "UV Interval not supported.");
                }

                if (valueExtract is Plane)
                {
                    props.Set(key, (Plane)valueExtract);
                }

                if (valueExtract is ArchivableDictionary)
                {
                    props.Set(key, (ArchivableDictionary)valueExtract);
                }
            }

            DA.SetData(0, props);
        }