MATSIM
HullEdge.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * *
4  * *********************************************************************** *
5  * *
6  * copyright : (C) 2013 by the members listed in the COPYING, *
7  * LICENSE and WARRANTY file. *
8  * email : info at matsim dot org *
9  * *
10  * *********************************************************************** *
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * See also COPYING, LICENSE and WARRANTY file *
17  * *
18  * *********************************************************************** */
19 
20 package org.matsim.core.network.algorithms.intersectionSimplifier.containers;
21 
22 import java.util.ArrayList;
23 import java.util.List;
24 
25 import org.locationtech.jts.geom.LineSegment;
26 
27 public class HullEdge {
29  private int id;
30 
32  private LineSegment geometry;
33 
36  private boolean border;
37 
40 
43 
45  private List<HullTriangle> triangles = new ArrayList<HullTriangle>();
46 
48  private List<HullEdge> incidentEdges = new ArrayList<HullEdge>();
49 
50 
54  public HullEdge() {
55  //
56  }
57 
64  public HullEdge(int id) {
65  this.id = id;
66  }
67 
76  public HullEdge(int id, LineSegment geometry) {
77  this.id = id;
78  this.geometry = geometry;
79  }
80 
90  public HullEdge(int id, boolean border) {
91  this.id = id;
92  this.border = border;
93  }
94 
106  public HullEdge(int id, LineSegment geometry, boolean border) {
107  this.id = id;
108  this.geometry = geometry;
109  this.border = border;
110  }
111 
127  public HullEdge(int id, LineSegment geometry, HullNode oV, HullNode eV, boolean border) {
128  this.id = id;
129  this.geometry = geometry;
130  this.originNode = oV;
131  this.destinationNode = eV;
132  this.border = border;
133  }
134 
135 
142  public int getId() {
143  return this.id;
144  }
145 
152  public void setId(int id) {
153  this.id = id;
154  }
155 
162  public LineSegment getGeometry() {
163  return this.geometry;
164  }
165 
172  public void setGeometry(LineSegment geometry) {
173  this.geometry = geometry;
174  }
175 
184  public boolean isBorder() {
185  return this.border;
186  /*TODO Change this so that it checks the number of triangles with which
187  * the edge is associated. At least throw a warning if the boolean
188  * attribute remains, by checking the number of related triangles before
189  * returning the boolean value. */
190  }
191 
200  public void setBorder(boolean border) {
201  this.border = border;
202 
203  /* If an edge is changed to a border edge, also flag both origin and
204  * destination node as border nodes. The opposite, however, is NOT true:
205  * that is, if an edge is an internal edge, one (or both) of its nodes
206  * may be border nodes.
207  */
208  if(border == true){
209  this.originNode.setBorder(true);
210  this.destinationNode.setBorder(true);
211  }
212  }
213 
221  return this.originNode;
222  }
223 
230  public void setOriginNode(HullNode originNode) {
231  this.originNode = originNode;
232  }
233 
241  return this.destinationNode;
242  }
243 
250  public void setDestinationNode(HullNode destinationNodeV) {
251  this.destinationNode = destinationNodeV;
252  }
253 
260  public List<HullTriangle> getTriangles() {
261  return this.triangles;
262  }
263 
270  public void setTriangles(List<HullTriangle> triangles) {
271  this.triangles = triangles;
272  }
273 
280  public List<HullEdge> getIncidentEdges() {
281  return this.incidentEdges;
282  }
283 
290  public void setIncidentEdges(List<HullEdge> edges) {
291  this.incidentEdges = edges;
292  }
293 
300  public boolean addTriangle(HullTriangle triangle) {
301  return getTriangles().add(triangle);
302  }
303 
310  public boolean addTriangles(List<HullTriangle> triangles) {
311  return getTriangles().addAll(triangles);
312  }
313 
320  public boolean removeTriangle(HullTriangle triangle) {
321  return getTriangles().remove(triangle);
322  }
323 
330  public boolean removeTriangles(List<HullTriangle> triangles) {
331  return getTriangles().removeAll(triangles);
332  }
333 
340  public boolean addIncidentEdge(HullEdge edge) {
341  return getIncidentEdges().add(edge);
342  }
343 
350  public boolean addIncidentEdges(List<HullEdge> edges) {
351  return getIncidentEdges().addAll(edges);
352  }
353 
360  public boolean removeIncidentEdge(HullEdge edge) {
361  return getIncidentEdges().remove(edge);
362  }
363 
370  public boolean removeAllIncidentEdges(List<HullEdge> edges) {
371  return getIncidentEdges().removeAll(edges);
372  }
373 }
HullEdge(int id, LineSegment geometry, HullNode oV, HullNode eV, boolean border)
Definition: HullEdge.java:127