use of org.hwyl.sexytopo.model.graph.Space 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.graph.Space in project sexytopo by richsmith.
the class CrossSection method getProjection.
public Space<Coord2D> getProjection() {
Space<Coord2D> projection = new Space<>();
projection.addStation(station, Coord2D.ORIGIN);
for (Leg leg : station.getUnconnectedOnwardLegs()) {
// first of all normalise to match the angle of the cross section
Leg rotated = leg.rotate(-angle);
Coord3D coord3D = Space3DUtils.toCartesian(Coord3D.ORIGIN, rotated);
Coord2D coord2D = new Coord2D(coord3D.x, -coord3D.z);
Line<Coord2D> line = new Line<>(Coord2D.ORIGIN, coord2D);
projection.addLeg(rotated, line);
}
return projection;
}
use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.
the class ConnectedSurveysTest method testConnectedSurveySketchGetsTranslatedCorrectly.
@Test
public void testConnectedSurveySketchGetsTranslatedCorrectly() {
Survey currentSurvey = getBasicSurvey("current");
Survey joinedSurvey = getBasicSurvey("joined");
Sketch sketch = joinedSurvey.getPlanSketch();
PathDetail pathDetail = sketch.startNewPath(new Coord2D(0, 0));
pathDetail.lineTo(new Coord2D(0, 1));
sketch.finishPath();
connectTwoSurveys(currentSurvey, currentSurvey.getActiveStation(), joinedSurvey, joinedSurvey.getOrigin());
GraphActivity activity = new PlanActivity();
Space<Coord2D> planProjection = Projection2D.PLAN.project(currentSurvey);
Map<Survey, Space<Coord2D>> translated = ConnectedSurveys.getTranslatedConnectedSurveys(activity, currentSurvey, planProjection);
Sketch translatedSketch = translated.keySet().iterator().next().getPlanSketch();
PathDetail translatedPathDetail = translatedSketch.getPathDetails().toArray(new PathDetail[] {})[0];
List<Coord2D> coords = translatedPathDetail.getPath();
Assert.assertEquals(new Coord2D(0, -1), coords.get(0));
Assert.assertEquals(new Coord2D(0, 0), coords.get(1));
}
use of org.hwyl.sexytopo.model.graph.Space in project sexytopo by richsmith.
the class Space2DUtils method transform.
@SuppressWarnings("ConstantConditions")
public static Space<Coord2D> transform(Space<Coord2D> space, Coord2D point) {
Space<Coord2D> newSpace = new Space<>();
Map<Station, Coord2D> stations = space.getStationMap();
for (Station station : stations.keySet()) {
Coord2D coord = stations.get(station);
Coord2D newCoord = coord.plus(point);
newSpace.addStation(station, newCoord);
}
Map<Leg, Line<Coord2D>> legs = space.getLegMap();
for (Leg leg : legs.keySet()) {
Line<Coord2D> line = legs.get(leg);
Line<Coord2D> newLine = transformLine(line, point);
newSpace.addLeg(leg, newLine);
}
return newSpace;
}
Aggregations