diff --git a/surfacemanager.cpp b/surfacemanager.cpp index 12833c47..b3f70d3a 100644 --- a/surfacemanager.cpp +++ b/surfacemanager.cpp @@ -75,6 +75,7 @@ #include "ui_oglrendered.h" #include "astigpolargraph.h" + cv::Mat theMask; cv::Mat deb; double outputLambda; @@ -438,6 +439,13 @@ cv::Mat SurfaceManager::computeWaveFrontFromZernikes(int wx, int wy, std::vector double rho; + int maxZernToUse = 0; + for (int value : zernsToUse) { + if (value > maxZernToUse) + maxZernToUse = value; + } + + std::vector &en = zernEnables; mirrorDlg *md = mirrorDlg::get_Instance(); for (int i = 0; i < wx; ++i) @@ -452,7 +460,7 @@ cv::Mat SurfaceManager::computeWaveFrontFromZernikes(int wx, int wy, std::vector { double S1 = 0; double theta = atan2(y1,x1); - zernikePolar zpolar(rho, theta, zernsToUse.size()); + zernikePolar zpolar(rho, theta, maxZernToUse+1); for (int ii = 0; ii < zernsToUse.size(); ++ii) { int z = zernsToUse[ii]; @@ -1099,12 +1107,14 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){ QMessageBox::warning(NULL, tr("Read Wavefront File"),b); return 0; } + spdlog::get("logger")->trace("readWaveFront() step 1"); wavefront *wf = new wavefront(); double width; double height; file >> width; file >> height; cv::Mat data(height,width, numType,0.); + spdlog::get("logger")->trace("readWaveFront() width {} height {}", width, height); for( size_t y = 0; y < height; y++ ) { for( size_t x = 0; x < width; x++ ) { @@ -1112,6 +1122,7 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){ //data.at(height - y - 1, x) += dist(generator); } } + spdlog::get("logger")->trace("readWaveFront() step 2"); std::string line; QString l; @@ -1160,6 +1171,7 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){ } } + wf->m_outside = CircleOutline(QPointF(xm,ym), radm); if (rado == 0){ xo = xm; @@ -1290,8 +1302,9 @@ bool SurfaceManager::loadWavefront(const QString &fileName){ QMessageBox::warning(NULL, tr("Read Wavefront File"),b); } wavefront *wf; - + spdlog::get("logger")->trace("loadWavefront()"); if (m_currentNdx == 0 && m_wavefronts[0]->name == "Demo"){ + spdlog::get("logger")->trace("loadWavefront() delete current"); deleteCurrent(); } @@ -1306,16 +1319,17 @@ bool SurfaceManager::loadWavefront(const QString &fileName){ // if resize to smaller if (Settings2::getInstance()->m_general->shouldDownsize()){ + spdlog::get("logger")->trace("loadWavefront() downSize"); downSizeWf(wf); } makeMask(m_currentNdx); - m_surface_finished = false; try { generateSurfacefromWavefront(m_currentNdx); } catch (int i){ deleteCurrent(); + spdlog::get("logger")->critical("loadWavefront() crash while generating surface"); throw i; } @@ -2414,7 +2428,7 @@ textres SurfaceManager::Phase2(QList list, QList inp void SurfaceManager::computeStandAstig(define_input *wizPage, QList list){ // check for pairs QVector lookat = list.toVector(); - + spdlog::get("logger")->trace("computeStandAstig()"); while (lookat.size()){ for (int i = 0; i < lookat.size(); ++i){ double angle1 = wrapAngle(lookat[i]->angle); @@ -2449,6 +2463,7 @@ void SurfaceManager::computeStandAstig(define_input *wizPage, QListtrace("computeStandAstig() create printer step 1"); QPrinter printer(QPrinter::HighResolution); printer.setColorMode( QPrinter::Color ); printer.setFullPage( true ); @@ -2486,6 +2501,7 @@ void SurfaceManager::computeStandAstig(define_input *wizPage, QList

Counter Rotated

"); + QTextDocument *doc = editor->document(); QList doc1Res; doc->setPageSize(printer.pageLayout().paintRectPixels(printer.resolution()).size()); // This is necessary if you want to hide the page number diff --git a/zernikepolar.cpp b/zernikepolar.cpp index 633484e0..11222482 100644 --- a/zernikepolar.cpp +++ b/zernikepolar.cpp @@ -19,6 +19,7 @@ #include "zernikepolar.h" #include #include +#include "spdlog/spdlog.h" zernikePolar::zernikePolar(double rho, double theta, size_t nbTerms) { // Having all terms computed at once here let's compiler optimize the code better @@ -61,7 +62,7 @@ zernikePolar::zernikePolar(double rho, double theta, size_t nbTerms) { // only compute what is actually needed // but to avoid complex code I use only 4 ranges - if(nbTerms > 8) + if(nbTerms > 9) { rho3 = rho2 * rho; rho4 = rho3 * rho; @@ -91,7 +92,7 @@ zernikePolar::zernikePolar(double rho, double theta, size_t nbTerms) { zernTerms[24] = 1. - 20. * rho2 + 90. * rho4 - 140. * rho6 + 70. * rho8; } - if(nbTerms > 24) { + if(nbTerms > 25) { rho10 = rho8 * rho2; cos5theta = std::cos(5. * theta); sin5theta = std::sin(5. * theta); @@ -109,7 +110,7 @@ zernikePolar::zernikePolar(double rho, double theta, size_t nbTerms) { zernTerms[35] = -1 + 30. * rho2 -210 * rho4 + 560. * rho6 - 630 * rho8 + 252. * rho10; } - if(nbTerms > 35) + if(nbTerms > 36) { zernTerms[36] = rho6 * std::cos(6. * theta); zernTerms[37] = rho6 * std::sin(6. * theta); @@ -133,6 +134,7 @@ double zernikePolar::zernike(size_t n){ } else { + spdlog::get("logger")->critical("zernikePolar() Zernike order exceeds maximum computed."); throw std::out_of_range("Zernike order exceeds maximum computed order"); return 0.; }