Inkscape
Vector Graphics Editor
|
A dynamic Polygon, to which points can be easily added and removed. More...
#include <geomtypes.h>
Public Member Functions | |
Polygon () | |
Constructs an empty polygon (with zero points). | |
Polygon (const int n) | |
Constructs a new polygon with n points. | |
Polygon (const PolygonInterface &poly) | |
Constructs a new polygon from an existing Polygon. | |
void | clear (void) |
Resets this to the empty polygon. | |
bool | empty (void) const |
Returns true if this polygon is empty. | |
size_t | size (void) const |
Returns the number of points in this polygon. | |
int | id (void) const |
Returns the ID value associated with this polygon. | |
const Point & | at (size_t index) const |
Returns a specific point in the polygon. | |
void | setPoint (size_t index, const Point &point) |
Sets a position for a particular point in the polygon. | |
Polygon | simplify (void) const |
Returns a simplified Polyline, where all collinear line segments have been collapsed down into single line segments. | |
Polygon | curvedPolyline (const double curve_amount, const bool closed=false) const |
Returns a curved approximation of this multi-segment PolyLine, with the corners replaced by smooth Bezier curves. | |
void | translate (const double xDist, const double yDist) |
Translates the polygon position by a relative amount. | |
std::vector< Point > | checkpointsOnSegment (size_t segmentLowerIndex, int indexModifier=0) const |
![]() | |
PolygonInterface () | |
Constructor. | |
virtual | ~PolygonInterface () |
Destructor. | |
Polygon | boundingRectPolygon (void) const |
Returns the bounding rectangle for this polygon. | |
Box | offsetBoundingBox (double offset) const |
Returns the bounding rectangle that contains this polygon with optionally some buffer space around it for routing. | |
Polygon | offsetPolygon (double offset) const |
Public Attributes | |
int | _id |
An ID for the polygon. | |
std::vector< Point > | ps |
A vector of the points that make up the Polygon. | |
std::vector< char > | ts |
If used, denotes whether the corresponding point in ps is a move-to operation or a Bezier curve-to. | |
std::vector< std::pair< size_t, Point > > | checkpointsOnRoute |
A dynamic Polygon, to which points can be easily added and removed.
Definition at line 207 of file geomtypes.h.
Avoid::Polygon::Polygon | ( | ) |
Constructs an empty polygon (with zero points).
Definition at line 254 of file geomtypes.cpp.
References clear().
Avoid::Polygon::Polygon | ( | const int | n | ) |
Constructs a new polygon with n points.
A rectangle would be comprised of four point. An n segment PolyLine (represented as a Polygon) would be comprised of n+1 points. Whether a particular Polygon is closed or not, depends on whether it is a Polygon or Polyline. Shape polygons are always considered to be closed, meaning the last point joins back to the first point.
The values for points can be set by setting the Polygon:ps vector, or via the Polygon::setPoint() method.
[in] | n | Number of points in the polygon. |
Definition at line 262 of file geomtypes.cpp.
Avoid::Polygon::Polygon | ( | const PolygonInterface & | poly | ) |
Constructs a new polygon from an existing Polygon.
[in] | poly | An existing polygon to copy the new polygon from. |
Definition at line 270 of file geomtypes.cpp.
References Avoid::PolygonInterface::at(), ps, and Avoid::PolygonInterface::size().
|
virtual |
Returns a specific point in the polygon.
[in] | index | The array index of the point to be returned. |
Implements Avoid::PolygonInterface.
Definition at line 390 of file geomtypes.cpp.
References index, ps, and size().
Referenced by Avoid::ConnRef::calcRouteDist(), Avoid::cost(), Avoid::HyperedgeImprover::execute(), Avoid::Router::existsInvalidOrthogonalPaths(), Avoid::ConnRef::generateStandardPath(), Avoid::Router::outputInstanceToSVG(), and Avoid::ConnRef::splitAtSegment().
std::vector< Point > Avoid::Polygon::checkpointsOnSegment | ( | size_t | segmentLowerIndex, |
int | indexModifier = 0 |
||
) | const |
Definition at line 594 of file geomtypes.cpp.
References checkpointsOnRoute, and index.
|
virtual |
Resets this to the empty polygon.
Implements Avoid::PolygonInterface.
Definition at line 365 of file geomtypes.cpp.
References clear(), ps, and ts.
Referenced by clear(), Avoid::ConnRef::ConnRef(), Avoid::ConnRef::ConnRef(), Avoid::ConnRef::freeRoutes(), Polygon(), and Avoid::HyperedgeTreeEdge::writeEdgesToConns().
Polygon Avoid::Polygon::curvedPolyline | ( | const double | curve_amount, |
const bool | closed = false |
||
) | const |
Returns a curved approximation of this multi-segment PolyLine, with the corners replaced by smooth Bezier curves.
This function does not do any further obstacle avoidance with the curves produced. Hence, you would usually specify a curve_amount in similar size to the space buffer around obstacles in the scene. This way the curves will cut the corners around shapes but still run within this buffer space.
curve_amount | Describes the distance along the end of each line segment to turn into a curve. |
closed | Describes whether the Polygon should be treated as closed. Defaults to false. |
Definition at line 640 of file geomtypes.cpp.
References _id, mode, ps, Avoid::SHORTEN_BOTH, Avoid::SHORTEN_END, Avoid::shorten_line(), Avoid::SHORTEN_START, simplify(), size(), and ts.
Referenced by SPConnEndPair::createCurve(), and Avoid::Router::outputInstanceToSVG().
|
virtual |
Returns true if this polygon is empty.
Implements Avoid::PolygonInterface.
Definition at line 372 of file geomtypes.cpp.
References ps.
Referenced by avoid_item_move(), Avoid::cost(), Avoid::ConnRef::displayRoute(), Avoid::Router::markPolylineConnectorsNeedingReroutingForDeletedObstacle(), Avoid::Router::outputDiagramSVG(), Avoid::Router::outputDiagramText(), Avoid::Router::outputInstanceToSVG(), Avoid::ShapeConnectionPin::position(), Avoid::Obstacle::routingBox(), Avoid::Obstacle::routingPolygon(), and Avoid::HyperedgeTreeEdge::writeEdgesToConns().
|
virtual |
Returns the ID value associated with this polygon.
Implements Avoid::PolygonInterface.
Definition at line 384 of file geomtypes.cpp.
References _id.
void Avoid::Polygon::setPoint | ( | size_t | index, |
const Point & | point | ||
) |
Polygon Avoid::Polygon::simplify | ( | void | ) | const |
Returns a simplified Polyline, where all collinear line segments have been collapsed down into single line segments.
Definition at line 532 of file geomtypes.cpp.
References checkpointsOnRoute, ps, size(), and Avoid::vecDir().
Referenced by curvedPolyline(), Avoid::ConnRef::displayRoute(), and Avoid::ConnRef::setFixedRoute().
|
virtual |
Returns the number of points in this polygon.
Implements Avoid::PolygonInterface.
Definition at line 378 of file geomtypes.cpp.
References ps.
Referenced by at(), Avoid::ReferencingPolygon::at(), Avoid::buildConnectorRouteCheckpointCache(), Avoid::ConnRef::calcRouteDist(), Avoid::cheapEstimatedCost(), Avoid::constructPolygonPath(), Avoid::cost(), Avoid::ConnectorCrossings::countForSegment(), SPConnEndPair::createCurve(), curvedPolyline(), Avoid::HyperedgeImprover::execute(), Avoid::Router::existsCrossings(), Avoid::Router::existsInvalidOrthogonalPaths(), Avoid::Router::existsOrthogonalFixedSegmentOverlap(), Avoid::Router::existsOrthogonalSegmentOverlap(), Avoid::Router::existsOrthogonalTouchingPaths(), Avoid::ConnRef::generateStandardPath(), SPAvoidRef::handleSettingChange(), Avoid::Router::improveCrossings(), Avoid::inPoly(), Avoid::inPolyGen(), main(), makeFeasible(), Avoid::Router::markPolylineConnectorsNeedingReroutingForDeletedObstacle(), Avoid::Router::newBlockingShape(), Avoid::Obstacle::Obstacle(), Avoid::PolygonInterface::offsetPolygon(), Avoid::ConnRef::outputCode(), Avoid::ShapeRef::outputCode(), Avoid::Router::outputDiagramSVG(), Avoid::Router::outputDiagramText(), Avoid::Router::outputInstanceToSVG(), Avoid::posInlineWithConnEndSegs(), Avoid::ReferencingPolygon::ReferencingPolygon(), Avoid::ConnRef::setFixedExistingRoute(), Avoid::ConnRef::setFixedRoute(), Avoid::Obstacle::setNewPoly(), setPoint(), simplify(), Avoid::ConnRef::splitAtSegment(), Avoid::totalLength(), and translate().
void Avoid::Polygon::translate | ( | const double | xDist, |
const double | yDist | ||
) |
Translates the polygon position by a relative amount.
[in] | xDist | Distance to move polygon in the x dimension. |
[in] | yDist | Distance to move polygon in the y dimension. |
Definition at line 522 of file geomtypes.cpp.
Referenced by Avoid::Router::moveShape(), and Avoid::ShapeRef::setCentrePos().
int Avoid::Polygon::_id |
An ID for the polygon.
Definition at line 283 of file geomtypes.h.
Referenced by curvedPolyline(), id(), main(), and Avoid::PolygonInterface::offsetPolygon().
std::vector<std::pair<size_t, Point> > Avoid::Polygon::checkpointsOnRoute |
Definition at line 314 of file geomtypes.h.
Referenced by Avoid::buildConnectorRouteCheckpointCache(), checkpointsOnSegment(), Avoid::clearConnectorRouteCheckpointCache(), and simplify().
std::vector<Point> Avoid::Polygon::ps |
A vector of the points that make up the Polygon.
Definition at line 285 of file geomtypes.h.
Referenced by at(), Avoid::ReferencingPolygon::at(), avoid_item_poly(), Avoid::buildConnectorRouteCheckpointCache(), Avoid::cheapEstimatedCost(), clear(), connCallback(), connCallback(), connCallback(), connCallback(), Avoid::constructPolygonPath(), Avoid::cost(), Avoid::ConnectorCrossings::countForSegment(), SPConnEndPair::createCurve(), curvedPolyline(), empty(), Avoid::ConnRef::generatePath(), Avoid::ConnRef::generateStandardPath(), Avoid::inPoly(), Avoid::inPolyGen(), main(), makeFeasible(), Avoid::Router::markPolylineConnectorsNeedingReroutingForDeletedObstacle(), Avoid::Router::newBlockingShape(), Avoid::Obstacle::Obstacle(), Avoid::PolygonInterface::offsetPolygon(), Avoid::ConnRef::outputCode(), Avoid::Router::outputDiagramSVG(), Avoid::Router::outputDiagramText(), Avoid::Router::outputInstanceToSVG(), Polygon(), Avoid::posInlineWithConnEndSegs(), Avoid::Rectangle::Rectangle(), Avoid::Rectangle::Rectangle(), Avoid::ReferencingPolygon::ReferencingPolygon(), Avoid::ConnRef::set_route(), Avoid::ConnRef::setFixedRoute(), Avoid::Obstacle::setNewPoly(), setPoint(), simplify(), size(), Avoid::splitBranchingSegments(), Avoid::totalLength(), translate(), and Avoid::HyperedgeTreeEdge::writeEdgesToConns().
std::vector<char> Avoid::Polygon::ts |
If used, denotes whether the corresponding point in ps is a move-to operation or a Bezier curve-to.
Each character describes the drawing operation for the corresponding point in the ps vector. Possible values are:
Definition at line 301 of file geomtypes.h.
Referenced by clear(), SPConnEndPair::createCurve(), curvedPolyline(), and Avoid::Router::outputInstanceToSVG().