ActiveLib
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
active::geometry::Polygon Class Reference

#include <Polygon.h>

Inheritance diagram for active::geometry::Polygon:
Inheritance graph
[legend]
Collaboration diagram for active::geometry::Polygon:
Collaboration graph
[legend]

Classes

struct  Index
 

Public Types

using base = container::Vector<PolyPoint>
 Base storage class for Polygon.
 
using Unique = std::unique_ptr<Polygon>
 Unique pointer.
 
using Shared = std::shared_ptr<Polygon>
 Shared pointer.
 
using Option = std::optional<Polygon>
 Optional.
 
- Public Types inherited from active::container::Vector< PolyPoint >
using base
 Base container type.
 
using value_type
 Stored type.
 
using size_type
 Container size (index) type.
 
using iterator
 Container iterator type.
 
using const_iterator
 Container const iterator type.
 

Public Member Functions

 Polygon (vertex_index size=defSize, part_index holeSize=0, bool isClosed=true)
 
 Polygon (const std::initializer_list< PolyPoint > &points, bool isClosed=true)
 
 Polygon (const Box &source, double angle=0.0)
 
 Polygon (const Polygon &source)
 
 Polygon (Polygon &&source) noexcept
 
virtual ~Polygon ()=default
 
virtual PolygonclonePtr () const
 
virtual PolygonmovePtr ()
 
virtual Polygon::Unique cloneGeometry () const
 
virtual Polygonoperator= (const Polygon &source)
 
virtual Polygonoperator= (Polygon &&source) noexcept
 
PolyPointoperator[] (vertex_index index)
 
const PolyPointoperator[] (vertex_index index) const
 
Polygon operator+ (const Point &offset) const
 
Polygonoperator+= (const Point &offset)
 
Polygon operator- (const Point &offset) const
 
Polygonoperator-= (const Point &offset)
 
Polygon operator* (const double &mult) const
 
Polygonoperator*= (const double &mult)
 
Polygon operator* (const Matrix3x3 &mult) const
 
Polygonoperator*= (const Matrix3x3 &mult)
 
Polygon operator* (const Matrix4x4 &mult) const
 
Polygonoperator*= (const Matrix4x4 &mult)
 
Polygon operator/ (const double &mult) const
 
Polygonoperator/= (const double &mult)
 
virtual bool isValid (bool doIntersect=false, double prec=math::eps) const
 
bool isEqual2D (const Polygon &ref, double prec=math::eps) const
 
bool isEqual3D (const Polygon &ref, double prec=math::eps) const
 
vertex_index vertSize (bool isOuter=true) const
 
vertex_index edgeSize () const
 
part_index getHoleSize () const
 
vertex_id getTopID () const
 
PolygongetHole (part_index which) const
 
PolyVectorgetHoles () const
 
std::optional< RotationgetDirection () const
 
Box::Option bounds () const
 
double getPerimeter2D () const
 
double getPerimeter3D () const
 
vertex_index tracePerimeter (double len, PolyPoint &endPos) const
 
double getArea (bool isNet=true, bool isResultSigned=false) const
 
double getInternalAngleAt (vertex_index index) const
 
bool isTangentialAt (vertex_index vertex, double anglePrec=math::epsAngle) const
 
bool isReflection (vertex_index index, const LinEquation &ref, double prec=math::eps) const
 
Point::Option getInternalPoint () const
 
std::optional< IndexfindVertexById (vertex_id ID) const
 
std::optional< IndexfindVertexByLocation (const Point &pt, double prec=math::eps) const
 
const PolygongetShape (part_index index) const
 
PolygongetShape (part_index index)
 
base::iterator iteratorAt (vertex_index index)
 
base::const_iterator iteratorAt (vertex_index index) const
 
vertex_index wrapIndex (vertex_index index) const
 
XPoint closestPointAlong3D (const Point &ref, bool withHoles, double prec=math::eps) const
 
