Package org.osm2world.core.math

Examples of org.osm2world.core.math.SimplePolygonXZ


          }
         
          TerrainBoundaryWorldObject terrainBoundary =
            (TerrainBoundaryWorldObject)otherWO;
         
          SimplePolygonXZ outlinePolygon = terrainBoundary.getOutlinePolygonXZ();
         
          if (outlinePolygon != null) {
           
            subtractPolys.add(outlinePolygon);
            allPolys.add(outlinePolygon);
           
            for (EleConnector eleConnector : otherWO.getEleConnectors()) {
             
              if (!outlinePolygon.getVertexCollection().contains(eleConnector.pos)) {
                eleConnectorPoints.add(eleConnector.pos);
              }
             
            }
           
          }
         
        } else {
         
          for (EleConnector eleConnector : otherWO.getEleConnectors()) {
           
            if (eleConnector.reference == null) {
              /* workaround to avoid using connectors at intersections,
               * which might fall on area segments
               * //TODO cleaner solution
               */
              continue;
            }
           
            eleConnectorPoints.add(eleConnector.pos);
          }
         
          if (otherWO instanceof WorldObjectWithOutline) {
           
            SimplePolygonXZ outlinePolygon =
                ((WorldObjectWithOutline)otherWO).getOutlinePolygonXZ();
           
            if (outlinePolygon != null) {
             
              allPolys.add(outlinePolygon);
View Full Code Here


   
    //It is possible that some holes block other holes' access to the outline.
    //However, at least one hole will be inserted during each loop execution.
    while (!remainingHoles.isEmpty()) {
      for (Iterator<SimplePolygonXZ> holeIt = remainingHoles.iterator(); holeIt.hasNext(); ) {
        SimplePolygonXZ hole = (SimplePolygonXZ) holeIt.next();
        boolean success = insertHoleInPolygonOutline(polygonOutline, hole, remainingHoles);
        if (success) {
          holeIt.remove();
        }
      }
View Full Code Here

   
    if (outerIndex == null) {
      return false;
    } else {

      SimplePolygonXZ outerPolygon = new SimplePolygonXZ(new ArrayList<VectorXZ>(polygonOutline)); //TODO: avoid creating this every time
     
      polygonOutline.add(outerIndex+1, polygonOutline.get(outerIndex));
     
      if (hole.isClockwise() ^ outerPolygon.isClockwise()) {
        polygonOutline.addAll(outerIndex+1,
            rearrangeOutline(hole.getVertexLoop(), innerIndex, false));
      } else {
        polygonOutline.addAll(outerIndex+1,
            rearrangeOutline(hole.getVertexLoop(), innerIndex, true));
View Full Code Here

   */
  static boolean isConvex(int i, List<VectorXZ> outline) {
   
    List<VectorXZ> tempVertices = new ArrayList<VectorXZ>(outline);
    tempVertices.add(outline.get(0));
    SimplePolygonXZ tempPolygon = new SimplePolygonXZ(tempVertices);

    //TODO (performance) avoid creating polygon by passing clockwise information
   
    VectorXZ segBefore = outline.get(i).subtract(vertexBefore(outline, i));
    VectorXZ segAfter = vertexAfter(outline, i).subtract(outline.get(i));
   
    return tempPolygon.isClockwise() ^
      segBefore.z * segAfter.x - segBefore.x * segAfter.z < 0;
   
  }
View Full Code Here

        holeRing.add(vertex);
      }
     
      holeRing.add(holeRing.get(0));
     
      pinHoleLoop = new SimplePolygonXZ(holeRing);
     
      pinConnectors = new EleConnectorGroup();
      pinConnectors.addConnectorsFor(pinHoleLoop.getVertexCollection(), area, GroundState.ON);
     
    }
View Full Code Here

      new VectorXZ(100, 0));
 
  @Test
  public void triangulateTest() throws TriangulationException {
   
    SimplePolygonXZ polygon = new SimplePolygonXZ(outlineB);
   
    List<TriangleXZ> triangles = Poly2TriTriangulationUtil.triangulate(
        polygon,
        Collections.<SimplePolygonXZ>emptyList(),
        Collections.<LineSegmentXZ>emptyList(),
        Collections.<VectorXZ>emptyList());
   
    double triangleArea = 0;
   
    for (TriangleXZ t : triangles) {
      triangleArea += t.getArea();
    }
   
    assertAlmostEquals(polygon.getArea(), triangleArea);
   
  }
View Full Code Here

        new VectorXZ( 2,-1)
    );
   
    List<PolygonWithHolesXZ> results = new ArrayList<PolygonWithHolesXZ>(
        CAGUtil.subtractPolygons(
            new SimplePolygonXZ(outline),
            Arrays.asList(new SimplePolygonXZ(subOutline))));
   
    assertSame(1, results.size());
   
    assertSameCyclicOrder(results.get(0).getOuter().getVertices(),
        new VectorXZ( 1,-2),
View Full Code Here

        new VectorXZ( 2, 0)
    );
   
    List<PolygonWithHolesXZ> results = new ArrayList<PolygonWithHolesXZ>(
        CAGUtil.subtractPolygons(
            new SimplePolygonXZ(outline),
            Arrays.asList(
                new SimplePolygonXZ(subOutline1),
                new SimplePolygonXZ(subOutline2))));
   
    assertSame(1, results.size());
   
    List<VectorXZ> res = results.get(0).getOuter().getVertices();
   
View Full Code Here

        new VectorXZ( 0,-3)
    );
   
    List<PolygonWithHolesXZ> results = new ArrayList<PolygonWithHolesXZ>(
        CAGUtil.subtractPolygons(
            new SimplePolygonXZ(outline),
            Arrays.asList(new SimplePolygonXZ(subOutline))));
   
    assertSame(1, results.size());
   
    List<VectorXZ> res = results.get(0).getOuter().getVertices();
   
View Full Code Here

     
      PolygonXZ poly = new PolygonXZ(vectors);
     
      try {
       
        SimplePolygonXZ simplePoly = poly.asSimplePolygon();
       
        if (simplePoly.isClockwise()) {
          return simplePoly.reverse();
        } else {
          return simplePoly;
        }
       
      } catch (InvalidGeometryException e) {
View Full Code Here

TOP

Related Classes of org.osm2world.core.math.SimplePolygonXZ

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.