private Dictionary <Point3d, Point3dCollection> InitializeEndLpMesh() { var scanlines = new Dictionary <Point3d, Point3dCollection>(); var ld = _properties.Parts.SelectedLd; var lp = _properties.Parts.SelectedLp; var startLp = _properties.Algorythim.SelectedStartLp; var useStartLp = startLp != null; var cast = _properties.Parts.SelectedCast; var spacing = _properties.Algorythim.Options.DistanceBetweenLpAndLd; var startVector = new Vector3d(0, startLp?.StartOffset ?? _properties.Parts.SelectedLp.StartOffset, 0); var startPoint = _properties.StartPoint.Add(startVector); var incrVect = new Vector2d(ld.Width + lp.Height + spacing * 2.0, lp.Width + _properties.Algorythim.Options.DistanceBetweenLp); if (useStartLp) { startPoint = startPoint.Add(new Vector3d(0, startLp.Width + _properties.Algorythim.Options.DistanceBetweenLp, 0)); } for (double x = startPoint.X; x < _properties.MaxPoint.X; x += incrVect.X) { scanlines.Add(new Point3d(x, startPoint.Y, 0), ScanLine.GetOutlineSurroudingPointsY(new Point3d(x, startPoint.Y, 0), _properties.MaxPoint, lp.Width + _properties.Algorythim.Options.DistanceBetweenLp, _outline)); } return(scanlines); }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; if (count <= 2) { return(source); } ScanLine ret = new ScanLine(source.LaserID, source.Count); ret.DisplayAsLine = source.DisplayAsLine; uint order = Order; for (int i = 0; i < count; i++) { if (this.CancelPending) { return(ret); } // Debug.Write("["); List <Point3D> sourceWindow = new List <Point3D>(); for (int j = 0; j < order; j++) { int indice = (int)(i + j - order / 2); indice = Math.Max(0, Math.Min(indice, count - 1)); // Debug.Write(" "+indice); sourceWindow.Add(source[indice]); } // Debug.WriteLine("]"); ret.Add(Utils.GetMedian(sourceWindow)); } return(ret); }
protected override bool VerifyConfirmedLine(ScanHeader header, ScanLine line, Action rollbackAction, out WMSFlowStatus flowStatus) { if (!base.VerifyConfirmedLine(header, line, rollbackAction, out flowStatus)) { return(false); } if (header.Remove == true) { return(true); } var args = new WMSLineVerifyingArguments <Header, INTran>( (Header)HeaderView.Cache.GetMain(header), (INTran)LinesView.Cache.GetMain(line)); Base1.VerifyAvailability(args); if (args.Cancel) { flowStatus = WMSFlowStatus.Fail(args.ErrorInfo.MessageFormat, args.ErrorInfo.MessageArguments); rollbackAction(); args.Processed = true; SetScanState(MainCycleStartState); return(false); } flowStatus = WMSFlowStatus.Ok; return(true); }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; ScanLine ret = new ScanLine(source.LaserID, count); ret.DisplayAsLine = source.DisplayAsLine; if (count < 4) ret.AddRange(source); else { BezierBuilder bez = new BezierBuilder(SegmentPerCurve, MinSquareDistance); bez.SetControlPoints(source); switch (Mode) { case eMode.Mode0: ret.AddRange(bez.GetDrawingPoints0()); break; case eMode.Mode1: ret.AddRange(bez.GetDrawingPoints1()); break; default: ret.AddRange(bez.GetDrawingPoints2()); break; } } return ret; }
private async Task LoadLinesAsync() { Lines = new List <ScanLine>(); var plcs = await _store.GetPlcListAsync(); var targets = await _store.GetTargetListAsync(); int iPageSize = 10; foreach (var plc in plcs) { var line = new ScanLine(DataTypeHelper.GetPlcType(plc.CpuType), plc.Ip, plc.Port, plc.Slot, plc.Rack); line.PlcId = plc.Id; line.RunHandler += Line_RunHandler; line.StatusChangeHandler += Line_StatusChangeHandler; var nomaltgs = (from u in targets where u.PlcId == plc.Id && u.VarType != 7 select u).ToList(); var stringtgs = (from u in targets where u.PlcId == plc.Id && u.VarType == 7 select u).ToList(); RegistReader(line, nomaltgs, iPageSize); RegistStringReader(line, stringtgs); Lines.Add(line); line.Start(1000); } }
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); }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; ScanLine ret = new ScanLine(source.LaserID, count); ret.DisplayAsLine = source.DisplayAsLine; if (count < 4) { ret.AddRange(source); } else { BezierBuilder bez = new BezierBuilder(SegmentPerCurve, MinSquareDistance); bez.SetControlPoints(source); switch (Mode) { case eMode.Mode0: ret.AddRange(bez.GetDrawingPoints0()); break; case eMode.Mode1: ret.AddRange(bez.GetDrawingPoints1()); break; default: ret.AddRange(bez.GetDrawingPoints2()); break; } } return(ret); }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; if (count <= 2) return source; ScanLine ret = new ScanLine(source.LaserID, source.Count); ret.DisplayAsLine = source.DisplayAsLine; uint order = Order; for (int i = 0; i < count; i++) { if (this.CancelPending) return ret; // Debug.Write("["); List<Point3D> sourceWindow = new List<Point3D>(); for (int j = 0; j < order; j++) { int indice =(int)( i + j - order / 2); indice = Math.Max(0, Math.Min(indice, count - 1)); // Debug.Write(" "+indice); sourceWindow.Add(source[indice]); } // Debug.WriteLine("]"); ret.Add(Utils.GetMedian(sourceWindow)); } return ret; }
protected Point3D Smooth(int index, ScanLine prev, ScanLine current, ScanLine next) { //http://paulbourke.net/geometry/polygonmesh/ Point3DList nearPoints = new Point3DList(); if (index > 0) { Point3D prevP = current[index - 1]; nearPoints.Add(prevP); nearPoints.Add(prev.GetInterpolateByY(prevP.Position.Y)); nearPoints.Add(next.GetInterpolateByY(prevP.Position.Y)); } Point3D pt = current[index]; nearPoints.Add(pt); nearPoints.Add(prev.GetInterpolateByY(pt.Position.Y)); nearPoints.Add(next.GetInterpolateByY(pt.Position.Y)); if (index < current.Count - 1) { Point3D nextP = current[index + 1]; nearPoints.Add(nextP); nearPoints.Add(prev.GetInterpolateByY(nextP.Position.Y)); nearPoints.Add(next.GetInterpolateByY(nextP.Position.Y)); } Point3D ret = Smooth(current[index], nearPoints); return(ret); }
public override ScanLine DoTask(ScanLine source) { if (source.Count < 5) { //not enough points, less than 5 points surely a false positive return(new ScanLine(source.LaserID, 0)); } ValidityRange range = GetRange(source, Factor); ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D sp = source[i]; bool valid = range.IsValid(GetVal(sp)); #if DEBUG if (ColoriseOnly) { Color col = valid ? Color.WhiteSmoke : Color.Red; ret.Add(new Point3D(sp.Position, sp.Normal, col)); } else #endif if (valid) { ret.Add(new Point3D(sp.Position, sp.Normal, sp.Color)); } } return(ret); }
// OBB corner structure // ZMax ZMin // 0----1 4----5 // | | | | // | | | | // 3----2 7----6 private void Init() { var corners = new Vector3D[8]; _shipyardItem.ShipyardBox.GetCorners(corners, 0); //our endpoints are in the center of the faces //z plane _endpoints[0] = (corners[0] + corners[1] + corners[2] + corners[3]) / 4; _endpoints[1] = (corners[4] + corners[5] + corners[6] + corners[7]) / 4; // x plane _endpoints[2] = (corners[2] + corners[3] + corners[6] + corners[7]) / 4; _endpoints[3] = (corners[0] + corners[1] + corners[4] + corners[5]) / 4; /* * Scanning Z moves from [0] to [4] * Scanning X moves from [0] to [3] */ //start by scanning the line on the z plane, from zmax to zmin _line = new ScanLine { Origin = _endpoints[0], //get half the dimensions for each face ZWidth = (float)_shipyardItem.ShipyardBox.HalfExtent.X, ZLength = (float)_shipyardItem.ShipyardBox.HalfExtent.Y, XWidth = (float)_shipyardItem.ShipyardBox.HalfExtent.X, XLength = (float)_shipyardItem.ShipyardBox.HalfExtent.Z, //we need the up and left vectors to align the billboard to the shipyard grid ZLeft = _shipyardItem.ShipyardBox.Orientation.Right, ZUp = -_shipyardItem.ShipyardBox.Orientation.Up, XLeft = -_shipyardItem.ShipyardBox.Orientation.Right, XUp = _shipyardItem.ShipyardBox.Orientation.Forward }; }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source); ret.DisplayAsLine = this.DisplayAsLine; return(ret); }
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; }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; ScanLine ret = new ScanLine(source.LaserID, count); ret.DisplayAsLine = source.DisplayAsLine; if (count < 3) { ret.AddRange(source); } else { ret.Add(source[0]); for (int i = 1; i < count - 1; i++) { if (CancelPending) { return(source); } ret.Add(source[i - 1].Average(source[i + 1])); } ret.Add(source[count - 1]); } return(ret); }
protected override StripResult CreateStrip(ScanLine previous, ScanLine current) { int count1 = previous.Count; int count2 = current.Count; ScanLine ret1 = new ScanLine(previous.LaserID, previous.Count); ScanLine ret2 = new ScanLine(current.LaserID, current.Count); int i1 = 0; int i2 = 0; while (i1 < count1 && i2 < count2) { Point3D p1 = previous[i1]; Point3D p2 = current[i2]; ret1.Add(p1); ret2.Add(p2); if (i2 == 0 && p1.Position.Y > p2.Position.Y) i1++; else if (i1 == 0 && p1.Position.Y < p2.Position.Y) i2++; else if (i1 == count1 - 1 && i2 != count2 - 1) i2++; else if (i2 == count2 - 1 && i1 != count1 - 1) i1++; else { i1++; i2++; } } return new StripResult(ret1, ret2); }
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData) { if (scanLineMat == null) { UnityEngine.Debug.LogError("材质没找到!"); return; } if (!renderingData.cameraData.postProcessEnabled) { return; } //通过队列来找到HologramBlock组件,然后 var stack = VolumeManager.instance.stack; scanLine = stack.GetComponent <ScanLine>(); if (scanLine == null) { return; } if (!scanLine.IsActive()) { return; } var cmd = CommandBufferPool.Get(k_RenderTag); Render(cmd, ref renderingData); context.ExecuteCommandBuffer(cmd); CommandBufferPool.Release(cmd); }
void Parse(Stream s) { BinaryReader r = new BinaryReader(s); s.Position = 0; this.version = r.ReadUInt32(); this.doubledWidth = r.ReadUInt32(); this.height = r.ReadUInt32(); this.ageGender = (AgeGenderFlags)r.ReadUInt32(); this.physique = (Physiques)r.ReadByte(); this.shapeOrNormals = (ShapeOrNormals)r.ReadByte(); this.minCol = r.ReadUInt32(); this.maxCol = r.ReadUInt32(); this.minRow = r.ReadUInt32(); this.maxRow = r.ReadUInt32(); this.robeChannel = (RobeChannel)r.ReadByte(); int totalBytes = r.ReadInt32(); if (totalBytes == 0) { this.scanLines = new ScanLine[0]; } else { int width = (int)(maxCol - minCol + 1); uint numScanLines = maxRow - minRow + 1; this.scanLines = new ScanLine[numScanLines]; for (int i = 0; i < numScanLines; i++) { scanLines[i] = new ScanLine(recommendedApiVersion, OnResourceChanged, s, width); } } }
public MainWindow() { InitializeComponent(); SetupButtonTab(); _width = (int)PaintSurface.Width; _height = (int)PaintSurface.Height; _sourceRect = new Int32Rect(0, 0, _width, _height); SetupBitmap(); _sourceBuffer = new byte[_width * _height * (_wb.Format.BitsPerPixel / 8)]; ClearScreen(); Instance = this; RedrawAll(); var points1 = new System.Windows.Point[] { new System.Windows.Point(1, 1), new System.Windows.Point(1, 50), new System.Windows.Point(50, 1) }; var points2 = new System.Windows.Point[] { new System.Windows.Point(10, 10), new System.Windows.Point(10, 50), new System.Windows.Point(50, 10) }; var clip = SutherlandHodgman.GetIntersectedPolygon(points1, points2); List <Point> pointz = new List <Point>() { new Point(3, 0), new Point(0, 3), new Point(3, 6), new Point(6, 3) }; var filling = ScanLine.PolygonFilling(pointz, out var colorTab, true); UpdateDotProducts(); StartMainLoop(); }
protected override void Start() { base.Start(); m_ScanLine = FindObjectOfType <ScanLine>(); m_CloudRecoContentManager = FindObjectOfType <CloudRecoContentManager>(); }
/// <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); }
/// <summary> /// Do the work /// </summary> /// <param name="source"></param> /// <returns></returns> public override ScanLine DoTask(ScanLine source) { if (source.Count != 0) { return(source); } return(null); }
// Start is called before the first frame update void Start() { m_scanLine = ScriptableObject.CreateInstance <ScanLine>(); m_scanLine.enabled.Override(true); m_Volume = PostProcessManager.instance.QuickVolume(gameObject.layer, 100f, m_scanLine); }
private void PreviewPanel_Paint(object sender, PaintEventArgs e) { //Graphics g = e.Graphics; using (Bitmap bmp = new Bitmap(PreviewPanel.Width, PreviewPanel.Height)) { using (Graphics g = Graphics.FromImage(bmp)) { g.Clip = new Region(); using (SolidBrush b = new SolidBrush(PreviewPanel.BackColor)) g.FillRectangle(b, 0, 0, PreviewPanel.Width, PreviewPanel.Height); if (ScanInfo != null) { try { ScanLine line = null; LaserCorrection corr = null; double size = ScanInfo.Size() * 0.66f; double factor = Math.Min(PreviewPanel.Width, PreviewPanel.Height) / size; Matrix4d baseMatrix = Matrix4d.Scale(factor); PointF center = new PointF(PreviewPanel.Width / 2, PreviewPanel.Height / 2); DrawGrid(g, center, (float)factor); int currentLaser = CurrentLaserIndex; List <ScanLine> selectedLaserLine = new List <ScanLine>(); for (int i = 0; i < ScanInfo.Count; i++) { line = ScanInfo[i]; corr = new LaserCorrection(); corr.LoadFromSettings(line.LaserID); bool selected = currentLaser == line.LaserID; if (!selected) { DrawScanLine(g, center, factor, line, corr, false); } else { selectedLaserLine.Add(line); } } corr = new LaserCorrection(); corr.LoadFromSettings(selectedLaserLine[Math.Max(0, currentLaser)].LaserID); corr.Apply(Drag); for (int i = 0; i < selectedLaserLine.Count; i++) { DrawScanLine(g, center, factor, selectedLaserLine[i], corr, true); } } catch { } } } e.Graphics.Clip = new Region(); e.Graphics.DrawImageUnscaled(bmp, new Point(0, 0)); } }
public void Scanline() { Pontos[] pol = GerarPoligono(); Reta.AlocarBitmap(ret); ScanLine.Scanline(Reta.getImgDta(), pol); Reta.DesalocarBitmap(ret); pictureBox.Image = ret; imgBmp = ret; }
public Point3D GetSample(ScanLine line,int numClass, int index) { int classCount = line.Count / numClass; int classStart = index * classCount; if (classCount == 0 && line.Count > 0) return line[0]; List<Point3D> sub = new List<Point3D>(); for (int i = 0; i < classCount; i++) sub.Add(line[classStart + i]); return Point3D.Average(sub); }
private void btScan_Click(object sender, EventArgs e) { if (polist.SelectedItems.Count > 0) { ScanLine scan = new ScanLine(polys[polist.SelectedIndex]); img = scan.Fill(Color.DarkGreen, (Bitmap)img); picBox.Image = img; ScanLine scanVP = new ScanLine(VPs[polist.SelectedIndex]); VP = scanVP.Fill(Color.DarkGreen, VP); ViewPort.Image = VP; } }
/// <summary> /// register for events at the CloudRecoBehaviour /// </summary> void Start() { m_ScanLine = FindObjectOfType <ScanLine>(); m_CloudRecoContentManager = FindObjectOfType <CloudRecoContentManager>(); m_TrackableSettings = FindObjectOfType <TrackableSettings>(); // register this event handler at the cloud reco behaviour m_CloudRecoBehaviour = GetComponent <CloudRecoBehaviour>(); if (m_CloudRecoBehaviour) { m_CloudRecoBehaviour.RegisterEventHandler(this); } }
public override ScanLine DoTask(ScanLine source) { double clamp = Math.Abs(Utils.DeltaAngle(-180, source.Angle) / 360); ScanLine ret = new ScanLine(source.LaserID,source.Count); for (int i = 0; i < source.Count; i++) { Point3D p = source[i]; Vector4 c = new Vector4(0.25f, 0.25f, 0.25f, 1); c[source.LaserID%3] = (float)clamp; ret.Add(new Point3D(p.Position,p.Normal,ColorExtension.ColorFromVector(c))); } return ret; }
public override ScanLine DoTask(ScanLine source) { double clamp = Math.Abs(Utils.DeltaAngle(-180, source.Angle) / 360); ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D p = source[i]; Vector4 c = new Vector4(0.25f, 0.25f, 0.25f, 1); c[source.LaserID % 3] = (float)clamp; ret.Add(new Point3D(p.Position, p.Normal, ColorExtension.ColorFromVector(c))); } return(ret); }
/// <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); }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D p = source[i]; Vector3d pos = p.Position; pos.X *= XFactor; pos.Y *= YFactor; pos.Z *= ZFactor; ret.Add(new Point3D(pos, p.Normal, p.Color)); } return ret; }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D p = source[i]; Vector3d pos = p.Position; pos.X *= XFactor; pos.Y *= YFactor; pos.Z *= ZFactor; ret.Add(new Point3D(pos, p.Normal, p.Color)); } return(ret); }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source.LaserID, source.Count); ret.AddRange(source); /* * if (source != null && source.Count > 0) * { * Point3D avg = Point3D.Average(source); * ret.Add(avg); * } */ return(ret); }
/// <summary> /// Create a strip result for 2 Scanline (with same Nbr of Points) /// </summary> /// <param name="prev"></param> /// <param name="current"></param> public StripResult(ScanLine prev, ScanLine current) { if (prev.Count != current.Count) throw new Exception(" previous and current pointlist doesn't have the same point count"); Previous = prev; Current = current; Result = new ScanSlice(Previous.Count + current.Count); //GL.Begin(PrimitiveType.LineStrip); int count = Math.Min(Previous.Count, current.Count); for (int i = 0; i < count; i++) { Result.Add(Previous[i]); Result.Add(current[i]); } AbstractMeshBuilder.AdjustNormalFromTriangleStrip(Result); }
protected ScanLine AverageLines(int count, int biggestIndex, List<ScanLine> scanlines) { int numLines = scanlines.Count; ScanLine ret = new ScanLine(-1, count); for (int i = 0; i < count; i++) { List<Point3D> list = new List<Point3D>(numLines); double refy = scanlines[biggestIndex][i].Position.Y; for (int line = 0; line < numLines; line++) { list.Add(scanlines[line].GetInterpolateByY(refy, i == 0)); } ret.Add(Point3D.Average(list)); } return ret; }
protected ScanLine AverageLines(int count, int biggestIndex, List <ScanLine> scanlines) { int numLines = scanlines.Count; ScanLine ret = new ScanLine(-1, count); for (int i = 0; i < count; i++) { List <Point3D> list = new List <Point3D>(numLines); double refy = scanlines[biggestIndex][i].Position.Y; for (int line = 0; line < numLines; line++) { list.Add(scanlines[line].GetInterpolateByY(refy, i == 0)); } ret.Add(Point3D.Average(list)); } return(ret); }
public Point3D GetSample(ScanLine line, int numClass, int index) { int classCount = line.Count / numClass; int classStart = index * classCount; if (classCount == 0 && line.Count > 0) { return(line[0]); } List <Point3D> sub = new List <Point3D>(); for (int i = 0; i < classCount; i++) { sub.Add(line[classStart + i]); } return(Point3D.Average(sub)); }
public static void UpdateMinMax(ScanLine scanLine, ref float minX, ref float minY, ref float maxX, ref float maxY) { var xVals = new float[] { scanLine.X1, scanLine.X2 }; var yVals = new float[] { scanLine.Y1, scanLine.Y2 }; foreach (float val in xVals) { minX = (val < minX) ? val : minX; maxX = (val > maxX) ? val : maxX; } foreach (float val in yVals) { minY = (val < minY) ? val : minY; maxY = (val > maxY) ? val : maxY; } }
private void RegistReader(ScanLine line, List <TargetModel> targets, int pageSize) { int iPageCount = 0; if (targets.Count == 0) { iPageCount = 0; } else if (targets.Count <= pageSize) { iPageCount = 1; } else if (targets.Count % pageSize == 0) { iPageCount = targets.Count / pageSize; } else { iPageCount = targets.Count / pageSize; iPageCount += 1; } int currentPage = 1; while (currentPage <= iPageCount) { var reader = new Reader(); reader.ReadHandler += Reader_ReadHandler; var data = (targets.Skip((currentPage - 1) * pageSize).Take(pageSize)).ToList(); foreach (var target in data) { DataItem item = new DataItem(); item.DataType = DataTypeHelper.GetDataType(target.DataType); item.VarType = DataTypeHelper.GetVarType(target.VarType); item.DB = target.DB; item.StartByteAdr = target.StartByteAdr; item.BitAdr = System.BitConverter.GetBytes(target.BitAdr)[0]; item.Count = target.Count; reader.Items.Add(target.Address, item); } line.RegistReader(reader); currentPage += 1; } }
public override ScanLine DoTask(ScanLine source) { int count = source.Count; ScanLine ret = new ScanLine(source.LaserID, count); ret.DisplayAsLine = source.DisplayAsLine; if (count < 3) ret.AddRange(source); else { ret.Add(source[0]); for (int i = 1; i < count - 1; i++) { if (CancelPending) return source; ret.Add(source[i - 1].Average(source[i + 1])); } ret.Add(source[count - 1]); } return ret; }
public override ScanLine DoTask(ScanLine source) { int count =source.Count; ScanLine ret = new ScanLine(source.LaserID, count); for (int i = 0; i < count;i++ ) { Point3D p = source[i]; Vector3d pos = p.Position; Vector3d norm = p.Normal; Color col = p.Color; double r = col.R; double g = col.G; double b = col.B; if (m_Brigthness != 0) { r = r + m_Brigthness; g = g + m_Brigthness; b = b + m_Brigthness; } if(m_Contrast!=0) { double factor = (259 * (m_Contrast + 255)) / (255 * (259 - m_Contrast)); r = factor * (r - 128) + 128; g = factor * (g - 128) + 128; b = factor * (b - 128) + 128; } if(m_Gamma!=0) { double gammaCorrection = 1 / m_Gamma; r = 255 * Math.Pow((r / 255), gammaCorrection); g = 255 * Math.Pow((g / 255), gammaCorrection); b = 255 * Math.Pow((b / 255), gammaCorrection); } ret.Add(new Point3D(pos, norm, Color.FromArgb(255,Truncate(r),Truncate(g),Truncate(b)))); } return ret; }
protected override StripResult CreateStrip(ScanLine previous, ScanLine current) { ScanLine ret1 = new ScanLine(previous.LaserID); ScanLine ret2 = new ScanLine(current.LaserID); Point3DList all = new Point3DList(); all.AddRange(previous); all.AddRange(current.Where(p2 => previous.All(p1 => p1.Position.Y != p2.Position.Y))); all.Sort(); all.Reverse(); // all.AddRange(list1.Union(list2, )); for (int i = 0; i < all.Count; i++) { double y = all[i].Position.Y; Point3D p1 = previous.GetNearestY(y); Point3D p2 = current.GetNearestY(y); ret1.Add(p1); ret2.Add(p2); } return new StripResult(ret1, ret2); }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source.LaserID, source.Count); ret.AddRange(source); /* if (source != null && source.Count > 0) { Point3D avg = Point3D.Average(source); ret.Add(avg); } */ return ret; }
protected override StripResult CreateStrip(ScanLine previous, ScanLine current) { ScanLine interpolated = new ScanLine(current.LaserID, current.GetYInterpolated(previous)); return new StripResult(previous, interpolated); }
void GenerateFromEvents(Solver solver, OverlapRemovalParameters parameters, List<Event> events, bool isHorizontal) { // First, sort the events on the perpendicular coordinate of the event // (e.g. for horizontal constraint generation, order on vertical position). events.Sort(); #if VERBOSE Console.WriteLine("Events:"); foreach (Event evt in events) { Console.WriteLine(" {0}", evt); } #endif // VERBOSE var scanLine = new ScanLine(); foreach (Event evt in events) { OverlapRemovalNode currentNode = evt.Node; if (evt.IsForOpen) { // Insert the current node into the scan line. scanLine.Insert(currentNode); #if VERBOSE Console.WriteLine("ScanAdd: {0}", currentNode); #endif // VERBOSE // Find the nodes that are currently open to either side of it and are either overlapping // nodes or the first non-overlapping node in that direction. currentNode.LeftNeighbors = GetLeftNeighbours(parameters, scanLine, currentNode, isHorizontal); currentNode.RightNeighbors = GetRightNeighbours(parameters, scanLine, currentNode, isHorizontal); // Use counts for indexing for performance (rather than foreach, and hoist the count-control // variable out of the loop so .Count isn't checked on each iteration, since we know it's // not going to be changed). int numLeftNeighbors = currentNode.LeftNeighbors.Count; int numRightNeighbors = currentNode.RightNeighbors.Count; // If there is currently a non-overlap constraint between any two nodes across the // two neighbour lists we've just created, we can remove them because they will be // transitively enforced by the constraints we'll create for the current node. // I.e., we can remove the specification for the constraint // leftNeighborNode + gap + padding <= rightNeighborNode // because it is implied by the constraints we'll create for // leftNeighborNode + gap + padding <= node // node + gap + padding <= rightNeighborNode // We must also add the current node as a neighbour in the appropriate direction. // @@PERF: List<T>.Remove is a sequential search so averages 1/2 the size of the // lists. We currently don't expect the neighbour lists to be very large or Remove // to be a frequent operation, and using HashSets would incur the GetEnumerator overhead // on the outer and inner loops; but .Remove creates an inner-inner loop so do some // timing runs to compare performance. // @@PERF: handles the case where we are node c and have added node b as a lnbour // and node d as rnbour, where those nodes are already nbours. But it does not handle // the case where we add node b and node a as lnbours, and node b already has node a // as an lnbour. To do this I think we'd just want to skip adding the node-a lnbour, // but that forms a new inner loop (iterating all lnbours before adding a new one) // unless we develop different storage for nbours. for (int ii = 0; ii < numLeftNeighbors; ++ii) { OverlapRemovalNode leftNeighborNode = currentNode.LeftNeighbors[ii]; for (int jj = 0; jj < numRightNeighbors; ++jj) { // TODOunit: test this OverlapRemovalNode nodeToRemove = currentNode.RightNeighbors[jj]; if (leftNeighborNode.RightNeighbors.Remove(nodeToRemove)) { #if VERBOSE Console.WriteLine(" {0} RnbourRem {1} --> {2}", isHorizontal ? "H" : "V", leftNeighborNode, nodeToRemove); #endif // VERBOSE } } leftNeighborNode.RightNeighbors.Add(currentNode); } for (int ii = 0; ii < numRightNeighbors; ++ii) { // TODOunit: test this OverlapRemovalNode rightNeighborNode = currentNode.RightNeighbors[ii]; for (int jj = 0; jj < numLeftNeighbors; ++jj) { OverlapRemovalNode nodeToRemove = currentNode.LeftNeighbors[jj]; if (rightNeighborNode.LeftNeighbors.Remove(nodeToRemove)) { #if VERBOSE Console.WriteLine(" {0} LnbourRem {1} --> {2}", isHorizontal ? "H" : "V", nodeToRemove, rightNeighborNode); #endif // VERBOSE } } rightNeighborNode.LeftNeighbors.Add(currentNode); } } // endif evt.IsForOpen else { // This is a close event, so generate the constraints and remove the closing node // from its neighbours lists. If we're closing we should have left neighbours so // this is null then we've likely got some sort of internal calculation error. if (null == currentNode.LeftNeighbors) { Debug.Assert(null != currentNode.LeftNeighbors, "LeftNeighbors should not be null for a Close event"); continue; } // currentNode is the current node; if it's a cluster, translate it to the node that // should be involved in the constraint (if it's the left neighbour then use its // right border as the constraint variable, and vice-versa). OverlapRemovalNode currentLeftNode = GetLeftConstraintNode(currentNode); OverlapRemovalNode currentRightNode = GetRightConstraintNode(currentNode); // LeftNeighbors must end before the current node... int cLeftNeighbours = currentNode.LeftNeighbors.Count; for (int ii = 0; ii < cLeftNeighbours; ++ii) { // Keep track of the original Node; it may be the base of a Cluster, in which // case it will have the active neighbours list, not leftNeighborNode (which will // be the left border "fake Node"). OverlapRemovalNode origLeftNeighborNode = currentNode.LeftNeighbors[ii]; origLeftNeighborNode.RightNeighbors.Remove(currentNode); OverlapRemovalNode leftNeighborNode = GetLeftConstraintNode(origLeftNeighborNode); Debug.Assert(leftNeighborNode.OpenP == origLeftNeighborNode.OpenP, "leftNeighborNode.OpenP must == origLeftNeighborNode.OpenP"); // This assert verifies we match the Solver.ViolationTolerance check in AddNeighbor. // We are closing the node here so use an alternative to OverlapP for additional // consistency verification. Allow a little rounding error. Debug.Assert(isHorizontal || ((currentNode.CloseP + NodePaddingP - leftNeighborNode.OpenP) > (parameters.SolverParameters.GapTolerance - 1e-6)), "LeftNeighbors: unexpected close/open overlap"); double p = leftNeighborNode == LeftBorderNode || currentRightNode == RightBorderNode ? ClusterPadding : NodePadding; double separation = ((leftNeighborNode.Size + currentRightNode.Size) / 2) + p; if (TranslateChildren) { separation = Math.Max(separation, currentRightNode.Position - leftNeighborNode.Position); } Constraint cst = solver.AddConstraint(leftNeighborNode.Variable, currentRightNode.Variable, separation); Debug.Assert(null != cst, "LeftNeighbors: unexpected null cst"); #if VERBOSE Console.WriteLine(" {0} LnbourCst {1} -> {2} g {3:F5}", isHorizontal ? "H" : "V" , cst.Left.Name, cst.Right.Name, cst.Gap); #endif // VERBOSE } // ... and RightNeighbors must start after the current node. int cRightNeighbours = currentNode.RightNeighbors.Count; for (int ii = 0; ii < cRightNeighbours; ++ii) { // Keep original node, which may be a cluster; see comments in LeftNeighbors above. OverlapRemovalNode origRightNeighborNode = currentNode.RightNeighbors[ii]; origRightNeighborNode.LeftNeighbors.Remove(currentNode); OverlapRemovalNode rightNeighborNode = GetRightConstraintNode(origRightNeighborNode); // This assert verifies we match the Solver.ViolationTolerance check in AddNeighbor. // Allow a little rounding error. Debug.Assert(isHorizontal || ((currentNode.CloseP + NodePaddingP - rightNeighborNode.OpenP) > (parameters.SolverParameters.GapTolerance - 1e-6)), "RightNeighbors: unexpected close/open overlap"); double p = currentLeftNode == LeftBorderNode || rightNeighborNode == RightBorderNode ? ClusterPadding : NodePadding; double separation = ((currentLeftNode.Size + rightNeighborNode.Size) / 2) + p; if (TranslateChildren) { separation = Math.Max(separation, rightNeighborNode.Position - currentLeftNode.Position); } Constraint cst = solver.AddConstraint(currentLeftNode.Variable, rightNeighborNode.Variable, separation); Debug.Assert(null != cst, "RightNeighbors: unexpected null cst"); #if VERBOSE Console.WriteLine(" {0} RnbourCst {1} -> {2} g {3:F5}", isHorizontal ? "H" : "V" , cst.Left.Name, cst.Right.Name, cst.Gap); #endif // VERBOSE } // Note: although currentNode is closed, there may still be open nodes in its // Neighbour lists; these will subsequently be processed (and removed from // currentNode.*Neighbour) when those Neighbors are closed. scanLine.Remove(currentNode); #if VERBOSE Console.WriteLine("ScanRem: {0}", currentNode); #endif // VERBOSE } // endelse !evt.IsForOpen // @@PERF: Set Node.Left/RightNeighbors null to let the GC know we're not using them // anymore, unless we can reasonably assume a short lifetime for the ConstraintGenerator. } // endforeach Event }
} // end GetLeftNeighbours List<OverlapRemovalNode> GetRightNeighbours(OverlapRemovalParameters parameters, ScanLine scanLine, OverlapRemovalNode currentNode, bool isHorizontal) { var lstNeighbours = new List<OverlapRemovalNode>(); OverlapRemovalNode nextNode = scanLine.NextRight(currentNode); for (; null != nextNode; nextNode = scanLine.NextRight(nextNode)) { // AddNeighbor returns false if we are done adding them. if (!AddNeighbour(parameters, currentNode, nextNode, lstNeighbours, false /* isLeftNeighbor */ , isHorizontal)) { if (!nextNode.DeferredRightNeighborToV) { break; } } } // endfor NextLeft return lstNeighbours; } // end GetRightNeighbours
/// <summary> /// Create a StripResult from 2 ScanLine /// </summary> /// <param name="previous"></param> /// <param name="current"></param> /// <returns></returns> protected abstract StripResult CreateStrip(ScanLine previous, ScanLine current);
public Stream ToBitMap(OutputType type) { MemoryStream ms = new MemoryStream(); BinaryWriter w = new BinaryWriter(ms); if (maxCol == 0) return null; int height = (int)(maxRow - minRow + 1); int width = (int)(this.maxCol - this.minCol + 1); ScanLine[] scanLines = new ScanLine[height]; using (MemoryStream scanLineStream = new MemoryStream(this.scanLineData)) { for (int i = 0; i < scanLines.Length; i++) scanLines[i] = new ScanLine(width, scanLineStream); } byte[] pixelArraySkinTight = new byte[width * height * 3]; byte[] pixelArrayRobe = new byte[width * height * 3]; int destIndexRobe = 0; int destSkinTight = 0; int pixelsize = 0; for (int i = 0; i < height; i++) { if (scanLines[i].RobeChannel == RobeChannel.ROBECHANNEL_PRESENT) { pixelsize = 6; } else { pixelsize = 3; } var scan = scanLines[i]; if (!scan.IsCompressed) { for (int j = 0; j < width; j++) { pixelArraySkinTight[destSkinTight++] = scan.UncompressedPixels[(j * pixelsize) + 0]; pixelArraySkinTight[destSkinTight++] = scan.UncompressedPixels[(j * pixelsize) + 1]; pixelArraySkinTight[destSkinTight++] = scan.UncompressedPixels[(j * pixelsize) + 2]; switch (scan.RobeChannel) { case RobeChannel.ROBECHANNEL_PRESENT: pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 3]; pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 4]; pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 5]; break; case RobeChannel.ROBECHANNEL_DROPPED: pixelArrayRobe[destIndexRobe++] = 0; pixelArrayRobe[destIndexRobe++] = 0; pixelArrayRobe[destIndexRobe++] = 0; break; case RobeChannel.ROBECHANNEL_ISCOPY: pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 0]; pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 1]; pixelArrayRobe[destIndexRobe++] = scan.UncompressedPixels[(j * pixelsize) + 2]; break; } } } else { // Look up each pixel using index tables for (int j = 0; j < width; j++) { // To get pointer to the RLE encoded data we need first find // proper RLE run in the buffer. Use index for this: // Cache increment for indexing in pixel space? int step = 1 + width / (scan.NumIndexes - 1); // 1 entry was added for the remainder of the division // Find index into the positions and data table: int idx = j / step; // This is location of the run first covering this interval. int pixelPosX = scan.PixelPosIndexes[idx]; // Position of the RLE data of the place where need to unwind to the pixel. int dataPos = scan.DataPosIndexes[idx] * (pixelsize + 1); // +1 for run length byte // This is run length for the RLE entry found at int runLength = scan.RLEArrayOfPixels[dataPos]; // Loop forward unwinding RLE data from the found indexed position. // Continue until the pixel position in question is not covered // by the current run interval. By design the loop should execute // only few times until we find the value we are looking for. while (j >= pixelPosX + runLength) { pixelPosX += runLength; dataPos += (1 + pixelsize); // 1 for run length, +pixelSize for the run value runLength = scan.RLEArrayOfPixels[dataPos]; } // After breaking out of the cycle, we have the current run length interval // covering the pixel position x we are interested in. So just return the pointer // to the pixel data we were after: int pixelStart = dataPos + 1; // pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[pixelStart + 0]; pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[pixelStart + 1]; pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[pixelStart + 2]; switch (scan.RobeChannel) { case RobeChannel.ROBECHANNEL_PRESENT: pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 3]; pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 4]; pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 5]; break; case RobeChannel.ROBECHANNEL_DROPPED: pixelArrayRobe[destIndexRobe++] = 0; pixelArrayRobe[destIndexRobe++] = 0; pixelArrayRobe[destIndexRobe++] = 0; break; case RobeChannel.ROBECHANNEL_ISCOPY: pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 0]; pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 1]; pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[pixelStart + 2]; break; } } //// Unpack the RLE Scan line without using index tables //numpixelsdecoded = 0; //rleindex = 0; //while (numpixelsdecoded < width) //{ // runlen = scan.RLEArrayOfPixels[rleindex++]; // for (int j = 0; j < runlen; j++) // { // pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[rleindex + 0]; // pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[rleindex + 1]; // pixelArraySkinTight[destSkinTight++] = scan.RLEArrayOfPixels[rleindex + 2]; // switch (scan.RobeChannel) // { // case RobeChannel.ROBECHANNEL_PRESENT: // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // break; // case RobeChannel.ROBECHANNEL_DROPPED: // pixelArrayRobe[destIndexRobe++] = 0; // pixelArrayRobe[destIndexRobe++] = 0; // pixelArrayRobe[destIndexRobe++] = 0; // break; // case RobeChannel.ROBECHANNEL_ISCOPY: // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // pixelArrayRobe[destIndexRobe++] = scan.RLEArrayOfPixels[rleindex + 0]; // break; // } // numpixelsdecoded++; // } // rleindex += pixelsize; //} } } w.Write((ushort)0x4d42); w.Write(0); w.Write(0); w.Write(54); w.Write(40); w.Write(width); w.Write(height); w.Write((ushort)1); w.Write((ushort)24); for (int i = 0; i < 6; i++) w.Write(0); int bytesPerLine = (int)Math.Ceiling(width * 24.0 / 8.0); int padding = 4 - bytesPerLine % 4; long sourcePosition = 0; for (int i = 0; i < height; i++) { for (int j = 0; j < width * 3; j++) { w.Write(type == OutputType.Robe? pixelArrayRobe[sourcePosition++] : pixelArraySkinTight[sourcePosition++]); } for (int j = 0; j < padding; j++) { w.Write((byte)0); } } return ms; }
/// <summary> /// Do the work /// </summary> /// <param name="source"></param> /// <returns></returns> public override ScanLine DoTask(ScanLine source) { if (source.Count != 0) return source; return null; }
/// <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; }
public override ScanLine DoTask(ScanLine source) { if (source.Count < 5) { //not enough points, less than 5 points surely a false positive return new ScanLine(source.LaserID, 0); } ValidityRange range = GetRange(source, Factor); ScanLine ret = new ScanLine(source.LaserID, source.Count); for (int i = 0; i < source.Count; i++) { Point3D sp = source[i]; bool valid = range.IsValid(GetVal(sp)); #if DEBUG if (ColoriseOnly) { Color col = valid ? Color.WhiteSmoke : Color.Red; ret.Add(new Point3D(sp.Position, sp.Normal, col)); } else #endif if(valid) ret.Add(new Point3D(sp.Position, sp.Normal, sp.Color)); } return ret; }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source); return ret; }
protected ScanData DoIteration(ScanData source, double pctMin, double pctMax) { ScanData ret = new ScanData(source.Count); ret.AddRange(source); int count = source.Count; int doneCount = 0; int ParallelCount = Settings.Get<Settings>().Read(Settings.SYSTEM, Settings.MAXTHREADS, 8); Parallel.For(1, count+1, new ParallelOptions { MaxDegreeOfParallelism = ParallelCount }, i => {//for (int i = 1; i <= count; i++) { if (this.CancelPending) return; ScanLine current = source[i % count]; ScanLine prev = source[(i - 1) % count]; ScanLine next = source[(i + 1) % count]; int lineCount = current.Count; ScanLine smoothed = new ScanLine(current.Count); smoothed.DisplayAsLine = current.DisplayAsLine; for (int l = 0; l < lineCount; l++) { smoothed.Add(Smooth(l, prev, current, next)); } ret[i % count] = smoothed; doneCount++; int pct = (int)(pctMin + ((pctMax - pctMin) * doneCount) / count); UpdatePercent(pct, ret); } }); return ret; }
public override ScanLine DoTask(ScanLine source) { ScanLine ret = new ScanLine(source); ret.DisplayAsLine = this.DisplayAsLine; return ret; }
/// <summary> /// Abstract function for work to do on a Scanline /// </summary> /// <param name="source"></param> /// <returns></returns> public abstract ScanLine DoTask(ScanLine source);
protected Point3D Smooth(int index, ScanLine prev, ScanLine current, ScanLine next) { //http://paulbourke.net/geometry/polygonmesh/ Point3DList nearPoints = new Point3DList(); if (index > 0) { Point3D prevP = current[index - 1]; nearPoints.Add(prevP); nearPoints.Add(prev.GetInterpolateByY(prevP.Position.Y)); nearPoints.Add(next.GetInterpolateByY(prevP.Position.Y)); } Point3D pt = current[index]; nearPoints.Add(pt); nearPoints.Add(prev.GetInterpolateByY(pt.Position.Y)); nearPoints.Add(next.GetInterpolateByY(pt.Position.Y)); if (index <current.Count-1) { Point3D nextP = current[index + 1]; nearPoints.Add(nextP); nearPoints.Add(prev.GetInterpolateByY(nextP.Position.Y)); nearPoints.Add(next.GetInterpolateByY(nextP.Position.Y)); } Point3D ret = Smooth(current[index], nearPoints); return ret; }