GEOS  3.9.1dev
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
geos::operation::buffer::OffsetSegmentGenerator Class Reference

#include <OffsetSegmentGenerator.h>

Collaboration diagram for geos::operation::buffer::OffsetSegmentGenerator:
[legend]

Public Member Functions

 OffsetSegmentGenerator (const geom::PrecisionModel *newPrecisionModel, const BufferParameters &bufParams, double distance)
 
bool hasNarrowConcaveAngle () const
 
void initSideSegments (const geom::Coordinate &nS1, const geom::Coordinate &nS2, int nSide)
 
void getCoordinates (std::vector< geom::CoordinateSequence * > &to)
 
void closeRing ()
 
void createCircle (const geom::Coordinate &p, double distance)
 Adds a CW circle around a point. More...
 
void createSquare (const geom::Coordinate &p, double distance)
 Adds a CW square around a point. More...
 
void addFirstSegment ()
 Add first offset point. More...
 
void addLastSegment ()
 Add last offset point. More...
 
void addNextSegment (const geom::Coordinate &p, bool addStartPoint)
 
void addLineEndCap (const geom::Coordinate &p0, const geom::Coordinate &p1)
 Add an end cap around point p1, terminating a line segment coming from p0. More...
 
void addSegments (const geom::CoordinateSequence &pts, bool isForward)
 

Private Member Functions

void addCollinear (bool addStartPoint)
 
void addMitreJoin (const geom::Coordinate &p, const geom::LineSegment &offset0, const geom::LineSegment &offset1, double distance)
 
void addLimitedMitreJoin (const geom::LineSegment &offset0, const geom::LineSegment &offset1, double distance, double mitreLimit)
 
void addBevelJoin (const geom::LineSegment &offset0, const geom::LineSegment &offset1)
 Adds a bevel join connecting the two offset segments around a reflex corner. More...
 
void init (double newDistance)
 
void addOutsideTurn (int orientation, bool addStartPoint)
 
void addInsideTurn (int orientation, bool addStartPoint)
 
void computeOffsetSegment (const geom::LineSegment &seg, int side, double distance, geom::LineSegment &offset)
 Compute an offset segment for an input segment on a given side and at a given distance. More...
 
void addDirectedFillet (const geom::Coordinate &p, const geom::Coordinate &p0, const geom::Coordinate &p1, int direction, double radius)
 
void addDirectedFillet (const geom::Coordinate &p, double startAngle, double endAngle, int direction, double radius)
 
 OffsetSegmentGenerator (const OffsetSegmentGenerator &)
 
void operator= (const OffsetSegmentGenerator &)
 

Private Attributes

double maxCurveSegmentError
 the max error of approximation (distance) between a quad segment and the true fillet curve More...
 
