17#include <geos/geom/GeometryFactory.h>
19#include <geos/export.h>
41namespace triangulate {
53template<
typename TriType>
59 std::deque<TriType> triStore;
60 std::vector<TriType*> tris;
65 triStore.emplace_back(c0, c1, c2);
66 TriType* newTri = &triStore.back();
75 std::vector<TriType*>& getTris()
80 void remove(TriType* tri)
84 for (
auto it = tris.begin(); it != tris.end(); ++it) {
94 auto* newTri = create(c0, c1, c2);
95 tris.push_back(newTri);
98 void add(std::array<Coordinate, 3>& corner)
100 add(corner[0], corner[1], corner[2]);
106 for (
const auto* tri : tris) {
107 dArea += tri->getArea();
114 double dLength = 0.0;
115 for (
const auto* tri : tris) {
116 dLength += tri->getLength();
123 degree(
const TriType* tri, TriIndex index)
125 const Coordinate& v = tri->getCoordinate(index);
126 std::size_t szDegree = 0;
127 for (
auto* t : *
this) {
128 for (TriIndex i = 0; i < 3; i++) {
129 if (v.equals2D(t->getCoordinate(i)))
138 for (
auto* tri : *
this) {
143 std::unique_ptr<Geometry> toGeometry(
146 std::vector<std::unique_ptr<Geometry>> geoms;
147 for (
auto* tri: tris) {
148 std::unique_ptr<Geometry> geom = tri->toPolygon(geomFact);
149 geoms.emplace_back(geom.release());
154 friend std::ostream& operator << (std::ostream& os,
TriList& triList)
157 os <<
"[" << triList.size() <<
"] (";
158 for (
auto* tri: triList) {
159 os <<
" " << *tri <<
"," << std::endl;
166 typedef typename std::vector<TriType*>::iterator iterator;
167 typedef typename std::vector<TriType*>::const_iterator const_iterator;
168 size_t size()
const {
return tris.size(); }
169 bool empty()
const {
return tris.empty(); }
170 iterator begin() {
return tris.begin(); }
171 iterator end() {
return tris.end(); }
172 const_iterator begin()
const {
return tris.begin(); }
173 const_iterator end()
const {
return tris.end(); }
174 TriType* operator [] (std::size_t index) {
return tris[index]; }
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:58
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
std::unique_ptr< GeometryCollection > createGeometryCollection() const
Construct an EMPTY GeometryCollection.
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Basic namespace for all GEOS functionalities.
Definition: geos.h:39