Esempio n. 1
0
        public override ScanData DoTask(ScanData source)
        {
            source.Sort();
            ScanData ret = source;
            Dictionary<int, ScanData> laserScanData = new Dictionary<int, ScanData>();
            UpdatePercent(0, ret);
            ret = new ScanData();

            int count = source.Count ;
            double delta_angle = DeltaAngle;
            int step = (int)((count * delta_angle) / 360.0);
            for (double ang = 0; ang < 360; ang += delta_angle)
            {
                int biggestIndex = 0;
                int biggestCount = 0;
                List<ScanLine> lines = GetScanlinesByAngle(ang, ang + delta_angle, source);
                for (int j = 0; j < lines.Count; j++)
                {
                    ScanLine l = lines[j];
                    int cnt = l.Count;
                    if (biggestCount < cnt)
                    {
                        biggestCount = cnt;
                        biggestIndex = j;
                    }
                }
                if(lines.Count>0)
                    ret.Add(AverageLines(biggestCount,biggestIndex, lines));
                UpdatePercent((int)(100 * ang/360), ret);
            }
            UpdatePercent(100, ret);
            return ret;
            
        }
Esempio n. 2
0
        public override ScanData DoTask(ScanData source)
        {
            ScanData step1 = base.DoTask(source);

            step1.Sort();             //SORT
            Dictionary <string, ScanLine> step2 = new Dictionary <string, ScanLine>();

            for (int i = 0; i < step1.Count; i++)
            {
                ScanLine line = step1[i];
                if (line.Count > 0)
                {
                    for (int c = 0; c < NumClass; c++)
                    {
                        string key = string.Format("{0}->{1}", line.LaserID, c);
                        if (!step2.ContainsKey(key))
                        {
                            step2[key] = new ScanLine(line.LaserID, NumClass);
                        }
                        step2[key].Add(GetSample(line, NumClass, c));
                    }

                    //step2[line.LaserID].Add(line[0]);
                }
            }

            ScanData step3 = new ScanData(step2.Keys.Count);

            for (int i = 0; i < step2.Keys.Count; i++)
            {
                string k = step2.Keys.ElementAt(i);
                step3.Add(step2[k]);
            }
            return(step3);
        }
Esempio n. 3
0
        /// <summary>
        /// Do the task
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public override ScanData DoTask(ScanData source)
        {
            ScanData ret = new ScanData(source.Count);

            source.Sort();
            int count         = source.Count;
            int ParallelCount = Settings.Get <Settings>().Read(Settings.SYSTEM, Settings.MAXTHREADS, 8);

            UpdatePercent(0, ret);
            if (LaunchParallel)
            {
                int doneCount = 0;
                Parallel.For(0, count, new ParallelOptions {
                    MaxDegreeOfParallelism = ParallelCount
                }, i =>
                {
                    if (this.CancelPending)
                    {
                        return;
                    }
                    ScanLine line = DoTask(source[i]);
                    if (line != null)
                    {
                        //line.DisplayAsLine = source[i].DisplayAsLine;
                        lock (ret)
                        {
                            ret.Add(line);
                        }
                        doneCount++;
                        {
                            int percent = (int)((100 * doneCount) / count);
                            if (percent % 10 == 0)
                            {
                                UpdatePercent(percent, ret);
                            }
                        }
                    }
                }
                             );
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    if (this.CancelPending)
                    {
                        return(ret);
                    }
                    ScanLine line = DoTask(source[i]);
                    if (line != null)
                    {
                        ret.Add(line);
                    }
                    UpdatePercent((int)(100 * i / count), ret);
                }
            }
            UpdatePercent(100, ret);
            return(ret);
        }
Esempio n. 4
0
        public override ScanData DoTask(ScanData source)
        {
            CameraPosition = new Vector3d();
            Settings settings = Settings.Get <Settings>();

            CameraPosition.X = settings.Read(Settings.CAMERA, Settings.X, 0f);
            CameraPosition.Y = settings.Read(Settings.CAMERA, Settings.Y, 270f);
            CameraPosition.Z = settings.Read(Settings.CAMERA, Settings.Z, 70f);
            ScanData ret = base.DoTask(source);

            ret.Sort();
            return(ret);
        }