XPoint closestPointAlong2D (const Point &ref, bool withHoles, double prec=math::eps) const
 
Position positionOf (const Point &ref, double prec=math::eps) const
 
vertex_index intersectionWith (const Line &ref, XList &inter, double prec=math::eps) const
 
vertex_index intersectionWith (const Arc &ref, XList &inter, double prec=math::eps) const
 
vertex_index intersectionWith (const PolyEdge &ref, XList &inter, double prec=math::eps) const
 
vertex_index intersectionWith (const Polygon &ref, XList &inter, double prec=math::eps) const
 
void splitWith (const LinEquation &ref, PolyVector *polyRight=nullptr, PolyVector *polyLeft=nullptr, double prec=math::eps) const
 
void splitWith (const Polygon &ref, PolyVector *polyIn=nullptr, PolyVector *polyOut=nullptr, double prec=math::eps) const
 
part_index resolveSelfIntersect (PolyVector &resolved, double prec=math::eps) const
 
bool crosses (const Line &ref, double prec=math::eps) const
 
bool encloses (const Point &ref, double prec=math::eps) const
 
bool encloses (const Polygon &ref, double prec=math::eps) const
 
bool overlaps (const Polygon &ref, double prec=math::eps) const
 
vertex_id allocateID ()
 
void setTopID (vertex_id topId)
 
void clear (bool allVertices=true, bool allHoles=true)
 
PolygoninsertHole (const Polygon &hole)
 
PolygoninsertHole (Polygon *hole=nullptr)
 
PolygonemplaceHole (Polygon::Unique &&hole)
 
PolygonemplaceHole (Polygon &&hole)
 
void setHoles (std::unique_ptr< PolyVector > &&holes=nullptr)
 
void setHoles (PolyVector &&hole)
 
void removeHole (part_index which)
 
Polygon::Unique releaseHole (part_index which)
 
vertex_id addNodeAlong (vertex_id ID, const Point &pos, double prec=math::eps)
 
virtual bool insertUniqueVertex (PolyPoint &&pt, vertOption where=std::nullopt)
 
std::unique_ptr< PolyVectorreleaseHoles ()
 
virtual void setDirection (Rotation direct=clockwise, bool withHoles=true, bool invertHoleDir=false)
 
virtual void reverse ()
 
bool removeDuplicates2D (double prec=math::eps)
 
bool removeDuplicates3D (double prec=math::eps)
 
void optimise (bool doColin=false, double prec=math::eps)
 
void renumber (bool restart=false)
 
void facet ()
 
void setBaseLevel (double z=0)
 
void alignTo (const Plane &plane)
 
- Public Member Functions inherited from active::container::Vector< PolyPoint >
 Vector (size_type toReserve=0)
 
 Vector (const std::initializer_list< Derived > &items)
 
 Vector (const Vector &source)
 
 Vector (Vector &&source)
 
virtual ~Vector ()=default
 
auto operator= (const Vector &source)
 
auto operator= (Vector &&source)
 
void push_back (PolyPoint *item)
 
void emplace_back (PolyPoint &&item)
 
void emplace_back (const PolyPoint &item)
 
void emplace_back (value_type &&item)
 
void emplace_back (value_type &item)
 
auto insert (const_iterator pos, PolyPoint *item)
 
auto emplace (const_iterator pos, PolyPoint &&item)
 
auto emplace (const_iterator pos, value_type &item)
 
auto release (iterator &pos)
 
auto release (const_iterator pos)
 
- Public Member Functions inherited from active::utility::Cloner
virtual ~Cloner ()=default
 
- Public Member Functions inherited from active::utility::Mover
virtual ~Mover ()=default
 

Public Attributes

bool isHole = false
 True if the polygon is a hole.
 
bool isClosed = true
 True if the polygon is closed, i.e. an edge is assumed from the last vertex to the first.
 

Static Public Attributes

