Search in sources :

Example 6 with Space

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;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 7 with Space

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;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Line(org.hwyl.sexytopo.model.graph.Line) Coord3D(org.hwyl.sexytopo.model.graph.Coord3D) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Example 8 with Space

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));
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Survey(org.hwyl.sexytopo.model.survey.Survey) GraphActivity(org.hwyl.sexytopo.control.activity.GraphActivity) PathDetail(org.hwyl.sexytopo.model.sketch.PathDetail) PlanActivity(org.hwyl.sexytopo.control.activity.PlanActivity) Sketch(org.hwyl.sexytopo.model.sketch.Sketch) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Test(org.junit.Test)

Example 9 with Space

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;
}
Also used : Space(org.hwyl.sexytopo.model.graph.Space) Station(org.hwyl.sexytopo.model.survey.Station) Line(org.hwyl.sexytopo.model.graph.Line) Coord2D(org.hwyl.sexytopo.model.graph.Coord2D) Leg(org.hwyl.sexytopo.model.survey.Leg)

Aggregations

Space (org.hwyl.sexytopo.model.graph.Space)9 Coord2D (org.hwyl.sexytopo.model.graph.Coord2D)7 Line (org.hwyl.sexytopo.model.graph.Line)4 Leg (org.hwyl.sexytopo.model.survey.Leg)4 Survey (org.hwyl.sexytopo.model.survey.Survey)4 Test (org.junit.Test)4 GraphActivity (org.hwyl.sexytopo.control.activity.GraphActivity)3 PlanActivity (org.hwyl.sexytopo.control.activity.PlanActivity)3 Station (org.hwyl.sexytopo.model.survey.Station)3 Coord3D (org.hwyl.sexytopo.model.graph.Coord3D)1 PathDetail (org.hwyl.sexytopo.model.sketch.PathDetail)1 Sketch (org.hwyl.sexytopo.model.sketch.Sketch)1