コード例 #1
0
 private void Awake()
 {
     pointGrid = gameObject.AddComponent <PointGrid>();
     pointGrid.GridPointPrefab = GridPointPrefab;
     pointGrid.GridWidth       = GridWidth * (TileSideLength - 1) + 1;
     pointGrid.GridHeight      = GridHeight * (TileSideLength - 1) + 1;
 }
コード例 #2
0
ファイル: BlockMap.cs プロジェクト: ProjectoFinal/PS
 PointGrid InitCorners()
 {
     PointGrid grid = new PointGrid(CornerCount);
     for (int y = 0; y < CornerCount.Y; ++y)
         grid.AllY[y] = y * PixelCount.Y / BlockCount.Y;
     for (int x = 0; x < CornerCount.X; ++x)
         grid.AllX[x] = x * PixelCount.X / BlockCount.X;
     return grid;
 }
コード例 #3
0
    private void Awake()
    {
        _pointGrid = GetComponent <PointGrid>();

        if (Singleton == null)
        {
            Singleton = this;
        }
    }
コード例 #4
0
ファイル: BlockMap.cs プロジェクト: masukuma/Nimbus
 PointGrid InitCorners()
 {
     PointGrid grid = new PointGrid(CornerCount);
     for (int y = 0; y < CornerCount.Height; ++y)
         grid.AllY[y] = y * PixelCount.Height / BlockCount.Height;
     for (int x = 0; x < CornerCount.Width; ++x)
         grid.AllX[x] = x * PixelCount.Width / BlockCount.Width;
     return grid;
 }
コード例 #5
0
ファイル: BlockMap.cs プロジェクト: masukuma/Nimbus
 PointGrid InitBlockCenters()
 {
     PointGrid grid = new PointGrid(BlockCount);
     for (int y = 0; y < BlockCount.Height; ++y)
         grid.AllY[y] = BlockAreas[y, 0].Center.Y;
     for (int x = 0; x < BlockCount.Width; ++x)
         grid.AllX[x] = BlockAreas[0, x].Center.X;
     return grid;
 }
コード例 #6
0
 public static void FindEdgeSpans(
     string pointGridFilePath,
     string outputFilePath)
 {
     using var pointGrid = PointGrid.Load(pointGridFilePath);
     using var timer     = TimedOperation.Start("points", totalWork: pointGrid.ViewPort.Resolution.Height);
     EdgeSpanStream.Write(
         outputFilePath,
         pointGrid.ViewPort,
         pointGrid.ComputationType,
         GetEdgeSpans(pointGrid, timer));
 }
コード例 #7
0
        PointGrid InitCorners()
        {
            PointGrid grid = new PointGrid(CornerCount);

            for (int y = 0; y < CornerCount.Y; ++y)
            {
                grid.AllY[y] = y * PixelCount.Y / BlockCount.Y;
            }
            for (int x = 0; x < CornerCount.X; ++x)
            {
                grid.AllX[x] = x * PixelCount.X / BlockCount.X;
            }
            return(grid);
        }
コード例 #8
0
        PointGrid InitBlockCenters()
        {
            PointGrid grid = new PointGrid(BlockCount);

            for (int y = 0; y < BlockCount.Height; ++y)
            {
                grid.AllY[y] = BlockAreas[y, 0].Center.Y;
            }
            for (int x = 0; x < BlockCount.Width; ++x)
            {
                grid.AllX[x] = BlockAreas[0, x].Center.X;
            }
            return(grid);
        }
コード例 #9
0
ファイル: BlockMap.cs プロジェクト: joskraps/FingerPuppet
        private PointGrid InitBlockCenters()
        {
            var grid = new PointGrid(BlockCount);

            for (var y = 0; y < BlockCount.Y; ++y)
            {
                grid.AllY[y] = BlockAreas[y, 0].Center.Y;
            }
            for (var x = 0; x < BlockCount.X; ++x)
            {
                grid.AllX[x] = BlockAreas[0, x].Center.X;
            }
            return(grid);
        }
