Class: TPrimitiveRegion

Declaration: PrintPrimitives.h

Taxonomy Categories:

Member Functions:


Interface Category:

API.

Inherits From:

MCollectible

Inherited By:

None.

Purpose:

Items in a grid array can be grouped in various combinations to form collections or sets. These sets can be queried for containment of a specific coordinate and sets can be manipulated to modify their contents. In fact, sets of coordinates act very much like classical sets, because they obey the rules of Union, Intersection, Difference, and ExclusiveOr operations that pertain to primitive sets. The class that represents sets of grid coordinates is called TPrimitiveRegion. A TPrimitiveRegion can cover the entire 2-D unsigned integer space. All the elements of a TSimpleGrid can be represented by a region whose set contents are all the elements surrounded by the grid. Elements are added to or removed from the grid using SetRange, Union, Intersection, Difference, or ExclusiveOr. In addition, all elements inside the set can be placed outside and all elements outside the set can be placed inside by using Not.

Instantiation:

Allocate on the heap or the stack.

Deriving Classes:

This class is not intended to have derived classes descend from it. This is a fully functional class. Other classes could be derived from this class to change basic functionality such as the set operations.

Concurrency:

Not multithread safe.

Resource Use:

No special requirements.

Member Function: TPrimitiveRegion::TPrimitiveRegion

  1. TPrimitiveRegion ()
  2. TPrimitiveRegion (const TPrimitiveRegion &)
  3. TPrimitiveRegion (const TULongPair & rectRegion)

Interface Category:

API.

Purpose:

  1. Default constructor.
  2. Copy constructor.
  3. Constructor initially set to be the rectangular region.

Calling Context:

  1. Called by the stream-in operators and directly.
  2. Called to copy an object.
  3. Called to create an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::~TPrimitiveRegion

virtual ~ TPrimitiveRegion ()

Interface Category:

API.

Purpose:

Destructor.

Calling Context:

Called to destroy an object.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Contains

virtual bool Contains (const TULongPair &) const

Interface Category:

API.

Purpose:

Determines if the coordinate is contained in the region.

Calling Context:

Called to verify if a coordinate is within the region.

Parameters:

Return Value:

Returns true if the TULongPair point is within the region.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::IsEmpty

virtual bool IsEmpty () const

Interface Category:

API.

Purpose:

Determines if the region is empty.

Calling Context:

Called to test for an empty region.

Parameters:

Return Value:

Returns true if the region is empty.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::IsFull

virtual bool IsFull () const

Interface Category:

API.

Purpose:

Determines if the region is full (contains all elements it is capable of holding).

Calling Context:

Called to test if the region is full.

Parameters:

Return Value:

Returns true if the region can contain no more items.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::GetItemCountInRange

virtual unsigned long GetItemCountInRange () const

Interface Category:

API.

Purpose:

Returns the number of items in the range.

Calling Context:

Called to obtain a count of items in the range.

Parameters:

Return Value:

Returns the number of items within the range.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::GetBounds

virtual TULongRect GetBounds () const

Interface Category:

API.

Purpose:

Gets the loose bounds of the region as a TULongRect.

Calling Context:

Called to obtain the loose bounds of the region.

Parameters:

Return Value:

