Region2d Class

A region is basically a collection of Poly2d objects, where counter clockwise contours are seen as outer contours and clockwise polygons are seen as holes.
Public Class Region2d 
Inherits Geometry2d 
Implements IEnumerable(Of Poly2d)
This language is not supported or no code example is available.
public class Region2d : Geometry2d
IEnumerable<Poly2d>
This language is not supported or no code example is available.
public ref class Region2d : public Geometry2d^, 
public IEnumerable<Poly2d^>^
This language is not supported or no code example is available.
JScript does not support generic types and methods.
This language is not supported or no code example is available.
Name Description
Public constructor Region2d() Constructor to create an empty region.
Public constructor Region2d(IEnumerable<Poly2d>) Create a region form a list of polys (copies are made).
Public constructor Region2d(Region2d) Copy constructor.
Public constructor Region2d(params Poly2d[]) Create a region from a list of polys (copies are made).
Top
Name Description
Public property Area Gets the area of the region, considering holes. Assumes the region is simple and the contour directions is correct.
Public property AreaOuter Sum of all CCW polys area
Public property Centroid Gets the center of gravity for this region taking holes into account. The computation is done as the region is a plate.
Public property Count Gets the number of contours in the region.
Public property Extents Gets the axis aligned extents of the region.
Public property Item(int) Indexed direct access to the polys in the region. Setting a poly will clone this poly before inserting it into the region. Indexing an empty region will throw an exception.
Public property Length Gets the length of the region, that is the sum of lengths all contours it contains.
Public property LengthOuter
Public property Polys Gets a reference to the list of poly in this region or sets it to a new array of polys.
Public property WireCentroid
Top
Methods
 
Name Description
Public method Add(Poly2d) Adds a copy of a poly to the region.
Public method Add(Region2d) Appends a copy of a region to this region.
Public method AddRaw(Poly2d) Adds the poly directly to the region without cloning it. This means, modifying the poly afterwards, also modifies the region. Fast, but use with care.
Public method ArcFit(double) Returns a copy of this region for which each poly is ArcFit():ed. See ArcFit() function in Poly2d() for details.
Public method Clean()
Public method Clean(double) Calls the Clean() function for each poly in this region, which will remove short segments etc. in-place.
Public method Clear() Removes all contours from this region in-place, making this an empty region.
Public method Clip(Extents2d, out Region2d) Clips the Region2d to a specified clipping box. The result is a new Region2d defining the part that is completely inside the clip box. The Region2d must consist of Poly2d that are closed and consist of only lines.
Public method ClosestNode(Point2d, out int, out int) Computes the index of the node and contour that is closest to a given point. If the region is empty, an exception will be thrown.
Public method ClosestNode(Point2d, out int, out int, out double) Computes the index of the node and contour that is closest to a given point. If the region is empty, an exception will be thrown. This function also givest the actual distance between point and node.
Public method ClosestPoint(Point2d) Computes a point somewhere on the regions contours that is as close as possible to a given point.
Public method ClosestPoly(Point2d)
Public method ClosestSegment(Point2d, out int, out int) Computes the index of the segment and contour that is closest to a given point. If the region is empty, an exception will be thrown.
Public method ClosestSegment(Point2d, out int, out int, out double) Computes the index of the segment and contour that is closest to a given point. If the region is empty, an exception will be thrown. This function also givest the actual distance between point and segment.
Public method Contains(Point2d) Checks if a point is inside the region. It handles holes, but assumes the region is simple.
Public method Distance(Point2d) Computes the minimum distance to the circumference of a contour in this region. If the region is empty, an exception will be thrown.
Public method Flatten(double, FlattenMode) Approximates this region into another region where each contour contains line segments only.
Public method GetCentralPoint()
Public method GetCentralPoint(out double)
Public method GetEnumerator()
Public method GetPoints()
Public method Mirror(Point2d, Point2d) Mirrors the region in-place over a reflection line. Note that this will cause all bulge factors to be inverted.
Public method Normalize() Modifies the region in place so that the direction of the polys is winding correct and arranges them in order so that a counter clockwise outer poly is followed by all clockwise polys that are holes in it. Assumes the polys in the region are simple and closed.
Public method NormalizeSplit() Normalizes the region with Normalize() function and splits each separate contour to a separate region that are put in the list returned. Note that this function modifies the region in-place. Assumes the polys in the region are simple and closed. Also note that polys are copied into the new regions!
Public method NormalizeSplitRaw() Normalizes the region with Normalize() function and splits each separate contour to a separate region that are put in the list returned. Note that this function modifies the region in-place. Assumes the polys in the region are simple and closed. Also note that Polys are added to the new regions using Region2d.AddRaw()!
Public method Offset(double, OffsetGapType, double) Offsets each contour in this region. See offset in Poly2d() for details.
Public method Offset(double, OffsetGapType, double, bool)
Public method OffsetUnion(double, OffsetGapType, double)
Public method PSOffset(double)
Public method RemoveEmptyPolys()
Public method ReversePolys() Reverses the direction of every poly in the region
Public method Rotate(double) Rotates the region in-place around world origo.
Public method Rotate(double, Point2d) Rotates the region in-place around a point.
Public method Scale(double) Scales the region in-place using world origo as scaling center.
Public method Scale(double, Point2d) Scales the region using a specified point as scaling center.
Public method Split(bool) Similar to NormalizeSplit but region is assumed to be normalized allready. Splits the region in CCW+CW... regions
Public method Swell(double) Shortcut to Stroke(...) the region with Round linecaps and round endcaps, that is the 'real' offset of the segments (all points of the result has the given distance to the original line). The result is _not_ trimmed. See Union() function for this. If the region is closed, an exception will be thrown.
Public method ToRegion(double) Somewhat silly function in region class but is needed to fullfill the class hirearchy. returns a copy of itself.
Public method ToString() Creates a new string suitable for debug purposes.
Public method Transform(Matrix2d) Transform the region in-place with a matrix.
Public method TransformSafeMirror(Matrix2d) Transform the region in-place with a matrix. If the matrix is a mirror matrix then all contours are reversed to maintain correct directions
Public method Translate(double, double) Translates the poly in-place a specified distance in x and y.
Public method Union() Computes a self-union of this region into a new region. Direction of contours matters, Counter clockwise are outer and clockwise are holes. This function is good for trimming offsets of closed region contours.
Public method WriteAutoCADScript(StreamWriter, int) Writes the object as an AutoCAD loadable script to a stream using a specified color
Top

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

In this article

Definition