/// <summary>
        /// Reads data for this dependency cache from disk
        /// </summary>
        private void Read()
        {
            try
            {
                using (BinaryArchiveReader Reader = new BinaryArchiveReader(Location))
                {
                    int Version = Reader.ReadInt();
                    if (Version != CurrentVersion)
                    {
                        Log.TraceLog("Unable to read dependency cache from {0}; version {1} vs current {2}", Location, Version, CurrentVersion);
                        return;
                    }

                    int Count = Reader.ReadInt();
                    for (int Idx = 0; Idx < Count; Idx++)
                    {
                        FileItem File = Reader.ReadFileItem();
                        DependencyFileToInfo[File] = DependencyInfo.Read(Reader);
                    }
                }
            }
            catch (Exception Ex)
            {
                Log.TraceWarning("Unable to read {0}. See log for additional information.", Location);
                Log.TraceLog("{0}", ExceptionUtils.FormatExceptionDetails(Ex));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor. Reads a makefile from disk.
 /// </summary>
 /// <param name="Reader">The archive to read from</param>
 public TargetMakefile(BinaryArchiveReader Reader)
 {
     CreateTimeUtc                = new DateTime(Reader.ReadLong(), DateTimeKind.Utc);
     ToolchainInfo                = Reader.ReadString();
     ExternalMetadata             = Reader.ReadString();
     ReceiptFile                  = Reader.ReadFileReference();
     ProjectIntermediateDirectory = Reader.ReadDirectoryReference();
     TargetType              = (TargetType)Reader.ReadInt();
     bDeployAfterCompile     = Reader.ReadBool();
     bHasProjectScriptPlugin = Reader.ReadBool();
     AdditionalArguments     = Reader.ReadArray(() => Reader.ReadString());
     PreBuildScripts         = Reader.ReadArray(() => Reader.ReadFileReference());
     Actions = Reader.ReadList(() => new Action(Reader));
     EnvironmentVariables    = Reader.ReadList(() => Tuple.Create(Reader.ReadString(), Reader.ReadString()));
     OutputItems             = Reader.ReadList(() => Reader.ReadFileItem());
     ModuleNameToOutputItems = Reader.ReadDictionary(() => Reader.ReadString(), () => Reader.ReadArray(() => Reader.ReadFileItem()), StringComparer.OrdinalIgnoreCase);
     HotReloadModuleNames    = Reader.ReadHashSet(() => Reader.ReadString(), StringComparer.OrdinalIgnoreCase);
     DirectoryToSourceFiles  = Reader.ReadDictionary(() => Reader.ReadDirectoryItem(), () => Reader.ReadArray(() => Reader.ReadFileItem()));
     WorkingSet = Reader.ReadHashSet(() => Reader.ReadFileItem());
     CandidatesForWorkingSet = Reader.ReadHashSet(() => Reader.ReadFileItem());
     UObjectModules          = Reader.ReadList(() => new UHTModuleInfo(Reader));
     UObjectModuleHeaders    = Reader.ReadList(() => new UHTModuleHeaderInfo(Reader));
     PluginFiles             = Reader.ReadHashSet(() => Reader.ReadFileItem());
     AdditionalDependencies  = Reader.ReadHashSet(() => Reader.ReadFileItem());
 }
Exemplo n.º 3
0
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool ReadDocument(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    int major, minor;
                    archive.Read3dmChunkVersion(out major, out minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        var count = archive.ReadInt();
                        for (var i = 0; i < count; i++)
                        {
                            var data = new SampleCsSimpleDocumentData();
                            if (data.Read(archive))
                            {
                                Add(data);
                            }
                        }
                        rc = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
        /// <summary>
        /// Read from binary archive
        /// </summary>
        public bool ReadDocument(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                try
                {
                    archive.Read3dmChunkVersion(out var major, out var minor);
                    if (major == MAJOR && minor == MINOR)
                    {
                        var count = archive.ReadInt();
                        for (var i = 0; i < count; i++)
                        {
                            var key  = archive.ReadString();
                            var data = new ModelEntity();
                            if (data.ReadArchive(archive))
                            {
                                this.Add(key, data);
                            }
                        }
                        rc = archive.ReadErrorOccured;
                    }
                }
                catch
                {
                    // ignored
                }
            }
            return(rc);
        }
        public bool Read(BinaryArchiveReader archive)
        {
            var rc = false;

            if (null != archive)
            {
                // Read and verify chunk version
                int major, minor;
                archive.Read3dmChunkVersion(out major, out minor);
                if (1 == major && 0 == minor)
                {
                    try
                    {
                        // Read this object
                        var bytes     = archive.ReadByteArray();
                        var stream    = new MemoryStream(bytes);
                        var formatter = new BinaryFormatter();
                        var data      = formatter.Deserialize(stream) as SampleCsCustomClass;
                        Create(data);

                        // Verify reading
                        rc = archive.ReadErrorOccured;
                    }
                    catch
                    {
                        // TODO
                    }
                }
            }
            return(rc);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 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.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (MAJOR == major && MINOR == minor)
            {
                // Always read user data even though you might not use it.

                var string_table = new SampleCsStringDocumentData();
                string_table.ReadDocument(archive);

                var simple_table = new SampleCsSimpleDocumentDataTable();
                simple_table.ReadDocument(archive);

                var dictionary = archive.ReadDictionary();

                if (!options.ImportMode && !options.ImportReferenceMode)
                {
                    if (string_table.Count > 0)
                    {
                        StringDocumentDataTable.AddRange(string_table.ToArray());
                    }

                    if (simple_table.Count > 0)
                    {
                        SimpleDocumentDataTable.AddRange(simple_table.ToArray());
                    }

                    if (null != dictionary && dictionary.Count > 0)
                    {
                        Dictionary = dictionary;
                    }
                }
            }
        }
            public static DependencyInfo Read(BinaryArchiveReader Reader)
            {
                long            LastWriteTimeUtc = Reader.ReadLong();
                List <FileItem> Files            = Reader.ReadList(() => Reader.ReadCompactFileItem());

                return(new DependencyInfo(LastWriteTimeUtc, Files));
            }
Exemplo n.º 8
0
 /// <summary>
 /// Construct a key from an archive
 /// </summary>
 /// <param name="Reader">Archive to read from</param>
 public ConfigDependencyKey(BinaryArchiveReader Reader)
 {
     Type        = (ConfigHierarchyType)Reader.ReadInt();
     ProjectDir  = Reader.ReadDirectoryReference();
     Platform    = Reader.ReadUnrealTargetPlatform();
     SectionName = Reader.ReadString();
     KeyName     = Reader.ReadString();
 }
Exemplo n.º 9
0
 protected override bool Read(BinaryArchiveReader archive)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (1 == major && 0 == minor)
     {
         Data.Read(archive);
     }
     return(!archive.ReadErrorOccured);
 }
 /// <summary>
 /// 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.
 /// </summary>
 protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (MAJOR == major && MINOR == minor)
     {
         SampleCsStringTable string_table = SampleCsStringTable.Instance;
         string_table.ReadDocument(doc, archive, options);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Read a file item as a DirectoryItem and name. This is slower than reading it directly, but results in a significantly smaller archive
        /// where most files are in the same directories.
        /// </summary>
        /// <param name="Reader">Archive to read from</param>
        /// <returns>FileItem read from the archive</returns>
        static FileItem ReadCompactFileItemData(this BinaryArchiveReader Reader)
        {
            DirectoryItem Directory = Reader.ReadDirectoryItem();
            string        Name      = Reader.ReadString();

            FileItem FileItem = FileItem.GetItemByFileReference(FileReference.Combine(Directory.Location, Name));

            FileItem.UpdateCachedDirectory(Directory);
            return(FileItem);
        }
Exemplo n.º 12
0
        //=========================== Select and highlight =================================

        //public bool SelectRoom() => SelectByIDs(new Guid[] { this.RoomID });

        //public bool SelectApertures() => SelectByIDs(this.ApertureIDs);

        //public bool SelectShades() => SelectByIDs(this.ShadeIDs);

        //public bool SelectEntireEntity()
        //{
        //    return this.SelectRoom() &&
        //        this.SelectApertures() &&
        //        this.SelectShades();
        //}

        //private bool SelectByIDs(IEnumerable<Guid> guids)
        //{
        //    var ids = guids;
        //    var rc = true;
        //    foreach (var item in ids)
        //    {
        //        //TODO: may need to check if object is visible or locked. deleted
        //        var obj = RhinoDoc.ActiveDoc.Objects.FindId(item);
        //        if (obj == null)
        //            continue;

        //        //Object might have been deleted
        //        if (this.RoomID == item)
        //        {

        //        }
        //        else if (!this.ApertureIDs.Any(_ => _ == item))
        //        {
        //            this.ApertureIDs.Remove(item);
        //        }

        //        if (obj.IsSelected(checkSubObjects: false) == 2)
        //        {
        //            //the entire object (including subobjects) is already selected
        //            //Do nothing
        //        }
        //        else
        //        {
        //            rc = rc && RhinoDoc.ActiveDoc.Objects.Select(item, true, true);
        //        }


        //    }
        //    return rc;
        //}

        //========================= Read/Write ===================================

        //public bool ShouldWrite => this.IsValid;


        public bool ReadArchive(BinaryArchiveReader archive)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (major == 1 && minor == 0)
            {
                //HBObject, orphaned objects
                var dic = archive.ReadDictionary();
                Deserialize(dic);
            }
            return(!archive.ReadErrorOccured);
        }
 /// <summary>
 /// Reads the content of this data from a stream archive.
 /// </summary>
 protected override bool Read(BinaryArchiveReader archive)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (1 == major && 0 == minor)
     {
         Plane      = archive.ReadPlane();
         ViewportId = archive.ReadGuid();
         Enabled    = archive.ReadBool();
     }
     return(!archive.ReadErrorOccured);
 }
 protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     RigidBodyManager.World = new World(new CollisionSystemSAP());
     Rhino.Collections.ArchivableDictionary dict = archive.ReadDictionary();
     RigidBodyManager.GuidList           = (List <Guid>)RigidBodyManager.ByteArrayToObject(dict["guidList"] as byte[]);
     RigidBodyManager.RigidBodies        = (List <RigidBody>)RigidBodyManager.ByteArrayToObject(dict["rigidBodies"] as byte[]);
     RigidBodyManager.GeometryList       = (List <Brep>)RigidBodyManager.ByteArrayToObject(dict["geometryList"] as byte[]);
     TimePanel.Instance.MaxFrameBoxValue = (int)dict["MaxFrameBoxValue"];
     //Reset
     TimePanel.Instance.ResetNotSavable();
     WorldCount = (int)dict["worldCount"];
 }
 /// <summary>
 /// Read from binary archive
 /// </summary>
 public void ReadDocument(BinaryArchiveReader archive)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (MAJOR == major && MINOR == minor)
     {
         var string_table = archive.ReadStringArray();
         if (null != string_table)
         {
             m_string_table.AddRange(string_table);
         }
     }
 }
