VPTissue Reference Manual
SimPT_Editor::PolygonUtils Class Reference

Functions to manipulate polygons. More...

#include <PolygonUtils.h>

Collaboration diagram for SimPT_Editor::PolygonUtils:
Collaboration graph

Static Public Member Functions

static double CalculateArea (const QPolygonF &polygon)
 Calculate the area of a polygon. More...
 
static std::list< QPolygonF > ClipPolygon (const QPolygonF &polygon1, const QPolygonF &polygon2)
 Clip a polygon with another polygon and return the intersecting subpolygons. More...
 
static QPolygonF Counterclockwise (const QPolygonF &polygon)
 Checks if the order of the polygon's points is clockwise and if so, reverts it, else the original polygon is returned. More...
 
static bool IsClockwise (const QPolygonF &polygon)
 Checks whether the vertices of a polygon are ordered clockwise or counterclockwise. More...
 
static bool IsSimplePolygon (const QPolygonF &polygon)
 Checks whether a polygon is simple. More...
 
static QPolygonF OpenPolygon (const QPolygonF &polygon)
 Opens the polygon, ie. More...
 
static std::list< QPolygonF > SlicePolygon (const QPolygonF &polygon, QLineF cut)
 Slice an open, simple and valid polygon in multiple polygons with a given line. More...
 

Detailed Description

Functions to manipulate polygons.

Definition at line 30 of file PolygonUtils.h.

Member Function Documentation

double SimPT_Editor::PolygonUtils::CalculateArea ( const QPolygonF &  polygon)
static

Calculate the area of a polygon.

The polygon should be open, valid and simple.

Parameters
polygonThe given polygon.
Returns
The area of the polygon.

Definition at line 111 of file PolygonUtils.cpp.

References SimPT_Sim::Container::make_const_circular(), and SimPT_Sim::Container::next().

Here is the call graph for this function:

std::list< QPolygonF > SimPT_Editor::PolygonUtils::ClipPolygon ( const QPolygonF &  polygon1,
const QPolygonF &  polygon2 
)
static

Clip a polygon with another polygon and return the intersecting subpolygons.

The polygons should be open, valid and simple.

Parameters
polygon1The first polygon.
polygon2The second polygon.
Returns
The subpolygons, which are also open.

Definition at line 130 of file PolygonUtils.cpp.

References SimPT_Sim::Container::prev().

Referenced by SimPT_Editor::VoronoiTesselation::GetCellPolygons(), and SimPT_Editor::RegularGeneratorDialog::GetGeneratedPolygons().

Here is the call graph for this function:

Here is the caller graph for this function:

QPolygonF SimPT_Editor::PolygonUtils::Counterclockwise ( const QPolygonF &  polygon)
static

Checks if the order of the polygon's points is clockwise and if so, reverts it, else the original polygon is returned.

Clockwise and counterclockwise order of points is checked for in a standard right-handed coordinate system. The polygon should be simple, valid and open.

Parameters
polygonThe polygon to make counterclockwise.
Returns
The polygon in counterclockwise direction.

Definition at line 96 of file PolygonUtils.cpp.

Referenced by SimPT_Editor::VoronoiGeneratorDialog::GetGeneratedPolygons(), and SimPT_Editor::RegularGeneratorDialog::GetGeneratedPolygons().

Here is the caller graph for this function:

bool SimPT_Editor::PolygonUtils::IsClockwise ( const QPolygonF &  polygon)
static

Checks whether the vertices of a polygon are ordered clockwise or counterclockwise.

The polygon should be open, valid and simple.

Parameters
polygonThe given polygon.
Returns
True if the vertices are clockwise.

Definition at line 35 of file PolygonUtils.cpp.

References SimPT_Sim::Container::make_const_circular(), and SimPT_Sim::Container::next().

Referenced by SimPT_Editor::EditableMesh::CreateCell(), and SimPT_Editor::EditableMesh::ReplaceCell().

Here is the call graph for this function:

Here is the caller graph for this function:

bool SimPT_Editor::PolygonUtils::IsSimplePolygon ( const QPolygonF &  polygon)
static

Checks whether a polygon is simple.

The polygon should be open and valid.

Parameters
polygonThe given polygon.
Returns
True if the polygon is simple.

Definition at line 54 of file PolygonUtils.cpp.

References SimPT_Sim::Container::make_const_circular(), and SimPT_Sim::Container::next().

Here is the call graph for this function:

QPolygonF SimPT_Editor::PolygonUtils::OpenPolygon ( const QPolygonF &  polygon)
static

Opens the polygon, ie.

if the last point is equal to the first, a new polygon without the last point is returned, else the original polygon is returned. The polygon should be valid.

Parameters
polygonThe polygon to open.
Returns
The opened polygon if it was closed, or the same if it was already open.

Definition at line 83 of file PolygonUtils.cpp.

Referenced by SimPT_Editor::RegularGeneratorDialog::GetGeneratedPolygons().

Here is the caller graph for this function:

std::list< QPolygonF > SimPT_Editor::PolygonUtils::SlicePolygon ( const QPolygonF &  polygon,
QLineF  cut 
)
static

Slice an open, simple and valid polygon in multiple polygons with a given line.

The endpoints of the line should be located outside the polygon.

If there are no (useful) intersections, the original polygon will be returned.

Parameters
polygonThe given polygon.
cutThe given line.
Returns
The subpolygons, which are also open. These are in the same direction ((counter-)clockwise) as the given polygon.

Definition at line 227 of file PolygonUtils.cpp.

References SimPT_Sim::Container::make_const_circular(), SimPT_Sim::Container::next(), and SimPT_Sim::Container::prev().

Referenced by SimPT_Editor::EditableMesh::CanSplitCell(), SimPT_Editor::TissueSlicer::EndCut(), and SimPT_Editor::EditableMesh::SplitCell().

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: