Search in sources :

Example 1 with Output

use of org.twak.camp.Output in project chordatlas by twak.

the class Campz method findChains.

public static List<List<Face>> findChains(Output output) {
    Set<Face> remaining = new LinkedHashSet<>(output.faces.values());
    MultiMap<Face, Face> parent2children = new MultiMap<>();
    while (!remaining.isEmpty()) {
        Set<Face> above = new LinkedHashSet<>();
        Face f = remaining.iterator().next();
        do {
            remaining.remove(f);
            above.add(f);
            if (f.parent != null)
                f = f.parent;
        } while (f.parent != null);
        above.add(f);
        parent2children.putAll(f, above, true);
    }
    return parent2children.keySet().stream().map(f -> parent2children.get(f)).collect(Collectors.toList());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) List(java.util.List) Output(org.twak.camp.Output) MultiMap(org.twak.utils.collections.MultiMap) Set(java.util.Set) Face(org.twak.camp.Output.Face) Collectors(java.util.stream.Collectors) LinkedHashSet(java.util.LinkedHashSet) MultiMap(org.twak.utils.collections.MultiMap) Face(org.twak.camp.Output.Face)

Example 2 with Output

use of org.twak.camp.Output in project chordatlas by twak.

the class SkelGen method selected.

private void selected(PlanSkeleton skel, Node house, SuperFace sf, SuperEdge se) {
    JPanel ui = new JPanel();
    ui.setLayout(new ListDownLayout());
    JButton fac = new JButton("edit facade");
    fac.addActionListener(e -> editFacade(skel, sf, se, false));
    ui.add(fac);
    // JButton tex = new JButton( "texture facade" );
    // tex.addActionListener( e -> editFacade( skel, sf, se, true ) );
    // ui.add( tex );
    JButton proc = new JButton("procedural facade");
    proc.addActionListener(e -> cgaFacade(skel, sf, se));
    ui.add(proc);
    JButton camp = new JButton("procedural extrusions");
    camp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeSitePlan();
            siteplan = new Siteplan(skel.plan, false) {

                SuperFace workon = sf;

                public void show(Output output, Skeleton threadKey) {
                    super.show(output, threadKey);
                    Plot.closeLast();
                    tweed.enqueue(new Runnable() {

                        @Override
                        public void run() {
                            removeGeometryFor(workon);
                            // current selection is invalid
                            tweed.frame.setGenUI(null);
                            setSkel((PlanSkeleton) threadKey, output, workon);
                        }
                    });
                }
            };
            siteplan.setVisible(true);
            siteplan.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        }
    });
    ui.add(camp);
    JButton mini = new JButton("street-view");
    mini.addActionListener(e -> new MiniViewer(se));
    if (sf != null)
        ui.add(mini);
    JButton prof = new JButton("profiles");
    prof.addActionListener(e -> new ProfileAssignmentViewer(sf, skelFootprint == null ? null : skelFootprint.globalProfs));
    ui.add(prof);
    ui.add(new JLabel("height " + sf.heights.size()));
    JButton plan = new JButton("plan");
    plan.addActionListener(e -> new Plot(toRender, footprint));
    ui.add(plan);
    JButton remove = new JButton("remove");
    remove.addActionListener(e -> {
        visible = false;
        calculateOnJmeThread();
        tweed.frame.removeGen(SkelGen.this);
    });
    ui.add(plan);
    JButton b = new JButton("view clean profiles");
    b.addActionListener(e -> SkelFootprint.debugFindCleanProfiles(footprint, this, new ProgressMonitor(null, "", "", 0, 100), tweed));
    ui.add(b);
    JButton c = new JButton("compare profiles");
    c.addActionListener(e -> skelFootprint.debugCompareProfs(skelFootprint.globalProfs));
    ui.add(c);
    tweed.frame.setGenUI(ui);
}
Also used : JPanel(javax.swing.JPanel) ListDownLayout(org.twak.utils.ui.ListDownLayout) PlanSkeleton(org.twak.siteplan.campskeleton.PlanSkeleton) ActionEvent(java.awt.event.ActionEvent) Plot(org.twak.utils.ui.Plot) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) SuperFace(org.twak.tweed.gen.SuperFace) ProgressMonitor(javax.swing.ProgressMonitor) ActionListener(java.awt.event.ActionListener) Siteplan(org.twak.siteplan.campskeleton.Siteplan) Output(org.twak.camp.Output) MiniViewer(org.twak.tweed.gen.MiniViewer) PlanSkeleton(org.twak.siteplan.campskeleton.PlanSkeleton) Skeleton(org.twak.camp.Skeleton) ProfileAssignmentViewer(org.twak.tweed.gen.ProfileAssignmentViewer)