static const vertex_index defSize = 5
 The default number of vertices in a new polygon.
 

Detailed Description

A class to represent a polygon (or open polyline)

NB: Refer to PolyPoint for an description of the vertex/edge class. A polygon/polyline is simply an array of PolyPoint objects (or objects serived from PolyPoint). Note that using an array of polymorphic objects (allocated on the heap) is intentional. Although not as fast as a contiguous allocation for the entire array, supporting a polymorphic vertex type supports additional metadata describing the edge leading to the edge (or the vertex itself in some cases). The base PolyPoint class only defines a sweep angle for the edge, but polygonal shapes often add more information, e.g. graphic attributes (colour/linetype/etc) or 3D properties (edge profile/visibility/etc). Maintaining parallel arrays or vertices and edges compounds the complexity of all functions that mutate the polygon shape. Any function processing or mutating polygon vertices can treat any polygon in the same way irrespective of the associated metadata. Although there is a slight speed penalty to this approach, the ease of managing polygon content outweighs it (and alernative may not ultimately prove to be faster).

A Polygon can be marked as open or closed - open simply means there is no edge connecting the first and last vertex, i.e. an open polyline. This modifies functions like edgeSize (counts the number of edges) which will be less than the number or vertices for open polylines. Closure should not be denoted by duplicating the first into the last (this is seen as a redundancy at best).

The Polygon array acts like a loop for indexing or subscripting into a specific vertex, e.g. the last vertex can be accessed like this:

auto lastVertex = polygon[-1];

Therefore it is impossible for the index to be out of range (unless the polygon is empty). This greatly simplifies algorithms that iterate through the edges - it is perfectly valid to write:

    double len = 0.0;
    for (auto vertex = edgeSize(); vertex--; )
        len += (*this)[vertex + 1]->lengthFrom2D(*(*this)[vertex]);

…where vertex + 1 will exceed the array bounds and loop back to the first vertex (0).

Constructor & Destructor Documentation

◆ Polygon() [1/5]

Polygon::Polygon ( vertex_index size = defSize,
part_index holeSize = 0,
bool isClosed = true )

Constructor

Parameters
sizeThe number of vertices to reserve space for
holeSizeThe number of holes to reserve space for
isClosedSet to true if this polygon is closed
Here is the caller graph for this function:

◆ Polygon() [2/5]

active::geometry::Polygon::Polygon ( const std::initializer_list< PolyPoint > & points,
bool isClosed = true )
inline

Constructor

Parameters
pointsThe polygon vertices
isClosedSet to true if this polygon is closed

◆ Polygon() [3/5]

Polygon::Polygon ( const Box & source,
double angle = 0.0 )

Constructor

Parameters
sourceThe box to base the construction of this polygon on
angleThe rotation angle of the box
Here is the call graph for this function:

◆ Polygon() [4/5]

Polygon::Polygon ( const Polygon & source)

Copy constructor

Parameters
sourceThe object to copy

◆ Polygon() [5/5]

Polygon::Polygon ( Polygon && source)
noexcept

Move constructor

Parameters
sourceThe object to move

◆ ~Polygon()

virtual active::geometry::Polygon::~Polygon ( )
virtualdefault

Destructor

Member Function Documentation

◆ addNodeAlong()

vertex_id Polygon::addNodeAlong ( vertex_id ID,
const Point & pos,
double prec = math::eps )

Introduce a new node along the specified polygon edge

Parameters
IDThe ID of the edge vertex to start searching from
posThe coordinates of the new node
precThe required precision
Returns
The ID of the new node (0 on failure)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ alignTo()

void Polygon::alignTo ( const Plane & plane)

Align the z coordinates of the polygon vertices to a specified plane

Parameters
planeThe plane to align the polygon to
Here is the call graph for this function:

◆ allocateID()

vertex_id active::geometry::Polygon::allocateID ( )
inline

Allocate a new vertex ID

