58 lines
1.7 KiB
Java
58 lines
1.7 KiB
Java
package de.wwwu.awolf.presenter.util;
|
|
|
|
import com.google.common.collect.Lists;
|
|
import de.wwwu.awolf.model.dao.Interval;
|
|
import de.wwwu.awolf.model.dao.Line;
|
|
import de.wwwu.awolf.model.dao.Point;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.LinkedList;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.concurrent.ForkJoinPool;
|
|
import java.util.concurrent.ForkJoinTask;
|
|
import java.util.concurrent.RecursiveTask;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
|
*
|
|
* @Author: Armin Wolf
|
|
* @Email: a_wolf28@uni-muenster.de
|
|
* @Date: 18.09.2017.
|
|
*/
|
|
public class IntersectionComputer {
|
|
|
|
private static IntersectionComputer instance;
|
|
|
|
/**
|
|
* Konstruktor
|
|
*/
|
|
private IntersectionComputer() {
|
|
}
|
|
|
|
public static IntersectionComputer getInstance() {
|
|
if (instance == null) {
|
|
instance = new IntersectionComputer();
|
|
Logging.logInfo("Created instance of IntersectionComputer");
|
|
}
|
|
|
|
return instance;
|
|
}
|
|
|
|
/**
|
|
* Berechnet zu einer gegebenen Menge von dualen Geraden die Schnittpunkte. Dafür wird ein modifizierter Merge-Sort Algorithmus verwendett. Um die Performance zu steigern wird die Berechnung ab
|
|
* einer passenden Größe auf vier Threads ausgelagert.
|
|
*
|
|
* @return Liste der Schnittpunkte
|
|
*/
|
|
public Set<Point> compute(final Collection<Line> lines) {
|
|
BentleyOttmann bentleyOttmann = new BentleyOttmann(lines);
|
|
bentleyOttmann.find_intersections();
|
|
return bentleyOttmann.get_intersections();
|
|
}
|
|
}
|