save dq_final and edq in wolman results

This commit is contained in:
Paul Leroy
2025-03-07 09:11:09 +01:00
parent 6a1982a0a0
commit e22da7f322
7 changed files with 122 additions and 22 deletions
+1 -3
View File
@@ -41,7 +41,7 @@ public:
void fit();
void exportResults();
void plots();
void showWolman(const Eigen::ArrayXf& d_sample);
void showWolman(const Eigen::ArrayXf& d_sample, const Eigen::Array3d &dq_final, const Eigen::Array3d &edq);
bool wolman();
bool angles();
bool processNewStacks(std::vector<std::vector<int>>& newStacks, int pointCount);
@@ -117,8 +117,6 @@ private:
GrainsAsEllipsoids* m_grainsAsEllipsoids;
std::unique_ptr<QProgressBar> m_progress;
int m_currentNumberOfSteps;
};
}
+4 -1
View File
@@ -5,6 +5,9 @@
#include <qcustomplot.h>
// Eigen
#include <Eigen/Geometry>
namespace Ui {
class G3PointPlots;
}
@@ -24,7 +27,7 @@ public:
void closeCurrentWidget();
template<typename SharedDataContainer>
bool exportToCSV(QString filename, SharedDataContainer container) const;
bool exportToCSV(QString filename, SharedDataContainer container, const Eigen::Array3d* dq_final=nullptr, const Eigen::Array3d* edq=nullptr) const;
void onExportToCSV();
+9 -1
View File
@@ -68,14 +68,22 @@ class WolmanCustomPlot : public QCustomPlot
{
Q_OBJECT
public:
WolmanCustomPlot(const Eigen::ArrayXf& d_sample);
WolmanCustomPlot(const Eigen::ArrayXf& d_sample, const Eigen::Array3d& dq_final, const Eigen::Array3d& edq);
QSharedPointer<QCPGraphDataContainer> dataContainer(){return m_graph->data();}
Eigen::Array3d m_dq_final;
Eigen::Array3d m_edq;
QCPGraph* m_graph;
void rescale();
void emitCloseTab(){emit closeTab();}
void mouseDoubleClickEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
signals:
+15 -11
View File
@@ -1075,10 +1075,11 @@ void myPrint(QString name, T array)
// Hyndman and Fan, 1996) R. J. Hyndman and Y. Fan, “Sample quantiles in statistical packages”,
// The American Statistician, 50(4), pp. 361-365, 1996
template <typename T1, typename T2>
typename T1::value_type quant(const T1 &x, T2 q)
typename T1::value_type quant(T1& x, const T2& q)
{
assert(q >= 0.0 && q <= 1.0);
std::sort(x.begin(), x.end());
const auto n = x.size();
const auto id = (n - 1) * q;
const auto lo = floor(id);
@@ -1101,12 +1102,12 @@ void G3PointAction::plots()
angles();
}
void G3PointAction::showWolman(const Eigen::ArrayXf& d_sample)
void G3PointAction::showWolman(const Eigen::ArrayXf& d_sample, const Eigen::Array3d& dq_final, const Eigen::Array3d& edq)
{
// QCustomPlot
if (!s_g3PointPlots)
s_g3PointPlots = new G3PointPlots(m_cloud->getName());
s_g3PointPlots->addToTabWidget(new WolmanCustomPlot(d_sample));
s_g3PointPlots->addToTabWidget(new WolmanCustomPlot(d_sample, dq_final, edq));
s_g3PointPlots->show();
}
@@ -1171,6 +1172,10 @@ bool G3PointAction::wolman()
#endif
for (int k = 0; k < n_iter; k++)
{
if (k % 20 == 0)
{
std::cout << k << std::endl;
}
float r0 = dist(urbg);
float r1 = dist(urbg);
// std::cout << r0 << ", " << r1 << "," << std::endl;
@@ -1185,7 +1190,6 @@ bool G3PointAction::wolman()
for (int iy = 0; iy < ny; iy++)
{
distances = ((x - x_grid(ix)).pow(2) + (y - y_grid(iy)).pow(2)).sqrt();
dist(ix, iy) = distances.minCoeff(&minLoc);
iWolman(ix, iy) = minLoc;
}
@@ -1245,7 +1249,7 @@ bool G3PointAction::wolman()
quant(d_sample, 0.5),
quant(d_sample, 0.9)};
showWolman(d_sample);
showWolman(d_sample, dq_final, edq);
return true;
}
@@ -2030,10 +2034,10 @@ bool G3PointAction::setCloud(ccPointCloud *cloud)
// build stacks from g3point_index
int nPointsInGrains = 0;
m_progress.reset(new QProgressBar());
m_progress->setRange(0, m_cloud->size());
m_progress->setWindowTitle("Processing g3point_label");
m_progress->show();
std::unique_ptr<QProgressBar> progress(new QProgressBar());
progress->setRange(0, m_cloud->size());
progress->setWindowTitle("Processing g3point_label");
progress->show();
std::vector<std::vector<int>> newStacks(labelsSet.size());
@@ -2048,12 +2052,12 @@ bool G3PointAction::setCloud(ccPointCloud *cloud)
}
if (index % 20 == 0)
{
m_progress->setValue(index);
progress->setValue(index);
QApplication::processEvents();
}
}
m_progress->hide();
progress->hide();
QApplication::processEvents();
ccLog::Print("[G3PointAction::setCloud] g3point_label available, found "
+19 -3
View File
@@ -72,7 +72,7 @@ void G3PointPlots::closeCurrentWidget()
}
template<typename SharedDataContainer>
bool G3PointPlots::exportToCSV(QString filename, SharedDataContainer container) const
bool G3PointPlots::exportToCSV(QString filename, SharedDataContainer container, const Eigen::Array3d* dq_final, const Eigen::Array3d* edq) const
{
QFile file(filename);
if (!file.open(QFile::WriteOnly | QFile::Text))
@@ -86,7 +86,18 @@ bool G3PointPlots::exportToCSV(QString filename, SharedDataContainer container)
stream.setRealNumberNotation(QTextStream::FixedNotation);
//header
stream << "angle [°], counts" << endl;
if (dq_final) // WolmanCustomPlot
{
stream << "# D10 [mm], D50 [mm], D90 [mm]" << endl;
stream << (*dq_final)(0) << (*dq_final)(0) << (*dq_final)(0) << endl;
stream << "# std(D10) [mm], std(D50) [mm], std(D90) [mm]" << endl;
stream << (*edq)(0) << (*edq)(0) << (*edq)(0) << endl;
stream << "diameter [m], pdf" << endl;
}
else // AnglesCustomPlot
{
stream << "angle [degree], counts" << endl;
}
//data
{
@@ -132,13 +143,18 @@ void G3PointPlots::onExportToCSV()
if (currentWidget->property("TypeOfCustomPlot").toString() == "AnglesCustomPlot")
{
Eigen::Array3d dq_final;
Eigen::Array3d edq;
exportToCSV<SharedBarsDataContainer>(filename,
static_cast<AnglesCustomPlot*>(currentWidget)->dataContainer());
}
else if (currentWidget->property("TypeOfCustomPlot").toString() == "WolmanCustomPlot")
{
WolmanCustomPlot* wolmanCustomPlot = static_cast<WolmanCustomPlot*>(currentWidget);
exportToCSV<SharedGraphDataContainer>(filename,
static_cast<WolmanCustomPlot*>(currentWidget)->dataContainer());
wolmanCustomPlot->dataContainer(),
&wolmanCustomPlot->m_dq_final,
&wolmanCustomPlot->m_edq);
}
}
+43 -1
View File
@@ -1,7 +1,9 @@
#include "WolmanCustomPlot.h"
#include "ui_WolmanCustomPlot.h"
WolmanCustomPlot::WolmanCustomPlot(const Eigen::ArrayXf &d_sample):
WolmanCustomPlot::WolmanCustomPlot(const Eigen::ArrayXf &d_sample, const Eigen::Array3d& dq_final, const Eigen::Array3d& edq):
m_dq_final(dq_final),
m_edq(edq),
ui(new Ui::WolmanCustomPlot)
{
setProperty("TypeOfCustomPlot", "WolmanCustomPlot");
@@ -10,6 +12,8 @@ WolmanCustomPlot::WolmanCustomPlot(const Eigen::ArrayXf &d_sample):
setWindowTitle("Wolman");
QPen pen;
m_graph = this->addGraph();
QVector<double> x_data(d_sample.size());
QVector<double> y_data(d_sample.size());
@@ -25,6 +29,44 @@ WolmanCustomPlot::WolmanCustomPlot(const Eigen::ArrayXf &d_sample):
this->xAxis->setScaleType(QCPAxis::stLogarithmic);
this->xAxis->setLabel("Diameter [mm]");
this->yAxis->setLabel("CDF");
// add error bars
QCPGraph* errorBarsGraph = this->addGraph();
errorBarsGraph->setData(QVector<double>({dq_final[0], dq_final[1], dq_final[2]}),
QVector<double>({0.1, 0.5, 0.9}));
errorBarsGraph->setLineStyle(QCPGraph::lsNone);
errorBarsGraph->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, 4));
QCPErrorBars *errorBars = new QCPErrorBars(xAxis, yAxis);
errorBars->removeFromLegend();
errorBars->setAntialiased(false);
errorBars->setDataPlottable(errorBarsGraph);
errorBars->setErrorType(QCPErrorBars::etKeyError);
// pen.setWidth(1);
errorBars->setPen(pen);
errorBars->setData(QVector<double>({edq[0], edq[1], edq[2]}));
errorBars->setPen(QPen(QColorConstants::Red));
errorBars->rescaleAxes(true);
setInteractions(QCP::iRangeDrag | QCP::iRangeZoom);
}
void WolmanCustomPlot::rescale()
{
// set ranges appropriate to show data
if (m_graph)
{
m_graph->rescaleAxes();
replot();
}
}
void WolmanCustomPlot::mouseDoubleClickEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton)
{
rescale();
}
QCustomPlot::mouseDoubleClickEvent(event);
}
void WolmanCustomPlot::mousePressEvent(QMouseEvent *event)
+31 -2
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>384</width>
<height>608</height>
<width>412</width>
<height>675</height>
</rect>
</property>
<property name="windowTitle">
@@ -438,6 +438,35 @@
</layout>
</widget>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="enabled">
<bool>false</bool>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
hr { height: 1px; border-width: 0; }
li.unchecked::marker { content: &quot;\2610&quot;; }
li.checked::marker { content: &quot;\2612&quot;; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Wolman&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Grid step = 1.1 * max(b_axis)&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:700;&quot;&gt;Angles&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Dip is defined with respect to the z axis&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Azimut is defined in the xy plane&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Mind the CloudCompare trihedron in the GUI&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">