internal bool TryGetNext(out LinePair linePair, TemplateLineEvaluationResult lastTemplateLineEvaluationResult) { bool result = false; Line targetLine = null; TemplateLine templateLine = null; bool targetLineReturned = targetIterator.TryGetNext(out targetLine); //If there are no more target lines then escape the current repeating line if there is one //and move through the rest of the template. if (targetLineReturned == false && lastTemplateLineEvaluationResult != null) { lastTemplateLineEvaluationResult.EscapeRepeat = true; } bool templateLineReturned = templateIterator.TryGetNext(out templateLine, lastTemplateLineEvaluationResult); if (targetLineReturned || templateLineReturned) { result = true; linePair = factory.CreateLinePair(targetLine, templateLine); } else { linePair = null; } return(result); }
internal LinePairEvaluationResult EvaluateLinePair(LinePair linePair) { LinePairEvaluationResult result = new LinePairEvaluationResult(); if (linePair.TargetLine == null) { result.Outcome = LinePairEvaluationOutcome.MissNoTarget; } if (linePair.TemplateLine == null) { result.Outcome = LinePairEvaluationOutcome.MissNoTemplate; } if (result.Outcome == LinePairEvaluationOutcome.Match) { result.TemplateLineEvaluationResult = templateLineEvaluator.EvaluateLinePair(linePair); if (result.TemplateLineEvaluationResult.Match == false) { result.Outcome = LinePairEvaluationOutcome.Miss; } } result.TargetLine = linePair.TargetLine; result.TemplateLine = linePair.TemplateLine; return(result); }
void worker_ProgressChanged(object sender, ProgressChangedEventArgs e) { Application.Invoke(delegate { if (e.ProgressPercentage >= 100) { progressbar.Fraction = 1.0; return; } //Copy in the next line LinePair linePair = (LinePair)e.UserState; var width = linePair.Colors.GetUpperBound(0); for (int x = 0; x < width; x++) { var offset = 3 * x + rawPixbuf.Rowstride * linePair.Y; Marshal.WriteByte(rawPixbuf.Pixels, offset + 0, linePair.Colors [x, 0].R); Marshal.WriteByte(rawPixbuf.Pixels, offset + 1, linePair.Colors [x, 0].G); Marshal.WriteByte(rawPixbuf.Pixels, offset + 2, linePair.Colors [x, 0].B); offset += rawPixbuf.Rowstride; Marshal.WriteByte(rawPixbuf.Pixels, offset + 0, linePair.Colors [x, 1].R); Marshal.WriteByte(rawPixbuf.Pixels, offset + 1, linePair.Colors [x, 1].G); Marshal.WriteByte(rawPixbuf.Pixels, offset + 2, linePair.Colors [x, 1].B); } stretchyImage.NotifyPixbufChanged(); progressbar.Fraction = e.ProgressPercentage / 100d; }); }
public MarkupLine GetCommonLine(IFillerVertex other) { return(other switch { EnterSupportPoint otherE => First.ContainsPoint(otherE.Point) ? First : Second, IntersectSupportPoint otherI => LinePair.ContainLine(otherI.LinePair.First) ? otherI.LinePair.First : otherI.LinePair.Second, _ => null, });
void SpawnLine(LinePair pair, float density) { int numParticles = Mathf.RoundToInt(Vector3.Distance(pair.startPos.position, pair.endPos.position) * density); for (int i = 0; i < numParticles; i++) { GameObject newPart = Instantiate(particlePrefab, Vector3.Lerp(pair.startPos.position, pair.endPos.position, Random.value), Random.rotation); newPart.GetComponent <Renderer>().material = puffMat; newPart.GetComponent <ExplosionParticle>().Init(Random.Range(0f, 0.1f), Random.Range(0.9f, 1.7f), Random.Range(0.2f, 0.4f), transform.forward, Vector3.zero); } }
public MarkupLine GetCommonLine(IFillerVertex other) { switch (other) { case EnterSupportPoint otherE: return First.ContainsPoint(otherE.Point) ? First : Second; case IntersectSupportPoint otherI: return LinePair.ContainLine(otherI.LinePair.First) ? otherI.LinePair.First : otherI.LinePair.Second; default: return null; } }
internal TemplateEvaluationResult Evaluate(string target, string template) { TemplateEvaluationResult result = new TemplateEvaluationResult(); var linePairIterator = factory.CreateLinePairIterator(target, template); LinePair linePair = null; TemplateLineEvaluationResult lastTemplateLineEvaluationResult = null; while (linePairIterator.TryGetNext(out linePair, lastTemplateLineEvaluationResult)) { var linePairEvaluationResult = linePairEvaluator.EvaluateLinePair(linePair); result.Add(linePairEvaluationResult); lastTemplateLineEvaluationResult = linePairEvaluationResult.TemplateLineEvaluationResult; } return(result); }
internal LinePairEvaluationResult EvaluateLinePair(LinePair linePair) { LinePairEvaluationResult result = new LinePairEvaluationResult(); if (linePair.TargetLine == null) result.Outcome = LinePairEvaluationOutcome.MissNoTarget; if (linePair.TemplateLine == null) result.Outcome = LinePairEvaluationOutcome.MissNoTemplate; if (result.Outcome == LinePairEvaluationOutcome.Match) { result.TemplateLineEvaluationResult = templateLineEvaluator.EvaluateLinePair(linePair); if (result.TemplateLineEvaluationResult.Match == false) result.Outcome = LinePairEvaluationOutcome.Miss; } result.TargetLine = linePair.TargetLine; result.TemplateLine = linePair.TemplateLine; return result; }
internal bool TryGetNext(out LinePair linePair, TemplateLineEvaluationResult lastTemplateLineEvaluationResult) { bool result = false; Line targetLine = null; TemplateLine templateLine = null; bool targetLineReturned = targetIterator.TryGetNext(out targetLine); //If there are no more target lines then escape the current repeating line if there is one //and move through the rest of the template. if (targetLineReturned == false && lastTemplateLineEvaluationResult != null) lastTemplateLineEvaluationResult.EscapeRepeat = true; bool templateLineReturned = templateIterator.TryGetNext(out templateLine, lastTemplateLineEvaluationResult); if (targetLineReturned || templateLineReturned) { result = true; linePair = factory.CreateLinePair(targetLine, templateLine); } else { linePair = null; } return result; }
private void workerCapture_ProgressChanged(object sender, ProgressChangedEventArgs e) { if (e.ProgressPercentage < 100) { lbStatus.Text = "Capturing"; //Copy in the next line LinePair linePair = (LinePair)e.UserState; Bitmap bitmap = (Bitmap)pbBayer.Image; for (int x = 0; x < linePair.Colors.GetUpperBound(0); x++) { bitmap.SetPixel(x, linePair.Y, linePair.Colors[x, 0]); bitmap.SetPixel(x, linePair.Y + 1, linePair.Colors[x, 1]); } pbBayer.Refresh(); pbProgress.Value = e.ProgressPercentage; } else { lbStatus.Text = "Interpolating"; //Updating interpolated image pbProgress.Value = e.ProgressPercentage - 100; } }
private void ParseAllC13Lines(uint c13linesbytes) { C13LinesSeq = new ByteSequence(FlattenedBuffer, ReadOffset, (int)c13linesbytes); int begin = ReadOffset; while (ReadOffset < begin + c13linesbytes) { int chunkbegin = ReadOffset; var chunksig = ExtractUInt32(); var chunksize = ExtractUInt32(); var chunkend = ReadOffset + chunksize.ExtractedValue; if (chunksig.ExtractedValue == 0xf4) { while (ReadOffset < chunkend) { int csbegin = ReadOffset; var checksumfile = ExtractUInt32(); var bytecount = ExtractByte(); var checksumtype = ExtractByte(); var checksum = ExtractBytes(bytecount.ExtractedValue); var seq = new ByteSequence(FlattenedBuffer, csbegin, ReadOffset - csbegin); var csr = new Checksum { FileIndex = checksumfile, ByteCount = bytecount, Type = checksumtype, ChecksumBytes = checksum, OriginalSequence = seq }; Checksums.Add(csr); Extract4ByteAlignment(); } } else if (chunksig.ExtractedValue == 0xf2) { while (ReadOffset < chunkend) { int ldbegin = ReadOffset; var functionoffset = ExtractUInt32(); var segcontrib = ExtractUInt16(); var flags = ExtractUInt16(); var codesize = ExtractUInt32(); var ld = new LineData { FunctionOffset = functionoffset, SegmentOfContribution = segcontrib, Flags = flags, CodeSize = codesize, LineBlocks = new List <LineBlock>() }; while (ReadOffset < chunkend) { var nameindex = ExtractUInt32(); var numlines = ExtractUInt32(); var blocksize = ExtractUInt32(); var lb = new LineBlock { NameIndex = nameindex, NumLines = numlines, BlockSize = blocksize, Pairs = new List <LinePair>() }; for (uint i = 0; i < numlines.ExtractedValue; ++i) { var offset = ExtractUInt32(); var lpflags = ExtractUInt32(); var lp = new LinePair { CodeOffset = offset, Flags = lpflags }; lb.Pairs.Add(lp); } if ((flags.ExtractedValue & 1) != 0) { for (uint i = 0; i < numlines.ExtractedValue; ++i) { ExtractUInt32(); } } ld.LineBlocks.Add(lb); } ld.OriginalSequence = new ByteSequence(FlattenedBuffer, ldbegin, ReadOffset - ldbegin); Lines.Add(ld); } } else { ReadOffset += (int)chunksize.ExtractedValue; } } }