public void CreateGCodeFromStlFile() { var mesh = _stlReader.ReadStl(View.FileName); if (!_meshHelper.IsMeshManifold(mesh)) { return; } _meshHelper.CenterMesh(mesh); var layers = _slicer.Slice(mesh); var path = _pather.GeneratePath(layers); View.GCode = _generator.GenerateGCode(path); }
public PhaseResult GetPhase(double[] pulseSequence) { var crestIndices = _finder.Find(pulseSequence); if (crestIndices.IsEmpty()) { return(PhaseResult.FromException(ProcessException.NoPeakFound)); } var sliceInfos = _slicer.Slice(pulseSequence, crestIndices); if (sliceInfos.IsEmpty()) { return(PhaseResult.FromException(ProcessException.NoSliceValid)); } var example = sliceInfos.First(); var pulse = _preprocessor.RetrievePulse(pulseSequence, example.StartIndex, example.CrestOffset, example.Length); _rotator.TrySymmetrize(pulse, example.CrestOffset); double[] phase; try { phase = _phaseExtractor.GetPhase(pulse, null); } catch (PhaseFitException) { return(PhaseResult.FromException(ProcessException.NoFlatPhaseIntervalFound)); } var unwrap = Functions.Unwrap(phase); return(PhaseResult.WithoutException(unwrap)); }
public IList <SpecInfo> Process([NotNull] double[] pulseSequence) { var crestIndices = _finder.Find(pulseSequence); if (crestIndices.IsEmpty()) { return(new List <SpecInfo>()); } var sliceInfos = _slicer.Slice(pulseSequence, crestIndices); if (sliceInfos.IsEmpty()) { return(new List <SpecInfo>()); } return(sliceInfos.Select( (sliceInfo, i) => { var pulse = _preprocessor.RetrievePulse(pulseSequence, sliceInfo.StartIndex, sliceInfo.CrestOffset, sliceInfo.Length); _rotator.TrySymmetrize(pulse, sliceInfo.CrestOffset); // todo do it at preproposs var correctedSpectrum = _corrector.Correct(pulse); return new SpecInfo( correctedSpectrum.Aggregate((complex, complex1) => complex + complex1) / correctedSpectrum.Length, i); } ).ToList()); }
public AccumulationResult Process([NotNull] double[] pulseSequence) { var crestIndices = _finder.Find(pulseSequence); if (crestIndices.IsEmpty()) { return(AccumulationResult.FromException(ProcessException.NoPeakFound)); } var sliceInfos = _slicer.Slice(pulseSequence, crestIndices); if (sliceInfos.IsEmpty()) { return(AccumulationResult.FromException(ProcessException.NoSliceValid)); } var cnt = 0; Complex[] accumulatedSpectrum = null; var errorCnt = 0; foreach (var sliceInfo in sliceInfos) { var pulse = _preprocessor.RetrievePulse(pulseSequence, sliceInfo.StartIndex, sliceInfo.CrestOffset, sliceInfo.Length); _rotator.TrySymmetrize(pulse, sliceInfo.CrestOffset); // todo do it at preproposs Complex[] correctedSpectrum; try { correctedSpectrum = _corrector.Correct(pulse); } catch (CorrectFailException) { errorCnt++; continue; } accumulatedSpectrum = Accumulate(accumulatedSpectrum, correctedSpectrum); cnt++; } if (accumulatedSpectrum == null) { return(AccumulationResult.FromException(ProcessException.NoFlatPhaseIntervalFound, errorCnt)); } var spectrum = new Spectrum(accumulatedSpectrum, cnt); if (errorCnt == 0) { return(AccumulationResult.WithoutException(spectrum)); } return(new AccumulationResult(spectrum, ProcessException.NoFlatPhaseIntervalFound, errorCnt)); }