private IEnumerable<SplittedRegion> SplitRegions(IList<Split> splits) { var splitTree = new SplitTree(BlockBounds.Unbounded); foreach (Split split in splits) { splitTree.Split(split); } return splitTree.GatherSplitBounds().Select(bounds => new SplittedRegion(bounds)); }
private IEnumerable<MeshBlock> SplitMeshBlocks(IEnumerable<MeshBlock> meshBlocks, IList<Split> splits, IList<SplittedRegion> splittedRegions) { foreach(MeshBlock meshBlock in meshBlocks) { var splitTree = new SplitTree(meshBlock.OriginalBounds); splitTree.Split(splits); BlockBounds[] splitMeshBlockBounds = splitTree.GatherSplitBounds(); foreach(BlockBounds blockBounds in splitMeshBlockBounds) { SplittedRegion splittedRegion = splittedRegions.First(region => region.Contains(blockBounds)); yield return meshBlock.CopyOf(blockBounds, splittedRegion); } } }
public void Split_MeshBlocks_Parameterized(SplitTestCase testCase) { BlockBounds[] splitBounds = testCase.bounds.SelectMany(bounds => { SplitTree splitTree = new SplitTree(bounds); foreach(SplitData splitData in testCase.splits) { splitTree.Split(splitData.split); } return splitTree.GatherSplitBounds(); }).ToArray(); foreach(SplitData splitData in testCase.splits) { Split split = splitData.split; BlockBounds[] lhs = splitBounds.Where(bounds => split.Constrains(true, bounds) >= 0).ToArray(); BlockBounds[] rhs = splitBounds.Where(bounds => split.Constrains(false, bounds) >= 0).ToArray(); AssertBlocksMatchBlockBounds(lhs, splitData.expectedLeftBounds); AssertBlocksMatchBlockBounds(rhs, splitData.expectedRightBounds); } }