private Isothetic BakeIso(List <IsoBlock> blocks) { List <Point3d> isoVertex = new List <Point3d>(); IsoBlock firstBlock = blocks.First(); for (int i = 0; i < blocks.Count; i++) { IsoBlock tempBlock = blocks[i]; Point3d basePt = tempBlock.BasePt; Vector3d widthVec = tempBlock.WidthLine.UnitTangent; Vector3d heightVec = tempBlock.HeightLine.UnitTangent; if (i == 0) { isoVertex.Add(basePt); //add corner1 } Point3d corner2 = basePt + widthVec * tempBlock.Width; Point3d corner3 = corner2 + heightVec * tempBlock.Height; isoVertex.Add(corner2); isoVertex.Add(corner3); if (i == blocks.Count - 1) { isoVertex.Add(basePt + heightVec * tempBlock.Height); //add corner4 isoVertex.Add(isoVertex.First()); } } Polyline bakedOutline = new Polyline(isoVertex); PolylineTools.AlignCCW(bakedOutline); return(new Isothetic(bakedOutline, firstBlock.BasePt, firstBlock.WidthLine, firstBlock.HeightLine)); }
private List <IsoBlock> SearchLocalMaxIso(InitialPt initial, int concaveCount, bool isInitialPhase) { List <IsoBlock> bestBlocksL = new List <IsoBlock>(); double bestAreaL = 0; foreach (double ratio in aspectRatio) { List <IsoBlock> tempBlocks = new List <IsoBlock>(); IsoBlock tempBlock = new IsoBlock(initial, ratio); tempBlock.Inflate(boundary, boundCrv, minLength, !isInitialPhase); if (tempBlock.Area <= 0) { continue; } if (concaveCount == 0) { tempBlocks.Add(tempBlock); } else { tempBlocks.Add(tempBlock); tempBlocks.AddRange(SearchLocalMaxIso(tempBlock.NextInitialPt(), concaveCount - 1, false)); } double tempArea = 0; tempBlocks.ForEach(n => tempArea += n.Area); if (tempArea > bestAreaL) { bestBlocksL = tempBlocks; bestAreaL = tempArea; } } return(bestBlocksL); }