protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            Beam ownerBeam = ProjectPlugIn.Instance.Beams.Find(o => o.Id == dict.GetInteger("BeamId"));

            BaseBrep = (Brep)dict["baseBrep"];

            int noBaseCurves = dict.GetInteger("NoBaseCurves");

            for (int i = 0; i < noBaseCurves; i++)
            {
                BaseCurves.Add((Curve)dict["BaseCurve" + i]);
            }


            Id = (int)dict["Id"];
            if ((string)dict["Material"] == "Concrete")
            {
                Material = new ConcreteMaterial((string)dict["MaterialStrength"], ownerBeam);
            }
            else if ((string)dict["Material"] == "Steel")
            {
                Material = new SteelMaterial((string)dict["MaterialName"], SteelType.StructuralSteel, ownerBeam);
            }
            //TODO Add extra materials
            else
            {
                Material = new ConcreteMaterial("C30/37", ownerBeam);
            }

            return(true);
        }
        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);
        }
Ejemplo n.º 3
0
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            object ho = base.ReadHotLoadData(dict);

            if (dict.ContainsKey("alpha"))
            {
                alpha = (int)dict["alpha"];
            }
            if (dict.ContainsKey("beta"))
            {
                beta = (double)dict["beta"];
            }
            if (dict.ContainsKey("classA"))
            {
                classA = JsonConvert.DeserializeObject <TestClassA>(dict.GetString("classA"));
            }
            if (dict.ContainsKey("classB"))
            {
                classB = JsonConvert.DeserializeObject <TestClassB>(dict.GetString("classB"));
            }
            if (dict.ContainsKey("classC"))
            {
                classC = JsonConvert.DeserializeObject <TestClassC>(dict.GetString("classC"));
            }
            //if (dict.ContainsKey("classD")) classD = JsonConvert.DeserializeObject<TestClassD>(dict.GetString("classD"));
            if (dict.ContainsKey("classE"))
            {
                classE = JsonConvert.DeserializeObject <TestClassE>(dict.GetString("classE"));
            }
            return(true);
        }
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            object ho = base.ReadHotLoadData(dict);

            return(true);
        }
Ejemplo n.º 5
0
            //Called whenever a Rhino document is being loaded and plug-in user data was
            //encountered written by a plug-in with this plug-in's GUID.
            //
            //If any ON_BinaryArchive::Read*() functions return false than you should
            //immediately return false otherwise return true when all data was read.
            protected override void ReadDocument(Rhino.RhinoDoc doc, Rhino.FileIO.BinaryArchiveReader archive, Rhino.FileIO.FileReadOptions options)
            {
                //Always read data in the EXACT same order you wrote it
                int major, minor;

                archive.Read3dmChunkVersion(out major, out minor);

                //If you've changed your reading/writing code over time,
                //you can use the version number of what you read
                //to figure out what can be read from the archive
                if ((major > 1 | minor > 0))
                {
                    return;
                }

                //the data you read/write will probably be member variables of your plug-in class,
                //but for simplicity this sample is just using locally defined strings
                string date_string = archive.ReadString();
                string time_string = archive.ReadString();

                //Get the commands for "Insert_Source" and "Insert_Receiver". This is where the Source and Receiver conduits are stored.
                UI.Pach_Source_Object   S_command = Pach_Source_Object.Instance;
                UI.Pach_Receiver_Object R_command = Pach_Receiver_Object.Instance;

                System.Guid objectId = default(System.Guid);
                string      Type     = null;

                do
                {
                    try
                    {
                        objectId = archive.ReadGuid();
                        Type     = archive.ReadString();
                        if (Type == "Source")
                        {
                            Rhino.DocObjects.RhinoObject Source = doc.Objects.Find(objectId);
                            if (Source != null)
                            {
                                SourceConduit.Instance.SetSource(Source);
                                doc.Views.Redraw();
                            }
                        }
                        else if (Type == "Receiver")
                        {
                            Rhino.DocObjects.RhinoObject Receiver = doc.Objects.Find(objectId);
                            if (Receiver != null)
                            {
                                ReceiverConduit.Instance.SetReceiver(Receiver);
                                doc.Views.Redraw();
                            }
                        }
                        Type = null;
                    }catch (Exception)
                    {
                        break;
                    }
                }while (objectId != null);
            }
Ejemplo n.º 6
0
 protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
 {
     Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
     if (dict.ContainsKey("IntegerData") && dict.ContainsKey("StringData"))
     {
         IntegerData = (int)dict["IntegerData"];
         StringData  = dict["StringData"] as String;
     }
     return(true);
 }
Ejemplo n.º 7
0
 protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (major == 1 && minor == 0)
     {
         var dic = archive.ReadDictionary();
         Deserialize(dic);
     }
     return(!archive.ReadErrorOccured);
 }
Ejemplo n.º 8
0
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            if (1 == major && 0 == minor)
            {
                Notes = archive.ReadString();
            }
            return(!archive.ReadErrorOccured);
        }
        protected override bool Read(Rhino.FileIO.BinaryArchiveReader archive)
        {
            Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
            BasePoint = (Point3d)dict["Point"];
            OutLine   = (Curve)dict["OutLine"];
            Diameter  = (int)dict["Diameter"];

            double fyk = (double)dict["MaterialStrength"];

            //TODO add a coorect material assignment
            Material = new SteelMaterial((string)dict["MaterialName"]);

            return(true);
        }
Ejemplo n.º 10
0
 private static int InternalReadDocument(int plugin_serial_number, int doc_id, IntPtr pBinaryArchive, IntPtr pReadOptions)
 {
   int rc = 1; //TRUE
   PlugIn p = LookUpBySerialNumber(plugin_serial_number);
   RhinoDoc doc = RhinoDoc.FromId(doc_id);
   if (p != null && doc != null && pBinaryArchive != IntPtr.Zero && pReadOptions != IntPtr.Zero)
   {
     Rhino.FileIO.BinaryArchiveReader reader = new Rhino.FileIO.BinaryArchiveReader(pBinaryArchive);
     Rhino.FileIO.FileReadOptions ro = new Rhino.FileIO.FileReadOptions(pReadOptions);
     try
     {
       p.ReadDocument(doc, reader, ro);
       rc = reader.ReadErrorOccured ? 0 : 1;
     }
     catch (Exception ex)
     {
       HostUtils.ExceptionReport(ex);
       rc = 0; //FALSE
     }
     // in case someone tries to hold on to instances of these classes
     reader.ClearPointer();
     ro.Dispose();
   }
   return rc;
 }
Ejemplo n.º 11
0
 protected override void ReadDocument(RhinoDoc doc, Rhino.FileIO.BinaryArchiveReader archive, Rhino.FileIO.FileReadOptions options)
 {
     m_dict = archive.ReadDictionary();
 }
Ejemplo n.º 12
0
 /// <summary>Reads the content of this data from a stream archive.</summary>
 /// <param name="archive">An archive.</param>
 /// <returns>true if the data was successfully written. The default implementation always returns false.</returns>
 protected virtual bool Read(Rhino.FileIO.BinaryArchiveReader archive)
 {
     return(false);
 }