Example 3 with Output

use of org.twak.camp.Output in project chordatlas by twak.

the class SkelGen method setSkel.

public synchronized void setSkel(PlanSkeleton skel, Output output, SuperFace sf) {
    removeGeometryFor(sf);
    Node house;
    OnClick onclick = new OnClick() {

        @Override
        public void selected(Output output, Node house2, SuperEdge se) {
            SkelGen.this.selected(skel, house2, sf, se);
        }
    };
    GreebleSkel greeble = new GreebleSkel(tweed);
    house = greeble.showSkeleton(output, onclick);
    gNode.attachChild(house);
    geometry.put(sf, house);
    tweed.getRootNode().updateGeometricState();
    tweed.getRootNode().updateModelBound();
    tweed.gainFocus();
}
Also used : GreebleSkel(org.twak.viewTrace.facades.GreebleSkel) Node(com.jme3.scene.Node) Output(org.twak.camp.Output) SuperEdge(org.twak.tweed.gen.SuperEdge) OnClick(org.twak.viewTrace.facades.GreebleSkel.OnClick)

Example 4 with Output

use of org.twak.camp.Output in project chordatlas by twak.

the class GreebleSkel method createMesh.

public void createMesh(Output output) {
    float[] roofColor = new float[] { 0.3f, 0.3f, 0.3f, 1 }, wallColor = new float[] { 228 / 255f, 223 / 255f, 206 / 255f, 1.0f };
    if (output.faces == null)
        return;
    double bestWallArea = 0, bestRoofArea = 0;
    for (Face f : output.faces.values()) {
        double area = Loopz.area3(f.getLoopL());
        Tag t = getTag(f.profile, RoofTag.class);
        if (t != null && area > bestRoofArea && ((RoofTag) t).color != null) {
            roofColor = ((RoofTag) t).color;
            bestRoofArea = area;
        }
        t = getTag(f.profile, WallTag.class);
        if (t != null && area > bestWallArea && ((WallTag) t).color != null) {
            wallColor = ((WallTag) t).color;
            bestWallArea = area;
        }
    }
    greebleGrid = new GreebleGrid(tweed, mbs = new MMeshBuilderCache());
    output.addNonSkeletonSharedEdges(new RoofTag(roofColor));
    edges(output, roofColor);
    for (List<Face> chain : Campz.findChains(output)) {
        // for ( Face f : output.faces.values() )
        // mbs.get(roofColor).add3d( Loopz.insertInnerEdges( f.getLoopL() ), zToYup );
        Optional<Tag> opt = chain.stream().flatMap(f -> f.profile.stream()).filter(tag -> tag instanceof WallTag).findAny();
        WallTag wt = null;
        Set<QuadF> features = new HashSet<>();
        MiniFacade mf = null;
        if (opt.isPresent() && (wt = (WallTag) opt.get()).miniFacade != null) {
            MiniFacade mf2 = new MiniFacade(wt.miniFacade);
            Line facadeLine;
            {
                Edge e = chain.get(0).edge;
                // we might rotate the facade to apply a set of features to a different side of the building.
                facadeLine = new Line(e.end.x, e.end.y, e.start.x, e.start.y);
            }
            if (TweedSettings.settings.snapFacadeWidth) {
                // move/scale mf horizontally from mean-image-location to mesh-facade-location
                double[] meshSE = findSE(wt.miniFacade, facadeLine, chain);
                mf2.scaleX(meshSE[0], meshSE[1]);
            }
            // find window locations in 3 space
            mf2.rects.values().stream().flatMap(f -> f.stream()).map(r -> new QuadF(r, facadeLine)).forEach(q -> features.add(q));
            mf = mf2;
        }
        for (Face f : chain) {
            face(f, mf, features, roofColor, wallColor);
        }
        for (QuadF w : features) if ((w.original.f == Feature.WINDOW || w.original.f == Feature.SHOP) && w.foundAll()) {
            greebleGrid.createDormerWindow(w, mbs.WOOD, mbs.GLASS, (float) wt.sillDepth, (float) wt.sillHeight, (float) wt.corniceHeight, 0.6, 0.9);
        }
        // for ( String mName : mbs.cache.keySet() )
        // for (float[] mCol : mbs.cache.get( mName ).keySet() )
        // node.attachChild( mb2Geom( output, chain, mName, mCol ) );
        greebleGrid.attachAll(node, chain, output, new ClickMe() {

            @Override
            public void clicked(Object data) {
                try {
                    SwingUtilities.invokeAndWait(new Runnable() {

                        @Override
                        public void run() {
                            selected(output, node, findSuperEdge(output, chain));
                        }
                    });
                } catch (Throwable th) {
                    th.printStackTrace();
                }
            }
        });
    }
}
Also used : LinearForm3D(org.twak.utils.geom.LinearForm3D) PlanSkeleton(org.twak.siteplan.campskeleton.PlanSkeleton) Matrix4d(javax.vecmath.Matrix4d) ClickMe(org.twak.tweed.ClickMe) Tag(org.twak.camp.Tag) Vector3d(javax.vecmath.Vector3d) Bar(org.twak.camp.ui.Bar) Tweed(org.twak.tweed.Tweed) ArrayList(java.util.ArrayList) TweedSettings(org.twak.tweed.TweedSettings) HashSet(java.util.HashSet) SETag(org.twak.tweed.gen.skel.SETag) Loop(org.twak.utils.collections.Loop) Node(com.jme3.scene.Node) SwingUtilities(javax.swing.SwingUtilities) Pointz(org.twak.tweed.gen.Pointz) Mathz(org.twak.utils.Mathz) SuperEdge(org.twak.tweed.gen.SuperEdge) Point3d(javax.vecmath.Point3d) ColumnProperties(org.twak.siteplan.campskeleton.PlanSkeleton.ColumnProperties) LoopL(org.twak.utils.collections.LoopL) Iterator(java.util.Iterator) Output(org.twak.camp.Output) Edge(org.twak.camp.Edge) Line(org.twak.utils.Line) Set(java.util.Set) MeshBuilder(org.twak.siteplan.jme.MeshBuilder) LinearForm(org.twak.utils.geom.LinearForm) Collectors(java.util.stream.Collectors) LPoint2d(org.twak.viewTrace.facades.GreebleHelper.LPoint2d) Loopz(org.twak.utils.collections.Loopz) Point2d(javax.vecmath.Point2d) LPoint3d(org.twak.viewTrace.facades.GreebleHelper.LPoint3d) List(java.util.List) Loopable(org.twak.utils.collections.Loopable) DRectangle(org.twak.utils.geom.DRectangle) Optional(java.util.Optional) Face(org.twak.camp.Output.Face) Feature(org.twak.viewTrace.facades.MiniFacade.Feature) ClickMe(org.twak.tweed.ClickMe) Line(org.twak.utils.Line) Tag(org.twak.camp.Tag) SETag(org.twak.tweed.gen.skel.SETag) Face(org.twak.camp.Output.Face) SuperEdge(org.twak.tweed.gen.SuperEdge) Edge(org.twak.camp.Edge) HashSet(java.util.HashSet)

Aggregations

Output (org.twak.camp.Output)4 Node (com.jme3.scene.Node)2 List (java.util.List)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2 Face (org.twak.camp.Output.Face)2 PlanSkeleton (org.twak.siteplan.campskeleton.PlanSkeleton)2 SuperEdge (org.twak.tweed.gen.SuperEdge)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1 Optional (java.util.Optional)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 ProgressMonitor (javax.swing.ProgressMonitor)1 SwingUtilities (javax.swing.SwingUtilities)1