Example #1
0
        public void ContainsPoint()
        {
            Polygon2f polygon = CreatePolygon2.FromBox(new Vector2f(-2), new Vector2f(2));
            Polygon2f hole    = CreatePolygon2.FromBox(new Vector2f(-1), new Vector2f(1));

            hole.MakeCW();

            polygon.AddHole(hole);

            PolygonIntersection2.PushPolygon(polygon);

            //in polygon
            Assert.IsTrue(PolygonIntersection2.ContainsPoint(new Vector2f(1.5f, 1.5f)));
            Assert.IsTrue(PolygonIntersection2.ContainsPoint(new Vector2f(1.5f, -1.5f)));
            Assert.IsTrue(PolygonIntersection2.ContainsPoint(new Vector2f(-1.5f, 1.5f)));
            Assert.IsTrue(PolygonIntersection2.ContainsPoint(new Vector2f(-1.5f, -1.5f)));

            //in hole
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(0, 0)));

            //on polygon boundary
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(2, 2)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(2, -2)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(-2, 2)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(-2, -2)));

            //on hole boundary
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(1, 1)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(1, -1)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(-1, 1)));
            Assert.IsFalse(PolygonIntersection2.ContainsPoint(new Vector2f(-1, -1)));

            PolygonIntersection2.PopPolygon();
        }
Example #2
0
        protected override void OnLeftClick(Vector2f point)
        {
            if (MadePolygon)
            {
                PolygonIntersection2.PushPolygon(polygon);

                result          = new IntersectionResult();
                result.contains = PolygonIntersection2.ContainsPoint(point);
                result.point    = point;

                PolygonIntersection2.PopPolygon();
            }
        }
Example #3
0
        public static void Triangulate <MESH>(Polygon2f polygon, IMeshConstructor <MESH> constructor)
        {
            Insert(polygon);

            MeshDescriptor descriptor;

            if (CGAL_Triangulate(out descriptor) != SUCCESS)
            {
                throw new Exception("Error triangulating points.");
            }

            PolygonIntersection2.PushPolygon(polygon);
            CreateMesh(constructor, descriptor);
            PolygonIntersection2.PopPolygon();

            CGAL_Clear();
        }