250 lines
8.2 KiB
C++
250 lines
8.2 KiB
C++
|
#include "ToolDialog.h"
|
|||
|
#include <pcl/io/vtk_lib_io.h>
|
|||
|
#include <ui_BilateralFilterWindows.h>
|
|||
|
#include <ui_MedianFilterWindows.h>
|
|||
|
#include <ui_RadiusOutlierRemovalWindows.h>
|
|||
|
#include <ui_StatisticalOutlierRemovalWindows.h>
|
|||
|
#include <ui_DialogTriangulationSurfaceMesh.h>
|
|||
|
#include <ui_PoissonReSurfaceWindows.h>
|
|||
|
|
|||
|
|
|||
|
BilateralFilterWindows::BilateralFilterWindows(QWidget* parent):ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::BilateralFilterWindowsDialog ;
|
|||
|
this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
BilateralFilterWindows::~BilateralFilterWindows()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//
|
|||
|
// 返回计算结果 ply
|
|||
|
//
|
|||
|
QString BilateralFilterWindows::ExcuteCmd(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointcloudPtr)
|
|||
|
{
|
|||
|
// 计算点云滤波结果
|
|||
|
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGBA>); // 输出结果
|
|||
|
|
|||
|
float sigma_s = this->ui->lineEdit_NearSearchNumber->text().toFloat(); // 窗口
|
|||
|
float sigma_r = this->ui->lineEdit_NearSearchDistance->text().toFloat(); // 标准差
|
|||
|
|
|||
|
//bilateralFilter(pointcloudPtr, output, sigma_s, sigma_r); // 执行滤波
|
|||
|
// 保存滤波结果
|
|||
|
QString save_path = this->ui->lineEdit_savePath->text();
|
|||
|
save_path = save_path.trimmed();
|
|||
|
int flag=pcl::io::savePLYFileBinary(save_path.toUtf8().constData(), *output);
|
|||
|
QString logstr = "[" + QString::number(flag) + "]";
|
|||
|
QString logStrQString(logstr.toUtf8().constData());
|
|||
|
qDebug() << logStrQString << ":" << save_path;
|
|||
|
return save_path;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
MedianFilterWindows::MedianFilterWindows(QWidget* parent) :ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::MedianFilterWindowsDialog ;this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
}
|
|||
|
|
|||
|
MedianFilterWindows::~MedianFilterWindows()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
PoissonReSurfaceWindows::PoissonReSurfaceWindows(QWidget* parent) :ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::PoissonReSurfaceWindowsDialog ;this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
}
|
|||
|
|
|||
|
PoissonReSurfaceWindows::~PoissonReSurfaceWindows()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
RadiusOutlierRemovalWindows::RadiusOutlierRemovalWindows(QWidget* parent) :ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::RadiusOutlierRemovalWindowsDialog ;this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
}
|
|||
|
|
|||
|
RadiusOutlierRemovalWindows::~RadiusOutlierRemovalWindows()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
StatisticalOutlierRemovalWindows::StatisticalOutlierRemovalWindows(QWidget* parent) :ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::StatisticalOutlierRemovalWindowsDialog ;this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
}
|
|||
|
|
|||
|
StatisticalOutlierRemovalWindows::~StatisticalOutlierRemovalWindows()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
DialogTriangulationSurfaceMesh::DialogTriangulationSurfaceMesh(QWidget* parent) :ToolBaseFunClass(parent)
|
|||
|
{
|
|||
|
this->ui=new Ui::DialogTriangulationSurfaceMeshDialog ;this->ui->setupUi(this);
|
|||
|
this->setComboBox(this->ui->comboBox_clouldName);
|
|||
|
this->setLineEdit(this->ui->lineEdit_savePath);
|
|||
|
this->setPushButton(this->ui->FileOpenpushButton);
|
|||
|
QObject::connect(this->ui->FileOpenpushButton, SIGNAL(clicked()), this, SLOT(SaveFileSTLButton()));
|
|||
|
QObject::connect(this->ui->okButton, SIGNAL(clicked()), this, SLOT(OKpushButton()));
|
|||
|
QObject::connect(this->ui->cancelButton, SIGNAL(clicked()), this, SLOT(CannelpushButton()));
|
|||
|
}
|
|||
|
|
|||
|
DialogTriangulationSurfaceMesh::~DialogTriangulationSurfaceMesh()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
QString DialogTriangulationSurfaceMesh::ExcuteCmd(pcl::PointCloud<pcl::PointXYZRGBA>::Ptr pointcloudPtr)
|
|||
|
{
|
|||
|
|
|||
|
// 计算点云滤波结果
|
|||
|
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr output(new pcl::PointCloud<pcl::PointXYZRGBA>); // 输出结果
|
|||
|
pcl::PointCloud<pcl::PointNormal>::Ptr cloud_with_normals(new pcl::PointCloud<pcl::PointNormal>);
|
|||
|
|
|||
|
NormalEstimation(pointcloudPtr, cloud_with_normals);
|
|||
|
pcl::PolygonMesh mesh;
|
|||
|
double SearchRadius = this->ui->lineEdit_maxTrangleEdge->text().toDouble();
|
|||
|
double Mu = this->ui->lineEdit_NearSearchDistance->text().toDouble();
|
|||
|
int MaximumNearestNeighbors = this->ui->lineEdit_NearSearchNumber->text().toInt();
|
|||
|
double MaximumSurfaceAngle = this->ui->lineEdit_SurfaceAngle->text().toDouble() / 180.0 * M_PI;
|
|||
|
double MinimumAngle = this->ui->lineEdit_minTrangleAngle->text().toDouble() / 180.0 * M_PI;
|
|||
|
double MaximumAngle = this->ui->lineEdit_MaxTrangleAngle->text().toDouble() / 180.0 * M_PI;
|
|||
|
|
|||
|
GP(cloud_with_normals,
|
|||
|
mesh,
|
|||
|
SearchRadius,
|
|||
|
Mu,
|
|||
|
MaximumNearestNeighbors,
|
|||
|
MaximumSurfaceAngle,
|
|||
|
MinimumAngle,
|
|||
|
MaximumAngle
|
|||
|
);
|
|||
|
// 保存滤波结果
|
|||
|
QString save_path = this->ui->lineEdit_savePath->text();
|
|||
|
save_path = save_path.trimmed();
|
|||
|
int flag = pcl::io::savePolygonFileSTL(save_path.toUtf8().constData(), mesh);
|
|||
|
|
|||
|
QString logstr = "[" + QString::number(flag) + "]";
|
|||
|
QString logStrQString(logstr.toUtf8().constData());
|
|||
|
qDebug() << logStrQString << ":" << save_path;
|
|||
|
return save_path;
|
|||
|
}
|
|||
|
|
|||
|
void DialogTriangulationSurfaceMesh::SaveFileSTLButton() {
|
|||
|
|
|||
|
QString filepath = QFileDialog::getSaveFileName(
|
|||
|
this->FileOpenpushButton->parentWidget(),
|
|||
|
QString::fromUtf8(u8"另存为"),
|
|||
|
QString::fromUtf8(u8"stl文件 (*.stl)"));//多组扩展名用双分号";;"隔开
|
|||
|
this->lineEdit_savePath->setText(filepath);
|
|||
|
this->saveOk = true;
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
ToolBaseFunClass::ToolBaseFunClass(QWidget* parent) :QDialog(parent)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
ToolBaseFunClass::~ToolBaseFunClass()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
int ToolBaseFunClass::setComboBox(QComboBox* comboBox_clouldName)
|
|||
|
{
|
|||
|
this->comboBox_clouldName = comboBox_clouldName;
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
int ToolBaseFunClass::setLineEdit(QLineEdit* lineEdit_savePath)
|
|||
|
{
|
|||
|
this->lineEdit_savePath = lineEdit_savePath;
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
int ToolBaseFunClass::setPushButton(QPushButton* FileOpenpushButton)
|
|||
|
{
|
|||
|
this->FileOpenpushButton = FileOpenpushButton;
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
int ToolBaseFunClass::bandingComboxAndPoint(QStringList itemvalues)
|
|||
|
{
|
|||
|
this->comboBox_clouldName->addItems(itemvalues);
|
|||
|
return 0;
|
|||
|
}
|
|||
|
|
|||
|
QString ToolBaseFunClass::getComboxSelect()
|
|||
|
{
|
|||
|
return this->comboBox_clouldName->currentText();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
void ToolBaseFunClass::SaveFileButton() {
|
|||
|
QString filepath = QFileDialog::getSaveFileName(
|
|||
|
this->FileOpenpushButton->parentWidget(),
|
|||
|
QString::fromUtf8(u8"另存为"),
|
|||
|
|
|||
|
QString::fromUtf8(u8"ply文件 (*.ply)"));//多组扩展名用双分号";;"隔开
|
|||
|
this->lineEdit_savePath->setText(filepath);
|
|||
|
this->saveOk = true;
|
|||
|
}
|
|||
|
bool ToolBaseFunClass::isOK()
|
|||
|
{
|
|||
|
return this->isok&&this->saveOk;
|
|||
|
}
|
|||
|
void ToolBaseFunClass::OKpushButton()
|
|||
|
{
|
|||
|
this->isok = true;
|
|||
|
this->close();
|
|||
|
}
|
|||
|
|
|||
|
void ToolBaseFunClass::CannelpushButton()
|
|||
|
{
|
|||
|
this->isok = false;
|
|||
|
this->close();
|
|||
|
}
|
|||
|
|