Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
0
        private void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            Console.Out.WriteLine("Working 1");
            Dictionary <TerrainPlugin, TerrainPipelineLayer> pluginsToProcess = new Dictionary <TerrainPlugin, TerrainPipelineLayer>();

            Dictionary <TerrainPipelineLayer, TerrainPlugin> terrainPluginMap = terrainProject.PipelinePluginMap;

            Console.Out.WriteLine("Working 1.5");
            foreach (TerrainPipelineLayer terrainPipelieLayer in pipelineLayersToProcess)
            {
                pluginsToProcess.Add(terrainPluginMap[terrainPipelieLayer], terrainPipelieLayer);
            }
            Console.Out.WriteLine("Working 2");
            List <TerrainOutput> previousTerrainOutputs = new List <TerrainOutput>();
            bool somethingProcessed = false;

            foreach (TerrainPlugin terrainPlugin in terrainProject.TerrainPipeline)
            {
                Console.Out.WriteLine("Working 3");
                if (terrainPlugin != null)
                {
                    Console.Out.WriteLine("Working 4");
                    if (pluginsToProcess.ContainsKey(terrainPlugin))
                    {
                        Console.Out.WriteLine("Working 5");
                        List <TerrainOutput> newTerrainOutputs = terrainPlugin.StartProcess(terrainProject.TerrainInputs[pluginsToProcess[terrainPlugin]], terrainProject.WorkflowData);
                        somethingProcessed     = true;
                        previousTerrainOutputs = newTerrainOutputs;
                        Console.Out.WriteLine("Working 6");
                        try
                        {
                            if (terrainProject.TerrainOutputs.ContainsKey(pluginsToProcess[terrainPlugin]))
                            {
                                terrainProject.TerrainOutputs[pluginsToProcess[terrainPlugin]] = newTerrainOutputs;
                            }
                            else
                            {
                                terrainProject.TerrainOutputs.Add(pluginsToProcess[terrainPlugin], newTerrainOutputs);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                    else
                    {
                        TerrainPipelineLayer terrainPipelineLayer = new TerrainPipelineLayer();
                        terrainPipelineLayer.LayerCode = TerrainPipelineLayer.ToPipelineLayerCode(terrainPlugin.Out, terrainPlugin.In, terrainPlugin.Not);

                        if (terrainProject.TerrainOutputs.ContainsKey(terrainPipelineLayer))
                        {
                            if (somethingProcessed)
                            {
                                previousTerrainOutputs = new List <TerrainOutput>();
                                terrainProject.TerrainOutputs[terrainPipelineLayer] = new List <TerrainOutput>();
                            }
                            else
                            {
                                previousTerrainOutputs = terrainProject.TerrainOutputs[terrainPipelineLayer];
                            }
                        }
                    }
                }
            }
            Console.Out.WriteLine("Saving");
            terrainProject.Save();

            Console.Out.WriteLine("Working End");
        }