Inheritance: GridViewModel
        private SceneObject[] GetWellObjects(SimulationInputData inputData, CatesianGrid grid, string fileName)
        {
            var result = new List <SceneObject>();

            List <CSharpGL.Tuple <WellRenderer, LabelRenderer> > wellList = this.CreateWellList(inputData, grid);

            if (wellList == null)
            {
                return(result.ToArray());
            }
            //this.AddWellNodes(gridderNode, this.scene, well3dList);
            foreach (var item in wellList)
            {
                item.Item1.Initialize();
                SceneObject wellObj = item.Item1.WrapToSceneObject(new ModelScaleScript());
                {
                    BoundingBoxRenderer boxRenderer = item.Item1.GetBoundingBoxRenderer();
                    SceneObject         boxObj      = boxRenderer.WrapToSceneObject(new ModelScaleScript());
                    wellObj.Children.Add(boxObj);
                }
                result.Add(wellObj);
                {
                    SceneObject labelObj = item.Item2.WrapToSceneObject(
                        new ModelScaleScript(),
                        new LabelTargetScript(item.Item1));
                    wellObj.Children.Add(labelObj);
                }
            }

            return(result.ToArray());
        }
        public static CatesianGrid DumpCatesianGrid(this SimulationInputData inputData,
            float minColorCode, float maxColorCode)
        {
            GridDimens dimens = inputData.RootDataFile.GetDIMENS();
            if (dimens == null)
            { throw new ArgumentException("Missing DIMENS or SPECGRID"); }
            float[] dx = inputData.RootDataFile.GetDX();
            if (dx == null)
            { throw new ArgumentException("Missing DX or related description"); }
            float[] dy = inputData.RootDataFile.GetDY();
            if (dy == null)
            { throw new ArgumentException("Missing DY or related description"); }
            float[] dz = inputData.RootDataFile.GetDZ();
            if (dy == null)
            { throw new ArgumentException("Missing DZ or related description"); }

            var dataSource = new CatesianGridderSource();
            dataSource.NX = dimens.NI;
            dataSource.NY = dimens.NJ;
            dataSource.NZ = dimens.NK;
            dataSource.DX = dx;
            dataSource.DY = dy;
            dataSource.DZ = dz;
            dataSource.TOPS = inputData.RootDataFile.GetTOPS();
            dataSource.ActiveBlocks = inputData.RootDataFile.GetACTNUM();
            dataSource.IBlocks = SimLab.ArrayHelper.CreateAllSlices(dimens.NI);
            dataSource.JBlocks = SimLab.ArrayHelper.CreateAllSlices(dimens.NJ);
            dataSource.KBlocks = SimLab.ArrayHelper.CreateAllSlices(dimens.NK);
            dataSource.Init();
            List<GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties();
            var grid = new CatesianGrid(dataSource, gridProps, minColorCode, maxColorCode);

            return grid;
        }
        private SceneObject GetCatesianGridObj(CatesianGrid grid, List <GridBlockProperty> gridProperties, string fileName)
        {
            CatesianGridRenderer renderer = CatesianGridRenderer.Create(
                -grid.DataSource.Position, grid, this.scientificCanvas.ColorPalette.Sampler);

            //string caseFileName = System.IO.Path.GetFileName(fileName);
            renderer.WorldPosition = -grid.DataSource.Position;
            renderer.Initialize();
            SceneObject gridObj = renderer.WrapToSceneObject(
                new ModelScaleScript(),
                new DumpCatesianGridTreeNodeScript());

            {
                BoundingBoxRenderer boxRenderer = renderer.GetBoundingBoxRenderer();
                SceneObject         boxObj      = boxRenderer.WrapToSceneObject(
                    new ModelScaleScript());
                gridObj.Children.Add(boxObj);
            }

            foreach (GridBlockProperty gbp in gridProperties)
            {
                var script = new ScientificModelScript(gridObj, gbp, this.scientificCanvas.ColorPalette);
                gridObj.Scripts.Add(script);
            }
            return(gridObj);
        }
        private SceneObject[] GetWellObjects(SimulationInputData inputData, CatesianGrid grid, string fileName)
        {
            var result = new List<SceneObject>();

            List<CSharpGL.Tuple<WellRenderer, LabelRenderer>> wellList = this.CreateWellList(inputData, grid);
            if (wellList == null) { return result.ToArray(); }
            //this.AddWellNodes(gridderNode, this.scene, well3dList);
            foreach (var item in wellList)
            {
                item.Item1.Initialize();
                SceneObject wellObj = item.Item1.WrapToSceneObject(new ModelScaleScript());
                {
                    BoundingBoxRenderer boxRenderer = item.Item1.GetBoundingBoxRenderer();
                    SceneObject boxObj = boxRenderer.WrapToSceneObject(new ModelScaleScript());
                    wellObj.Children.Add(boxObj);
                }
                result.Add(wellObj);
                {
                    SceneObject labelObj = item.Item2.WrapToSceneObject(
                        new ModelScaleScript(),
                        new LabelTargetScript(item.Item1));
                    wellObj.Children.Add(labelObj);
                }
            }

            return result.ToArray();
        }
        private void UpdateCatesianGrid(CatesianGrid grid, GridBlockProperty property)
        {
            double axisMin, axisMax, step;

            ColorIndicatorAxisAutomator.Automate(property.MinValue, property.MaxValue, out axisMin, out axisMax, out step);
            grid.MinColorCode = (float)axisMin;
            grid.MaxColorCode = (float)axisMax;
            grid.UpdateColor(property);
            this.scientificCanvas.ColorPalette.SetCodedColor(axisMin, axisMax, step);
        }
 private List<CSharpGL.Tuple<WellRenderer, LabelRenderer>> CreateWellList(SimulationInputData inputData, CatesianGrid grid)
 {
     WellSpecsCollection wellSpecsList = inputData.RootDataFile.GetWELSPECS();
     WellCompatCollection wellCompatList = inputData.RootDataFile.GetCOMPDAT();
     if (wellSpecsList == null || wellSpecsList.Count <= 0)
     {
         throw new ArgumentException("not found WELLSPECS info for the well");
     }
     // rename Well3DHelper to WellPipelineBuilder.
     WellPipelineBuilder well3DHelper = new HexahedronGridWellPipelineBuilder(grid);
     return well3DHelper.Convert(-grid.DataSource.Position, wellSpecsList, wellCompatList);
 }
 public static CatesianGridRenderer Create(vec3 originalWorldPosition, CatesianGrid grid, Texture codedColorSampler)
 {
     var shaderCodes = new ShaderCode[2];
     shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader);
     shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader);
     var map = new AttributeMap();
     map.Add("in_Position", CatesianGrid.strPosition);
     map.Add("in_uv", CatesianGrid.strColor);
     var renderer = new CatesianGridRenderer(originalWorldPosition, grid, shaderCodes, map, codedColorSampler);
     renderer.ModelSize = (grid.DataSource.SourceActiveBounds.MaxPosition - grid.DataSource.SourceActiveBounds.MinPosition).Abs();
     renderer.WorldPosition = -grid.DataSource.Position;
     return renderer;
 }
        public static CatesianGridRenderer Create(vec3 originalWorldPosition, CatesianGrid grid, Texture codedColorSampler)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader);
            var map = new PropertyNameMap();

            map.Add("in_Position", CatesianGrid.strPosition);
            map.Add("in_uv", CatesianGrid.strColor);
            var renderer = new CatesianGridRenderer(originalWorldPosition, grid, shaderCodes, map, codedColorSampler);

            renderer.lengths     = grid.DataSource.SourceActiveBounds.Max - grid.DataSource.SourceActiveBounds.Min;
            renderer.ModelMatrix = glm.translate(mat4.identity(), -grid.DataSource.Position);
            return(renderer);
        }
        public static CatesianGridRenderer Create(vec3 originalWorldPosition, CatesianGrid grid, Texture codedColorSampler)
        {
            var shaderCodes = new ShaderCode[2];

            shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.vert"), ShaderType.VertexShader);
            shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\HexahedronGrid.frag"), ShaderType.FragmentShader);
            var map = new AttributeMap();

            map.Add("in_Position", CatesianGrid.strPosition);
            map.Add("in_uv", CatesianGrid.strColor);
            var renderer = new CatesianGridRenderer(originalWorldPosition, grid, shaderCodes, map, codedColorSampler);

            renderer.ModelSize     = (grid.DataSource.SourceActiveBounds.MaxPosition - grid.DataSource.SourceActiveBounds.MinPosition).Abs();
            renderer.WorldPosition = -grid.DataSource.Position;
            return(renderer);
        }
        public static CatesianGrid DumpCatesianGrid(this SimulationInputData inputData,
                                                    float minColorCode, float maxColorCode)
        {
            GridDimens dimens = inputData.RootDataFile.GetDIMENS();

            if (dimens == null)
            {
                throw new ArgumentException("Missing DIMENS or SPECGRID");
            }
            float[] dx = inputData.RootDataFile.GetDX();
            if (dx == null)
            {
                throw new ArgumentException("Missing DX or related description");
            }
            float[] dy = inputData.RootDataFile.GetDY();
            if (dy == null)
            {
                throw new ArgumentException("Missing DY or related description");
            }
            float[] dz = inputData.RootDataFile.GetDZ();
            if (dy == null)
            {
                throw new ArgumentException("Missing DZ or related description");
            }

            var dataSource = new CatesianGridderSource();

            dataSource.NX           = dimens.NI;
            dataSource.NY           = dimens.NJ;
            dataSource.NZ           = dimens.NK;
            dataSource.DX           = dx;
            dataSource.DY           = dy;
            dataSource.DZ           = dz;
            dataSource.TOPS         = inputData.RootDataFile.GetTOPS();
            dataSource.ActiveBlocks = inputData.RootDataFile.GetACTNUM();
            dataSource.IBlocks      = SimLab.ArrayHelper.CreateAllSlices(dimens.NI);
            dataSource.JBlocks      = SimLab.ArrayHelper.CreateAllSlices(dimens.NJ);
            dataSource.KBlocks      = SimLab.ArrayHelper.CreateAllSlices(dimens.NK);
            dataSource.Init();
            List <GridBlockProperty> gridProps = inputData.RootDataFile.GetGridProperties();
            var grid = new CatesianGrid(dataSource, gridProps, minColorCode, maxColorCode);

            return(grid);
        }
        private SceneObject GetCatesianGridObj(CatesianGrid grid, List<GridBlockProperty> gridProperties, string fileName)
        {
            CatesianGridRenderer renderer = CatesianGridRenderer.Create(
                -grid.DataSource.Position, grid, this.scientificCanvas.ColorPalette.Sampler);
            //string caseFileName = System.IO.Path.GetFileName(fileName);
            renderer.WorldPosition = -grid.DataSource.Position;
            renderer.Initialize();
            SceneObject gridObj = renderer.WrapToSceneObject(
                new ModelScaleScript(),
                new DumpCatesianGridTreeNodeScript());
            {
                BoundingBoxRenderer boxRenderer = renderer.GetBoundingBoxRenderer();
                SceneObject boxObj = boxRenderer.WrapToSceneObject(
                    new ModelScaleScript());
                gridObj.Children.Add(boxObj);
            }

            foreach (GridBlockProperty gbp in gridProperties)
            {
                var script = new ScientificModelScript(gridObj, gbp, this.scientificCanvas.ColorPalette);
                gridObj.Scripts.Add(script);
            }
            return gridObj;
        }
