Search in sources :

Example 6 with MiniFacade

use of org.twak.viewTrace.facades.MiniFacade in project chordatlas by twak.

the class SkelGen method ensureMF.

private static void ensureMF(SuperFace sf, SuperEdge se) {
    se.toEdit = new MiniFacade();
    se.toEdit.left = 0;
    se.toEdit.width = se.length();
    if (se.mini != null && !se.mini.isEmpty())
        se.toEdit.height = se.mini.get(0).height;
    else
        se.toEdit.height = sf.height;
}
Also used : MiniFacade(org.twak.viewTrace.facades.MiniFacade)

Example 7 with MiniFacade

use of org.twak.viewTrace.facades.MiniFacade in project chordatlas by twak.

the class SkelGen method tagWalls.

public static Profile tagWalls(Profile profile, float[] roofColor, SuperEdge se, Point2d s, Point2d e) {
    MiniFacade mini;
    if (se.toEdit == null) {
        if (se.mini == null || (se.mini.isEmpty() && se.proceduralFacade == null))
            mini = null;
        else {
            double[] range = findRange(se, s, e, se.proceduralFacade == null ? null : se.proceduralFacade.megafacade);
            if (range == null)
                mini = null;
            else
                mini = new Regularizer().go(se.mini, range[0], range[1], se.proceduralFacade);
        }
    } else
        // second time through, use the edited results
        mini = se.toEdit;
    Tag wall = new WallTag(se.profLine, se.occlusions, mini), roof = new RoofTag(roofColor);
    boolean first = true;
    for (Loop<Bar> lb : profile.points) {
        for (Loopable<Bar> ll : lb.loopableIterator()) {
            Bar b = ll.get();
            if (// || ll != lb.start && isRoof ( ll.getPrev().get() ) && b.start.distanceSquared( b.end ) < 16 )
            isRoof(b))
                b.tags.add(roof);
            else {
                if (first)
                    b.tags.add(new WallTag(se.profLine, se.occlusions, mini, true));
                else
                    b.tags.add(wall);
            }
        }
        first = false;
    }
    return profile;
}
Also used : MiniFacade(org.twak.viewTrace.facades.MiniFacade) RoofTag(org.twak.viewTrace.facades.RoofTag) Bar(org.twak.camp.ui.Bar) Regularizer(org.twak.viewTrace.facades.Regularizer) WallTag(org.twak.viewTrace.facades.WallTag) Tag(org.twak.camp.Tag) WallTag(org.twak.viewTrace.facades.WallTag) RoofTag(org.twak.viewTrace.facades.RoofTag)

Example 8 with MiniFacade

use of org.twak.viewTrace.facades.MiniFacade in project chordatlas by twak.

the class FeatureCache method createMinis.

public MultiMap<MegaFeatures, MFPoint> createMinis(BlockGen blockGen) {
    MultiMap<MegaFeatures, MFPoint> out = new MultiMap();
    for (MegaFeatures m : getBlock(blockGen.center).getFeatures()) {
        double mLen = m.megafacade.length();
        for (ImageFeatures i : m.features) {
            for (int mi = 0; mi <= i.miniFacades.size(); mi++) {
                MiniFacade n = mi < i.miniFacades.size() ? i.miniFacades.get(mi) : null, p = (mi - 1) >= 0 ? i.miniFacades.get(mi - 1) : null;
                if (// skinny mf filter
                n != null && (n.width < MFWidthTol || (n.rects.countValue() == 0 && n.width < MFWidthTol * 3)))
                    n = null;
                if (p != null && (p.width < MFWidthTol || (p.rects.countValue() == 0 && p.width < MFWidthTol * 3)))
                    p = null;
                if (n == null && p == null || n == null && p.softRight || p == null && n.softLeft || p != null && n != null && p.softRight && n.softLeft)
                    continue;
                double ptDist = n == null ? (p.left + p.width) : n.left;
                Point2d pt = m.megafacade.fromPPram(ptDist / mLen);
                double covTol = 2;
                Set<ImageFeatures> covering = m.features.stream().filter(ii -> ii.start + covTol < ptDist && ii.end > ptDist + covTol).collect(Collectors.toSet());
                // stuff beyond the end of the facade
                double pa = m.megafacade.findPPram(pt) * mLen;
                if (pa < -5 || pa > mLen + 5)
                    continue;
                out.put(m, new MFPoint(pt, covering, m, i, p, n));
            }
        }
    }
    return out;
}
Also used : Color(java.awt.Color) XStream(com.thoughtworks.xstream.XStream) Arrays(java.util.Arrays) Rectangle2D(java.awt.geom.Rectangle2D) FacadeTool(org.twak.tweed.tools.FacadeTool) MiniFacade(org.twak.viewTrace.facades.MiniFacade) Tweed(org.twak.tweed.Tweed) ArrayList(java.util.ArrayList) TweedSettings(org.twak.tweed.TweedSettings) LinkedHashMap(java.util.LinkedHashMap) AlphaComposite(java.awt.AlphaComposite) PanMouseAdaptor(org.twak.utils.PanMouseAdaptor) Spatial(com.jme3.scene.Spatial) Graphics2D(java.awt.Graphics2D) Map(java.util.Map) ICanPaintU(org.twak.utils.PaintThing.ICanPaintU) ImageIO(javax.imageio.ImageIO) PaintThing(org.twak.utils.PaintThing) JComponent(javax.swing.JComponent) ICanPaint(org.twak.utils.PaintThing.ICanPaint) Composite(java.awt.Composite) BufferedImage(java.awt.image.BufferedImage) Files(java.nio.file.Files) MultiMap(org.twak.utils.collections.MultiMap) Line(org.twak.utils.Line) HalfEdge(org.twak.utils.geom.HalfMesh2.HalfEdge) Set(java.util.Set) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) Collectors(java.util.stream.Collectors) File(java.io.File) Point2d(javax.vecmath.Point2d) List(java.util.List) Paths(java.nio.file.Paths) JLabel(javax.swing.JLabel) YamlReader(com.esotericsoftware.yamlbeans.YamlReader) Optional(java.util.Optional) FileReader(java.io.FileReader) MultiMap(org.twak.utils.collections.MultiMap) MiniFacade(org.twak.viewTrace.facades.MiniFacade) Point2d(javax.vecmath.Point2d) ICanPaint(org.twak.utils.PaintThing.ICanPaint)

Aggregations

MiniFacade (org.twak.viewTrace.facades.MiniFacade)8 ArrayList (java.util.ArrayList)4 Point2d (javax.vecmath.Point2d)4 Line (org.twak.utils.Line)4 List (java.util.List)3 MegaFeatures (org.twak.tweed.gen.FeatureCache.MegaFeatures)3 ICanPaint (org.twak.utils.PaintThing.ICanPaint)3 HalfEdge (org.twak.utils.geom.HalfMesh2.HalfEdge)3 YamlReader (com.esotericsoftware.yamlbeans.YamlReader)2 Spatial (com.jme3.scene.Spatial)2 Graphics2D (java.awt.Graphics2D)2 File (java.io.File)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Vector2d (javax.vecmath.Vector2d)2 ImageFeatures (org.twak.tweed.gen.FeatureCache.ImageFeatures)2 PanMouseAdaptor (org.twak.utils.PanMouseAdaptor)2 MultiMap (org.twak.utils.collections.MultiMap)2