コード例 #10
0
    public void ShouldRountTrip()
    {
        using (var tempFile = new TempFile())
        {
            var pointsInSet = new[]
            {
                true,
                true,
                true,
                true,

                false,
                true,
                true,
                false,

                false,
                false,
                true,
                false,

                false,
                false,
                false,
                false,
            };

            PointGrid.Write(
                tempFile.Path,
                new ViewPort(
                    new ComplexArea(new DoubleRange(-1, 1), new DoubleRange(-1, 1)),
                    new Size(4, 4)),
                ComputationType.ScalarFloat,
                pointsInSet);

            using (var pointGrid = PointGrid.Load(tempFile.Path))
            {
                var rows = pointGrid.ToArray();

                for (int rowIndex = 0; rowIndex < 4; rowIndex++)
                {
                    Assert.That(rows[rowIndex].Y, Is.EqualTo(rowIndex), "Wrong row Y position.");
                    Assert.That(
                        rows[rowIndex].ToArray(),
                        Is.EqualTo(pointsInSet.Skip(rowIndex * 4).Take(4).ToArray()),
                        "Did not return correct values for points in set.");
                }
            }
        }
    }
コード例 #11
0
        PointGrid InitCorners()
        {
            PointGrid grid = new PointGrid(CornerCount);

            for (int y = 0; y < CornerCount.Height; ++y)
            {
                grid.AllY[y] = y * PixelCount.Height / BlockCount.Height;
            }
            for (int x = 0; x < CornerCount.Width; ++x)
            {
                grid.AllX[x] = x * PixelCount.Width / BlockCount.Width;
            }
            return(grid);
        }
コード例 #12
0
        public void PointGrid_Compute(
            [ArgDescription("The resolution (it will be squared)."), ArgRequired] int resolution,
            [ArgDescription("Computation type."), ArgDefaultValue(ComputationType.ScalarDouble)] ComputationType computationType,
            [ArgDescription("The directory for the resulting grid file."), ArgExistingDirectory, ArgDefaultValue(".")] string outputPath)
        {
            var viewPort = new ViewPort(
                Constant.RenderingArea.GetPositiveImagArea(),
                new Size(resolution, resolution / 2));

            PointGrid.Compute(
                Path.Combine(outputPath, $"pointGrid_{resolution}_{computationType}"),
                viewPort,
                computationType,
                _token);
        }
コード例 #13
0
ファイル: BlockMap.cs プロジェクト: masukuma/Nimbus
        public BlockMap(Size pixelSize, int maxBlockSize)
        {
            PixelCount = pixelSize;
            BlockCount = new Size(
                Calc.DivRoundUp(PixelCount.Width, maxBlockSize),
                Calc.DivRoundUp(PixelCount.Height, maxBlockSize));
            CornerCount = BlockToCornerCount(BlockCount);

            AllBlocks = new RectangleC(BlockCount);
            AllCorners = new RectangleC(CornerCount);

            Corners = InitCorners();
            BlockAreas = new RectangleGrid(Corners);
            BlockCenters = InitBlockCenters();
            CornerAreas = InitCornerAreas();
        }
コード例 #14
0
ファイル: BlockMap.cs プロジェクト: TristramN/SourceAFIS
        RectangleGrid InitCornerAreas()
        {
            PointGrid grid = new PointGrid(new Size(CornerCount.Width + 1, CornerCount.Height + 1));

            grid.AllY[0] = 0;
            for (int y = 0; y < BlockCount.Height; ++y)
                grid.AllY[y + 1] = BlockCenters[y, 0].Y;
            grid.AllY[BlockCount.Height] = PixelCount.Height;

            grid.AllX[0] = 0;
            for (int x = 0; x < BlockCount.Width; ++x)
                grid.AllX[x + 1] = BlockCenters[0, x].X;
            grid.AllX[BlockCount.Width] = PixelCount.Width;

            return new RectangleGrid(grid);
        }
コード例 #15
0
        public BlockMap(Point pixelSize, int maxBlockSize)
        {
            PixelCount = pixelSize;
            BlockCount = new Point(
                MathEx.DivRoundUp(PixelCount.X, maxBlockSize),
                MathEx.DivRoundUp(PixelCount.Y, maxBlockSize));
            CornerCount = BlockToCornerCount(BlockCount);

            AllBlocks  = new Rectangle(BlockCount);
            AllCorners = new Rectangle(CornerCount);

            Corners      = InitCorners();
            BlockAreas   = new RectangleGrid(Corners);
            BlockCenters = InitBlockCenters();
            CornerAreas  = InitCornerAreas();
        }
