public void BasicSegmentAllocator() { var alloc = new SegmentAllocator(128); Assert.IsTrue(alloc.Allocate(1, 0, out var slice1, false)); Assert.AreEqual(0u, slice1.SegmentIndex); Assert.AreEqual(0, slice1.Offset); Assert.IsTrue(alloc.Allocate(1, 1, out var slice2, false)); Assert.AreEqual(0u, slice2.SegmentIndex); Assert.AreEqual(1, slice2.Offset); Assert.IsTrue(alloc.Allocate(127, 0, out var slice3, false)); Assert.AreEqual(1u, slice3.SegmentIndex); Assert.AreEqual(0, slice3.Offset); Assert.IsFalse(alloc.Allocate(127, 0, out var slice4, true)); Assert.IsFalse(alloc.Allocate(127, 1, out var slice5, true)); Assert.IsTrue(alloc.Allocate(2, 0, out var slice6, true)); Assert.AreEqual(0u, slice6.SegmentIndex); Assert.AreEqual(2, slice6.Offset); Assert.IsTrue(alloc.Allocate(1, 1, out var slice7, true)); Assert.AreEqual(1u, slice7.SegmentIndex); Assert.AreEqual(127, slice7.Offset); Assert.IsTrue(alloc.Allocate(129, 0, out var slice8, false)); Assert.AreEqual(2u, slice8.SegmentIndex); Assert.AreEqual(0, slice8.Offset); }
public MinisegCreator(VertexAllocator vertexAllocator, SegmentAllocator segmentAllocator, JunctionClassifier junctionClassifier) { VertexAllocator = vertexAllocator; SegmentAllocator = segmentAllocator; JunctionClassifier = junctionClassifier; }
public BspBuilder(BspConfig config, MapData map) { BspConfig = config; CollinearTracker collinearTracker = new CollinearTracker(config.VertexWeldingEpsilon); JunctionClassifier junctionClassifier = new JunctionClassifier(); VertexAllocator = new VertexAllocator(config.VertexWeldingEpsilon); SegmentAllocator = new SegmentAllocator(VertexAllocator, collinearTracker); ConvexChecker = new ConvexChecker(); SplitCalculator = new SplitCalculator(config, collinearTracker); Partitioner = new Partitioner(config, SegmentAllocator, junctionClassifier); MinisegCreator = new MinisegCreator(VertexAllocator, SegmentAllocator, junctionClassifier); List <BspSegment> segments = ProcessMapLines(map); junctionClassifier.Add(segments); CreateInitialWorkItem(segments); }
/// <summary> /// Creates a partitioner tha allows steppable debugging. /// </summary> /// <param name="config">The config with partitioning info.</param> /// <param name="segmentAllocator">The segment allocator to create new /// BSP segments when splitting.</param> /// <param name="junctionClassifier">The junction classifier to update /// with new junctions.</param> public Partitioner(BspConfig config, SegmentAllocator segmentAllocator, JunctionClassifier junctionClassifier) { BspConfig = config; SegmentAllocator = segmentAllocator; JunctionClassifier = junctionClassifier; }