protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            int i = 0;

            while (dict.ContainsKey("geoSeg" + i))
            {
                Brep     brep = (Brep)dict["gsBrep" + i];
                Material material;

                if (dict[$"gsMaterial{i}"] == "Concrete")
                {
                    material = new ConcreteMaterial((string)dict[$"gsMaterialStrength{i}"]);
                    GeometrySegments.Add(new GeometrySegment(brep, material));
                }
                else if (dict[$"gsMaterial{i}"] == "Steel")
                {
                    material = new SteelMaterial((string)dict[$"gsMaterialName{i}"]);
                    GeometrySegments.Add(new GeometrySegment(brep, material));
                }
                //TODO Add extra materials
                else
                {
                    material = new ConcreteMaterial("C30/37");
                    GeometrySegments.Add(new GeometrySegment(brep, material));
                }

                i++;
            }
            return(true);
        }
        protected override bool Write(Rhino.FileIO.BinaryArchiveWriter archive)
        {
            var dict = new Rhino.Collections.ArchivableDictionary(20171031, "Values");

            int i = 0;

            foreach (GeometrySegment geoSeg in GeometrySegments)
            {
                dict.Set("geoSeg" + i, i);
                dict.Set("gsBrep" + i, geoSeg.BrepGeometry);
                if (geoSeg.Material.GetType() == typeof(ConcreteMaterial))
                {
                    ConcreteMaterial material = geoSeg.Material as ConcreteMaterial;

                    dict.Set("gsMaterial" + i, "Concrete");
                    dict.Set("gsMaterialStrength" + i, material.StrenghtClass);
                }
                else if (geoSeg.Material.GetType() == typeof(SteelMaterial))
                {
                    SteelMaterial material = geoSeg.Material as SteelMaterial;
                    dict.Set("gsMaterial" + i, "Steel");
                    dict.Set("gsMaterialName" + i, material.Name);
                }

                i++;
            }

            archive.WriteDictionary(dict);

            return(true);
        }
Example #3
0
 public CrossSection(ConcreteMaterial concreteMtMaterial)
 {
     ConcreteMaterial = concreteMtMaterial;
     _number          = _sNumber;
     _sNumber        += 1;
 }