public void Test_SubGridTreeBitmapSubGridBitsTests_IndicativeSizeInBytes() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); Assert.True(bits.Bits.Length == 32, "Bits does not contain 32 by 32 bit uints"); Assert.True(bits.IndicativeSizeInBytes() == 4 * bits.Bits.Length, "Bits does not contain 32 by 32 bit uints"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_ForEach_Action() { // Test iteration action for empty, full and arbitrary masks SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); int sum; sum = 0; bits.ForEach((x, y) => { if (bits.BitSet(x, y)) { sum++; } }); Assert.True(sum == bits.CountBits() && sum == SubGridTreeConsts.CellsPerSubGrid, "Summation via ForEach on full mask did not give expected result"); sum = 0; bits.Clear(); bits.ForEach((x, y) => { if (bits.BitSet(x, y)) { sum++; } }); Assert.True(sum == bits.CountBits() && sum == 0, "Summation via ForEach on empty mask did not give expected result"); sum = 0; bits.SetBit(1, 1); bits.ForEach((x, y) => { if (bits.BitSet(x, y)) { sum++; } }); Assert.True(sum == bits.CountBits() && sum == 1, "Summation via ForEach on mask with single bit set at (1, 1) did not give expected result"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_ClearBit() { // Test setting a bit on and off, at two corners to test boundary conditions SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); bits.SetBit(0, 0); Assert.NotEqual(0U, bits.Bits[0]); Assert.Equal(1, bits.CountBits()); bits.ClearBit(0, 0); Assert.Equal(0U, bits.Bits[0]); Assert.Equal(0, bits.CountBits()); bits.SetBit(31, 31); Assert.NotEqual(0U, bits.Bits[31]); Assert.Equal(1, bits.CountBits()); bits.ClearBit(31, 31); Assert.Equal(0U, bits.Bits[31]); Assert.Equal(0, bits.CountBits()); }
public override bool UpdateProcessingMapForSurveyedSurfaces(SubGridTreeBitmapSubGridBits processingMap, IList filteredSurveyedSurfaces, bool returnEarliestFilteredCellPass) { if (!(filteredSurveyedSurfaces is ISurveyedSurfaces surveyedSurfaces)) { return(false); } processingMap.Assign(FilterMap); // If we're interested in a particular cell, but we don't have any surveyed surfaces later (or earlier) // than the cell production data pass time (depending on PassFilter.ReturnEarliestFilteredCellPass) // then there's no point in asking the Design Profiler service for an elevation processingMap.ForEachSetBit((x, y) => { // ReSharper disable once CompareOfFloatsByEqualityOperator if (Cells[x, y] != Consts.NullHeight && !(returnEarliestFilteredCellPass ? surveyedSurfaces.HasSurfaceEarlierThan(Times[x, y]) : surveyedSurfaces.HasSurfaceLaterThan(Times[x, y]))) { processingMap.ClearBit(x, y); } }); return(true); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Serialisation_Arbitrary() { // Test serialisation with arbitrary bits set SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); bits.SetBit(0, 0); bits.SetBit(10, 10); bits.SetBit(20, 20); bits.SetBit(31, 31); MemoryStream ms = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION); BinaryWriter bw = new BinaryWriter(ms, Encoding.UTF8, true); bits.Write(bw); BinaryReader br = new BinaryReader(ms, Encoding.UTF8, true); ms.Position = 0; SubGridTreeBitmapSubGridBits bits2 = SubGridTreeBitmapSubGridBits.FullMask; bits2.Read(br); Assert.True(bits.Equals(bits2), "Bits not equal after serialisation with arbitrary mask"); Assert.Equal(4, bits.CountBits()); }
/// <summary> /// Calculates a filter mask for a designated sub grid on this design /// </summary> public (SubGridTreeBitmapSubGridBits filterMask, DesignProfilerRequestResult errorCode) GetFilterMaskViaLocalCompute( ISiteModelBase siteModel, SubGridCellAddress originCellAddress, double cellSize) { // Calculate an elevation patch for the requested location and convert it into a bitmask detailing which cells have non-null values var patch = _designElevationCalculator.Execute(siteModel, new DesignOffset(DesignDescriptor.DesignID, 0), cellSize, originCellAddress.X, originCellAddress.Y, out var calcResult); if (patch == null) { _log.LogWarning($"Request for design elevation patch that does not exist: Project: {siteModel.ID}, design {DesignDescriptor.DesignID}, location {originCellAddress.X}:{originCellAddress.Y}, calcResult: {calcResult}"); return(null, calcResult); // Requestors should not ask for sub grids that don't exist in the design. } var mask = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); var patchCells = patch.Cells; for (byte i = 0; i < SubGridTreeConsts.SubGridTreeDimension; i++) { for (byte j = 0; j < SubGridTreeConsts.SubGridTreeDimension; j++) { if (patchCells[i, j].Equals(Common.Consts.NullHeight)) { mask[i, j] = true; } } } return(mask, calcResult); }
public override bool ComputeFilterPatch(double startStn, double endStn, double leftOffset, double rightOffset, SubGridTreeBitmapSubGridBits mask, SubGridTreeBitmapSubGridBits patch, double originX, double originY, double cellSize, double offset) { var Heights = new float[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension]; if (InterpolateHeights(Heights, originX, originY, cellSize, offset)) { mask.ForEachSetBit((x, y) => { if (Heights[x, y] == Common.Consts.NullHeight) { mask.ClearBit(x, y); } }); patch.Assign(mask); //SIGLogMessage.PublishNoODS(Self, Format('Filter patch construction successful with %d bits', [patch.CountBits]), ...); return(true); } //SIGLogMessage.PublishNoODS(Self, Format('Filter patch construction failed...', []), ...); return(false); }
public override void InternalFromBinary(IBinaryRawReader reader) { base.InternalFromBinary(reader); var version = VersionSerializationHelper.CheckVersionByte(reader, VERSION_NUMBER); if (version == 1) { SiteModelID = reader.ReadGuid() ?? Guid.Empty; OTGCellBottomLeftX = reader.ReadInt(); OTGCellBottomLeftY = reader.ReadInt(); CellSize = reader.ReadDouble(); SurveyedSurfacePatchType = (SurveyedSurfacePatchType)reader.ReadByte(); if (reader.ReadBoolean()) { ProcessingMap = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); ProcessingMap.FromBytes(reader.ReadByteArray()); } if (reader.ReadBoolean()) { var count = reader.ReadInt(); IncludedSurveyedSurfaces = new Guid[count]; for (int i = 0; i < count; i++) { IncludedSurveyedSurfaces[i] = reader.ReadGuid() ?? Guid.Empty; } } } }
private static void PerformScan(double siteModelCellSize, FilteredValueAssignmentContext assignmentContext, SubGridTreeBitmapSubGridBits sieveBitmask, int numRowsToScan, int numColsToScan, double stepNorthX, double stepNorthY, double stepEastX, double stepEastY, double subGridMinX, double subGridMinY, double firstScanPointEast, double firstScanPointNorth) { // Skip-Iterate through the cells marking those cells that require values // calculated for them in the bitmask. Also record the actual probe locations // that determined the cells to be processed. for (var I = 0; I < numRowsToScan; I++) { var currentNorth = firstScanPointNorth + I * stepNorthY; var currentEast = firstScanPointEast + I * stepNorthX; for (var J = 0; J < numColsToScan; J++) { var eastCol = (int)Math.Floor((currentEast - subGridMinX) / siteModelCellSize); var northRow = (int)Math.Floor((currentNorth - subGridMinY) / siteModelCellSize); if (Range.InRange(eastCol, 0, SubGridTreeConsts.SubGridTreeDimensionMinus1) && Range.InRange(northRow, 0, SubGridTreeConsts.SubGridTreeDimensionMinus1)) { sieveBitmask.SetBit(eastCol, northRow); assignmentContext.ProbePositions[eastCol, northRow] .SetOffsets((float)(currentEast - subGridMinX), (float)(currentNorth - subGridMinY)); } currentEast += stepEastX; currentNorth += stepEastY; } } }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_Subtraction() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.True((bits1 - bits2).IsFull(), "Subtracting clear from full mask did not return full mask"); Assert.True((bits2 - bits1).IsEmpty(), "Subtracting full from clear mask did not return clear mask"); }
/// <summary> /// Constructs a mask using all spatial filtering elements active in the supplied filter /// </summary> public static bool ConstructSubGridCellFilterMask(ISiteModel siteModel, SubGridCellAddress currentSubGridOrigin, InterceptList intercepts, int fromProfileCellIndex, SubGridTreeBitmapSubGridBits mask, ICellSpatialFilter cellFilter, IDesign surfaceDesignMaskDesign) { ConstructSubGridSpatialAndPositionalMask(currentSubGridOrigin, intercepts, fromProfileCellIndex, mask, cellFilter, siteModel.Grid); // If the filter contains an alignment design mask filter then compute this and AND it with the // mask calculated in the step above to derive the final required filter mask if (cellFilter.HasAlignmentDesignMask()) { if (cellFilter.AlignmentFence.IsNull()) // Should have been done in ASNode but if not { throw new ArgumentException($"Spatial filter does not contained pre-prepared alignment fence for design {cellFilter.AlignmentDesignMaskDesignUID}"); } var tree = siteModel.Grid; // Go over set bits and determine if they are in Design fence boundary mask.ForEachSetBit((x, y) => { tree.GetCellCenterPosition(currentSubGridOrigin.X + x, currentSubGridOrigin.Y + y, out var cx, out var cy); if (!cellFilter.AlignmentFence.IncludesPoint(cx, cy)) { mask.ClearBit(x, y); // remove interest as its not in design boundary } }); } // If the filter contains a design mask filter then compute this and AND it with the // mask calculated in the step above to derive the final required filter mask if (surfaceDesignMaskDesign != null) { var getFilterMaskResult = surfaceDesignMaskDesign.GetFilterMaskViaLocalCompute(siteModel, currentSubGridOrigin, siteModel.CellSize); if (getFilterMaskResult.errorCode == DesignProfilerRequestResult.OK || getFilterMaskResult.errorCode == DesignProfilerRequestResult.NoElevationsInRequestedPatch) { if (getFilterMaskResult.filterMask == null) { _log.LogWarning("FilterMask null in response from surfaceDesignMaskDesign.GetFilterMask, ignoring it's contribution to filter mask"); } else { mask.AndWith(getFilterMaskResult.filterMask); } } else { _log.LogError($"Call (A2) to {nameof(ConstructSubGridCellFilterMask)} returned error result {getFilterMaskResult.errorCode} for {cellFilter.SurfaceDesignMaskDesignUid}"); return(false); } } return(true); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_Inequality() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.NotEqual(bits1, bits3); Assert.Equal(bits1, bits2); }
public override bool PerformHeightAnnotation(SubGridTreeBitmapSubGridBits processingMap, IList filteredSurveyedSurfaces, bool returnEarliestFilteredCellPass, IClientLeafSubGrid surfaceElevationsSource, Func <int, int, float, bool> elevationRangeFilterLambda) { if (!(surfaceElevationsSource is ClientHeightAndTimeLeafSubGrid surfaceElevations)) { _log.LogError($"{nameof(ClientHeightAndTimeLeafSubGrid)}.{nameof(PerformHeightAnnotation)} not supplied a ClientHeightAndTimeLeafSubGrid instance, but an instance of {surfaceElevationsSource?.GetType().FullName}"); return(false); } // For all cells we wanted to request a surveyed surface elevation for, // update the cell elevation if a non null surveyed surface of appropriate time was computed // Note: The surveyed surface will return all cells in the requested sub grid, not just the ones indicated in the processing map // IE: It is unsafe to test for null top indicate not-filtered, use the processing map iterators to cover only those cells required processingMap.ForEachSetBit((x, y) => { var surveyedSurfaceCellHeight = surfaceElevations.Cells[x, y]; // ReSharper disable once CompareOfFloatsByEqualityOperator if (surveyedSurfaceCellHeight == Consts.NullHeight) { return; } // If we got back a surveyed surface elevation... var surveyedSurfaceCellTime = surfaceElevations.Times[x, y]; var prodHeight = Cells[x, y]; var prodTime = Times[x, y]; // Determine if the elevation from the surveyed surface data is required based on the production data elevation being null, and // the relative age of the measured surveyed surface elevation compared with a non-null production data height // ReSharper disable once CompareOfFloatsByEqualityOperator if (!(prodHeight == Consts.NullHeight || (returnEarliestFilteredCellPass ? surveyedSurfaceCellTime <prodTime : surveyedSurfaceCellTime> prodTime))) { // We didn't get a surveyed surface elevation, so clear the bit in the processing map to indicate there is no surveyed surface information present for it processingMap.ClearBit(x, y); return; } // Check if there is an elevation range filter in effect and whether the surveyed surface elevation data matches it if (elevationRangeFilterLambda != null) { if (!elevationRangeFilterLambda(x, y, surveyedSurfaceCellHeight)) { // We didn't get a surveyed surface elevation, so clear the bit in the processing map to indicate there is no surveyed surface information present for it processingMap.ClearBit(x, y); return; } } Cells[x, y] = surveyedSurfaceCellHeight; Times[x, y] = surveyedSurfaceCellTime; }); // if (ClientGrid_is_TICClientSubGridTreeLeaf_HeightAndTime) // ClientGridAsHeightAndTime.SurveyedSurfaceMap.Assign(ProcessingMap); return(true); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Fill() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.True(bits.IsEmpty(), "Bits not empty"); bits.Fill(); Assert.True(bits.IsFull(), "Bits not empty after performing a Fill()"); }
public override bool ComputeFilterPatch(double startStn, double endStn, double leftOffset, double rightOffset, SubGridTreeBitmapSubGridBits mask, SubGridTreeBitmapSubGridBits patch, double originX, double originY, double cellSize, double offset) { // todo when SDK available return(false); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Creation_Failure() { // Test the constructor with filled false produces bitmask with all bits set to off Action act = () => { var _ = new SubGridTreeBitmapSubGridBits((SubGridBitsCreationOptions)100); }; act.Should().Throw <TRexSubGridTreeException>().WithMessage("Unknown SubGridTreeBitmapSubGridBits creation option"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_AND() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.Equal((bits1 & bits2), bits2); bits1.ClearBit(1, 1); Assert.NotEqual((bits1 & bits2), bits1); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Equality() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); Assert.True(bits.Equals(bits2), "Bits does not equal bits2, which it should"); Assert.False(bits.Equals(bits3), "Bits equals bits3, which it should not"); Assert.False(bits.Equals(null), "Bits equals null, which it should not"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_CellXY_Indexer() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.True(bits.IsEmpty(), "Bits not empty after creation"); bits[0, 0] = true; Assert.False(bits.IsEmpty(), "Bits empty after setting bit"); bits[0, 0] = false; Assert.True(bits.IsEmpty(), "Bits not empty after clearing bit"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_NOT() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.Equal(~bits1, bits2); Assert.Equal(bits1, ~bits2); bits1.ClearBit(1, 1); Assert.True((~bits1).BitSet(1, 1), "NOTing single bit did not flip it"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Assignment() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); Assert.True(bits.Equals(bits2), "Bits does not equal bits2, which it should"); Assert.False(bits.Equals(bits3), "Bits equals bits3, which it should not"); bits2.Assign(bits3); Assert.True(bits2.Equals(bits3), "Bits2 does not equal bits3 after assignment of bits3 to bits2, which it should"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_CountBits() { SubGridTreeBitmapSubGridBits bits = SubGridTreeBitmapSubGridBits.FullMask; Assert.Equal(bits.CountBits(), SubGridTreeConsts.CellsPerSubGrid); bits.Clear(); Assert.Equal(0, bits.CountBits()); bits.SetBit(1, 1); Assert.Equal(1, bits.CountBits()); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Creation() { // Test the constructor with filled false produces bitmask with all bits set to off SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.True(bits2.IsEmpty() && !bits2.IsFull(), "Bits is not empty as expected"); // Test the constructor with filled true produces bitmask with all bits set to on SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); Assert.True(!bits3.IsEmpty() && bits3.IsFull(), "Bits is not full as expected"); }
public async Task <IClientLeafSubGrid> ExecuteAsync(ISurfaceElevationPatchArgument arg) => Execute(arg); // Task.Run(() => Execute(arg)); public IClientLeafSubGrid Execute(ISurfaceElevationPatchArgument arg) { if (arg.SurveyedSurfacePatchType > SurveyedSurfacePatchType.CompositeElevations) { return(null); } var cachingSupported = arg.SurveyedSurfacePatchType != SurveyedSurfacePatchType.CompositeElevations && _cache != null; // Check the item is available in the cache if (cachingSupported && _cache?.Get(arg.OTGCellBottomLeftX, arg.OTGCellBottomLeftY) is IClientLeafSubGrid cacheResult) { return(_cache.ExtractFromCachedItem(cacheResult, arg.ProcessingMap, arg.SurveyedSurfacePatchType)); } SubGridTreeBitmapSubGridBits savedMap = null; // Always request the full sub grid from the surveyed surface engine unless composite elevations are requested if (cachingSupported) { savedMap = arg.ProcessingMap; arg.ProcessingMap = SubGridTreeBitmapSubGridBits.FullMask; } var subGridInvalidationVersion = cachingSupported ? _cache.InvalidationVersion : 0; var executor = new CalculateSurfaceElevationPatch(); _sitemodel ??= DIContext.ObtainRequired <ISiteModels>().GetSiteModel(arg.SiteModelID); _designFiles ??= DIContext.ObtainRequired <IDesignFiles>(); _surveyedSurfaces ??= _sitemodel.SurveyedSurfaces; var clientResult = executor.Execute(_sitemodel, arg.OTGCellBottomLeftX, arg.OTGCellBottomLeftY, arg.CellSize, arg.SurveyedSurfacePatchType, arg.IncludedSurveyedSurfaces, _designFiles, _surveyedSurfaces, arg.ProcessingMap); if (clientResult != null) { // For now, only cache non-composite elevation sub grids if (cachingSupported) { _cache?.Add(clientResult, subGridInvalidationVersion); } if (savedMap != null) { clientResult = _cache.ExtractFromCachedItem(clientResult, savedMap, arg.SurveyedSurfacePatchType); } } return(clientResult); }
public void Test_SubGridTreeBitmapSubGridBitsTests_BitSet_Uint() { // Test testing a bit is on or off, at two corners to test boundary conditions SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.False(bits.BitSet(0, 0U)); Assert.False(bits.BitSet(31, 31U)); bits.Fill(); Assert.True(bits.BitSet(0, 0U)); Assert.True(bits.BitSet(31, 31U)); }
public void Test_SubGridTreeBitmapSubGridBitsTests_RowToString() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); string s = bits.RowToString(0); Assert.True(s == " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"); bits.Fill(); string s2 = bits.RowToString(0); Assert.True(s2 == " 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_OR() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.Equal((bits1 | bits2), bits1); bits1.ClearBit(1, 1); Assert.Equal((bits1 | bits2), bits1); bits2.SetBit(1, 1); Assert.True((bits1 | bits2).IsFull(), "ORing after clearing/setting bits did not return full mask"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_Operators_XOR() { SubGridTreeBitmapSubGridBits bits1 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.True((bits1 ^ bits1).IsEmpty(), "XORing bits with self did not result in empty mask"); Assert.Equal(bits1, (bits1 ^ bits2)); Assert.True((bits1 ^ bits2).IsFull(), "XORing an empty mask with a full mask did not produce a full mask"); bits2.SetBit(1, 1); Assert.True((bits1 ^ bits1).IsEmpty(), "XORing single bit with itself did not clear bit"); Assert.False((bits1 ^ bits1).BitSet(1, 1), "XORing single bit with itself did not clear bit"); }
public void Test_SubGridTreeBitmapSubGridBitsTests_SumBitRows() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); Assert.Equal(0, bits.SumBitRows()); bits[0, 0] = true; Assert.NotEqual(bits.SumBitRows(), (1 << SubGridTreeConsts.SubGridTreeDimension) - 1); bits[0, SubGridTreeConsts.SubGridTreeDimensionMinus1] = true; Assert.NotEqual(bits.SumBitRows(), (1 << SubGridTreeConsts.SubGridTreeDimension)); bits.Fill(); Assert.Equal(bits.SumBitRows(), SubGridTreeBitmapSubGridBits.SumBitRowsFullCount); }
public void Test_SubGridTreeBitmapSubGridBitsTests_InEquality_Operator() { SubGridTreeBitmapSubGridBits bits = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits2 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Unfilled); SubGridTreeBitmapSubGridBits bits3 = new SubGridTreeBitmapSubGridBits(SubGridBitsCreationOptions.Filled); Assert.False(bits != bits2); Assert.True(bits != bits3); SubGridTreeBitmapSubGridBits nullBits1 = null; SubGridTreeBitmapSubGridBits nullBits2 = null; Assert.False(nullBits1 != nullBits2); Assert.True(nullBits1 != bits); Assert.True(bits != nullBits1); }