Returns
A new vertex ID
Here is the caller graph for this function:

◆ bounds()

Box::Option Polygon::bounds ( ) const

Get the polygon bounds

Returns
The polygon bounds
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void Polygon::clear ( bool allVertices = true,
bool allHoles = true )

Clear the specified polygon content

Parameters
allVerticesTrue to clear all vertices
allHolesTrue to clear all holes
Here is the caller graph for this function:

◆ cloneGeometry()

Polygon::Unique Polygon::cloneGeometry ( ) const
virtual

Clone method, copying just the raw geometry (all vertices will be reduced to PolyPoints)

Returns
A duplicate of this object's geometry

◆ clonePtr()

virtual Polygon * active::geometry::Polygon::clonePtr ( ) const
inlinevirtual

Clone method

Returns
A duplicate of this object

Implements active::utility::Cloner.

Here is the call graph for this function:

◆ closestPointAlong2D()

XPoint Polygon::closestPointAlong2D ( const Point & ref,
bool withHoles,
double prec = math::eps ) const

Get the closest point in the polygon to a given point in 2D

Parameters
refThe reference point
precThe required precision
Returns
The closest point in the polygon to the reference point, coupled with the intercept position info
Here is the call graph for this function:
Here is the caller graph for this function:

◆ closestPointAlong3D()

XPoint Polygon::closestPointAlong3D ( const Point & ref,
bool withHoles,
double prec = math::eps ) const

Get the closest point in the polygon to a given point in 3D

Parameters
refThe reference point
precThe required precision
Returns
The closest point in the polygon to the reference point, coupled with the intercept position info
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crosses()

bool Polygon::crosses ( const Line & ref,
double prec = math::eps ) const

Determine if this crosses a specified line (not just touching)

Parameters
refThe reference line
precThe required precision
Returns
True if the polygon perimeter crosses the line
Here is the call graph for this function:

◆ edgeSize()

vertex_index active::geometry::Polygon::edgeSize ( ) const
inline

Get the number of edges in the polygon

Returns
The number of edges (dependent on whether a closed path is defined)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emplaceHole() [1/2]

Polygon * Polygon::emplaceHole ( Polygon && hole)

Emplace a hole in the polygon

Parameters
holeThe hole to emplace
Returns
The emplaced hole
Here is the call graph for this function:

◆ emplaceHole() [2/2]

Polygon * Polygon::emplaceHole ( Polygon::Unique && hole)

Emplace a hole in the polygon

Parameters
holeThe hole to emplace
Returns
The emplaced hole
Here is the caller graph for this function:

◆ encloses() [1/2]

bool Polygon::encloses ( const Point & ref,
double prec = math::eps ) const

Determine if the this encloses a specified point (closure assumed)

Parameters
refThe reference point
precThe required precision
Returns
True if the point is enclosed by the polygon (in or along)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ encloses() [2/2]

bool Polygon::encloses ( const Polygon & ref,
double prec = math::eps ) const

Determine if the this encloses a specified polygon (closure assumed)

Parameters
refThe reference point
precThe required precision
Returns
True if the polygon is enclosed by this (in or along)
Here is the call graph for this function:

◆ facet()

void Polygon::facet ( )

Facet the curved edges on the polygon

Here is the call graph for this function:

◆ findVertexById()

std::optional< Polygon::Index > Polygon::findVertexById ( vertex_id ID) const

Find a vertex with the specified ID (optionally searching holes)

Parameters
IDThe ID to search for
Returns
The index of a vertex with the specified ID (nullopt on failure)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findVertexByLocation()

std::optional< Polygon::Index > Polygon::findVertexByLocation ( const Point & pt,
double prec = math::eps ) const

Find a vertex at the specified point

Parameters
ptThe point to match
precThe required precision
Returns
The index of a vertex at the specified point (npos = failure)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getArea()

double Polygon::getArea ( bool isNet = true,
bool isResultSigned = false ) const

