Esempio n. 1
0
 public void SliceTopReturnsPolygonForRectangle()
 {
     var Points = new List<Point2D>
     {
         new Point2D(-1, -1),
         new Point2D(-1, 1),
         new Point2D(1, 1),
         new Point2D(1, -1)
     };
     var rect = new GenericShape(Points);
     IMoveableSection sect = rect.GetTopSliceSection(1, SlicingPlaneOffsetType.Top);
     Assert.AreEqual(1.0,sect.YMax);
 }
Esempio n. 2
0
        IMoveableSection GetCutPolygon(List<Point2D> CuttingRectanglePoints)
        {
            #region GPC
            ////Cutting polygon
            //Polygon CuttingPoly = new Polygon();
            //CuttingPoly.AddContour(CuttingRectanglePoints, false);


            ////Original polygon
            //Polygon OriginalPoly = new Polygon();
            //OriginalPoly.AddContour(Vertices, false);

            //Polygon result = OriginalPoly.Clip(GpcOperation.Intersection, CuttingPoly);
            //GenericShape shape = new GenericShape(result);
            //return shape; 
            #endregion

            #region Clipper
            Paths subj = GetPolyPaths(Vertices);
            Paths clip = GetPolyPaths(CuttingRectanglePoints);
	        Paths solution = new Paths();

	        Clipper c = new Clipper();
	        c.AddPaths(subj, PolyType.ptSubject, true);
	        c.AddPaths(clip, PolyType.ptClip, true);
	        c.Execute(ClipType.ctIntersection, solution, 
	        PolyFillType.pftEvenOdd, PolyFillType.pftEvenOdd);

            GenericShape shape = new GenericShape(solution);
            return shape; 

            #endregion
        }