Esempio n. 5
0
        /// <summary>
        /// Do the task function override
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public override ScanData DoTask(ScanData source)
        {
            ScanData ret = new ScanData(source.Count);

            UpdatePercent(0, ret);
            source.Sort();
            int count = source.Count;
            //count = 2;
            //primitiveType = PrimitiveType.LineStrip;
            ScanLine top    = new ScanLine(count);
            ScanLine bottom = new ScanLine(count);

            ScanLine prev = source[0];

            top.Add(prev.First());
            bottom.Add(prev.Last());

            for (int i = 1; i <= count; i++)
            {
                if (this.CancelPending)
                {
                    return(source);
                }
                ScanLine    current = source[i % count];
                StripResult strip   = CreateStrip(prev, current);

                top.Add(strip.Current.First());
                bottom.Add(strip.Current.Last());

                prev = strip.Current;

                ret.Add(strip.Result);
                UpdatePercent((int)((100 * i) / count), ret);
            }
            if (count <= 2)
            {
                return(ret);
            }
            Point3D topcenter    = Point3D.Average(top);
            Point3D bottomcenter = Point3D.Average(bottom);

            for (int i = 0; i < ret.Count; i++)
            {
                ret[i].Insert(0, topcenter);
                ret[i].Add(bottomcenter);
                AdjustNormalFromTriangleStrip(ret[i]);
            }
            UpdatePercent(100, ret);
            return(ret);
        }
Esempio n. 6
0
		/// <summary>
		/// Do the task
		/// </summary>
		/// <param name="source"></param>
		/// <returns></returns>
		public override ScanData DoTask(ScanData source)
		{
			ScanData ret = new ScanData(source.Count);
			source.Sort();
			int count = source.Count;
			int ParallelCount = Settings.Get<Settings>().Read(Settings.SYSTEM, Settings.MAXTHREADS, 8);
			UpdatePercent(0, ret);
			if (LaunchParallel)
			{
				int doneCount = 0;
				Parallel.For(0, count, new ParallelOptions { MaxDegreeOfParallelism = ParallelCount }, i =>
				{
					if (this.CancelPending) return;
					ScanLine line = DoTask(source[i]);
					if (line != null)
					{
						//line.DisplayAsLine = source[i].DisplayAsLine;
						lock (ret)
						{
							ret.Add(line);
						}
						doneCount++;
						{
							int percent = (int)((100 * doneCount) / count);
							if (percent % 10 == 0)
								UpdatePercent(percent, ret);
						}
					}

				}
							 );
			}
			else
			{

				for (int i = 0; i < count; i++)
				{
					if (this.CancelPending) return ret;
					ScanLine line = DoTask(source[i]);
					if (line != null)
						ret.Add(line);
					UpdatePercent((int)(100 * i / count), ret);
				}
			}
			UpdatePercent(100, ret);
			return ret;
		}
Esempio n. 7
0
        List <ScanLine> GetScanlinesByAngle(double from, double to, ScanData data)
        {
            List <ScanLine> ret = new List <ScanLine>();

            data.Sort();
            int startindex = -1;
            int cnt        = data.Count;/*
                                         * for (int i = 0; i < cnt && startindex == -1; i++) // find first of range
                                         * {
                                         * ScanLine line = data[i];
                                         * double angle = line.Angle;
                                         * while (angle < 0)
                                         * angle += 360;
                                         * if (angle >= from && angle <= to)
                                         * startindex = i;
                                         * }
                                         * if (startindex < 0)
                                         * return ret;*/

            startindex = 0;
            for (int i = 0; i < cnt; i++) // fill the range
            {
                ScanLine line  = data[(i + startindex) % cnt];
                double   angle = line.Angle;
                while (angle < 0)
                {
                    angle += 360;
                }
                if (angle >= from && angle <= to)
                {
                    ret.Add(line);
                }
                if (angle > to)
                {
                    return(ret);
                }
            }
            return(ret);
        }
Esempio n. 8
0
        public override ScanData DoTask(ScanData source)
        {
            ScanData ret = new ScanData(source.Count);

            UpdatePercent(0, ret);
            source.Sort();
            int count = source.Count;

            /*
             * for (int i = 1; i <= count; i++)
             * {
             *      if (this.CancelPending) return source;
             *      ScanLine current = source[i % count];
             *      ScanLine prev = source[(i-1) % count];
             *      ScanLine next = source[(i+1) % count];
             *      int lineCount = current.Count;
             *
             *      ScanLine smoothed = new ScanSlice(current.Count);
             *      smoothed.DisplayAsLine = current.DisplayAsLine;
             *
             *      for (int l = 0; l < lineCount; l++)
             *      {
             *              smoothed.Add(Smooth(l, prev, current, next));
             *      }
             *      ret.Add(smoothed);
             *      UpdatePercent((int)((100 * i) / count), ret);
             * }
             */
            ret = source;
            for (int i = 0; i < Iteration; i++)
            {
                double pctstart = i * 100f / Iteration;
                double pctend   = pctstart + 100f / Iteration;
                ret = DoIteration(ret, pctstart, pctend);
            }
            UpdatePercent(100, ret);
            return(ret);
        }
