public void Assign(ICellSpatialFilter source) { if (source.Fence != null) { Fence = new Fence(); Fence.Assign(source.Fence); } if (source.AlignmentFence != null) { AlignmentFence = new Fence(); // contains alignment boundary to help speed up filtering on alignment files AlignmentFence.Assign(source.AlignmentFence); } PositionX = source.PositionX; PositionY = source.PositionY; PositionRadius = source.PositionRadius; IsSquare = source.IsSquare; OverrideSpatialCellRestriction = new BoundingIntegerExtent2D(source.OverrideSpatialCellRestriction); StartStation = source.StartStation; EndStation = source.EndStation; LeftOffset = source.LeftOffset; RightOffset = source.RightOffset; CoordsAreGrid = source.CoordsAreGrid; IsSpatial = source.IsSpatial; IsPositional = source.IsPositional; IsDesignMask = source.IsDesignMask; SurfaceDesignMaskDesignUid = source.SurfaceDesignMaskDesignUid; IsAlignmentMask = source.IsAlignmentMask; AlignmentDesignMaskDesignUID = source.AlignmentDesignMaskDesignUID; }
/// <summary> /// Constructs a cell profile analyzer that analyzes cells in a cell profile vector /// </summary> /// <param name="siteModel"></param> /// <param name="pDExistenceMap"></param> /// <param name="filterSet"></param> /// <param name="cellLiftBuilder"></param> /// <param name="overrides"></param> public CellProfileAnalyzer(ISiteModel siteModel, ISubGridTreeBitMask pDExistenceMap, IFilterSet filterSet, ICellLiftBuilder cellLiftBuilder, IOverrideParameters overrides, ILiftParameters liftParams) : base(siteModel, pDExistenceMap, filterSet, overrides, liftParams) { CellLiftBuilder = cellLiftBuilder; PassFilter = filterSet.Filters[0].AttributeFilter; if (PassFilter.HasElevationRangeFilter && PassFilter.ElevationRangeDesign.DesignID != Guid.Empty) { var design = siteModel.Designs.Locate(PassFilter.ElevationRangeDesign.DesignID); if (design == null) { Log.LogError($"ElevationRangeDesign {PassFilter.ElevationRangeDesign.DesignID} is unknown in project {siteModel.ID}"); } else { PassFilterElevationRangeDesign = new DesignWrapper(PassFilter.ElevationRangeDesign, design); } } PassFilterAnnex = new CellPassAttributeFilterProcessingAnnex(); CellFilter = filterSet.Filters[0].SpatialFilter; }
/// <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); }
/// <summary> /// Creates a CellProfile builder given a list of coordinates defining the path to profile and a container to place the resulting cells into /// </summary> /// <param name="siteModel"></param> /// <param name="filterSet"></param> /// <param name="cutFillDesignWrapper"></param> /// <param name="slicerToolUsed"></param> public CellProfileBuilder(ISiteModel siteModel, IFilterSet filterSet, IDesignWrapper cutFillDesignWrapper, bool slicerToolUsed) { SiteModel = siteModel; CellFilter = filterSet?.Filters[0].SpatialFilter; CutFillDesignWrapper = cutFillDesignWrapper; SlicerToolUsed = slicerToolUsed; Initialise(); }
/// <summary> /// Constructs a mask using polygonal and positional spatial filtering aspects of a filter. /// </summary> private static void ConstructSubGridSpatialAndPositionalMask(SubGridCellAddress currentSubGridOrigin, InterceptList intercepts, int fromProfileCellIndex, SubGridTreeBitmapSubGridBits mask, ICellSpatialFilter cellFilter, ISubGridTree subGridTree) { var cellFilterHasSpatialOrPositionalFilters = cellFilter.HasSpatialOrPositionalFilters; var interceptsCount = intercepts.Count; mask.Clear(); for (var interceptIdx = fromProfileCellIndex; interceptIdx < interceptsCount; interceptIdx++) { // Determine the on-the-ground cell underneath the midpoint of each cell on the intercept line subGridTree.CalculateIndexOfCellContainingPosition(intercepts.Items[interceptIdx].MidPointX, intercepts.Items[interceptIdx].MidPointY, out var otgCellX, out var otgCellY); var thisSubGridOrigin = new SubGridCellAddress(otgCellX & ~SubGridTreeConsts.SubGridLocalKeyMask, otgCellY & ~SubGridTreeConsts.SubGridLocalKeyMask); if (!currentSubGridOrigin.Equals(thisSubGridOrigin)) { break; } var cellX = otgCellX & SubGridTreeConsts.SubGridLocalKeyMask; var cellY = otgCellY & SubGridTreeConsts.SubGridLocalKeyMask; if (cellFilterHasSpatialOrPositionalFilters) { subGridTree.GetCellCenterPosition(otgCellX, otgCellY, out var cellCenterX, out var cellCenterY); if (cellFilter.IsCellInSelection(cellCenterX, cellCenterY)) { mask.SetBit(cellX, cellY); } } else { mask.SetBit(cellX, cellY); } } }
private static void ConstructSubGridSpatialAndPositionalMask(ISubGridTree tree, SubGridCellAddress currentSubGridOrigin, List <T> profileCells, SubGridTreeBitmapSubGridBits mask, int fromProfileCellIndex, ICellSpatialFilter cellFilter) { mask.Clear(); // From current position to end... for (var cellIdx = fromProfileCellIndex; cellIdx < profileCells.Count; cellIdx++) { var profileCell = profileCells[cellIdx]; var thisSubGridOrigin = new SubGridCellAddress( profileCell.OTGCellX & ~SubGridTreeConsts.SubGridLocalKeyMask, profileCell.OTGCellY & ~SubGridTreeConsts.SubGridLocalKeyMask); if (!currentSubGridOrigin.Equals(thisSubGridOrigin)) { break; } var cellX = (byte)(profileCell.OTGCellX & SubGridTreeConsts.SubGridLocalKeyMask); var cellY = (byte)(profileCell.OTGCellY & SubGridTreeConsts.SubGridLocalKeyMask); if (cellFilter.HasSpatialOrPositionalFilters) { tree.GetCellCenterPosition(profileCell.OTGCellX, profileCell.OTGCellY, out var cellCenterX, out var cellCenterY); if (cellFilter.IsCellInSelection(cellCenterX, cellCenterY)) { mask.SetBit(cellX, cellY); } } else { mask.SetBit(cellX, cellY); } } }
/// <summary> /// Constructor accepting attribute and spatial filters /// </summary> public CombinedFilter(ICellPassAttributeFilter attributeFilter, ICellSpatialFilter spatialFilter) { AttributeFilter = attributeFilter; SpatialFilter = spatialFilter; }
/// <summary> /// Default no-arg constructor /// </summary> public CombinedFilter() { AttributeFilter = new CellPassAttributeFilter(); SpatialFilter = new CellSpatialFilter(); }