Exemplo n.º 16
0
        private static int RestoreDocument(int serial, uint doc_serial, IntPtr pArchive)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc     = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                BinaryArchiveReader archive = new BinaryArchiveReader(pArchive);
                bool save_doc = client.RestoreDocument(doc, archive);
                return(save_doc ? 1 : 0);
            }
            return(0);
        }
Exemplo n.º 17
0
        private static void ExtendBoundingBoxForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                client.ExtendBoundingBoxForDocumentAnimation(doc, archive_start, archive_stop, ref bbox);
            }
        }
 /// <summary>
 /// 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.
 /// </summary>
 public void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
 {
     archive.Read3dmChunkVersion(out var major, out var minor);
     if (MAJOR == major && MINOR == minor)
     {
         // Always read user data even though you might not use it...
         var strings = archive.ReadStringArray();
         if (null != strings && !options.ImportMode && !options.ImportReferenceMode)
         {
             m_strings.AddRange(strings);
         }
     }
 }
Exemplo n.º 19
0
        private static void ExtendBoundingBoxForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                Rhino.DocObjects.RhinoObject obj           = new DocObjects.RhinoObject(obj_serial);
                BinaryArchiveReader          archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader          archive_stop  = new BinaryArchiveReader(pArchive_stop);

                client.ExtendBoundingBoxForObjectAnimation(doc, obj, ref transform, archive_start, archive_stop, ref bbox);
            }
        }
