CODRgn Class

class CODRgn

A region object defines a shape or area as a set of polygons. The mesh of polygons maintained by the region is useful for calculating the bounding rectangle of complex objects and also for hit testing. Curves are translated into regions by approximating them as polygons.

Defined in: OdRgn.h

Class Members

VIEWS_API CODRgn()

Constructor.

VIEWS_API CODRgn(const CODRgn& rgn)

Copy constructor.

VIEWS_API virtual ~CODRgn()

Destructor.

VIEWS_API void CreateLineRgn(LPPOINT lpPoints, int nCount)

Create the region from a polyline.

VIEWS_API void CreatePolygonRgn(LPPOINT lpPoints, int nCount)

Create the region from a polygon.

VIEWS_API void CreateCurveRgn(LPPOINT lpPoints, int nCount)

Create the region from a curve.

VIEWS_API void CreateClosedCurveRgn(LPPOINT lpPoints, int nCount)

Create the region from a closed curve.

CRect m_rcBounds

Bounding rectangle defined by the region.

CODPointArray* m_pApprox

Points used to convert a curve to a set of polygons.

CArray<CODPolygonRgn, const CODPolygonRgn&> m_arPolygons

Set of polygons that define the region.

VIEWS_API CRect GetBounds() const

Return the bounding rectangle of the region.

VIEWS_API int GetPolygonCount() const

Get the number of polygons used to define the region.

VIEWS_API const CODPolygonRgn& GetPolygon(int nIndex) const

Get a specified polygon of the region.

VIEWS_API void SetPolygon(int nIndex, const CODPolygonRgn& rgn)

Set a specified polygon of the region.

VIEWS_API CRect GetPolygonBounds(int nIndex) const

Return the bounding rectangle of a given polygon.

VIEWS_API BOOL operator==(const CODRgn& rgn) const

Compare two regions for equality.

VIEWS_API BOOL operator!=(const CODRgn& rgn) const

Compare two regions for inequality.

VIEWS_API CODRgn& operator=(const CODRgn& rgn)

Assign one region to another region.

VIEWS_API BOOL PtInRegion(POINT ptLog, int nPadding = 0)

Determines if the specified point is within the region.

VIEWS_API int PtInSubregion(POINT ptLog, int nPadding = 0)

Determines which subregion of the point falls into, if any.

VIEWS_API void CombineRgn(const CODRgn& rgn)

Add a specified region to this region.

VIEWS_API void UpdateBounds()

Recalculate the bounding rectangle of the region.

VIEWS_API void Empty()

Remove all polygons from a region.

VIEWS_API CODRgn Transform(CODTransform* pXform) const

Apply a transformation to the polygons in a region.

VIEWS_API CODRgn InvTransform(CODTransform* pXform) const

Apply the inverse of a transformation to the polygons in a region.

VIEWS_API CODPolygonRgn CalcLineSegmentRgn(CPoint pt0, CPoint pt1)

Calculates the region of a line segment.

VIEWS_API void CurveToPolyline(LPPOINT lpPoints, int nCount)

Calculates a linear approximation from a set of points that define a bezier curve.

VIEWS_API void ApproximateCurve(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3)

Approximates a curve by creating a series of line segments.

VIEWS_API BOOL CanApproximate(float x0, float y0, float x1, float y1, float x2, float y2)

Determines if a curve can be approximated by a line.

VIEWS_API void AddApproximation(float x0, float y0, float x1, float y1)

Adds a line segment to the approximation array.

VIEWS_API void Midpoint(float x0, float y0, float x1, float y1, float& midX, float& midY)

Finds the midpoint of a line.

VIEWS_API CPoint GetBoundaryPoint(LPPOINT ptNear, LPPOINT ptFar, int nSpacing=0) const

Finds the boundary point given points of a line.