private IDictionary <int, Point3D> BuildHeightMap(Point3D point, Axis origianlAxis, Probe probe) { var map = new Dictionary <int, Point3D>(); foreach (Axis axis in Enum.GetValues(typeof(Axis))) { if (axis != origianlAxis) { var projection = _scanData.GetProjection(axis, point[axis]); var marks = RayCasting(point, projection, probe); foreach (var mark in marks) { map[mark[origianlAxis]] = mark; } } } return(map); }
public void Build(Point3D point, Axis axis, IProgress progress) { _labelMap().Reset(); _labelMap().ScannerProperties = new VoidScannerProperties() { LastScanPoint = ScannerProperties.LastScanPoint, MaxSkip = ScannerProperties.MaxSkip, OptimizePlanes = ScannerProperties.OptimizePlanes, Rays = ScannerProperties.Rays, Smoothness = ScannerProperties.Smoothness, thDown = ScannerProperties.thDown, thUp = ScannerProperties.thUp }; _crossCheck.Prepare(_labelMap().Id); var fixProbe = Probe.GetStartingProbe(point, _scanData, _lookupTable, Probe.Method.MinMax, ScannerProperties.thUp, ScannerProperties.thDown); var heightMap = BuildHeightMap(point, axis, fixProbe); var maxHeight = heightMap.Keys.Max(); var minHeight = heightMap.Keys.Min(); progress.Min(1); progress.Max(maxHeight - minHeight); progress.Reset(); var tasks = new List <Task>(); tasks.Add(Task.Factory.StartNew(() => { Point3D center = point; //go up for (var h = point[axis]; h <= maxHeight; h++) { var p = new Point3D(center) { [axis] = h }; center = ScanProjection(p, axis, fixProbe); progress.Tick(); } })); tasks.Add(Task.Factory.StartNew(() => { Point3D center = point; ////go down for (var h = point[axis] - 1; h >= minHeight; h--) { var p = new Point3D(center) { [axis] = h }; center = ScanProjection(p, axis, fixProbe); progress.Tick(); } })); Task.WaitAll(tasks.ToArray()); if (ScannerProperties.OptimizePlanes) { RemoveSharpEdges(); } Helpers.CalculateVolume(_labelMap(), _scanData); _labelMap().CalculateCrop(); _labelMap().FireUpdate(); Task.Factory.StartNew(GC.Collect); }
private IEnumerable <Point3D> RayCasting(Point3D point, Projection projection, Probe probe) { var res = new List <Point3D>(); if (projection.Empty) { return(res); } var scalarPoint = point.To2D(projection.Axis); var rayOffset = Math.PI * 2 / ScannerProperties.Rays; for (int r = 0; r < ScannerProperties.Rays; r++) { var angle = r * rayOffset; var p2d = Cast(scalarPoint, angle, projection, probe); var p3d = p2d.To3D(projection.Axis, point[projection.Axis]); p3d.Index = r; res.Add(p3d); } return(res); }