Exemplo n.º 20
0
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            int major, minor;

            archive.Read3dmChunkVersion(out major, out minor);
            byte[] data = archive.ReadByteArray();
            if (!archive.ReadErrorOccured && data != null)
            {
                Host.EnsureInitialisation(true);
                ModelDocument mDoc = Document.FromBinary <ModelDocument>(data);
                Core.Instance.ActiveDocument = mDoc;
            }
            base.ReadDocument(doc, archive, options);
        }
Exemplo n.º 21
0
        private static int RestoreObject(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc                     doc     = RhinoDoc.FromRuntimeSerialNumber(doc_serial);
                BinaryArchiveReader          archive = new BinaryArchiveReader(pArchive);
                Rhino.DocObjects.RhinoObject obj     = new DocObjects.RhinoObject(obj_serial);

                bool save_doc = client.RestoreObject(doc, obj, ref transform, archive);
                return(save_doc ? 1 : 0);
            }
            return(0);
        }
Exemplo n.º 22
0
        private static int PrepareForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool prep_doc = client.PrepareForDocumentAnimation(doc, archive_start, archive_stop);
                return(prep_doc? 1 : 0);
            }
            return(0);
        }
Exemplo n.º 23
0
        private static int AnimateDocument(int serial, uint pDoc_serial, double dPos, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc            doc           = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                BinaryArchiveReader archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool animate_doc = client.AnimateDocument(doc, dPos, archive_start, archive_stop);
                return(animate_doc ? 1 : 0);
            }
            return(0);
        }