コード例 #16
0
ファイル: BlockMap.cs プロジェクト: ProjectoFinal/PS
        RectangleGrid InitCornerAreas()
        {
            PointGrid grid = new PointGrid(new Point(CornerCount.X + 1, CornerCount.Y + 1));

            grid.AllY[0] = 0;
            for (int y = 0; y < BlockCount.Y; ++y)
                grid.AllY[y + 1] = BlockCenters[y, 0].Y;
            grid.AllY[BlockCount.Y + 1] = PixelCount.Y;

            grid.AllX[0] = 0;
            for (int x = 0; x < BlockCount.X; ++x)
                grid.AllX[x + 1] = BlockCenters[0, x].X;
            grid.AllX[BlockCount.X + 1] = PixelCount.X;

            return new RectangleGrid(grid);
        }
コード例 #17
0
ファイル: BlockMap.cs プロジェクト: ProjectoFinal/PS
        public BlockMap(Point pixelSize, int maxBlockSize)
        {
            PixelCount = pixelSize;
            BlockCount = new Point(
                MathEx.DivRoundUp(PixelCount.X, maxBlockSize),
                MathEx.DivRoundUp(PixelCount.Y, maxBlockSize));
            CornerCount = BlockToCornerCount(BlockCount);

            AllBlocks = new Rectangle(BlockCount);
            AllCorners = new Rectangle(CornerCount);

            Corners = InitCorners();
            BlockAreas = new RectangleGrid(Corners);
            BlockCenters = InitBlockCenters();
            CornerAreas = InitCornerAreas();
        }
コード例 #18
0
        public BlockMap(Size pixelSize, int maxBlockSize)
        {
            PixelCount = pixelSize;
            BlockCount = new Size(
                Calc.DivRoundUp(PixelCount.Width, maxBlockSize),
                Calc.DivRoundUp(PixelCount.Height, maxBlockSize));
            CornerCount = BlockToCornerCount(BlockCount);

            AllBlocks  = new RectangleC(BlockCount);
            AllCorners = new RectangleC(CornerCount);

            Corners      = InitCorners();
            BlockAreas   = new RectangleGrid(Corners);
            BlockCenters = InitBlockCenters();
            CornerAreas  = InitCornerAreas();
        }
コード例 #19
0
        RectangleGrid InitCornerAreas()
        {
            PointGrid grid = new PointGrid(new Point(CornerCount.X + 1, CornerCount.Y + 1));

            grid.AllY[0] = 0;
            for (int y = 0; y < BlockCount.Y; ++y)
            {
                grid.AllY[y + 1] = BlockCenters[y, 0].Y;
            }
            grid.AllY[BlockCount.Y + 1] = PixelCount.Y;

            grid.AllX[0] = 0;
            for (int x = 0; x < BlockCount.X; ++x)
            {
                grid.AllX[x + 1] = BlockCenters[0, x].X;
            }
            grid.AllX[BlockCount.X + 1] = PixelCount.X;

            return(new RectangleGrid(grid));
        }
コード例 #20
0
        RectangleGrid InitCornerAreas()
        {
            PointGrid grid = new PointGrid(new Size(CornerCount.Width + 1, CornerCount.Height + 1));

            grid.AllY[0] = 0;
            for (int y = 0; y < BlockCount.Height; ++y)
            {
                grid.AllY[y + 1] = BlockCenters[y, 0].Y;
            }
            grid.AllY[BlockCount.Height] = PixelCount.Height;

            grid.AllX[0] = 0;
            for (int x = 0; x < BlockCount.Width; ++x)
            {
                grid.AllX[x + 1] = BlockCenters[0, x].X;
            }
            grid.AllX[BlockCount.Width] = PixelCount.Width;

            return(new RectangleGrid(grid));
        }
コード例 #21
0
    public static void Render(string gridFilePath, string imageFilePath)
    {
        Log.Info($"Output image: {imageFilePath}");

        using var grid  = PointGrid.Load(gridFilePath);
        using var timer = TimedOperation.Start("points", totalWork: grid.ViewPort.Resolution.Area());
        var image = new FastImage(grid.ViewPort.Resolution);

        image.Fill(Color.White);

        Parallel.ForEach(grid, row =>
        {
            foreach (var setSegment in row.GetSegmentsInSet())
            {
                foreach (var x in Enumerable.Range(setSegment.StartCol, setSegment.Length))
                {
                    image.SetPixel(x, row.Y, Color.Black);
                }
            }
            timer.AddWorkDone(grid.ViewPort.Resolution.Width);
        });

        image.Save(imageFilePath);
    }
