InnerHatchRegion

class pyslm.hatching.InnerHatchRegion

Bases: abc.ABC

The InnerHatchRegion class provides a representation for a single sub-region used for efficiently generating various sub-scale hatch infills. This requires providing a boundary (boundary) to represent the region used. The user typically in derived BaseHatcher class should set via setRequiresClipping() if the region requires further clipping.

Finally the derived class must generate a set of hatch vectors covering the boundary region, by re-implementing the abstract method hatch(). If the boundary requires clipping, the interior hatches are also clipped.

Attributes Summary

orientation

The orientation describes the rotation of the local coordinate system with respect to the global coordinate system \((x,y)\).

origin

The origin is the \((x',y')\) position of the local coordinate system.

Methods Summary

boundary()

The boundary of the internal region

hatch()

The hatch method should provide a list of hatch vectors, within the boundary.

isIntersecting()

Returns True if the region requires additional clipping.

requiresClipping()

Returns True if the region requires additional clipping.

rotationMatrix2D()

Generates an affine matrix covering the transformation based on the origin and orientation based on a rotation around the local coordinate system.

rotationMatrix3D()

Generates an affine matrix covering the transformation based on the origin and orientation based on a rotation around the local coordinate system.

setIntersecting(intersectingState)

Setting True indicates the region has been intersected

setRequiresClipping(clippingState)

Sets the internal region to require additional clipping following hatch generation.

transformCoordinates(coords)

Transforms a set of (n x 3) coordinates with a sort id using the rotation angle InnerHatchRegion.orientation using the 3D rotation matrix in InnerHatchRegion.rotationMatrix3D().

transformCoordinates2D(coords)

Transforms a set of (n x 2) coordinates using the rotation angle InnerHatchRegion.orientation using the 2D rotation matrix in InnerHatchRegion.rotationMatrix2D().

Attributes Documentation

orientation

The orientation describes the rotation of the local coordinate system with respect to the global coordinate system \((x,y)\). The angle of rotation is given in rads.

Return type:

float

origin

The origin is the \((x',y')\) position of the local coordinate system.

Methods Documentation

abstract boundary()

The boundary of the internal region

Raises:

NotImplementedError

Return type:

Polygon

abstract hatch()

The hatch method should provide a list of hatch vectors, within the boundary. This must be re-implemented in the derived class. The hatch vectors should be ordered.

Raises:

NotImplementedError

Return type:

ndarray

isIntersecting()

Returns True if the region requires additional clipping.

Return type:

bool

requiresClipping()

Returns True if the region requires additional clipping.

Return type:

bool

rotationMatrix2D()

Generates an affine matrix covering the transformation based on the origin and orientation based on a rotation around the local coordinate system. This should be used when only a series of x,y coordinate required to be transformed.

Return type:

ndarray

Returns:

Affine Transformation Matrix

rotationMatrix3D()

Generates an affine matrix covering the transformation based on the origin and orientation based on a rotation around the local coordinate system. A pseudo third row and column is provided to retain the hatch sort id used.

Return type:

ndarray

Returns:

Affine Transformation Matrix

setIntersecting(intersectingState)

Setting True indicates the region has been intersected

Parameters:

intersectingState (bool) – True if the region intersects

Return type:

None

setRequiresClipping(clippingState)

Sets the internal region to require additional clipping following hatch generation.

Parameters:

clippingState (bool) – True if the region requires additional clipping

Return type:

None

transformCoordinates(coords)

Transforms a set of (n x 3) coordinates with a sort id using the rotation angle InnerHatchRegion.orientation using the 3D rotation matrix in InnerHatchRegion.rotationMatrix3D().

Parameters:

coords (ndarray) – (nx3) coordinates to be transformed

Return type:

ndarray

Returns:

The transformed coordinates

transformCoordinates2D(coords)

Transforms a set of (n x 2) coordinates using the rotation angle InnerHatchRegion.orientation using the 2D rotation matrix in InnerHatchRegion.rotationMatrix2D().

Parameters:

coords (ndarray) – (nx2) coordinates to be transformed

Return type:

ndarray

Returns:

The transformed coordinates