Calculate the polygon area (closure assumed)

Parameters
isNetTrue if the net area is calculated (less holes)
isResultSignedTrue if the result should be signed (reflecting the polygon direction)
Returns
The total area
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDirection()

std::optional< Rotation > Polygon::getDirection ( ) const

Get the direction of the polygon

Returns
The polygon direction (nullopt if the polygon is invalid)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getHole()

Polygon * Polygon::getHole ( part_index which) const

Get the requested hole

Parameters
whichThe index of the polygon to get
Returns
The requested polygon
Here is the caller graph for this function:

◆ getHoles()

PolyVector * active::geometry::Polygon::getHoles ( ) const
inline

Get the list of holes in this polygon

Returns
The list of holes in this polygon

◆ getHoleSize()

part_index Polygon::getHoleSize ( ) const

Get the number of holes in the polygon

Returns
The number of holes in the polygon
Here is the caller graph for this function:

◆ getInternalAngleAt()

double Polygon::getInternalAngleAt ( vertex_index index) const

Get the internal angle between the edges at the given index index The vertex index return The angle between the two edges

Here is the call graph for this function:

◆ getInternalPoint()

Point::Option Polygon::getInternalPoint ( ) const

Get a point inside the polygon

Returns
A point inside the polygon (nullopt on failure)
Here is the call graph for this function:

◆ getPerimeter2D()

double Polygon::getPerimeter2D ( ) const

Calculate the polygon perimeter (non-closure handled)

Returns
The total perimeter (plan only)
Here is the call graph for this function:

◆ getPerimeter3D()

double Polygon::getPerimeter3D ( ) const

Calculate the polygon perimeter (non-closure handled)

Returns
The total perimeter (3D polyline)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getShape() [1/2]

Polygon & Polygon::getShape ( part_index index)

Get one of the subpolygons of which this polygon consists

Parameters
indexThe index of the shape
Returns
If index == 0, the polygon itself, otherwise the hole with number index - 1
Here is the call graph for this function:

◆ getShape() [2/2]

const Polygon & Polygon::getShape ( part_index index) const

Get one of the subpolygons of which this polygon consists

Parameters
indexThe index of the shape
Returns
If index == 0, the polygon itself, otherwise the hole with number index - 1
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTopID()

vertex_id active::geometry::Polygon::getTopID ( ) const
inline

Get the highest vertex ID

Returns
The highest vertex ID
Here is the caller graph for this function:

◆ insertHole() [1/2]

Polygon * Polygon::insertHole ( const Polygon & hole)

Insert a hole in the polygon

Parameters
holeThe hole to insert
Returns
The inserted hole
Here is the call graph for this function:

◆ insertHole() [2/2]

Polygon * Polygon::insertHole ( Polygon * hole = nullptr)

Insert a hole in the polygon

Parameters
holeThe hole to insert (nullptr = create a new polygon)
Returns
The inserted hole
Here is the call graph for this function:

◆ insertUniqueVertex()

bool Polygon::insertUniqueVertex ( PolyPoint && pt,
vertOption where = std::nullopt )
virtual

Insert a new node to a polygon, testing that the vertex is unique

Parameters
ptThe new node to insert
whereThe position to insert the new point (nullopt = at the end)
Returns
True if the new vertex is unique (not inserted if false)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersectionWith() [1/4]

vertex_index Polygon::intersectionWith ( const Arc & ref,
XList & inter,
double prec = math::eps ) const

Get the intersection(s) between this polygon and an arc

Parameters
refThe reference arc
interThe intersection list to populate
precThe required precision
Returns
The number of intersections calculated
Here is the call graph for this function:

◆ intersectionWith() [2/4]

vertex_index Polygon::intersectionWith ( const Line & ref,
XList & inter,
double prec = math::eps ) const

Get the intersection(s) between this polygon and a line

