Table of Contents

Struct ClipRect

Namespace
CADability
Assembly
CADability.dll

An axis aligned 2d rectangle (Left, Right, Bottom, Top) which provides primitive clipping functions: classification of points by outcodes (Cohen-Sutherland), clipping of line segments and fast hit tests of line segments against the rectangle. Used by the 2d curves and borders for hit testing.

public struct ClipRect
Inherited Members

Constructors

ClipRect(BoundingRect)

public ClipRect(BoundingRect r)

Parameters

r BoundingRect

ClipRect(double, double, double, double)

public ClipRect(double Left, double Right, double Bottom, double Top)

Parameters

Left double
Right double
Bottom double
Top double

Fields

Bottom

public double Bottom

Field Value

double

Left

public double Left

Field Value

double

Right

public double Right

Field Value

double

Top

public double Top

Field Value

double

Properties

Center

public GeoPoint2D Center { get; }

Property Value

GeoPoint2D

Size

public double Size { get; }

Property Value

double

Methods

ArcHitTest(GeoPoint2D, double, int, GeoPoint2D, GeoPoint2D)

public bool ArcHitTest(GeoPoint2D c, double r, int q, GeoPoint2D ps, GeoPoint2D pe)

Parameters

c GeoPoint2D
r double
q int
ps GeoPoint2D
pe GeoPoint2D

Returns

bool

ClipCode(ref GeoPoint2D, ref BoundingRect)

public static int ClipCode(ref GeoPoint2D p, ref BoundingRect rect)

Parameters

p GeoPoint2D
rect BoundingRect

Returns

int

ClipLine(ref GeoPoint2D, ref GeoPoint2D)

Clips the line segment given by the two points to this rectangle: the points are moved onto the sides of the rectangle so that the resulting segment is the part of the original segment inside the rectangle. If the segment lies completely outside, false is returned (the points may then have been partially modified).

public bool ClipLine(ref GeoPoint2D p1, ref GeoPoint2D p2)

Parameters

p1 GeoPoint2D

Start point of the line, modified on return

p2 GeoPoint2D

End point of the line, modified on return

Returns

bool

true if a part of the line remains visible (inside the rectangle), false otherwise

Contains(GeoPoint2D)

public bool Contains(GeoPoint2D p)

Parameters

p GeoPoint2D

Returns

bool

EllipseArcHitTest(GeoPoint2D, double, double, Angle, int, GeoPoint2D, GeoPoint2D)

public bool EllipseArcHitTest(GeoPoint2D cnt, double rx, double ry, Angle a, int q, GeoPoint2D ps, GeoPoint2D pe)

Parameters

cnt GeoPoint2D
rx double
ry double
a Angle
q int
ps GeoPoint2D
pe GeoPoint2D

Returns

bool

LineHitTest(GeoPoint2D, GeoPoint2D)

Tests whether the line segment given by the two points touches or crosses this rectangle. The points are not modified.

public bool LineHitTest(GeoPoint2D p1, GeoPoint2D p2)

Parameters

p1 GeoPoint2D

Start point of the line

p2 GeoPoint2D

End point of the line

Returns

bool

true if the line segment intersects the rectangle or lies (partially) inside of it

LineHitTest(GeoPoint2D, GeoPoint2D, ref BoundingRect)

public static bool LineHitTest(GeoPoint2D p1, GeoPoint2D p2, ref BoundingRect rect)

Parameters

p1 GeoPoint2D
p2 GeoPoint2D
rect BoundingRect

Returns

bool

ParallelogramHitTest(GeoPoint2D, GeoVector2D, GeoVector2D)

public bool ParallelogramHitTest(GeoPoint2D p, GeoVector2D v1, GeoVector2D v2)

Parameters

p GeoPoint2D
v1 GeoVector2D
v2 GeoVector2D

Returns

bool

PointsHitTest(GeoPoint2D[])

public int PointsHitTest(GeoPoint2D[] points)

Parameters

points GeoPoint2D[]

Returns

int

Split()

public ClipRect[] Split()

Returns

ClipRect[]

TriangleHitTest(GeoPoint2D, GeoPoint2D, GeoPoint2D)

public bool TriangleHitTest(GeoPoint2D p1, GeoPoint2D p2, GeoPoint2D p3)

Parameters

p1 GeoPoint2D
p2 GeoPoint2D
p3 GeoPoint2D

Returns

bool