Returns the loose bounds of the region as a rectangle.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::SetRange

  1. virtual void SetRange (const TULongPair &)
  2. virtual void SetRange (const TULongPair & from, const TULongPair & to)
  3. virtual void SetRange (const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

  1. Sets the range to be the single coordinate.
  2. Sets the range to be the rectangular area circumscribed by from and to.
  3. Sets the range to be the same as the input range.

Calling Context:

  1. Called to set the range to a single coordinate.
  2. Called to set the range to a rectangular region.
  3. Called to copy another region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::SetRangeEmpty

virtual void SetRangeEmpty ()

Interface Category:

API.

Purpose:

Sets the range to be empty (containing no elements).

Calling Context:

Called to set a range to be empty.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::SetRangeFull

virtual void SetRangeFull ()

Interface Category:

API.

Purpose:

Sets the region to be completely full, containing all the elements it can hold.

Calling Context:

Called to set a range to be full.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Union

  1. virtual void Union (const TULongPair &)
  2. virtual void Union (const TULongPair & from, const TULongPair & to)
  3. virtual void Union (const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

  1. Adds the coordinate to the set of elements in the region.
  2. Adds the area circumscribed by from and to.
  3. Adds the area designated by the region argument.

Calling Context:

  1. Called to add coordinates to the region.
  2. Called to add rectangles to the region.
  3. Called to add other regions to the region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Intersection

  1. virtual void Intersection (const TULongPair &)
  2. virtual void Intersection (const TULongPair & from, const TULongPair & to)
  3. virtual void Intersection (const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

  1. Only the coordinate given remains in the set, if it is already in the set. Otherwise, it is set to empty.
  2. Intersects the rectangular area circumscribed by from and to with the region.
  3. Intersects the provided region with the region.

Calling Context:

  1. Called to intersect with a coordinate.
  2. Called to intersect with a rectangle.
  3. Called to intersect with another region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Difference

  1. virtual void Difference (const TULongPair &)
  2. virtual void Difference (const TULongPair & from, const TULongPair & to)
  3. virtual void Difference (const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

  1. Removes the coordinate from the region.
  2. Removes the area circumscribed by from and to from the region.
  3. Removes the provided region from the region.

Calling Context:

  1. Called to subtract a coordinate.
  2. Called to subtract a rectangle.
  3. Called to subtract another region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::ExclusiveOr

  1. virtual void ExclusiveOr (const TULongPair &)
  2. virtual void ExclusiveOr (const TULongPair & from, const TULongPair & to)
  3. virtual void ExclusiveOr (const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

  1. If the given coordinate is in the region, it is removed, otherwise it is added.
  2. Those elements between from and to that are not in the range are added to the range, otherwise they are removed.
  3. Those elements of the input range that are not already in the range are added to the range, otherwise they are removed.

Calling Context:

  1. Called to exclusive OR a coordinate.
  2. Called to exclusive OR a rectangle.
  3. Called to exclusive OR another region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Not

virtual void Not ()

Interface Category:

API.

Purpose:

Takes items within the region and places them outside. Places items outside the region inside.

Calling Context:

Called to invert a region.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::operator=

TPrimitiveRegion & operator =(const TPrimitiveRegion &)

Interface Category:

API.

Purpose:

Assignment operator.

Calling Context:

Called when an object is assigned to another compatible object.

Parameters:

Return Value:

A non-const reference to the left-hand side object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::Hash

virtual long Hash () const

Interface Category:

API.

Purpose:

Generates a hash value.

Calling Context:

Called to obtain a hash value.

Parameters:

Return Value:

Returns a hash value.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::IsEqual

virtual bool IsEqual (const MCollectible *) const

Interface Category:

API.

Purpose:

Compares two objects for equality.

Calling Context:

Called to compare compatible objects.

Parameters:

Return Value:

Returns true if the object is equal to this object.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::operator<<=

virtual TStream & operator <<= (TStream & fromWhere)

Interface Category:

API.

Purpose:

Stream-in operator.

Calling Context:

Called to stream in data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself in from.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::operator>>=

virtual TStream & operator >>=(TStream & toWhere) const

Interface Category:

API.

Purpose:

Stream-out operator.

Calling Context:

Called to stream out data.

Parameters:

Return Value:

Returns a reference to the stream the object streams itself out to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::MapCount

virtual unsigned long MapCount (const TULongPair & pt, EMap map =kLeftToRight) const

Interface Category:

API.

Purpose:

A special purpose function that counts the number of points or locations in a region along a line from a specified edge to a specified point. This function counts the number of region intersections that occur while going along a line from the specified edge to the point in question and returns that count. The net effect of this function is to map a point in an arbitrary region into a fully populated region, that is, from region space into a grid space. This is an onto mapping but not always one to one. The utility of this function is to count objects in a region along various paths or sections, which has special uses when items in a region represent discrete objects such as items in a set.

Calling Context:

Called to obtain the count of items along a path inside the region.

Parameters:

Return Value:

Returns the count of items in the region that are intersected along the path specified.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TPrimitiveRegion::MapPoint

virtual bool MapPoint (TULongPair &, EMap map =kLeftToRight) const

Interface Category:

API.

Purpose:

A special purpose function that maps a point from grid space into region space. Because the mapping might not exist at all points for all regions, the function returns true if it was able to find a suitable mapping or false if not. The mapping produced by this function is not one-to-one and not onto. The result of the mapping, if it exists, is returned in the input specified when the MapPoint function is called. This function is utilized for ignoring open spaces in a sparse region, when the region represents discrete items such as objects in a set.

Calling Context:

Called to find a point that traverses the specified number of region items along the path indicated.

Parameters:

Return Value:

Returns true if the mapping exists, in which case, the TULongPair passed in is changed to reflect where the mapping maps to.

Exceptions:

Throws no exceptions, passes all exceptions through.

Concurrency:

Not multithread safe.

Other Considerations:

None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.