use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class SpaceFlipper method flipVertically.
@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> flipVertically(Space<Coord2D> space) {
Space<Coord2D> flippedSpace = new Space<>();
Map<Station, Coord2D> stationMap = space.getStationMap();
for (Station station : stationMap.keySet()) {
Coord2D point = stationMap.get(station);
flippedSpace.addStation(station, point.flipVertically());
}
Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
for (Leg leg : legMap.keySet()) {
Line<Coord2D> line = legMap.get(leg);
Coord2D start = line.getStart();
Coord2D end = line.getEnd();
Line<Coord2D> flippedLine = new Line<>(start.flipVertically(), end.flipVertically());
flippedSpace.addLeg(leg, flippedLine);
}
return flippedSpace;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class GraphToListTranslator method createListOfEntriesFromStation.
private List<SurveyListEntry> createListOfEntriesFromStation(Station from) {
List<SurveyListEntry> list = new ArrayList<>();
for (Leg leg : from.getUnconnectedOnwardLegs()) {
SurveyListEntry entry = new SurveyListEntry(from, leg);
list.add(entry);
}
for (Leg leg : from.getConnectedOnwardLegs()) {
SurveyListEntry entry = new SurveyListEntry(from, leg);
list.add(entry);
list.addAll(createListOfEntriesFromStation(leg.getDestination()));
}
return list;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class SpaceMover method move.
@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> move(Space<Coord2D> space, Coord2D delta) {
Space<Coord2D> moved = new Space<>();
Map<Station, Coord2D> stationMap = space.getStationMap();
for (Station station : stationMap.keySet()) {
Coord2D point = stationMap.get(station);
moved.addStation(station, point.plus(delta));
}
Map<Leg, Line<Coord2D>> legMap = space.getLegMap();
for (Leg leg : legMap.keySet()) {
Line<Coord2D> line = space.getLegMap().get(leg);
Line<Coord2D> shiftedLine = new Line<>(line.getStart().plus(delta), line.getEnd().plus(delta));
moved.addLeg(leg, shiftedLine);
}
return moved;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class SurveyTools method traverseIterator.
@SuppressWarnings("WhileLoopReplaceableByForEach")
public static boolean traverseIterator(Station station, SurveyLegTraversalCallback callback) {
// use an iterator because the callback might mutate the list of legs
Iterator<Leg> i = station.getOnwardLegs().iterator();
while (i.hasNext()) {
Leg leg = i.next();
boolean isFinished = callback.call(station, leg);
if (isFinished) {
return isFinished;
} else if (leg.hasDestination()) {
return traverseLegs(leg.getDestination(), callback);
}
}
return false;
}
use of org.hwyl.sexytopo.model.survey.Leg in project sexytopo by richsmith.
the class TestSurveyCreator method createBranch.
public static void createBranch(Survey survey, int numStations) {
for (int i = 0; i < numStations; i++) {
float distance = 5 + random.nextInt(10);
float azimuth = 40 + random.nextInt(100);
float inclination = -20 + random.nextInt(40);
Leg leg = new Leg(distance, azimuth, inclination);
SurveyUpdater.updateWithNewStation(survey, leg);
Station newStation = survey.getMostRecentLeg().getDestination();
createLruds(survey, newStation);
}
}
Aggregations