コード例 #1
0
  void build() {
    filename = "my_tile2.svg";
    shp = RG.loadShape(path + filename);
    shp = RG.centerIn(shp, g, 100);
    UVertexList vl, vl2;
    vl = new UVertexList();
    for (int i = 0; i < 5; i++) vl.add(i, 0);

    vl.close();
    vl.insert(2, vl.get(1));
    println(UMB.str(vl.removeDuplID()));

    println(vl.str());

    // We decided the separation between the polygon points dependent of the mouseX
    float pointSeparation = map(constrain(mouseX, 100, width - 100), 100, width - 100, 4, 20);

    //     We create the polygonized version
    RG.setPolygonizer(RG.UNIFORMLENGTH);
    RG.setPolygonizerLength(pointSeparation);

    polyshp = RG.polygonize(shp);
    poly = polyshp.toPolygon();

    ArrayList<UVertexList> cont = UGeomerative.fromRContour(poly.contours);
    println("contours " + cont.size());

    //    for(UVertexList tmp:cont) {
    //      tmp.removeDupl(true);
    ////      println("isClockwise "+tmp.isClockwise());
    //    }

    //    PGraphicsPDF pdf=(PGraphicsPDF)createGraphics(1000,1000,PDF,path+"test1.pdf");
    //  UMB.setGraphics(pdf);
    //  pdf.beginDraw();
    //  pdf.translate(500,500);
    //  pdf.stroke(0);
    //  geo.draw();
    //  pdf.endDraw();
    //  pdf.flush();
    //  pdf.dispose();

    geo2 = UPoly2Tri.triangulate(cont);

    geo = geo2.copy();
    geo.extrudeSelf(50, true);

    //    geo.removeDuplV().regenerateFaceData();
    geo.writeSTL(path + "test1.stl");
  }