Parameters
refThe reference line
interThe intersection list to populate
precThe required precision
Returns
The number of intersections calculated
Here is the call graph for this function:
Here is the caller graph for this function:

◆ intersectionWith() [3/4]

vertex_index Polygon::intersectionWith ( const PolyEdge & ref,
XList & inter,
double prec = math::eps ) const

Get the intersection(s) between this polygon and a poly-edge

Parameters
refThe reference poly-edge
interThe intersection list to populate
precThe required precision
Returns
The number of intersections calculated
Here is the call graph for this function:

◆ intersectionWith() [4/4]

vertex_index Polygon::intersectionWith ( const Polygon & ref,
XList & inter,
double prec = math::eps ) const

Get the intersection(s) between this polygon and another polygon

Parameters
refThe reference polygon
interThe intersection list to populate
precThe required precision
Returns
The number of intersections calculated
Here is the call graph for this function:

◆ isEqual2D()

bool Polygon::isEqual2D ( const Polygon & ref,
double prec = math::eps ) const

Determine if two polygons are equal in 2D

Parameters
refThe polygon to compare
precThe required precision
Returns
True if the polygons are identical
Here is the call graph for this function:

◆ isEqual3D()

bool Polygon::isEqual3D ( const Polygon & ref,
double prec = math::eps ) const

Determine if two polygons are equal in 3D

Parameters
refThe polygon to compare
precThe required precision
Returns
True if the polygons are identical
Here is the call graph for this function:

◆ isReflection()

bool Polygon::isReflection ( vertex_index index,
const LinEquation & ref,
double prec = math::eps ) const

Determine if the polygon reflects off a specified line at a specified vertex

Parameters
indexThe index of the vertex to test
refThe reference line
precThe required precision
Returns
True if a reflection ocurrs at the specified index
Here is the call graph for this function:

◆ isTangentialAt()

bool Polygon::isTangentialAt ( vertex_index vertex,
double anglePrec = math::epsAngle ) const

Determine if the edges at a specified vertex are tangential

Parameters
vertexThe index of the vertex to check
anglePrecThe angle precision
Returns
true if the incident and emerging edges are tangential
Here is the call graph for this function:

◆ isValid()

bool Polygon::isValid ( bool doIntersect = false,
double prec = math::eps ) const
virtual

Determine if the polygon is valid (must have 2 or more vertices)

Parameters
doIntersectTrue if the polygon should be checked for intersecting edges (crossing each other)
precThe required precision
Returns
True if this is a valid polygon
Here is the call graph for this function:
Here is the caller graph for this function:

◆ iteratorAt() [1/2]

Polygon::base::iterator Polygon::iteratorAt ( vertex_index index)

Get an iterator pointing to the specified vertex

Parameters
indexThe vertex index (will be wrapped)
Returns
The requested iterator
Here is the call graph for this function:

◆ iteratorAt() [2/2]

Polygon::base::const_iterator Polygon::iteratorAt ( vertex_index index) const

Get an iterator pointing to the specified vertex

Parameters
indexThe vertex index (will be wrapped)
Returns
The requested iterator
Here is the call graph for this function:

◆ movePtr()

virtual Polygon * active::geometry::Polygon::movePtr ( )
inlinevirtual

Object cloning with move

Returns
A clone of this object with resources moved to the clone

Implements active::utility::Mover.

Here is the call graph for this function:

◆ operator*() [1/3]

Polygon Polygon::operator* ( const double & mult) const

Multiplication operator

Parameters
multThe amount to scale the polygon by
Returns
A scaled copy of this

◆ operator*() [2/3]

Polygon Polygon::operator* ( const Matrix3x3 & mult) const

Multiplication operator

Parameters
multThe matrix to multiply the polygon by
Returns
The result

◆ operator*() [3/3]

Polygon Polygon::operator* ( const Matrix4x4 & mult) const

Multiplication operator

Parameters
multThe matrix to multiply the polygon by
Returns
The result

