示例#1
0
        public void Build(Point3D point, IProgress progress)
        {
            _labelMap().Reset();
            _labelMap().ScannerProperties = new ThresholdScannerProperties()
            {
                LastScanPoint = ScannerProperties.LastScanPoint,
                Threshold = ScannerProperties.Threshold
            };

            _crossCheck.Prepare(_labelMap().Id);

            var crop = _labelMap().Crop;

            progress.Min(1);
            progress.Max(crop.ZR - crop.ZL);
            progress.Reset();

            var fixProbe = Probe.GetStartingProbe(point, _scanData, _lookupTable, Probe.Method.Average, ScannerProperties.Threshold, ScannerProperties.Threshold);
            
            int volume = 0;
            const int MaxPoints = 10*1000*1000;
            
            Parallel.ForEach(_scanData.GetAllProjections(Axis.Z), (proj, state, z) =>
            {

                if (z < crop.ZL || z > crop.ZR)
                    return;

                for (int x = crop.XL; x < crop.XR; x++)
                {
                    for (int y = crop.YL; y < crop.YR; y++)
                    {
                        if (fixProbe.InRange(_lookupTable.Map(proj.Pixels[x, y])) && !_crossCheck.Check(new Point3D(x ,y, (int)z), _labelMap().Id))
                        {
                            _labelMap().Add(new Point3D(x, y, (int)z));
                            Interlocked.Increment(ref volume);

                            if (volume > MaxPoints)
                            {
                                state.Stop();
                                return;
                            }
                        }
                    }
                }

                progress.Tick();
            });

            double xres, yres, zres;
            _scanData.Resolution(out xres, out yres, out zres);

            _labelMap().Volume = (int)(volume * xres * yres * zres);

            _labelMap().FireUpdate();

            Task.Factory.StartNew(GC.Collect);
        }
示例#2
0
        public void Build(Point3D point, IProgress progress)
        {
            _labelMap().Reset();
            _labelMap().ScannerProperties = new EdgeScannerProperties()
            {
                LastScanPoint = ScannerProperties.LastScanPoint,
                Threshold     = ScannerProperties.Threshold
            };

            _crossCheck.Prepare(_labelMap().Id);

            var crop = _labelMap().Crop;

            progress.Min(1);
            progress.Max(crop.ZR - crop.ZL);
            progress.Reset();

            var fixProbe = Probe.GetStartingProbe(point, _scanData, _lookupTable, Probe.Method.MinMax, ScannerProperties.Threshold, ScannerProperties.Threshold);

            var tasks = new List <Task>();

            tasks.Add(Task.Factory.StartNew(() =>
            {
                Point3D center = point;

                //go up
                for (var h = point[Axis.Z]; h < crop.ZR; h++)
                {
                    var p = new Point3D(center)
                    {
                        [Axis.Z] = h
                    };

                    center = ScanProjection(p, fixProbe);

                    progress.Tick();
                }
            }));


            tasks.Add(Task.Factory.StartNew(() =>
            {
                Point3D center = point;

                ////go down
                for (var h = point[Axis.Z] - 1; h >= crop.ZL; h--)
                {
                    var p = new Point3D(center)
                    {
                        [Axis.Z] = h
                    };

                    center = ScanProjection(p, fixProbe);

                    progress.Tick();
                }
            }));

            Task.WaitAll(tasks.ToArray());

            Helpers.CalculateVolume(_labelMap(), _scanData);

            _labelMap().CalculateCrop();
            _labelMap().FireUpdate();

            Task.Factory.StartNew(GC.Collect);
        }
示例#3
0
        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);
        }