IClippable

Namespace: Digi21.DigiNG.Entities
Assembly: Digi21.DigiNG

Entity that can be split by a boundary line.

public interface IClippable

Implementing types: ReadOnlyLine (and Line) and ReadOnlyPolygon (and Polygon).

To obtain only the part of one enclosed area outside another, use ITrimable.Trim.

Methods

Member Description
IEnumerable<Entity> Clip(ReadOnlyLine limit) Splits the area enclosed by the entity using limit and returns the parts as new entities.

Example

This program splits a parcel using a closed boundary covering its right half (Clip) and calculates the part of the parcel outside the boundary (Trim):

using Digi21.DigiNG.Entities;
using Digi21.DigiNG.IO.BinDouble;
using Digi21.Math;

if (args.Length != 1)
{
    Console.WriteLine("Uso: RecortaPoligono <salida.bind>");
    return 1;
}

using var archivo = new BinDouble(args[0]);

var parcela = new Polygon(new Code("050101"));
parcela.Points.Add(new[]
{
    new Point3D(0.0, 0.0, 0.0),
    new Point3D(100.0, 0.0, 0.0),
    new Point3D(100.0, 100.0, 0.0),
    new Point3D(0.0, 100.0, 0.0),
    new Point3D(0.0, 0.0, 0.0),
});

// Closed boundary covering the parcel's right half and extending beyond it.
var límite = new Line(new Code("050102"));
límite.Points.Add(new[]
{
    new Point3D(50.0, -10.0, 0.0),
    new Point3D(110.0, -10.0, 0.0),
    new Point3D(110.0, 110.0, 0.0),
    new Point3D(50.0, 110.0, 0.0),
    new Point3D(50.0, -10.0, 0.0),
});

// Clip: parcel split by the boundary (two polygons, each with the parcel's codes).
foreach (var parte in parcela.Clip(límite))
    archivo.Add(parte);

// Trim: the part of the parcel outside the boundary.
foreach (Polygon resto in parcela.Trim(límite, true))
    Console.WriteLine($"Resto: {resto.Area}");

archivo.Add(límite);
return 0;