◆ operator*=() [1/3]

Polygon & Polygon::operator*= ( const double & mult)

Multiplication with assignment operator

Parameters
multThe amount to scale the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator*=() [2/3]

Polygon & Polygon::operator*= ( const Matrix3x3 & mult)

Multiplication with assignment operator

Parameters
multThe matrix to multiply the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator*=() [3/3]

Polygon & Polygon::operator*= ( const Matrix4x4 & mult)

Multiplication with assignment operator

Parameters
multThe matrix to multiply the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator+()

Polygon Polygon::operator+ ( const Point & offset) const

Addition operator

Parameters
offsetThe amount to offset the polygon by
Returns
An offset copy of this

◆ operator+=()

Polygon & Polygon::operator+= ( const Point & offset)

Addition with assignment operator

Parameters
offsetThe amount to offset the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator-()

Polygon Polygon::operator- ( const Point & offset) const

Subtraction operator

Parameters
offsetThe amount to offset the polygon by
Returns
An offset copy of this

◆ operator-=()

Polygon & Polygon::operator-= ( const Point & offset)

Subtraction with assignment operator

Parameters
offsetThe amount to offset the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator/()

Polygon Polygon::operator/ ( const double & mult) const

Division operator

Parameters
multThe amount to scale the polygon by
Returns
A scaled copy of this

◆ operator/=()

Polygon & Polygon::operator/= ( const double & mult)

Division with assignment operator

Parameters
multThe amount to scale the polygon by
Returns
A reference to this
Here is the call graph for this function:

◆ operator=() [1/2]

Polygon & Polygon::operator= ( const Polygon & source)
virtual

Assignment operator

Parameters
sourceThe object to copy
Returns
A reference to this
Here is the call graph for this function:

◆ operator=() [2/2]

Polygon & Polygon::operator= ( Polygon && source)
virtualnoexcept

Assignment operator

Parameters
sourceThe object to move
Returns
A reference to this
Here is the call graph for this function:

◆ operator[]() [1/2]

PolyPoint * Polygon::operator[] ( vertex_index index)

Subscript operator

Parameters
indexAn index into the polygon
Returns
The indexed vertex
Here is the call graph for this function:

◆ operator[]() [2/2]

const PolyPoint * Polygon::operator[] ( vertex_index index) const

Subscript operator

Parameters
indexAn index into the polygon
Returns
The indexed vertex
Here is the call graph for this function:

◆ optimise()

void Polygon::optimise ( bool doColin = false,
double prec = math::eps )

Optimise the polygon (eliminate duplicates, co-linear points) param doColin True if colinear points should be removed

Parameters
precThe required precision
Here is the call graph for this function:

◆ overlaps()

bool Polygon::overlaps ( const Polygon & ref,
double prec = math::eps ) const

Determine if the this overlaps a specified polygon (closure assumed)

Parameters
refThe reference point
precThe required precision
Returns
True if the polygon is overlapped by this (partial or total)
Here is the call graph for this function:

◆ positionOf()

Position Polygon::positionOf ( const Point & ref,
double prec = math::eps ) const

Get the position of a point relative to the polygon (closure assumed)

Parameters
refThe reference point
precThe required precision
Returns
The relative position
Here is the call graph for this function:
Here is the caller graph for this function:

◆ releaseHole()

Polygon::Unique Polygon::releaseHole ( part_index which)

Release a hole from the polygon

Parameters
whichThe index of the hole to release
Returns
The released hole polygon

◆ releaseHoles()

PolyVector::Unique Polygon::releaseHoles ( )

Remove the polygon holes and release them to the caller

Returns
The holes in the polygon

◆ removeDuplicates2D()

bool Polygon::removeDuplicates2D ( double prec = math::eps)

Remove duplicate adjoining vertices in 2D

Parameters
precThe required precision
Returns
True if duplicates were removed
Here is the call graph for this function:

