private void LoopFlatBodies(Face startFace) { List <FlatFin> remainingFins = new List <FlatFin>(); FlatFin nextFin = null; while (true) { FlatBody flatBody = new FlatBody(this); flatBodies.Add(flatBody); FlatFace baseFace = new FlatFace(startFace, flatBody); FlatLoop flatLoop = null; foreach (FlatLoop testLoop in baseFace.Loops) { if (testLoop.SourceLoop.IsOuter) { flatLoop = testLoop; break; } } Debug.Assert(flatLoop != null); Point startPoint = flatLoop.SourcePoints[0]; Point endPoint = flatLoop.SourcePoints[1]; Frame startFrame = Frame.Create(startPoint, (endPoint - startPoint).Direction, baseFace.SourcePlane.Frame.DirZ); Frame endFrame; if (nextFin == null) // Pick the origin on the first pass, otherwise place it where it overlaps { endFrame = Frame.Create(Point.Origin, Direction.DirX, -Direction.DirZ); } else // use the location of the open fin on the FlatBody where it couldn't be placed { endFrame = Frame.Create(nextFin.End, (nextFin.Start - nextFin.End).Direction, -Direction.DirZ); } baseFace.Transform = Matrix.CreateMapping(endFrame) * Matrix.CreateMapping(startFrame).Inverse; flatBody.AddFace(baseFace); remainingFins.AddRange(LoopUnfold(flatBody)); // Most of the unfolding work is here List <FlatFin> cleanRemainingFins = new List <FlatFin>(); foreach (FlatFin flatFin in remainingFins) { if (!FlatFaceExists(flatFin.AdjacentFin.FlatFace.SourceFace)) { cleanRemainingFins.Add(flatFin); } } remainingFins = cleanRemainingFins; if (remainingFins.Count == 0) { return; } else { nextFin = remainingFins[0]; remainingFins.Remove(nextFin); startFace = nextFin.AdjacentFin.FlatFace.SourceFace; } } }
public FlatFin(FlatLoop flatLoop, Fin sourceFin) { this.flatLoop = flatLoop; this.sourceFin = sourceFin; }