double filletAngleQuantum
 The angle quantum with which to approximate a fillet curve (based on the input # of quadrant segments) More...
 
int closingSegLengthFactor
 
OffsetSegmentString segList
 
double distance
 
const geom::PrecisionModelprecisionModel
 
const BufferParametersbufParams
 
algorithm::LineIntersector li
 
geom::Coordinate s0
 
geom::Coordinate s1
 
geom::Coordinate s2
 
geom::LineSegment seg0
 
geom::LineSegment seg1
 
geom::LineSegment offset0
 
geom::LineSegment offset1
 
int side
 
bool _hasNarrowConcaveAngle
 
int endCapIndex
 

Static Private Attributes

static const double OFFSET_SEGMENT_SEPARATION_FACTOR
 
static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR
 
static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR
 
static const int MAX_CLOSING_SEG_LEN_FACTOR = 80
 
static const double PI
 
static const double SIMPLIFY_FACTOR
 

Detailed Description

Generates segments which form an offset curve. Supports all end cap and join options provided for buffering. Implements various heuristics to produce smoother, simpler curves which are still within a reasonable tolerance of the true curve.

Author
Martin Davis

Definition at line 61 of file OffsetSegmentGenerator.h.

Constructor & Destructor Documentation

geos::operation::buffer::OffsetSegmentGenerator::OffsetSegmentGenerator ( const geom::PrecisionModel newPrecisionModel,
const BufferParameters bufParams,
double  distance 
)
geos::operation::buffer::OffsetSegmentGenerator::OffsetSegmentGenerator ( const OffsetSegmentGenerator )
private

Member Function Documentation

void geos::operation::buffer::OffsetSegmentGenerator::addBevelJoin ( const geom::LineSegment offset0,
const geom::LineSegment offset1 
)
private

Adds a bevel join connecting the two offset segments around a reflex corner.

Parameters
offset0the first offset segment
offset1the second offset segment
void geos::operation::buffer::OffsetSegmentGenerator::addCollinear ( bool  addStartPoint)
private
void geos::operation::buffer::OffsetSegmentGenerator::addDirectedFillet ( const geom::Coordinate p,
const geom::Coordinate p0,
const geom::Coordinate p1,
int  direction,
double  radius 
)
private

Adds points for a circular fillet around a reflex corner.

Adds the start and end points

Parameters
pbase point of curve
p0start point of fillet curve
p1endpoint of fillet curve
directionthe orientation of the fillet
radiusthe radius of the fillet
void geos::operation::buffer::OffsetSegmentGenerator::addDirectedFillet ( const geom::Coordinate p,
double  startAngle,
double  endAngle,
int  direction,
double  radius 
)
private

Adds points for a circular fillet arc between two specified angles.

The start and end point for the fillet are not added - the caller must add them if required.

Parameters
directionis -1 for a CW angle, 1 for a CCW angle
radiusthe radius of the fillet
void geos::operation::buffer::OffsetSegmentGenerator::addFirstSegment ( )
inline

Add first offset point.

Definition at line 124 of file OffsetSegmentGenerator.h.

void geos::operation::buffer::OffsetSegmentGenerator::addInsideTurn ( int  orientation,
bool  addStartPoint 
)
private

Adds the offset points for an inside (concave) turn

Parameters
orientation
addStartPoint
void geos::operation::buffer::OffsetSegmentGenerator::addLastSegment ( )
inline

Add last offset point.

Definition at line 131 of file OffsetSegmentGenerator.h.

void geos::operation::buffer::OffsetSegmentGenerator::addLimitedMitreJoin ( const geom::LineSegment offset0,
const geom::LineSegment offset1,
double  distance,
double  mitreLimit 
)
private

Adds a limited mitre join connecting the two reflex offset segments.

A limited mitre is a mitre which is beveled at the distance determined by the mitre ratio limit.

Parameters
offset0the first offset segment
offset1the second offset segment
distancethe offset distance
mitreLimitthe mitre limit ratio
void geos::operation::buffer::OffsetSegmentGenerator::addLineEndCap ( const geom::Coordinate p0,
const geom::Coordinate p1 
)

Add an end cap around point p1, terminating a line segment coming from p0.

void geos::operation::buffer::OffsetSegmentGenerator::addMitreJoin ( const geom::Coordinate p,
const geom::LineSegment offset0,
const geom::LineSegment offset1,
double  distance 
)
private

The mitre will be beveled if it exceeds the mitre ratio limit.

Parameters
offset0the first offset segment
offset1the second offset segment
distancethe offset distance
void geos::operation::buffer::OffsetSegmentGenerator::addNextSegment ( const geom::Coordinate p,
bool  addStartPoint 
)
void geos::operation::buffer::OffsetSegmentGenerator::addOutsideTurn ( int  orientation,
bool  addStartPoint 
)
private

Adds the offset points for an outside (convex) turn

Parameters
orientation
addStartPoint
void geos::operation::buffer::OffsetSegmentGenerator::addSegments ( const geom::CoordinateSequence pts,
bool  isForward 
)
inline

Definition at line 145 of file OffsetSegmentGenerator.h.

void geos::operation::buffer::OffsetSegmentGenerator::closeRing ( )
inline

Definition at line 111 of file OffsetSegmentGenerator.h.

void geos::operation::buffer::OffsetSegmentGenerator::computeOffsetSegment ( const geom::LineSegment seg,
int  side,
double  distance,
geom::LineSegment offset 
)
private

Compute an offset segment for an input segment on a given side and at a given distance.

The offset points are computed in full double precision, for accuracy.

Parameters
segthe segment to offset
sidethe side of the segment the offset lies on
distancethe offset distance
offsetthe points computed for the offset segment
void geos::operation::buffer::OffsetSegmentGenerator::createCircle ( const geom::Coordinate p,
double  distance 
)

Adds a CW circle around a point.

void geos::operation::buffer::OffsetSegmentGenerator::createSquare ( const geom::Coordinate p,
double  distance 
)

Adds a CW square around a point.

void geos::operation::buffer::OffsetSegmentGenerator::getCoordinates ( std::vector< geom::CoordinateSequence * > &  to)
inline

Get coordinates by taking ownership of them

After this call, the coordinates reference in this object are dropped. Calling twice will segfault...

FIXME: refactor memory management of this

Definition at line 105 of file OffsetSegmentGenerator.h.

bool geos::operation::buffer::OffsetSegmentGenerator::hasNarrowConcaveAngle ( ) const
inline

Tests whether the input has a narrow concave angle (relative to the offset distance). In this case the generated offset curve will contain self-intersections and heuristic closing segments. This is expected behaviour in the case of buffer curves. For pure offset curves, the output needs to be further treated before it can be used.

Returns
true if the input has a narrow concave angle

Definition at line 88 of file OffsetSegmentGenerator.h.

void geos::operation::buffer::OffsetSegmentGenerator::init ( double  newDistance)
private
void geos::operation::buffer::OffsetSegmentGenerator::initSideSegments ( const geom::Coordinate nS1,
const geom::Coordinate nS2,
int  nSide 
)
void geos::operation::buffer::OffsetSegmentGenerator::operator= ( const OffsetSegmentGenerator )
private

Member Data Documentation

bool geos::operation::buffer::OffsetSegmentGenerator::_hasNarrowConcaveAngle
private

Definition at line 235 of file OffsetSegmentGenerator.h.

const BufferParameters& geos::operation::buffer::OffsetSegmentGenerator::bufParams
private

Definition at line 219 of file OffsetSegmentGenerator.h.

int geos::operation::buffer::OffsetSegmentGenerator::closingSegLengthFactor
private

The Closing Segment Factor controls how long "closing segments" are. Closing segments are added at the middle of inside corners to ensure a smoother boundary for the buffer offset curve. In some cases (particularly for round joins with default-or-better quantization) the closing segments can be made quite short. This substantially improves performance (due to fewer intersections being created).

A closingSegFactor of 0 results in lines to the corner vertex. A closingSegFactor of 1 results in lines halfway to the corner vertex. A closingSegFactor of 80 results in lines 1/81 of the way to the corner vertex (this option is reasonable for the very common default situation of round joins and quadrantSegs >= 8).

The default is 1.

Definition at line 203 of file OffsetSegmentGenerator.h.

const double geos::operation::buffer::OffsetSegmentGenerator::CURVE_VERTEX_SNAP_DISTANCE_FACTOR
staticprivate

Factor which controls how close curve vertices can be to be snapped

Definition at line 167 of file OffsetSegmentGenerator.h.

double geos::operation::buffer::OffsetSegmentGenerator::distance
private

Definition at line 215 of file OffsetSegmentGenerator.h.

int geos::operation::buffer::OffsetSegmentGenerator::endCapIndex
private

Definition at line 278 of file OffsetSegmentGenerator.h.

double geos::operation::buffer::OffsetSegmentGenerator::filletAngleQuantum
private

The angle quantum with which to approximate a fillet curve (based on the input # of quadrant segments)

Definition at line 184 of file OffsetSegmentGenerator.h.

const double geos::operation::buffer::OffsetSegmentGenerator::INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR
staticprivate

Factor which controls how close curve vertices on inside turns can be to be snapped

Definition at line 162 of file OffsetSegmentGenerator.h.

algorithm::LineIntersector geos::operation::buffer::OffsetSegmentGenerator::li
private

Definition at line 221 of file OffsetSegmentGenerator.h.

const int geos::operation::buffer::OffsetSegmentGenerator::MAX_CLOSING_SEG_LEN_FACTOR = 80
staticprivate

Factor which determines how short closing segs can be for round buffers

Definition at line 172 of file OffsetSegmentGenerator.h.

double geos::operation::buffer::OffsetSegmentGenerator::maxCurveSegmentError
private

the max error of approximation (distance) between a quad segment and the true fillet curve

Definition at line 178 of file OffsetSegmentGenerator.h.

geom::LineSegment geos::operation::buffer::OffsetSegmentGenerator::offset0
private

Definition at line 229 of file OffsetSegmentGenerator.h.

geom::LineSegment geos::operation::buffer::OffsetSegmentGenerator::offset1
private

Definition at line 231 of file OffsetSegmentGenerator.h.

const double geos::operation::buffer::OffsetSegmentGenerator::OFFSET_SEGMENT_SEPARATION_FACTOR
staticprivate

Factor which controls how close offset segments can be to skip adding a filler or mitre.

Definition at line 156 of file OffsetSegmentGenerator.h.

const double geos::operation::buffer::OffsetSegmentGenerator::PI
staticprivate

Definition at line 275 of file OffsetSegmentGenerator.h.

const geom::PrecisionModel* geos::operation::buffer::OffsetSegmentGenerator::precisionModel
private

Definition at line 217 of file OffsetSegmentGenerator.h.

geom::Coordinate geos::operation::buffer::OffsetSegmentGenerator::s0
private

Definition at line 223 of file OffsetSegmentGenerator.h.

geom::Coordinate geos::operation::buffer::OffsetSegmentGenerator::s1
private

Definition at line 223 of file OffsetSegmentGenerator.h.

geom::Coordinate geos::operation::buffer::OffsetSegmentGenerator::s2
private

Definition at line 223 of file OffsetSegmentGenerator.h.

geom::LineSegment geos::operation::buffer::OffsetSegmentGenerator::seg0
private

Definition at line 225 of file OffsetSegmentGenerator.h.

geom::LineSegment geos::operation::buffer::OffsetSegmentGenerator::seg1
private

Definition at line 227 of file OffsetSegmentGenerator.h.

OffsetSegmentString geos::operation::buffer::OffsetSegmentGenerator::segList
private

Owned by this object, destroyed by dtor

This actually gets created multiple times and each of the old versions is pushed to the ptLists std::vector to ensure all created CoordinateSequences are properly destroyed.

Definition at line 213 of file OffsetSegmentGenerator.h.

int geos::operation::buffer::OffsetSegmentGenerator::side
private

Definition at line 233 of file OffsetSegmentGenerator.h.

const double geos::operation::buffer::OffsetSegmentGenerator::SIMPLIFY_FACTOR
staticprivate

Use a value which results in a potential distance error which is significantly less than the error due to the quadrant segment discretization. For QS = 8 a value of 100 is reasonable. This should produce a maximum of 1% distance error.

Definition at line 289 of file OffsetSegmentGenerator.h.


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