コード例 #22
0
 public RectangleGrid(PointGrid corners)
 {
     Corners = corners;
 }
コード例 #23
0
 private void Start()
 {
     grid = Astar_Manager.Singleton.gameObject.GetComponent <PointGrid>();
 }
コード例 #24
0
ファイル: BlockMap.cs プロジェクト: masukuma/Nimbus
 public RectangleGrid(PointGrid corners)
 {
     Corners = corners;
 }
コード例 #25
0
        private void CreateGridVisual3D(object sender, EventArgs e)
        {
            try
            {
                int   nx   = 236365;
                int   ny   = 1;
                int   nz   = 1;
                float step = System.Convert.ToSingle(tbColorIndicatorStep.Text);
                //float radius = System.Convert.ToSingle(this.tbRadius.Text);
                float propMin   = System.Convert.ToSingle(this.tbxPropertyMinValue.Text, CultureInfo.InvariantCulture);
                float propMax   = System.Convert.ToSingle(this.tbxPropertyMaxValue.Text, CultureInfo.InvariantCulture);
                int   dimenSize = nx * ny * nz;
                float dx        = System.Convert.ToSingle(this.tbDX.Text);
                float dy        = System.Convert.ToSingle(this.gbDY.Text);
                float dz        = System.Convert.ToSingle(this.tbDZ.Text);

                // use CatesianGridderSource to fill HexahedronGridderElement's content.
                string             fileName = @"TET5_cvxyz.txt";
                PointSetLoader     loader   = new PointSetLoader();
                PointGridderSource source   = loader.LoadFromFile(fileName, nx, ny, nz);
                source.Init();

                InitPropertiesAndSelectDefault(dimenSize, propMin, propMax);

                ///模拟获得网格属性
                ///获得当前选中的属性


                float minValue = this.CurrentProperty.MinValue;
                float maxValue = this.CurrentProperty.MaxValue;
                step = (maxValue * 1.0f - minValue * 1.0f) / 10;
                int[]   gridIndexes = this.CurrentProperty.GridIndexes;
                float[] gridValues  = this.CurrentProperty.Values;


                //设置色标的范围
                this.sim3D.SetColorIndicator(minValue, maxValue, step);


                // use HexahedronGridderElement
                DateTime            t0                = DateTime.Now;
                PointMeshGeometry3D geometry          = source.CreateMesh() as PointMeshGeometry3D;
                TexCoordBuffer      textureCoodinates = source.CreateTextureCoordinates(gridIndexes, gridValues, minValue, maxValue);
                Bitmap    texture = ColorPaletteHelper.GenBitmap(this.sim3D.uiColorIndicator.Data.ColorPalette);
                PointGrid gridder = new PointGrid(this.sim3D.OpenGL, this.sim3D.Scene.CurrentCamera);
                gridder.Init(geometry);
                gridder.RenderGrid          = true;
                gridder.RenderGridWireframe = this.IsShowWireframe;
                gridder.SetTexture(texture);
                gridder.SetTextureCoods(textureCoodinates);



                DateTime t1  = DateTime.Now;
                TimeSpan ts1 = t1 - t0;


                DateTime t2 = DateTime.Now;

                //gridderElement.SetBoundingBox(mesh.Min, mesh.Max);
                this.sim3D.Tag = source;

                DateTime t3 = DateTime.Now;
                // update ModelContainer's BoundingBox.
                BoundingBox boundingBox = this.sim3D.ModelContainer.BoundingBox;
                boundingBox.SetBounds(geometry.Min, geometry.Max);

                // update ViewType to UserView.
                this.sim3D.ViewType = ViewTypes.UserView;
                this.sim3D.AddModelElement(gridder);
                //mesh.Dispose();

                StringBuilder msgBuilder = new StringBuilder();
                msgBuilder.AppendLine(String.Format("create mesh in {0} secs", (t1 - t0).TotalSeconds));
                msgBuilder.AppendLine(String.Format("init SceneElement in {0} secs", (t2 - t1).TotalSeconds));
                msgBuilder.AppendLine(String.Format("total load in {0} secs", (t2 - t0).TotalSeconds));
                String msg = msgBuilder.ToString();
                MessageBox.Show(msg, "Summary", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception error)
            {
                MessageBox.Show(error.ToString());
            }
        }