All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opensphere.geometry.triangulation.model.Edge Maven / Gradle / Ivy

There is a newer version: 2.5.0
Show newest version
/* This file is based on code copied from project OpenSphere, see the LICENSE file for further information. */
package org.opensphere.geometry.triangulation.model;

import java.util.ArrayList;
import java.util.List;

import org.locationtech.jts.geom.LineSegment;

/**
 * Edge.
 * 
 * @author Eric Grosso
 *
 */
public class Edge {

	/** ID of the edge */
	private int id;
	
	/** Geometry of the edge */
	private LineSegment geometry;

	/** Indicator to know if the edge is a border edge
	 *  of the triangulation framework */
	private boolean border;

	/** Origin vertex of the edge */
	private Vertex oV;
	
	/** End vertex of the edge */
	private Vertex eV;

	/** Triangles in relationship with this edge */
	private List triangles = new ArrayList();
	
	/** Edges in relationship with this edge */
	private List incidentEdges = new ArrayList();

	
	/**
	 * Default constructor.
	 */
	public Edge() {
		//
	}
	
	/**
	 * Constructor.
	 * 
	 * @param id
	 * 		ID of the edge
	 */
	public Edge(int id) {
		this.id = id;
	}

	/**
	 * Constructor.
	 * 
	 * @param id
	 * 		ID of the edge
	 * @param geometry
	 * 		geometry of the edge (segment)
	 */
	public Edge(int id, LineSegment geometry) {
		this.id = id;
		this.geometry = geometry;
	}

	/**
	 * Constructor.
	 * 
	 * @param id
	 * 		ID of the edge
	 * @param border
	 * 		defines if the edge is a border edge
	 * 		or not in the triangulation framework
	 */
	public Edge(int id, boolean border) {
		this.id = id;
		this.border = border;
	}

	/**
	 * Constructor.
	 * 
	 * @param id
	 * 		ID of the edge
	 * @param geometry
	 * 		geometry of the edge (segment)
 	 * @param border
	 * 		defines if the edge is a border edge
	 * 		or not in the triangulation framework
	 */
	public Edge(int id, LineSegment geometry, boolean border) {
		this.id = id;
		this.geometry = geometry;
		this.border = border;
	}

	/**
	 * Constructor.
	 * 
	 * @param id
	 * 		ID of the edge
	 * @param geometry
	 * 		geometry of the edge (segment)
	 * @param oV
	 * 		origin vertex
	 * @param eV
	 * 		end vertex
	 * @param border
	 * 		defines if the edge is a border edge
	 * 		or not in the triangulation framework
	 */
	public Edge(int id, LineSegment geometry, Vertex oV, Vertex eV, boolean border) {
		this.id = id;
		this.geometry = geometry;
		this.oV = oV;
		this.eV = eV;
		this.border = border;
	}

	
	/**
	 * Returns the ID of the edge.
	 * 
	 * @return
	 * 		the ID of the edge
	 */
	public int getId() {
		return this.id;
	}

	/**
	 * Defines the ID of the edge.
	 * 
	 * @param id
	 * 		ID of the edge
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * Returns the geometry of the edge.
	 * 
	 * @return
	 * 		the geometry of the edge
	 */
	public LineSegment getGeometry() {
		return this.geometry;
	}

	/**
	 * Defines the geometry of the edge.
	 * 
	 * @param geometry
	 * 		geometry of the edge (segment)
	 */
	public void setGeometry(LineSegment geometry) {
		this.geometry = geometry;
	}

	/**
	 * Returns true if the edge is a border edge
	 * of the triangulation framework, false otherwise.
	 * 
	 * @return
	 * 		true if the edge is a border edge,
	 * 		false otherwise
	 */
	public boolean isBorder() {
		return this.border;
	}

	/**
	 * Defines the indicator to know if the edge
	 * is a border edge of the triangulation framework.
	 * 
	 * @param border
	 * 		true if the edge is a border edge,
	 * 		false otherwise
	 */
	public void setBorder(boolean border) {
		this.border = border;
	}
	
	/**
	 * Returns the origin vertex of the edge.
	 * 
	 * @return
	 * 		the origin vertex of the edge
	 */	
	public Vertex getOV() {
		return this.oV;
	}

	/**
	 * Defines the origin vertex of the edge.
	 * 
	 * @param oV
	 * 		origin vertex of the edge
	 */
	public void setOV(Vertex oV) {
		this.oV = oV;
	}

	/**
	 * Returns the end vertex of the edge.
	 * 
	 * @return
	 * 		the end vertex of the edge
	 */	
	public Vertex getEV() {
		return this.eV;
	}

	/**
	 * Defines the end vertex of the edge.
	 * 
	 * @param eV
	 * 		end vertex of the edge
	 */
	public void setEV(Vertex eV) {
		this.eV = eV;
	}
	
	/**
	 * Returns the triangles in relationship with the edge.
	 * 
	 * @return
	 * 		the triangles in relationship with the edge
	 */
	public List getTriangles() {
		return this.triangles;
	}

	/**
	 * Defines the triangles in relationship with the edge.
	 * 
	 * @param triangles
	 * 		the triangles in relationship with the edge
	 */
	public void setTriangles(List triangles) {
		this.triangles = triangles;
	}

	/**
	 * Returns the edges in relationship with the edge.
	 * 
	 * @return
	 * 		the edges in relationship with the edge
	 */
	public List getIncidentEdges() {
		return this.incidentEdges;
	}

	/**
	 * Defines the edges in relationship with the edge.
	 * 
	 * @param edges
	 * 		the edges in relationship with the edge
	 */
	public void setIncidentEdges(List edges) {
		this.incidentEdges = edges;
	}

	/**
	 * Add a triangle in relationship with the edge.
	 * 
	 * @return
	 * 		true if added, false otherwise
	 */
	public boolean addTriangle(Triangle triangle) {
		return getTriangles().add(triangle);
	}

	/**
	 * Add triangles in relationship with the edge.
	 * 
	 * @return
	 * 		true if added, false otherwise
	 */
	public boolean addTriangles(List triangles) {
		return getTriangles().addAll(triangles);
	}

	/**
	 * Remove a triangle in relationship with the edge.
	 * 
	 * @return
	 * 		true if removed, false otherwise
	 */
	public boolean removeTriangle(Triangle triangle) {
		return getTriangles().remove(triangle);
	}

	/**
	 * Remove triangles in relationship with the edge.
	 * 
	 * @return
	 * 		true if removed, false otherwise
	 */
	public boolean removeTriangles(List triangles) {
		return getTriangles().removeAll(triangles);
	}

	/**
	 * Add an incident edge in relationship with the edge.
	 * 
	 * @return
	 * 		true if added, false otherwise
	 */
	public boolean addIncidentEdge(Edge edge) {
		return getIncidentEdges().add(edge);
	}

	/**
	 * Add incident edges in relationship with the edge.
	 * 
	 * @return
	 * 		true if added, false otherwise
	 */
	public boolean addIncidentEdges(List edges) {
		return getIncidentEdges().addAll(edges);
	}

	/**
	 * Remove an incident edge in relationship with the edge.
	 * 
	 * @return
	 * 		true if removed, false otherwise
	 */
	public boolean removeIncidentEdge(Edge edge) {
		return getIncidentEdges().remove(edge);
	}

	/**
	 * Remove incident edges in relationship with the edge.
	 * 
	 * @return
	 * 		true if removed, false otherwise
	 */
	public boolean removeAllIncidentEdges(List edges) {
		return getIncidentEdges().removeAll(edges);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy