use of org.twak.utils.geom.HalfMesh2 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);
}
Aggregations