Search in sources :

Example 1 with PanoGen

use of org.twak.tweed.gen.PanoGen in project chordatlas by twak.

the class TweedFrame method addLayer.

private void addLayer(MouseEvent evt) {
    SimplePopup2 sp = new SimplePopup2(evt);
    if (hasGIS()) {
        sp.add("+ mesh (obj)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .obj mesh file", new File(Tweed.JME), "obj") {

                    public void heresTheFile(File obj) throws Throwable {
                        // removeMeshSources();
                        String f = tweed.makeWorkspaceRelative(obj).toString();
                        addGen(new MeshGen(f, tweed), true);
                    }
                };
            }
        });
        sp.add("+ mesh (minimesh)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select minimesh index file (index.xml), or obj to convert", new File(Tweed.JME), null) {

                    @Override
                    public void heresTheFile(File f) throws Throwable {
                        if (!f.getName().equals(MiniTransform.INDEX)) {
                            MiniTransform.convertToMini(f, new File(Tweed.DATA + "/minimesh"), () -> addGen(new MiniGen(new File("minimesh"), tweed), true));
                            return;
                        }
                        // removeMeshSources();
                        addGen(new MiniGen(tweed.makeWorkspaceRelative(f.getParentFile()), tweed), true);
                    }
                };
            }
        });
        sp.add("+ panos (jpg)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select one of many panoramas images in a directory, or todo.list", new File(Tweed.JME), null) {

                    public void heresTheFile(File oneOfMany) throws Throwable {
                        // removeGens( PanoGen.class );
                        addGen(new PanoGen(tweed.makeWorkspaceRelative(oneOfMany.getParentFile()), tweed, Tweed.LAT_LONG), true);
                    }
                };
            }
        });
    } else {
        sp.add("+ gis (2d obj)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .obj gis footprints", new File(Tweed.JME), "obj") {

                    public void heresTheFile(File obj) throws Throwable {
                        removeGISSources();
                        addGen(new GISGen(tweed.makeWorkspaceRelative(obj), tweed), true);
                    }
                };
            }
        });
        // sp.add( "+ gis (3d obj)", new Runnable() {
        // @Override
        // public void run() {
        // new SimpleFileChooser( frame, false, "Select .obj gis footprints", new File( Tweed.JME ), "obj" ) {
        // public void heresTheFile( File obj ) throws Throwable {
        // 
        // };
        // };
        // }
        // } );
        sp.add("+ gis (gml)", new Runnable() {

            @Override
            public void run() {
                new SimpleFileChooser(frame, false, "Select .gml gis footprints", new File(Tweed.JME), "gml") {

                    public void heresTheFile(File gml) throws Throwable {
                        removeGISSources();
                        tweed.addGML(gml, null);
                    }
                };
            }
        });
    }
    sp.show();
}
Also used : MiniGen(org.twak.tweed.gen.MiniGen) PanoGen(org.twak.tweed.gen.PanoGen) SimplePopup2(org.twak.utils.ui.SimplePopup2) GISGen(org.twak.tweed.gen.GISGen) SimpleFileChooser(org.twak.utils.ui.SimpleFileChooser) File(java.io.File) MeshGen(org.twak.tweed.gen.MeshGen)

Example 2 with PanoGen

use of org.twak.tweed.gen.PanoGen in project chordatlas by twak.

the class FacadeTool method facadeSelected.

public void facadeSelected(LoopL<Point3d> list, BlockGen block) {
    // if (block == null) {
    // JOptionPane.showMessageDialog( null, "generate mesh for block first" );
    // return;
    // }
    // Polygonz.findBounds( polies, min, max );
    double[] minMax = Loopz.minMax(list);
    Loopz.expand(minMax, 30);
    Map<Point2d, Pano> panos = new HashMap<>();
    for (Gen gen : tweed.frame.gens(PanoGen.class)) for (Pano pg : ((PanoGen) gen).getPanos()) {
        Point2d pt = new Point2d(pg.location.x, pg.location.z);
        if (pt.x > minMax[0] && pt.x < minMax[1] && pt.y > minMax[4] && pt.y < minMax[5])
            panos.put(pt, pg);
    }
    List<Point3d> objPoints = null;
    if (block != null) {
        objPoints = new ObjRead(block.getCroppedFile()).points();
    }
    FacadeFinder ff = new FacadeFinder(Loopz.toXZLoop(list), panos, objPoints, block, tweed.frame.getGenOf(PlanesGen.class));
    Point2d cen = Loopz.average(Loopz.to2dLoop(list, 1, null));
    renderFacades(block == null ? null : block.gNode, cen.x + "_" + cen.y, ff);
}
Also used : BlockGen(org.twak.tweed.gen.BlockGen) ImagePlaneGen(org.twak.tweed.gen.ImagePlaneGen) PlanesGen(org.twak.tweed.gen.PlanesGen) GISGen(org.twak.tweed.gen.GISGen) PanoGen(org.twak.tweed.gen.PanoGen) Gen(org.twak.tweed.gen.Gen) Point2d(javax.vecmath.Point2d) HashMap(java.util.HashMap) Point3d(javax.vecmath.Point3d) Pano(org.twak.tweed.gen.Pano) FacadeFinder(org.twak.viewTrace.FacadeFinder) ObjRead(org.twak.utils.geom.ObjRead) PlanesGen(org.twak.tweed.gen.PlanesGen)

Aggregations

GISGen (org.twak.tweed.gen.GISGen)2 PanoGen (org.twak.tweed.gen.PanoGen)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Point2d (javax.vecmath.Point2d)1 Point3d (javax.vecmath.Point3d)1 BlockGen (org.twak.tweed.gen.BlockGen)1 Gen (org.twak.tweed.gen.Gen)1 ImagePlaneGen (org.twak.tweed.gen.ImagePlaneGen)1 MeshGen (org.twak.tweed.gen.MeshGen)1 MiniGen (org.twak.tweed.gen.MiniGen)1 Pano (org.twak.tweed.gen.Pano)1 PlanesGen (org.twak.tweed.gen.PlanesGen)1 ObjRead (org.twak.utils.geom.ObjRead)1 SimpleFileChooser (org.twak.utils.ui.SimpleFileChooser)1 SimplePopup2 (org.twak.utils.ui.SimplePopup2)1 FacadeFinder (org.twak.viewTrace.FacadeFinder)1