Search in sources :

Example 31 with HalfEdge

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

the class SkelFootprint method fracture.

private static void fracture(HalfMesh2 mesh, HalfEdge previous, Vector2d dir, double remainingHard, double remainingSoft, Line line, boolean setLine) {
    if (previous == null)
        // at edge of shape: done
        return;
    HalfEdge p2 = previous.face.fracture(previous.end, dir, previous, previous.next);
    if (p2 == null) {
        System.err.println("failed to find intersection from " + previous.end + " dir " + dir);
        return;
    }
    HalfEdge next = p2.next.over;
    HalfEdge dividing = previous.face.split(mesh, previous, p2);
    ((SuperEdge) dividing).profLine = setLine ? (SuperLine) line : null;
    double l = dividing.length();
    if (remainingHard != 0)
        if (remainingHard < l) {
            Point2d softStart = new Point2d(dir);
            softStart.scale(remainingHard / dir.length());
            softStart.add(previous.end);
            dividing.split(softStart);
            ((SuperEdge) dividing.next).profLine = null;
            ((SuperEdge) dividing.next.over).profLine = null;
            fracture(mesh, next, dir, 0, remainingSoft - l + remainingHard, null, setLine);
        } else
            fracture(mesh, next, dir, remainingHard - l, remainingSoft, line, setLine);
    else if (remainingSoft > l)
        fracture(mesh, next, dir, 0, remainingSoft - l, line, setLine);
}
Also used : Point2d(javax.vecmath.Point2d) SuperLine(org.twak.viewTrace.SuperLine) HalfEdge(org.twak.utils.geom.HalfMesh2.HalfEdge)

Aggregations

HalfEdge (org.twak.utils.geom.HalfMesh2.HalfEdge)31 HalfFace (org.twak.utils.geom.HalfMesh2.HalfFace)25 Point2d (javax.vecmath.Point2d)15 MFPoint (org.twak.tweed.gen.FeatureCache.MFPoint)13 Line (org.twak.utils.Line)13 SuperLine (org.twak.viewTrace.SuperLine)11 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 MegaFeatures (org.twak.tweed.gen.FeatureCache.MegaFeatures)8 HalfMesh2 (org.twak.utils.geom.HalfMesh2)7 Color (java.awt.Color)6 LinkedHashSet (java.util.LinkedHashSet)6 List (java.util.List)6 Map (java.util.Map)6 MultiMap (org.twak.utils.collections.MultiMap)6 File (java.io.File)5 Set (java.util.Set)5 Vector2d (javax.vecmath.Vector2d)5 Cach (org.twak.utils.Cach)5