GEOS 3.10.1
TriList.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************/
14
15#pragma once
16
17#include <geos/triangulate/tri/Tri.h>
18
19#include <geos/export.h>
20#include <iostream>
21#include <deque>
22#include <array>
23
24// Forward declarations
25namespace geos {
26namespace geom {
27class Coordinate;
28class Geometry;
29}
30}
31
34
35namespace geos { // geos.
36namespace triangulate { // geos.triangulate
37namespace tri { // geos.triangulate.tri
38
39
48class GEOS_DLL TriList {
49
50private:
51
52 // Members
53 std::deque<Tri> triStore;
54 std::vector<Tri*> tris;
55
56 // Methods
57 Tri* create(const Coordinate& c0, const Coordinate& c1, const Coordinate& c2);
58
59
60public:
61
62 TriList() {};
63
64 void add(const Coordinate& c0, const Coordinate& c1, const Coordinate& c2);
65
66 void add(std::array<Coordinate, 3>& corner)
67 {
68 add(corner[0], corner[1], corner[2]);
69 }
70
71 std::unique_ptr<Geometry> toGeometry(
72 const GeometryFactory* geomFact) const;
73
74 static std::unique_ptr<Geometry> toGeometry(
75 const geom::GeometryFactory* geomFact,
76 const std::vector<std::unique_ptr<TriList>>& allTriLists);
77
78 friend std::ostream& operator << (std::ostream& os, TriList& te);
79
80 // Support for iterating on TriList
81 typedef std::vector<Tri*>::iterator iterator;
82 typedef std::vector<Tri*>::const_iterator const_iterator;
83 size_t size() const { return tris.size(); }
84 bool empty() const { return tris.empty(); }
85 iterator begin() { return tris.begin(); }
86 iterator end() { return tris.end(); }
87 const_iterator begin() const { return tris.begin(); }
88 const_iterator end() const { return tris.end(); }
89 Tri* operator [] (std::size_t index) { return tris[index]; }
90
91};
92
93
94} // namespace geos.triangulate.tri
95} // namespace geos.triangulate
96} // namespace geos
97
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:68
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: TriList.h:48
Definition: Tri.h:50
Basic namespace for all GEOS functionalities.
Definition: geos.h:40