IntersectionAdder.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2006 Refractions Research Inc.
*
* 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: noding/IntersectionAdder.java rev. 1.6 (JTS-1.9)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <vector>
#include <iostream>
#include <cstdlib> // for abs()
#include <geos/geom/Coordinate.h>
#include <geos/noding/SegmentIntersector.h> // for inheritance
// Forward declarations
namespace geos {
namespace noding {
class SegmentString;
}
namespace algorithm {
class LineIntersector;
}
}
namespace geos {
namespace noding { // geos.noding
class GEOS_DLL IntersectionAdder: public SegmentIntersector {
private:
bool hasIntersectionVar;
bool hasProper;
bool hasProperInterior;
bool hasInterior;
// the proper intersection point found
geom::CoordinateXYZM properIntersectionPoint;
algorithm::LineIntersector& li;
// bool isSelfIntersection;
// bool intersectionFound;
bool isTrivialIntersection(const SegmentString* e0, std::size_t segIndex0,
const SegmentString* e1, std::size_t segIndex1);
// Declare type as noncopyable
IntersectionAdder(const IntersectionAdder& other) = delete;
IntersectionAdder& operator=(const IntersectionAdder& rhs) = delete;
public:
int numIntersections;
int numInteriorIntersections;
int numProperIntersections;
// testing only
int numTests;
IntersectionAdder(algorithm::LineIntersector& newLi)
:
hasIntersectionVar(false),
hasProper(false),
hasProperInterior(false),
hasInterior(false),
properIntersectionPoint(),
li(newLi),
numIntersections(0),
numInteriorIntersections(0),
numProperIntersections(0),
numTests(0)
{}
algorithm::LineIntersector&
getLineIntersector()
{
return li;
}
const geom::CoordinateXYZM&
getProperIntersectionPoint()
{
return properIntersectionPoint;
}
bool
hasIntersection()
{
return hasIntersectionVar;
}
bool
hasProperIntersection()
{
return hasProper;
}
bool
hasProperInteriorIntersection()
{
return hasProperInterior;
}
bool
hasInteriorIntersection()
{
return hasInterior;
}
void processIntersections(
SegmentString* e0, std::size_t segIndex0,
SegmentString* e1, std::size_t segIndex1) override;
static bool
isAdjacentSegments(std::size_t i1, std::size_t i2)
{
return (i1 > i2 ? i1 - i2 : i2 - i1) == 1;
}
bool
isDone() const override
{
return false;
}
};
} // namespace geos.noding
} // namespace geos
geos::algorithm::LineIntersector
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:53
geos::noding::IntersectionAdder::hasInteriorIntersection
bool hasInteriorIntersection()
An interior intersection is an intersection which is in the interior of some segment.
Definition IntersectionAdder.h:162
geos::noding::IntersectionAdder::processIntersections
void processIntersections(SegmentString *e0, std::size_t segIndex0, SegmentString *e1, std::size_t segIndex1) override
This method is called by clients of the SegmentIntersector class to process intersections for two seg...
geos::noding::IntersectionAdder::hasProperInteriorIntersection
bool hasProperInteriorIntersection()
A proper interior intersection is a proper intersection which is not contained in the set of boundary...
Definition IntersectionAdder.h:152
geos::noding::IntersectionAdder::isDone
bool isDone() const override
Always process all intersections.
Definition IntersectionAdder.h:193
geos::noding::IntersectionAdder::hasProperIntersection
bool hasProperIntersection()
A proper intersection is an intersection which is interior to at least two line segments.
Definition IntersectionAdder.h:142
geos::noding::IntersectionAdder::getProperIntersectionPoint
const geom::CoordinateXYZM & getProperIntersectionPoint()
Definition IntersectionAdder.h:121
geos::noding::SegmentString
An interface for classes which represent a sequence of contiguous line segments.
Definition SegmentString.h:47
geos::algorithm
Contains classes and interfaces implementing fundamental computational geometry algorithms.
Definition Angle.h:32
geos::noding
Classes to compute nodings for arrangements of line segments and line segment sequences.
Definition CoverageCleaner.h:42
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38