Example #12
0
        private List <CSharpGL.Tuple <WellRenderer, LabelRenderer> > CreateWellList(SimulationInputData inputData, CatesianGrid grid)
        {
            WellSpecsCollection  wellSpecsList  = inputData.RootDataFile.GetWELSPECS();
            WellCompatCollection wellCompatList = inputData.RootDataFile.GetCOMPDAT();

            if (wellSpecsList == null || wellSpecsList.Count <= 0)
            {
                throw new ArgumentException("not found WELLSPECS info for the well");
            }
            // rename Well3DHelper to WellPipelineBuilder.
            WellPipelineBuilder well3DHelper = new HexahedronGridWellPipelineBuilder(grid);

            return(well3DHelper.Convert(-grid.DataSource.Position, wellSpecsList, wellCompatList));
        }
 public HexahedronGridWellPipelineBuilder(CatesianGrid grid)
 {
     // TODO: Complete member initialization
     this.grid = grid;
 }
Example #14
0
        private void mniLoadECLGrid_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            //ModelContainer modelContainer = this.ModelContainer;

            string fileName = openFileDialog1.FileName;
            SimulationInputData inputData;

            try
            {
                inputData = this.LoadEclInputData(fileName);
            }
            catch (Exception err)
            {
                MessageBox.Show(String.Format("Load Error,{0}", err.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                List <GridBlockProperty> gridProperties = inputData.RootDataFile.GetGridProperties();
                GridBlockProperty        firstProperty = gridProperties[0];
                double axisMin, axisMax, step;
                ColorIndicatorAxisAutomator.Automate(firstProperty.MinValue, firstProperty.MaxValue, out axisMin, out axisMax, out step);
                CatesianGrid grid = inputData.DumpCatesianGrid((float)axisMin, (float)axisMax);

                SceneObject   gridObj = GetCatesianGridObj(grid, gridProperties, fileName);
                SceneObject[] wellObjects = GetWellObjects(inputData, grid, fileName);
                var           list = new List <IModelSpace>();
                list.Add(gridObj.Renderer);
                list.AddRange(from item in wellObjects select item.Renderer);
                BoundingBoxRenderer boxRenderer = list.GetBoundingBoxRenderer();
                SceneObject         mainObj     = boxRenderer.WrapToSceneObject(
                    string.Format("CatesianGrid: {0}", fileName),
                    new ModelScaleScript());
                mainObj.Children.Add(gridObj);
                mainObj.Children.AddRange(wellObjects);

                this.scientificCanvas.Scene.RootObject.Children.Add(mainObj);
                this.scientificCanvas.Scene.FirstCamera.ZoomCamera(boxRenderer.GetBoundingBox());

                vec3 back = this.scientificCanvas.Scene.FirstCamera.GetBack();
                this.scientificCanvas.Scene.FirstCamera.Target   = -grid.DataSource.Position;
                this.scientificCanvas.Scene.FirstCamera.Position = this.scientificCanvas.Scene.FirstCamera.Target + back;
                this.scientificCanvas.ColorPalette.SetCodedColor(axisMin, axisMax, step);

                // update tree node.
                TreeNode rootNode = DumpTreeNode(this.scientificCanvas.Scene.RootObject);
                this.objectsTreeView.Nodes.Clear();
                this.objectsTreeView.Nodes.Add(rootNode);
                this.objectsTreeView.ExpandAll();

                // refresh objects state in scene.
                this.scientificCanvas.Scene.UpdateOnce();

                // render scene to this canvas.
                this.scientificCanvas.Invalidate();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #15
0
 private CatesianGridRenderer(vec3 originalWorldPosition, CatesianGrid catesianGrid, ShaderCode[] shaderCodes,
                              AttributeMap attributeMap, Texture codedColorSampler, params GLState[] switches)
     : base(originalWorldPosition, catesianGrid, shaderCodes, attributeMap, switches)
 {
     this.codedColorSampler = codedColorSampler;
 }
Example #16
0
 private void UpdateCatesianGrid(CatesianGrid grid, GridBlockProperty property)
 {
     double axisMin, axisMax, step;
     ColorIndicatorAxisAutomator.Automate(property.MinValue, property.MaxValue, out axisMin, out axisMax, out step);
     grid.MinColorCode = (float)axisMin;
     grid.MaxColorCode = (float)axisMax;
     grid.UpdateColor(property);
     this.scientificCanvas.ColorPalette.SetCodedColor(axisMin, axisMax, step);
 }
 public HexahedronGridWellPipelineBuilder(CatesianGrid grid)
 {
     // TODO: Complete member initialization
     this.grid = grid;
 }
Example #18
0
 private CatesianGridRenderer(vec3 originalWorldPosition, CatesianGrid catesianGrid, ShaderCode[] shaderCodes,
                              PropertyNameMap propertyNameMap, Texture codedColorSampler, params GLSwitch[] switches)
     : base(originalWorldPosition, catesianGrid, shaderCodes, propertyNameMap, switches)
 {
     this.codedColorSampler = codedColorSampler;
 }
 private CatesianGridRenderer(vec3 originalWorldPosition, CatesianGrid catesianGrid, ShaderCode[] shaderCodes,
     AttributeMap attributeMap, Texture codedColorSampler, params GLState[] switches)
     : base(originalWorldPosition, catesianGrid, shaderCodes, attributeMap, switches)
 {
     this.codedColorSampler = codedColorSampler;
 }