Search in sources :

Example 26 with HalfFace

use of org.twak.utils.geom.HalfMesh2.HalfFace in project chordatlas by twak.

the class SkelFootprint method dbgCountProfileEdges.

private void dbgCountProfileEdges(SolverState SS) {
    Set<SuperLine> used = new HashSet<>();
    for (HalfFace f : SS.mesh) for (HalfEdge e : f) {
        used.add(((SuperEdge) e).profLine);
    }
    used.remove(null);
    System.out.println("Input sweep edges: " + used.size());
}
Also used : SuperLine(org.twak.viewTrace.SuperLine) HalfEdge(org.twak.utils.geom.HalfMesh2.HalfEdge) HalfFace(org.twak.utils.geom.HalfMesh2.HalfFace) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 27 with HalfFace

use of org.twak.utils.geom.HalfMesh2.HalfFace in project chordatlas by twak.

the class SkelFootprint method buildFootprint.

public SolverState buildFootprint(List<Line> footprint, ProgressMonitor m, FeatureCache features, BlockGen blockGen) {
    MultiMap<MegaFeatures, MFPoint> minis = features == null ? null : features.createMinis(blockGen);
    Map<SuperEdge, double[]> profFit = new HashMap();
    HalfMesh2 mesh = boundMesh(footprint);
    globalProfs = null;
    Collections.sort(footprint, megaAreaComparator);
    for (Line l : footprint) {
        MegaFacade mf = ((SuperLine) l).getMega();
        if (mf.area < megaFacadeAreaThreshold)
            break;
        insert(mesh, l, 2, true, true);
        if (m.isCanceled())
            return null;
    }
    if (features != null)
        fractureOnFeatures(minis, footprint, mesh);
    m.setProgress(2);
    if (!TweedSettings.settings.useGreedyProfiles) {
        globalProfs = new ArrayList();
        findProfiles(footprint, globalProfs);
        calcProfFit(mesh, globalProfs, profFit, m);
    }
    if (FALSE && profMergeTol > 0)
        mergeOnProfiles(mesh, footprint);
    if (exitA)
        return new SolverState(mesh, minis, globalProfs, profFit, footprint);
    System.out.println("sampling...");
    for (HalfFace f : mesh) meanModeHeightColor(Loopz.from(f), (SuperFace) f, blockGen);
    pushHeightsToSmallFaces(mesh);
    for (HalfFace f : new ArrayList<>(mesh.faces)) {
        SuperFace sf = (SuperFace) f;
        if (sf.height < heightCutoff)
            sf.remove(mesh);
    }
    removeExposedFaces(mesh);
    return new SolverState(mesh, minis, globalProfs, profFit, footprint);
}
Also used : MegaFeatures(org.twak.tweed.gen.FeatureCache.MegaFeatures) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) MegaFacade(org.twak.tweed.gen.ProfileGen.MegaFacade) ArrayList(java.util.ArrayList) HalfFace(org.twak.utils.geom.HalfMesh2.HalfFace) Line(org.twak.utils.Line) SuperLine(org.twak.viewTrace.SuperLine) SuperLine(org.twak.viewTrace.SuperLine) MFPoint(org.twak.tweed.gen.FeatureCache.MFPoint) HalfMesh2(org.twak.utils.geom.HalfMesh2)

Example 28 with HalfFace

use of org.twak.utils.geom.HalfMesh2.HalfFace in project chordatlas by twak.

the class SkelFootprint method fractureOnFeatures.

private void fractureOnFeatures(MultiMap<MegaFeatures, MFPoint> minis, List<Line> footprint, HalfMesh2 mesh) {
    for (MegaFeatures mf : minis.keySet()) pt: for (MFPoint pt : minis.get(mf)) {
        if (!Mathz.inRange(mf.megafacade.findPPram(pt), 0, 1))
            continue;
        Vector2d dir = pt.mega.megafacade.dir();
        dir.set(dir.y, -dir.x);
        Point2d probe = new Point2d(dir);
        probe.scale(2 / dir.length());
        probe.add(pt);
        for (// don't fracture near minifacade boundaries...we can't distinguish nice block bondaries
        Point2d avoid : // don't fracture near minifacade boundaries...we can't distinguish nice block bondaries
        pt.mega.megafacade.points()) if (avoid.distanceSquared(pt) < 4)
            continue pt;
        double bestDist = Double.MAX_VALUE;
        for (HalfFace f : mesh.faces) for (HalfEdge e : f) if (e.line().dir().angle(dir) < 0.4) {
            double dist = e.line().distance(probe);
            if (dist < bestDist)
                bestDist = dist;
        }
        if (bestDist > 0.3) {
            Vector2d end = new Vector2d(dir);
            end.scale(3 / end.length());
            end.add(probe);
            Vector2d start = new Vector2d(dir);
            start.scale(0.5 / start.length());
            start.add(pt);
            Line extra = new Line(new Point2d(start), new Point2d(end));
            SkelFootprint.insert(mesh, extra, 2, false, false);
        }
    }
}
Also used : Line(org.twak.utils.Line) SuperLine(org.twak.viewTrace.SuperLine) MegaFeatures(org.twak.tweed.gen.FeatureCache.MegaFeatures) Vector2d(javax.vecmath.Vector2d) Point2d(javax.vecmath.Point2d) MFPoint(org.twak.tweed.gen.FeatureCache.MFPoint) HalfEdge(org.twak.utils.geom.HalfMesh2.HalfEdge) HalfFace(org.twak.utils.geom.HalfMesh2.HalfFace)

Aggregations

HalfFace (org.twak.utils.geom.HalfMesh2.HalfFace)28 HalfEdge (org.twak.utils.geom.HalfMesh2.HalfEdge)24 MFPoint (org.twak.tweed.gen.FeatureCache.MFPoint)12 Line (org.twak.utils.Line)12 Point2d (javax.vecmath.Point2d)10 SuperLine (org.twak.viewTrace.SuperLine)10 ArrayList (java.util.ArrayList)8 MegaFeatures (org.twak.tweed.gen.FeatureCache.MegaFeatures)8 HashMap (java.util.HashMap)7 HashSet (java.util.HashSet)7 LinkedHashSet (java.util.LinkedHashSet)7 Vector2d (javax.vecmath.Vector2d)6 HalfMesh2 (org.twak.utils.geom.HalfMesh2)6 Node (com.jme3.scene.Node)5 Color (java.awt.Color)5 LinkedHashMap (java.util.LinkedHashMap)5 Map (java.util.Map)5 MegaFacade (org.twak.tweed.gen.ProfileGen.MegaFacade)5 MultiMap (org.twak.utils.collections.MultiMap)5 Material (com.jme3.material.Material)4