Esempio n. 9
0
        public override ScanData DoTask(ScanData source)
        {
            source.Sort();
            ScanData ret = source;
            Dictionary <int, ScanData> laserScanData = new Dictionary <int, ScanData>();

            UpdatePercent(0, ret);
            ret = new ScanData();

            int    count       = source.Count;
            double delta_angle = DeltaAngle;
            int    step        = (int)((count * delta_angle) / 360.0);

            for (double ang = 0; ang < 360; ang += delta_angle)
            {
                int             biggestIndex = 0;
                int             biggestCount = 0;
                List <ScanLine> lines        = GetScanlinesByAngle(ang, ang + delta_angle, source);
                for (int j = 0; j < lines.Count; j++)
                {
                    ScanLine l   = lines[j];
                    int      cnt = l.Count;
                    if (biggestCount < cnt)
                    {
                        biggestCount = cnt;
                        biggestIndex = j;
                    }
                }
                if (lines.Count > 0)
                {
                    ret.Add(AverageLines(biggestCount, biggestIndex, lines));
                }
                UpdatePercent((int)(100 * ang / 360), ret);
            }
            UpdatePercent(100, ret);
            return(ret);
        }
Esempio n. 10
0
		public override ScanData DoTask(ScanData source)
		{
			ScanData ret = new ScanData(source.Count);
			UpdatePercent(0, ret);
			source.Sort();
			int count = source.Count;
			/*
			for (int i = 1; i <= count; i++)
			{
				if (this.CancelPending) return source;
				ScanLine current = source[i % count];
				ScanLine prev = source[(i-1) % count];
				ScanLine next = source[(i+1) % count];
				int lineCount = current.Count;

				ScanLine smoothed = new ScanSlice(current.Count);
				smoothed.DisplayAsLine = current.DisplayAsLine;

				for (int l = 0; l < lineCount; l++)
				{
					smoothed.Add(Smooth(l, prev, current, next));
				}
				ret.Add(smoothed);
				UpdatePercent((int)((100 * i) / count), ret);
			}
			 */
			ret = source;
			for (int i = 0; i < Iteration; i++)
			{
				double pctstart = i * 100f/Iteration;
				double pctend = pctstart + 100f / Iteration;
				ret = DoIteration(ret, pctstart, pctend);
			}
			UpdatePercent(100, ret);
			return ret;
		}
Esempio n. 11
0
 List<ScanLine> GetScanlinesByAngle(double from, double to,ScanData data)
 {
     List<ScanLine> ret = new List<ScanLine>();
     data.Sort();
     int startindex = -1;
     int cnt = data.Count;/*
     for (int i = 0; i < cnt && startindex == -1; i++) // find first of range
     {
         ScanLine line = data[i];
         double angle = line.Angle;
         while (angle < 0)
             angle += 360;
         if (angle >= from && angle <= to)
             startindex = i;
     }
     if (startindex < 0)
         return ret;*/
     startindex =0;
     for (int i = 0; i < cnt; i++) // fill the range
     {
         ScanLine line = data[(i + startindex)%cnt ];
         double angle = line.Angle;
         while (angle < 0)
             angle += 360;
         if (angle >= from && angle <= to)
             ret.Add(line);
         if (angle > to)
             return ret;
     }
     return ret;
 }
Esempio n. 12
0
        /// <summary>
        /// Do the task function override
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public override ScanData DoTask(ScanData source)
        {
            ScanData ret = new ScanData(source.Count);
            UpdatePercent(0, ret);
            source.Sort();
            int count = source.Count;
            //count = 2;
            //primitiveType = PrimitiveType.LineStrip;
            ScanLine top = new ScanLine(count);
            ScanLine bottom = new ScanLine(count);

            ScanLine prev = source[0];
            top.Add(prev.First());
            bottom.Add(prev.Last());

            for (int i = 1; i <= count; i++)
            {
                if (this.CancelPending) return source;
                ScanLine current = source[i % count];
                StripResult strip = CreateStrip(prev, current);

                top.Add(strip.Current.First());
                bottom.Add(strip.Current.Last());

                prev = strip.Current;

                ret.Add(strip.Result);
                UpdatePercent((int)((100 * i) / count), ret);
            }
            if (count <= 2)
                return ret;
            Point3D topcenter = Point3D.Average(top);
            Point3D bottomcenter = Point3D.Average(bottom);
            for (int i = 0; i < ret.Count; i++)
            {
                ret[i].Insert(0, topcenter);
                ret[i].Add(bottomcenter);
                AdjustNormalFromTriangleStrip(ret[i]);
            }
            UpdatePercent(100, ret);
            return ret;

        }