Beispiel #1
0
        internal void Commit()
        {
            string data = ObjectSerializer.Serialize(this);

            FileInterface.WriteString(currentPath + Path.DirectorySeparatorChar + CONFIGURATIONS_FILE, data);
        }
Beispiel #2
0
        private void loadTerrainOutputs()
        {
            terrainOutputs = new Dictionary <TerrainPipelineLayer, List <TerrainOutput> >(new TerrainPipelineLayerComparator());
            foreach (TerrainPlugin terrainPlugin in TerrainPipeline)
            {
                if (terrainPlugin != null)
                {
                    TerrainPipelineLayer pipelineLayer = new TerrainPipelineLayer();
                    TerrainPluginInfo    pluginInfo    = new TerrainPluginInfo(terrainPlugin);
                    pipelineLayer.PluginId  = pluginInfo.Id;
                    pipelineLayer.LayerCode = TerrainPipelineLayer.ToPipelineLayerCode(terrainPlugin.Out, terrainPlugin.In, terrainPlugin.Not);

                    string filename = Path + OUTPUT_SUBDIRECTORY + pipelineLayer.LayerCode + "_" + pipelineLayer.PluginId + ".tou";

                    string inputData = FileInterface.ReadString(filename);
                    if (inputData != null)
                    {
                        List <TerrainOutput> terrainOutputsList = (List <TerrainOutput>)ObjectSerializer.DeSerialize(inputData, typeof(List <TerrainOutput>));
                        if (terrainOutputsList != null)
                        {
                            terrainOutputs.Add(pipelineLayer, terrainOutputsList);
                        }
                    }
                }
            }

            cleanUnusedOutputs();
        }
Beispiel #3
0
        private List <TerrainInput> loadTerrainInputs(TerrainPipelineLayer terrainPipelineLayer, List <TerrainInput> terrainInputs)
        {
            string inputData = FileInterface.ReadString(Path + INPUT_SUBDIRECTORY + terrainPipelineLayer.LayerCode + "_" + terrainPipelineLayer.PluginId + ".tin");

            if (inputData != null)
            {
                try
                {
                    List <TerrainInput> allTerrainInputs = new List <TerrainInput>();
                    mergeInnerTerrainInputs(allTerrainInputs, terrainInputs);
                    List <TerrainInputValue> terrainInputValues = (List <TerrainInputValue>)ObjectSerializer.DeSerialize(inputData, typeof(List <TerrainInputValue>));

                    int i = 0;
                    foreach (TerrainInput terrainInput in allTerrainInputs)
                    {
                        switch (terrainInput.Type)
                        {
                        case InputType.Form:
                        case InputType.Sketch:
                            terrainInputValues[i].FillValue(terrainInput);
                            i++;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Saved input data does not match: " + ex.Message);
                }
            }

            return(terrainInputs);
        }
Beispiel #4
0
        private void saveTerrainOutputs()
        {
            HashSet <string> createdFiles = new HashSet <string>();

            Console.WriteLine("Will save terrain output");
            if (!FileInterface.DoesFolderExists(Path + OUTPUT_SUBDIRECTORY))
            {
                FileInterface.CreateFolder(Path + OUTPUT_SUBDIRECTORY);
            }

            foreach (TerrainPipelineLayer terrainPipelineLayer in TerrainOutputs.Keys)
            {
                List <TerrainOutput> allTerrainOutputs = new List <TerrainOutput>();
                mergeInnerTerrainOutputs(allTerrainOutputs, TerrainOutputs[terrainPipelineLayer]);

                int i = 0;
                foreach (TerrainOutput terrainOutput in allTerrainOutputs)
                {
                    switch (terrainOutput.Type)
                    {
                    case OutputType.Mesh:
                        Console.WriteLine("Will save terrain output");
                        if (((TerrainOutputMesh)terrainOutput).MeshPath == null || ((TerrainOutputMesh)terrainOutput).MeshPath.Count == 0)
                        {
                            FileInterface.SaveMeshFile(Path + OUTPUT_SUBDIRECTORY + (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + "_" + i + ".obj", (TerrainOutputMesh)terrainOutput);
                        }
                        break;

                    case OutputType.Image:
                        if (((TerrainOutputImage)terrainOutput).ImagePath == null || ((TerrainOutputImage)terrainOutput).ImagePath.Length == 0)
                        {
                            FileInterface.SaveImageFile(Path + OUTPUT_SUBDIRECTORY + (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds + "_" + i + ".bmp", (TerrainOutputImage)terrainOutput);
                        }
                        break;
                    }

                    i++;
                }

                if (TerrainOutputs[terrainPipelineLayer].Count > 0)
                {
                    Console.WriteLine("Saving terrain output");
                    string outputData = ObjectSerializer.Serialize(TerrainOutputs[terrainPipelineLayer]);
                    FileInterface.WriteString(Path + OUTPUT_SUBDIRECTORY + terrainPipelineLayer.LayerCode + "_" + terrainPipelineLayer.PluginId + ".tou", outputData);
                    createdFiles.Add(Path + OUTPUT_SUBDIRECTORY + terrainPipelineLayer.LayerCode + "_" + terrainPipelineLayer.PluginId + ".tou");
                }
            }

            if (FileInterface.DoesFolderExists(Path + OUTPUT_SUBDIRECTORY))
            {
                string[] files = FileInterface.GetChildFiles(Path + OUTPUT_SUBDIRECTORY);

                foreach (string file in files)
                {
                    if (file.EndsWith(".tou"))
                    {
                        if (!createdFiles.Contains(file))
                        {
                            FileInterface.DeleteFile(file);
                        }
                    }
                }
            }
        }
Beispiel #5
0
        private void saveInfo()
        {
            string infoFileContent = ObjectSerializer.Serialize(Info);

            FileInterface.WriteString(Path + System.IO.Path.DirectorySeparatorChar + PROJECT_INFO_FILE, infoFileContent);
        }