public class TerrainSegment : Segment {

    TerrainVertex v1;
    TerrainVertex v2;

    TerrainTriangle t1 = null;
    TerrainTriangle t2 = null;

    public TerrainSegment(TerrainVertex firstPoint, TerrainVertex secondPoint) : base(firstPoint, secondPoint) {
        v1 = firstPoint;
        v2 = secondPoint;
    }

    public void link(TerrainTriangle terrainTriangle) {
        if (t1 == null) {
            t1 = terrainTriangle;
        }
        else {
            t2 = terrainTriangle;
        }
    }

    public TerrainTriangle getOther(TerrainTriangle terrainTriangle) {
        if (t1 == terrainTriangle) {
            return t2;
        }
        else if (t2 == terrainTriangle) {
            return t1;
        }
        return null;
    }

    public bool hasTwoTriangles() {
        return t1 != null && t2 != null;
    }
}
