Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions surfacemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
#include "ui_oglrendered.h"
#include "astigpolargraph.h"


cv::Mat theMask;
cv::Mat deb;
double outputLambda;
Expand Down Expand Up @@ -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<bool> &en = zernEnables;
mirrorDlg *md = mirrorDlg::get_Instance();
for (int i = 0; i < wx; ++i)
Expand All @@ -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];

Expand Down Expand Up @@ -1099,19 +1107,22 @@ 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++ ) {
file >> data.at<double>(height - y-1,x);
//data.at<double>(height - y - 1, x) += dist(generator);
}
}
spdlog::get("logger")->trace("readWaveFront() step 2");

std::string line;
QString l;
Expand Down Expand Up @@ -1160,6 +1171,7 @@ wavefront * SurfaceManager::readWaveFront(const QString &fileName){
}
}


wf->m_outside = CircleOutline(QPointF(xm,ym), radm);
if (rado == 0){
xo = xm;
Expand Down Expand Up @@ -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();
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -2414,7 +2428,7 @@ textres SurfaceManager::Phase2(QList<rotationDef *> list, QList<wavefront *> inp
void SurfaceManager::computeStandAstig(define_input *wizPage, QList<rotationDef *> list){
// check for pairs
QVector<rotationDef*> 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);
Expand Down Expand Up @@ -2449,6 +2463,7 @@ void SurfaceManager::computeStandAstig(define_input *wizPage, QList<rotationDef
}
}
QApplication::setOverrideCursor(Qt::WaitCursor);
spdlog::get("logger")->trace("computeStandAstig() create printer step 1");
QPrinter printer(QPrinter::HighResolution);
printer.setColorMode( QPrinter::Color );
printer.setFullPage( true );
Expand Down Expand Up @@ -2486,6 +2501,7 @@ void SurfaceManager::computeStandAstig(define_input *wizPage, QList<rotationDef
html.append("<td><p align='center'><b> Counter Rotated </b></p></td></tr>");



QTextDocument *doc = editor->document();
QList<QString> doc1Res;
doc->setPageSize(printer.pageLayout().paintRectPixels(printer.resolution()).size()); // This is necessary if you want to hide the page number
Expand Down
8 changes: 5 additions & 3 deletions zernikepolar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "zernikepolar.h"
#include <cmath>
#include <QDebug>
#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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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.;
}
Expand Down
Loading