◆ removeDuplicates3D()

bool Polygon::removeDuplicates3D ( double prec = math::eps)

Remove duplicate adjoining vertices in 3D

Parameters
precThe required precision
Returns
True if duplicates were removed
Here is the call graph for this function:

◆ removeHole()

void Polygon::removeHole ( part_index which)

Remove a hole from the polygon

Parameters
whichThe index of the hole to remove

◆ renumber()

void Polygon::renumber ( bool restart = false)

Renumber the polygon vertices

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resolveSelfIntersect()

part_index Polygon::resolveSelfIntersect ( PolyVector & resolved,
double prec = math::eps ) const

Resolve the polygon into a list of polygons with no self-intersection

Parameters
resolvedThe list of resolved polygons
precThe required precision
Returns
The number of resolved polygons created (0 if the polygon is already resolved)
Here is the call graph for this function:

◆ reverse()

void Polygon::reverse ( )
virtual

Reverse the polygon direction (clockwise/anticlockwise)

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBaseLevel()

void Polygon::setBaseLevel ( double z = 0)

Set the level (z coordinate) of all the polygon vertices

Parameters
zThe required level
Here is the call graph for this function:

◆ setDirection()

void Polygon::setDirection ( Rotation direct = clockwise,
bool withHoles = true,
bool invertHoleDir = false )
virtual

Redirect the order of the polygon in the specified direction

Parameters
directThe direction of the polygon
withHolesTrue to also set the direction of holes
invertHoleDirTrue to set the opposite sense for the holes
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setHoles() [1/2]

void active::geometry::Polygon::setHoles ( PolyVector && hole)

Set the holes in the polygon

Parameters
holeThe list of holes to set in the polygon

◆ setHoles() [2/2]

void active::geometry::Polygon::setHoles ( std::unique_ptr< PolyVector > && holes = nullptr)

Set the holes in the polygon

Parameters
holesThe list of holes to set in the polygon (nullptr to erase all)

◆ setTopID()

void active::geometry::Polygon::setTopID ( vertex_id topId)
inline

Set the highest vertex ID

Parameters
topIdThe highest vertex ID

◆ splitWith() [1/2]

void Polygon::splitWith ( const LinEquation & ref,
PolyVector * polyRight = nullptr,
PolyVector * polyLeft = nullptr,
double prec = math::eps ) const

Calculate the polygons created by splitting this polygon along a line

Parameters
refThe cutting line
polyRightThe split polygons to the right of the reference line (nullptr = discard)
polyLeftThe split polygons to the left of the reference line (nullptr = discard)
precThe required precision
Here is the call graph for this function:

◆ splitWith() [2/2]

void Polygon::splitWith ( const Polygon & ref,
PolyVector * polyIn = nullptr,
PolyVector * polyOut = nullptr,
double prec = math::eps ) const

Calculate the polygons created by splitting this polygon with another polygon

Parameters
refThe cutting polygon
polyInThe split polygons inside the reference polygon (nullptr = discard)
polyOutThe split polygons outside the reference polygon (nullptr = discard)
precThe required precision
Here is the call graph for this function:

◆ tracePerimeter()

vertex_index Polygon::tracePerimeter ( double len,
PolyPoint & endPos ) const

Trace the polygon perimeter for the specified length

Parameters
lenThe length to length for
endPosThe point reached
Returns
The index of the last vertex passed
Here is the call graph for this function:

◆ vertSize()

vertex_index Polygon::vertSize ( bool isOuter = true) const

Get the number of vertices in the polygon

Parameters
isOuterTrue to count the outer polygon vertices only (exclude holes)
Returns
The number of vertices
Here is the call graph for this function:
Here is the caller graph for this function:

◆ wrapIndex()

vertex_index Polygon::wrapIndex ( vertex_index index) const

Wrap an index into the polygon range

Parameters
indexThe index
Returns
The wrapped index
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: