Ejemplo n.º 1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            Point2D point = new Point2D(e.X, e.Y - 30);
            Polygon2DAdorner polygonAdorner = null;
            Partition part = OnPart(point);

            this.statusBarPanel1.Text = this.GetPolygonStatus(point);
            if (part == Partition.Left)
            {
                polygonAdorner = this.LeftPolygon;
            }
            else
            {
                point.X -= this.ClientSize.Width / 2;
                polygonAdorner = this.RightPolygon;
            }

            int i = StatusController.CatchPoint;

            if (i != -1)
            {
                this.Cursor = System.Windows.Forms.Cursors.Default;

                if (StatusController.availablePartition == part)
                {
                    Polygon2DEditor pe = new Polygon2DEditor(polygonAdorner.polygon);

                    pe.SetPoint(point, i);

                    StatusController.canRestart = false;

                }

                this.Invalidate();
            }
            else
            {
                i = polygonAdorner.HitTest(point);
                if (i == -1)
                {
                    this.Cursor = System.Windows.Forms.Cursors.Default;
                }
                else
                {
                    this.Cursor = System.Windows.Forms.Cursors.Cross;
                }
                this.statusBarPanel2.Text =point.ToString() + "    " + "Hint Index : " + i.ToString() + " ";
            }

            if (StatusController.isZoomView)
            {
                PointF midPoint;
                if (part == Partition.Left)
                {
                    midPoint = new PointF(this.ClientSize.Width / 4, this.ClientSize.Height / 2);

                }
                else
                {
                    midPoint = new PointF(3 * this.ClientSize.Width / 4, this.ClientSize.Height / 2);
                }

                if (e.X < midPoint.X && e.Y  < midPoint.Y)
                {
                    this.Cursor = System.Windows.Forms.Cursors.PanNW;
                }
                else if (e.X > midPoint.X && e.Y  < midPoint.Y)
                {
                    this.Cursor = System.Windows.Forms.Cursors.PanNE;
                }
                else if (e.X < midPoint.X && e.Y > midPoint.Y)
                {
                    this.Cursor = System.Windows.Forms.Cursors.PanSW;
                }
                else
                {
                    this.Cursor = System.Windows.Forms.Cursors.PanSE;
                }
            }
        }
Ejemplo n.º 2
0
        public void AreaBasedRemeshing()
        {
            if (!this.available)
            {
                return;
            }

            for (int i = this.Polygon.VertexCount; i < this.Polygon.PointCount;  i++)
            {
                if (this.Polygon.isOnEdge(this.Polygon.GetPoint(i)) || this.Polygon.isVertex(this.Polygon.GetPoint(i)))
                {
                    continue;
                }

                double[] d = this.GetValue(i);

                Line2D line1 = null;
                Line2D line2 = null;
                Point2D point = null;

                try
                {
                    line1 = new Line2D(0.5 * d[3], 0.5 * d[4], 0.5 * d[5] - d[7] * d[1]);
                    line2 = new Line2D(0.5 * d[4], 0.5 * d[2], 0.5 * d[6] - d[7] * d[0]);
                }
                catch (ArgumentException)
                {
                    return;
                }

                point = line1.Intersects(line2);

                if (point.isRegular && this.isRegular(i, point) && this.Polygon.Contains(point))
                {
                    Polygon2DEditor polygonEditor = new Polygon2DEditor(this.Polygon);

                    polygonEditor.SetPoint(point.X, point.Y, i);
                }
            }
        }