Exemplo n.º 24
0
        protected override bool Read(BinaryArchiveReader archive)
        {
            // read archivable dict from archive
            var dict = archive.ReadDictionary();

            // test keys
            if (dict.ContainsKey("Width") && dict.ContainsKey("Height"))
            {
                // set properties from dict
                Plane  = dict.GetPlane("Plane");
                Width  = dict.GetDouble("Width");
                Height = dict.GetDouble("Height");
            }

            return(!archive.ReadErrorOccured);
        }
Exemplo n.º 25
0
        private static int PrepareForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop)
        {
            var client = FromSerialNumber(serial);

            if (client != null)
            {
                RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(pDoc_serial);
                Rhino.DocObjects.RhinoObject obj           = new DocObjects.RhinoObject(obj_serial);
                BinaryArchiveReader          archive_start = new BinaryArchiveReader(pArchive_start);
                BinaryArchiveReader          archive_stop  = new BinaryArchiveReader(pArchive_stop);

                bool animate_doc = client.PrepareForObjectAnimation(doc, obj, ref transform, archive_start, archive_stop);
                return(animate_doc ? 1 : 0);
            }
            return(0);
        }
        /// <inheritdoc />
        /// <summary>
        /// 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.
        /// </summary>
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (MAJOR == major && MINOR == minor)
            {
                var dictionary = archive.ReadDictionary();
                if (null != dictionary && !options.ImportMode && !options.ImportReferenceMode)
                {
                    m_dictionary = dictionary.Clone();

                    // Note, if we read our user data from a document, then
                    // assume that we can to track commands...
                    CommandTrackingEnabled = true;
                }
            }
        }
        protected override void ReadDocument(RhinoDoc doc, BinaryArchiveReader archive, FileReadOptions options)
        {
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (major == 1 && minor == 0)
            {
                var t = new ModelEntityTable();
                t.ReadDocument(archive);

                if (!options.ImportMode && !options.ImportReferenceMode)
                {
                    if (t.Count > 0)
                    {
                        this.ModelEntityTable = t;
                    }
                }
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Construct a TargetInfo from an archive on disk
        /// </summary>
        /// <param name="Reader">Archive to read from</param>
        public TargetInfo(BinaryArchiveReader Reader)
        {
            this.Name     = Reader.ReadString();
            this.Platform = UnrealTargetPlatform.Parse(Reader.ReadString());
            string ConfigurationStr = Reader.ReadString();

            this.Architecture = Reader.ReadString();
            this.ProjectFile  = Reader.ReadFileReference();
            string[] ArgumentStrs = Reader.ReadArray(() => Reader.ReadString());

            if (!UnrealTargetConfiguration.TryParse(ConfigurationStr, out Configuration))
            {
                throw new BuildException(string.Format("The configration name {0} is not a valid configration name. Valid names are ({1})", Name,
                                                       string.Join(",", Enum.GetValues(typeof(UnrealTargetConfiguration)).Cast <UnrealTargetConfiguration>().Select(x => x.ToString()))));
            }

            Arguments = new CommandLineArguments(ArgumentStrs);
        }
        /// <summary>
        /// Reads the content of this data from a stream archive.
        /// </summary>
        protected override bool Read(BinaryArchiveReader archive)
        {
            // Read the chuck version
            archive.Read3dmChunkVersion(out var major, out var minor);
            if (major == MAJOR_VERSION)
            {
                // Read 1.0 fields  here
                if (minor >= MINOR_VERSION)
                {
                    Notes = archive.ReadString();
                }

                // Note, if you every roll the minor version number,
                // then read those fields here.
            }

            return(!archive.ReadErrorOccured);
        }
        /// <summary>
        /// Reads data for this dependency cache from disk
        /// </summary>
        private void Read()
        {
            try
            {
                using (BinaryArchiveReader Reader = new BinaryArchiveReader(Location))
                {
                    int Version = Reader.ReadInt();
                    if (Version != CurrentVersion)
                    {
                        Log.TraceLog("Unable to read dependency cache from {0}; version {1} vs current {2}", Location, Version, CurrentVersion);
                        return;
                    }

                    int FileToFirstIncludeCount = Reader.ReadInt();
                    for (int Idx = 0; Idx < FileToFirstIncludeCount; Idx++)
                    {
                        FileItem File = Reader.ReadCompactFileItem();

                        IncludeInfo IncludeInfo = new IncludeInfo();
                        IncludeInfo.LastWriteTimeUtc = Reader.ReadLong();
                        IncludeInfo.IncludeText      = Reader.ReadString();

                        FileToIncludeInfo[File] = IncludeInfo;
                    }

                    int FileToMarkupFlagCount = Reader.ReadInt();
                    for (int Idx = 0; Idx < FileToMarkupFlagCount; Idx++)
                    {
                        FileItem File = Reader.ReadCompactFileItem();

                        ReflectionInfo ReflectionInfo = new ReflectionInfo();
                        ReflectionInfo.LastWriteTimeUtc = Reader.ReadLong();
                        ReflectionInfo.bContainsMarkup  = Reader.ReadBool();

                        FileToReflectionInfo[File] = ReflectionInfo;
                    }
                }
            }
            catch (Exception Ex)
            {
                Log.TraceWarning("Unable to read {0}. See log for additional information.", Location);
                Log.TraceLog("{0}", ExceptionUtils.FormatExceptionDetails(Ex));
            }
        }