OffsetSegmentGenerator.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Public Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: operation/buffer/OffsetSegmentGenerator.java r378 (JTS-1.12)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <vector>
#include <geos/algorithm/LineIntersector.h> // for composition
#include <geos/geom/Coordinate.h> // for composition
#include <geos/geom/LineSegment.h> // for composition
#include <geos/operation/buffer/BufferParameters.h> // for composition
#include <geos/operation/buffer/OffsetSegmentString.h> // for composition
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
// Forward declarations
namespace geos {
namespace geom {
class CoordinateSequence;
class PrecisionModel;
}
}
namespace geos {
namespace operation { // geos.operation
namespace buffer { // geos.operation.buffer
class GEOS_DLL OffsetSegmentGenerator {
public:
/*
* @param nBufParams buffer parameters, this object will
* keep a reference to the passed parameters
* so caller must make sure the object is
* kept alive for the whole lifetime of
* the buffer builder.
*/
OffsetSegmentGenerator(const geom::PrecisionModel* newPrecisionModel,
const BufferParameters& bufParams, double distance);
bool
hasNarrowConcaveAngle() const
{
return _hasNarrowConcaveAngle;
}
void initSideSegments(const geom::Coordinate& nS1,
const geom::Coordinate& nS2, int nSide);
void
getCoordinates(std::vector<geom::CoordinateSequence*>& to)
{
to.push_back(segList.getCoordinates());
}
std::unique_ptr<geom::CoordinateSequence>
getCoordinates()
{
return std::unique_ptr<geom::CoordinateSequence>(segList.getCoordinates());
}
void
closeRing()
{
segList.closeRing();
}
void createCircle(const geom::Coordinate& p, double distance);
void createSquare(const geom::Coordinate& p, double distance);
void
addFirstSegment()
{
segList.addPt(offset1.p0);
}
void
addLastSegment()
{
segList.addPt(offset1.p1);
}
void addNextSegment(const geom::Coordinate& p, bool addStartPoint);
void addLineEndCap(const geom::Coordinate& p0,
const geom::Coordinate& p1);
void
addSegments(const geom::CoordinateSequence& pts, bool isForward)
{
segList.addPts(pts, isForward);
}
static void computeOffsetSegment(const geom::LineSegment& seg,
int side, double distance,
geom::LineSegment& offset);
private:
static const double OFFSET_SEGMENT_SEPARATION_FACTOR; // 1.0E-3;
static const double INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-3;
static const double CURVE_VERTEX_SNAP_DISTANCE_FACTOR; // 1.0E-6;
static const int MAX_CLOSING_SEG_LEN_FACTOR = 80;
double maxCurveSegmentError; // 0.0
double filletAngleQuantum;
int closingSegLengthFactor; // 1;
OffsetSegmentString segList;
double distance;
const geom::PrecisionModel* precisionModel;
const BufferParameters& bufParams;
algorithm::LineIntersector li;
geom::Coordinate s0, s1, s2;
geom::LineSegment seg0;
geom::LineSegment seg1;
geom::LineSegment offset0;
geom::LineSegment offset1;
int side;
bool _hasNarrowConcaveAngle; // =false
void addCollinear(bool addStartPoint);
void addMitreJoin(const geom::Coordinate& cornerPt,
const geom::LineSegment& offset0,
const geom::LineSegment& offset1,
double distance);
void addLimitedMitreJoin(
const geom::LineSegment& offset0,
const geom::LineSegment& offset1,
double distance,
double mitreLimitDistance);
static geom::LineSegment extend(const geom::LineSegment& seg, double dist);
static geom::Coordinate project(const geom::Coordinate& pt, double d, double dir);
void addBevelJoin(const geom::LineSegment& offset0,
const geom::LineSegment& offset1);
static const double PI; // 3.14159265358979
// Not in JTS, used for single-sided buffers
int endCapIndex;
void init(double newDistance);
static const double SIMPLIFY_FACTOR; // 100.0;
void addOutsideTurn(int orientation, bool addStartPoint);
void addInsideTurn(int orientation, bool addStartPoint);
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);
private:
// An OffsetSegmentGenerator cannot be copied because of member "const BufferParameters& bufParams"
// Not declaring these functions triggers MSVC warning C4512: "assignment operator could not be generated"
OffsetSegmentGenerator(const OffsetSegmentGenerator&);
void operator=(const OffsetSegmentGenerator&);
};
} // namespace geos::operation::buffer
} // namespace geos::operation
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::geom::CoordinateSequence
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:56
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::LineSegment
Definition LineSegment.h:61
geos::geom::PrecisionModel
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:87
geos::operation::buffer::BufferParameters
Contains the parameters which describe how a buffer should be constructed.
Definition BufferParameters.h:56
geos::operation::buffer::OffsetSegmentGenerator::addFirstSegment
void addFirstSegment()
Add first offset point.
Definition OffsetSegmentGenerator.h:129
geos::operation::buffer::OffsetSegmentGenerator::hasNarrowConcaveAngle
bool hasNarrowConcaveAngle() const
Definition OffsetSegmentGenerator.h:87
geos::operation::buffer::OffsetSegmentGenerator::addLastSegment
void addLastSegment()
Add last offset point.
Definition OffsetSegmentGenerator.h:136
geos::operation::buffer::OffsetSegmentGenerator::computeOffsetSegment
static 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.
geos::operation::buffer::OffsetSegmentGenerator::addLineEndCap
void addLineEndCap(const geom::Coordinate &p0, const geom::Coordinate &p1)
Add an end cap around point p1, terminating a line segment coming from p0.
geos::operation::buffer::OffsetSegmentGenerator::createSquare
void createSquare(const geom::Coordinate &p, double distance)
Adds a CW square around a point.
geos::operation::buffer::OffsetSegmentGenerator::createCircle
void createCircle(const geom::Coordinate &p, double distance)
Adds a CW circle around a point.
geos::operation::buffer::OffsetSegmentGenerator::getCoordinates
void getCoordinates(std::vector< geom::CoordinateSequence * > &to)
Definition OffsetSegmentGenerator.h:104
geos::operation::buffer::OffsetSegmentString
Definition OffsetSegmentString.h:41
geos::geom
Definition Angle.h:26
geos::operation::buffer
Provides classes for computing buffers of geometries.
Definition namespaces.h:182
geos::operation
Provides classes for implementing operations on geometries.
Definition CleanCoverage.h:34
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38