File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/CPP/geos.x/i/geos/triangulate/DelaunayTriangulationBuilder.h
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 3 3 100.0


line stmt bran cond sub pod time code
1             /**********************************************************************
2             *
3             * GEOS - Geometry Engine Open Source
4             * http://geos.osgeo.org
5             *
6             * Copyright (C) 2012 Excensus LLC.
7             *
8             * This is free software; you can redistribute and/or modify it under
9             * the terms of the GNU Lesser General Licence as published
10             * by the Free Software Foundation.
11             * See the COPYING file for more information.
12             *
13             **********************************************************************
14             *
15             * Last port: triangulate/DelaunayTriangulationBuilder.java r524
16             *
17             **********************************************************************/
18              
19             #ifndef GEOS_TRIANGULATE_DELAUNAYTRIANGULATIONBUILDER_H
20             #define GEOS_TRIANGULATE_DELAUNAYTRIANGULATIONBUILDER_H
21              
22             #include
23              
24              
25             namespace geos {
26             namespace geom{
27             class CoordinateSequence;
28             class Geometry;
29             class MultiLineString;
30             class GeometryCollection;
31             class GeometryFactory;
32             class Envelope;
33             }
34             namespace triangulate {
35             namespace quadedge {
36             class QuadEdgeSubdivision;
37             }
38             }
39             }
40              
41             namespace geos {
42             namespace triangulate { //geos.triangulate
43              
44              
45             /**
46             * A utility class which creates Delaunay Triangulations
47             * from collections of points and extract the resulting
48             * triangulation edges or triangles as geometries.
49             *
50             * @author JTS: Martin Davis
51             * @author Benjamin Campbell
52             *
53             */
54             class GEOS_DLL DelaunayTriangulationBuilder
55             {
56             public:
57             /**
58             * Extracts the unique {@link Coordinate}s from the given {@link Geometry}.
59             * @param geom the geometry to extract from
60             * @return a List of the unique Coordinates. Caller takes ownership of the returned object.
61             */
62             static geom::CoordinateSequence* extractUniqueCoordinates(const geom::Geometry& geom);
63              
64             static void unique(geom::CoordinateSequence& coords);
65              
66             /**
67             * Converts all {@link Coordinate}s in a collection to {@link Vertex}es.
68             * @param coords the coordinates to convert
69             * @return a List of Vertex objects. Call takes ownership of returned object.
70             */
71             static IncrementalDelaunayTriangulator::VertexList* toVertices(const geom::CoordinateSequence &coords);
72              
73             private:
74             geom::CoordinateSequence* siteCoords;
75             double tolerance;
76             quadedge::QuadEdgeSubdivision *subdiv;
77              
78             public:
79             /**
80             * Creates a new triangulation builder.
81             *
82             */
83             DelaunayTriangulationBuilder();
84              
85             ~DelaunayTriangulationBuilder();
86              
87             /**
88             * Sets the sites (vertices) which will be triangulated.
89             * All vertices of the given geometry will be used as sites.
90             *
91             * @param geom the geometry from which the sites will be extracted.
92             */
93             void setSites(const geom::Geometry& geom);
94              
95             /**
96             * Sets the sites (vertices) which will be triangulated
97             * from a collection of {@link Coordinate}s.
98             *
99             * @param geom a CoordinateSequence.
100             */
101             void setSites(const geom::CoordinateSequence& coords);
102              
103             /**
104             * Sets the snapping tolerance which will be used
105             * to improved the robustness of the triangulation computation.
106             * A tolerance of 0.0 specifies that no snapping will take place.
107             *
108             * @param tolerance the tolerance distance to use
109             */
110 1           inline void setTolerance(double tolerance)
111             {
112 1           this->tolerance = tolerance;
113 1           }
114              
115             private:
116             void create();
117              
118             public:
119             /**
120             * Gets the {@link quadedge::QuadEdgeSubdivision} which models the computed triangulation.
121             *
122             * @return the subdivision containing the triangulation
123             */
124             quadedge::QuadEdgeSubdivision& getSubdivision();
125              
126             /**
127             * Gets the edges of the computed triangulation as a {@link MultiLineString}.
128             *
129             * @param geomFact the geometry factory to use to create the output
130             * @return the edges of the triangulation. The caller takes ownership of the returned object.
131             */
132             std::unique_ptr getEdges(const geom::GeometryFactory &geomFact);
133              
134             /**
135             * Gets the faces of the computed triangulation as a {@link GeometryCollection}
136             * of {@link Polygon}.
137             *
138             * @param geomFact the geometry factory to use to create the output
139             * @return the faces of the triangulation. The caller takes ownership of the returned object.
140             */
141             std::unique_ptr getTriangles(const geom::GeometryFactory& geomFact);
142              
143             /**
144             * Computes the {@link Envelope} of a collection of {@link Coordinate}s.
145             *
146             * @param coords a List of Coordinates
147             * @return the envelope of the set of coordinates
148             */
149              
150             static geom::Envelope envelope(const geom::CoordinateSequence& coords);
151              
152             };
153              
154             } //namespace geos.triangulate
155             } //namespace goes
156              
157             #endif //GEOS_TRIANGULATE_QUADEDGE_DELAUNAYTRIANGULATIONBUILDER_H
158