Tri.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
*
* 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.
*
**********************************************************************/
#pragma once
#include <geos/geom/Coordinate.h>
#include <geos/triangulate/tri/TriList.h>
#include <memory>
// Forward declarations
namespace geos {
namespace geom {
class Geometry;
class GeometryFactory;
class Polygon;
}
}
namespace geos { // geos.
namespace triangulate { // geos.triangulate
namespace tri { // geos.triangulate.tri
class GEOS_DLL Tri {
using Coordinate = geos::geom::Coordinate;
using Polygon = geos::geom::Polygon;
using Geometry = geos::geom::Geometry;
using GeometryFactory = geos::geom::GeometryFactory;
protected:
// Members
Coordinate p0;
Coordinate p1;
Coordinate p2;
Tri* tri0;
Tri* tri1;
Tri* tri2;
private:
void replace(Tri* triOld, Tri* triNew);
void remove(TriIndex index);
std::vector<Tri*> getAdjacentTris(Tri* tri, TriIndex index0, TriIndex index1);
void setCoordinates(const Coordinate& p0, const Coordinate& p1, const Coordinate& p2);
void flip(Tri* tri, TriIndex index0, TriIndex index1,
const Coordinate& adj0, const Coordinate& adj1,
const Coordinate& opp0, const Coordinate& opp1);
public:
Tri(const Coordinate& c0, const Coordinate& c1, const Coordinate& c2)
: p0(c0)
, p1(c1)
, p2(c2)
, tri0(nullptr)
, tri1(nullptr)
, tri2(nullptr)
{};
void setAdjacent(Tri* p_tri0, Tri* p_tri1, Tri* p_tri2);
void setAdjacent(const Coordinate& pt, Tri* tri);
void setTri(TriIndex edgeIndex, Tri* tri);
void flip(TriIndex index);
void remove();
void remove(TriList<Tri>& triList);
void validate();
void validateAdjacent(TriIndex index);
std::pair<const Coordinate&, const Coordinate&> getEdge(Tri* neighbor) const;
const Coordinate& getEdgeStart(TriIndex i) const;
const Coordinate& getEdgeEnd(TriIndex i) const;
bool hasCoordinate(const Coordinate& v) const;
const Coordinate& getCoordinate(TriIndex i) const;
TriIndex getIndex(const Coordinate& p) const;
TriIndex getIndex(const Tri* tri) const;
Tri* getAdjacent(TriIndex i) const;
bool hasAdjacent(TriIndex i) const;
bool hasAdjacent() const;
bool isAdjacent(Tri* tri) const;
int numAdjacent() const;
static TriIndex next(TriIndex i);
static TriIndex prev(TriIndex i);
static TriIndex oppVertex(TriIndex edgeIndex);
static TriIndex oppEdge(TriIndex vertexIndex);
bool isInteriorVertex(TriIndex index) const;
bool isBorder() const;
bool isBoundary(TriIndex index) const;
Coordinate midpoint(TriIndex edgeIndex) const;
double getArea() const;
double getLength() const;
double getLength(TriIndex i) const;
std::unique_ptr<Polygon> toPolygon(const GeometryFactory* gf) const;
static std::unique_ptr<Geometry> toGeometry(std::set<Tri*>& tris, const GeometryFactory* gf);
friend std::ostream& operator << (std::ostream& os, const Tri&);
};
} // namespace geos.triangulate.tri
} // namespace geos.triangulate
} // namespace geos
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition Polygon.h:61
geos::triangulate::tri::TriList
Definition TriList.h:50
geos::triangulate::tri::Tri
Definition Tri.h:45
geos::triangulate::tri::Tri::remove
void remove()
geos::triangulate::tri::Tri::isInteriorVertex
bool isInteriorVertex(TriIndex index) const
geos::triangulate::tri::Tri::flip
void flip(TriIndex index)
geos::triangulate::tri::Tri::tri0
Tri * tri0
Definition Tri.h:62
geos::geom
Definition Angle.h:26
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos::triangulate
Classes to compute Delaunay triangulations.
Definition ConcaveHull.h:32
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38