Commit 0a7d6299 authored by Matthias Betz's avatar Matthias Betz
Browse files

clearing adjacency list if unneeded, improving memory management

parent d163d7c4
Pipeline #1375 passed with stage
in 2 minutes and 2 seconds
......@@ -329,15 +329,15 @@ public class Geometry extends GmlElement {
public void updateVertices() {
Set<Vertex> vertexSet = new HashSet<>();
for (Polygon p : getPolygons()) {
updateRing(p, vertexSet, p.getExteriorRing());
updateRing(vertexSet, p.getExteriorRing());
for (LinearRing inner : p.getInnerRings()) {
updateRing(p, vertexSet, inner);
updateRing(vertexSet, inner);
}
}
vertices = new ArrayList<>(vertexSet);
}
private void updateRing(Polygon p, Set<Vertex> vertexSet, LinearRing ring) {
private void updateRing(Set<Vertex> vertexSet, LinearRing ring) {
for (Vertex v : ring.getVertices()) {
if (vertexSet.add(v)) {
// new vertex, clear adjacent rings in case new rings have been added
......@@ -413,6 +413,9 @@ public class Geometry extends GmlElement {
@Override
public void clearMetaInformation() {
for (Vertex v : vertices) {
v.clearAdjacentRings();
}
edges = null;
vertices = null;
edgeMap = null;
......
......@@ -197,4 +197,11 @@ public class Vertex extends Vector3d {
}
return false;
}
/**
* Remove all adjacent rings from this vertex, ignoring geometry association
*/
void clearAdjacentRings() {
adjacentRings = new ArrayList<>(2);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment