修复了点云滤波时,因为内存泄露可能导致的bug,(重新编译了PCL)

pull/1/head
剑古敛锋 2024-05-16 17:42:02 +08:00
parent 7bd8cf83c0
commit 24b84cbd18
15 changed files with 242 additions and 143 deletions

View File

@ -216,8 +216,8 @@
</message>
<message>
<location line="+56"/>
<source>Canvas %1mm * %2mm </source>
<translation> %1mm * %2mm </translation>
<source>Canvas %1m * %2m </source>
<translation> %1m * %2m </translation>
</message>
</context>
<context>

View File

@ -1,24 +1,7 @@
/**
* @file main.cpp
* @brief LAMPCAE
* @author LAMPCAE(LAMPCAE@diso.cn)
* @version 2.5.0
* @date 2022-02-13 15:34
* @copyright Copyright (c) Since 2020 All rights reserved.
*
* ============================================================================
* Program: LAMPCAE
*
* Copyright (c) Since 2020 All rights reserved.
* See License or http://www.LAMPCAE.com/ for details.
*
* BSD 3-Clause License
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED.
* ==================================================================================
*/
#include "CommandLine.h"
#include "LAMPCAEVersionMacros.h"

View File

@ -1429,7 +1429,7 @@ namespace GUI {
_graphRange = new QLabel(this);
_ui->statusbar->addPermanentWidget(_graphRange);
}
QString text = QString(tr("Canvas %1mm * %2mm ")).arg(w).arg(h);
QString text = QString(tr("Canvas %1m * %2m ")).arg(w).arg(h);
_graphRange->setText(text);
}

View File

@ -94,11 +94,8 @@ add_library(PluginMeshDataExchange
${_interface}
${_header}
${_source}
Dialogmeshsurfacesampling.cpp
Dialogmeshsurfacesampling.h
Dialogmeshsurfacesampling.ui
../PointCloudOperator/MeshSurfaceSamplingAlg.cpp
../PointCloudOperator/MeshSurfaceSamplingAlg.h
)

View File

@ -14,27 +14,24 @@
#include "ui_DialogMeshSurfaceSampling.h"
namespace MainWidget {
DialogMeshSurfaceSampling::DialogMeshSurfaceSampling(GUI::MainWindow* parent) : QFDialog(parent),
_ui(new Ui::DialogMeshSurfaceSampling), _mw(parent), _selectdlg(new DialogSelectComponents(parent)) {
// DialogMeshSurfaceSampling::DialogMeshSurfaceSampling(GUI::MainWindow* parent) : QFDialog(parent),
// _ui(new Ui::DialogMeshSurfaceSampling), _mw(parent), _selectdlg(new DialogSelectComponents(parent)) {
//
//
//
// }
// DialogMeshSurfaceSampling::~DialogMeshSurfaceSampling()
// {
// delete _ui;
// _ui = NULL;
// delete _selectdlg;
// _selectdlg = NULL;
// }
//
// void DialogMeshSurfaceSampling::removeCurrentItem(QListWidgetItem* curItem) {}
// void DialogMeshSurfaceSampling::accept()
// {
// QDialog::accept();
// }
// void DialogMeshSurfaceSampling::selectedComponentsSlot(QList<MeshData::MeshSet*> components) {}
// void DialogMeshSurfaceSampling::customContextMenuRequestedSlot(const QPoint& point) {}
}
DialogMeshSurfaceSampling::~DialogMeshSurfaceSampling()
{
delete _ui;
_ui = NULL;
delete _selectdlg;
_selectdlg = NULL;
}
void DialogMeshSurfaceSampling::removeCurrentItem(QListWidgetItem* curItem) {}
void DialogMeshSurfaceSampling::accept()
{
QDialog::accept();
}
void DialogMeshSurfaceSampling::selectedComponentsSlot(QList<MeshData::MeshSet*> components) {}
void DialogMeshSurfaceSampling::customContextMenuRequestedSlot(const QPoint& point) {}
} // namespace MeshSurfaceSampling

View File

@ -12,42 +12,47 @@
#include "meshDataExchangePluginAPI.h"
#include "SelfDefObject/QFDialog.h"
#include "MeshData/meshSet.h"
#include "MainWidgets/DialogVTKTransform.h"
#include "MainWindow/MainWindow.h"
#include "MainWindow/SubWindowManager.h"
#include <QDialog>
#include <QListWidgetItem>
namespace Ui {
class DialogMeshSurfaceSampling;
}
namespace MainWidget {
// class DialogSelectComponents;
//
//
// class MESHDATAEXCHANGEPLUGINAPI DialogMeshSurfaceSampling : public QFDialog {
// Q_OBJECT
//
// public:
// DialogMeshSurfaceSampling(GUI::MainWindow* parent);
// ~DialogMeshSurfaceSampling() ;
// private:
// void removeCurrentItem(QListWidgetItem* curItem);
// signals: // 这里采用信号来直接与 主界面通信,避免参数浪费
// private slots:
//
// virtual void accept();
// void selectedComponentsSlot(QList<MeshData::MeshSet*> components);
// void customContextMenuRequestedSlot(const QPoint& point);
//
// private:
// GUI::MainWindow* _mw;
// DialogSelectComponents* _selectdlg;
// QList<MeshData::MeshSet*> _components;
//
// private:
// Ui::DialogMeshSurfaceSampling* _ui;
// };
namespace Ui {
class DialogMeshSurfaceSampling;
}
class DialogSelectComponents;
class MESHDATAEXCHANGEPLUGINAPI DialogMeshSurfaceSampling : public QFDialog {
Q_OBJECT
public:
DialogMeshSurfaceSampling(GUI::MainWindow* parent);
~DialogMeshSurfaceSampling() ;
private:
void removeCurrentItem(QListWidgetItem* curItem);
signals: // 这里采用信号来直接与 主界面通信,避免参数浪费
private slots:
virtual void accept();
void selectedComponentsSlot(QList<MeshData::MeshSet*> components);
void customContextMenuRequestedSlot(const QPoint& point);
private:
GUI::MainWindow* _mw;
DialogSelectComponents* _selectdlg;
QList<MeshData::MeshSet*> _components;
private:
Ui::DialogMeshSurfaceSampling* _ui;
};

View File

@ -1,19 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MeshSurfaceSampling::DialogMeshSurfaceSampling</class>
<widget class="QDialog" name="MeshSurfaceSampling::DialogMeshSurfaceSampling">
<class>MainWidget::DialogMeshSurfaceSampling</class>
<widget class="QDialog" name="MainWidget::DialogMeshSurfaceSampling">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
<width>622</width>
<height>374</height>
</rect>
</property>
<property name="windowTitle">
<string>DialogMeshSurfaceSampling</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox_4">
<property name="minimumSize">
<size>
<width>357</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>600</width>
<height>300</height>
</size>
</property>
<property name="title">
<string>Selected Component</string>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0" rowspan="2">
<widget class="QListWidget" name="listWidget">
<property name="minimumSize">
<size>
<width>299</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>500</height>
</size>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="geoSelectPoint">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string extracomment="Clicked Button Selected Components"/>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qrc/qianfan.qrc">
<normaloff>:/QUI/geometry/selectface.png</normaloff>:/QUI/geometry/selectface.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>8</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QDialogButtonBox" name="btBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="../qrc/qianfan.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -204,7 +204,9 @@ WBFZ::PCLBilateralFilter::PCLBilateralFilter(const QString& fileName,
}
bool WBFZ::PCLBilateralFilter::filter()
{
return PCLBilateralFilterAlg( _componentIds, _sigmaR, _sigmaS);
bool flag=PCLBilateralFilterAlg( _componentIds, _sigmaR, _sigmaS);
qDebug("WBFZ::PCLBilateralFilter::filter finish !!");
return flag;
}
bool WBFZ::PCLBilateralFilter::PCLBilateralFilterAlg(QString componentIds, double sigmaR,
double sigmaS)
@ -238,7 +240,7 @@ bool WBFZ::PCLBilateralFilter::PCLBilateralFilterAlg(QString componentIds, doubl
cellToPointFilter->Update();
DebugInfo("cellToPointFilter ");
// 获取过滤后的 vtkPolyData
vtkPolyData* outpolyData = cellToPointFilter->GetOutput();
vtkSmartPointer<vtkPolyData> outpolyData = cellToPointFilter->GetOutput();
DebugInfo("outpolyData ");
@ -253,19 +255,25 @@ bool WBFZ::PCLBilateralFilter::PCLBilateralFilterAlg(QString componentIds, doubl
fbf.setSigmaR(sigmaR);
fbf.filter(*cloud_filtered);
DebugInfo("Set up the Convolution Filter \n ");
// 转换处理结果
vtkPolyData* polydata=nullptr;
polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
vtkSmartPointer<vtkPolyData> polydata=vtkSmartPointer<vtkPolyData>::New();
// polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
pcl::io::pointCloudTovtkPolyData(*cloud_filtered,polydata);
vtkDataSet* dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
vtkSmartPointer<vtkDataSet> dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
size_t pointCount = dataset->GetNumberOfPoints();
DebugInfo("vtkpolydata --> vtkdataset \n ");
if(pointCount==0){
//outpolyData->Delete(); // 释放指针
return false;
}
emit _mainwindow->printMessage(Common::Message::Normal,"PCLBilateralFilterAlg successfully!! Point Count : "+QString::number(pointCount));
outpolyData->Delete(); // 释放指针
return this->saveFilterResultFile(cloud_filtered);
emit _mainwindow->printMessage(Common::Message::Normal,"PCLGuassFilterAlg successfully!! Point Count : "+QString::number(pointCount));
//outpolyData->Delete(); // 释放指针
qDebug()<<"WBFZ::PCLGuassFilter::PCLGuassFilterAlg finish !!!";
bool saveflag=this->saveFilterResultFile(cloud_filtered);
qDebug()<<"saveFilterResultFile finish !!!";
return saveflag;
}
WBFZ::PCLBilateralFilter::~PCLBilateralFilter() {}

View File

@ -206,7 +206,9 @@ WBFZ::PCLGuassFilter::PCLGuassFilter(const QString& fileName, WBFZ::PointCloudOp
}
bool WBFZ::PCLGuassFilter::filter()
{
return PointCloudThreadBase::filter();
bool flag=this->PCLGuassFilterAlg(_componentIds,_sigma,_threshold,_radius);
qDebug("WBFZ::PCLGuassFilter::filter over!!!!");
return flag;
}
bool WBFZ::PCLGuassFilter::PCLGuassFilterAlg(QString componentIds, double sigma,
double threshold,double radius)
@ -227,21 +229,21 @@ bool WBFZ::PCLGuassFilter::PCLGuassFilterAlg(QString componentIds, double sigma,
QString outfilename;
for(QString compontId : qCompontIds) {
meshSet = meshData->getMeshSetByID(compontId.toInt());
DebugInfo("point count %d : %d ",compontId.toInt(),meshSet==nullptr);
DebugInfo("point count %d : %d \n",compontId.toInt(),meshSet==nullptr);
if(!meshSet)
continue;
outfilename=meshSet->getName();
vtkPolyData* temppolyData=PointCloudOperator::PointCloudCommon::meshSetToVtkDataset(meshSet);
cellToPointFilter->SetInputData(temppolyData);
DebugInfo("point count %d : %d ",compontId.toInt(),temppolyData==nullptr);
DebugInfo("point count %d : %d \n",compontId.toInt(),temppolyData==nullptr);
}
// 执行过滤操作
cellToPointFilter->Update();
DebugInfo("cellToPointFilter ");
DebugInfo("cellToPointFilter \n");
// 获取过滤后的 vtkPolyData
vtkPolyData* outpolyData = cellToPointFilter->GetOutput();
DebugInfo("outpolyData ");
DebugInfo("outpolyData \n");
pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_with_rgba(new pcl::PointCloud<pcl::PointXYZRGBA>);
@ -264,7 +266,7 @@ bool WBFZ::PCLGuassFilter::PCLGuassFilterAlg(QString componentIds, double sigma,
new pcl::search::KdTree<pcl::PointXYZRGBA>);
(*kdtree).setInputCloud(cloud_with_rgba);
emit _mainwindow->printMessage(Common::Message::Normal,"KdTree made" );
DebugInfo("KdTree made \n");
// Set up the Convolution Filter
pcl::filters::Convolution3D<
pcl::PointXYZRGBA,
@ -281,21 +283,25 @@ bool WBFZ::PCLGuassFilter::PCLGuassFilterAlg(QString componentIds, double sigma,
convolution.convolve(*cloud_filtered);
emit _mainwindow->printMessage(Common::Message::Normal,"Convoluted" );
DebugInfo("Set up the Convolution Filter \n ");
// 转换处理结果
vtkPolyData* polydata=nullptr;
polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
vtkSmartPointer<vtkPolyData> polydata=vtkSmartPointer<vtkPolyData>::New();
// polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
pcl::io::pointCloudTovtkPolyData(*cloud_filtered,polydata);
vtkDataSet* dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
vtkSmartPointer<vtkDataSet> dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
size_t pointCount = dataset->GetNumberOfPoints();
DebugInfo("vtkpolydata --> vtkdataset \n ");
if(pointCount==0){
//outpolyData->Delete(); // 释放指针
return false;
}
emit _mainwindow->printMessage(Common::Message::Normal,"PCLGuassFilterAlg successfully!! Point Count : "+QString::number(pointCount));
outpolyData->Delete(); // 释放指针
//outpolyData->Delete(); // 释放指针
return this->saveFilterResultFile(cloud_filtered);
qDebug()<<"WBFZ::PCLGuassFilter::PCLGuassFilterAlg finish !!!";
bool saveflag=this->saveFilterResultFile(cloud_filtered);
qDebug()<<"saveFilterResultFile finish !!!";
return saveflag;
}
WBFZ::PCLGuassFilter::~PCLGuassFilter() {}

View File

@ -252,23 +252,34 @@ namespace WBFZ{
sor.setMinNeighborsInRadius(MinNeighborsInRadius); //设置判断是否为离群点的阈值
sor.filter(*cloud_filtered); //将滤波结果保存在cloud_filtered中
DebugInfo("Set up the Convolution Filter \n ");
// 转换处理结果
vtkPolyData* polydata=nullptr;
polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
vtkSmartPointer<vtkPolyData> polydata=vtkSmartPointer<vtkPolyData>::New();
// polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
pcl::io::pointCloudTovtkPolyData(*cloud_filtered,polydata);
vtkDataSet* dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
vtkSmartPointer<vtkDataSet> dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
size_t pointCount = dataset->GetNumberOfPoints();
DebugInfo("vtkpolydata --> vtkdataset \n ");
if(pointCount==0){
//outpolyData->Delete(); // 释放指针
return false;
}
emit _mainwindow->printMessage(Common::Message::Normal,"PCLRadiusOutlierRemovalAlg successfully!! Point Count : "+QString::number(pointCount));
outpolyData->Delete(); // 释放指针
return this->saveFilterResultFile(cloud_filtered);
emit _mainwindow->printMessage(Common::Message::Normal,"PCLGuassFilterAlg successfully!! Point Count : "+QString::number(pointCount));
//outpolyData->Delete(); // 释放指针
qDebug()<<"WBFZ::PCLGuassFilter::PCLGuassFilterAlg finish !!!";
bool saveflag=this->saveFilterResultFile(cloud_filtered);
qDebug()<<"saveFilterResultFile finish !!!";
return saveflag;
}
bool PCLRadiusOutlierRemoval::filter()
{
return PCLRadiusOutlierRemovalAlg( _componentIds, _RadiusSearch,_MinNeighborsInRadius);
bool flag = PCLRadiusOutlierRemovalAlg(_componentIds, _RadiusSearch, _MinNeighborsInRadius);
qDebug() << "PCLRadiusOutlierRemoval::filter finish!!!";
return flag;
}
PCLRadiusOutlierRemoval::~PCLRadiusOutlierRemoval() {}

View File

@ -253,24 +253,33 @@ namespace WBFZ{
sor.setStddevMulThresh(StddevThresh); //设置判断是否为离群点的阈值
sor.filter(*cloud_filtered); //将滤波结果保存在cloud_filtered中
DebugInfo("Set up the Convolution Filter \n ");
// 转换处理结果
vtkPolyData* polydata=nullptr;
polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
vtkSmartPointer<vtkPolyData> polydata=vtkSmartPointer<vtkPolyData>::New();
// polydata=vtkPolyData::New(); // 创建新的指针,智能指针会释放
pcl::io::pointCloudTovtkPolyData(*cloud_filtered,polydata);
vtkDataSet* dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
vtkSmartPointer<vtkDataSet> dataset= vtkDataSet::SafeDownCast(polydata); // 默认完成 vtkpolydata --> vtkdataset
size_t pointCount = dataset->GetNumberOfPoints();
DebugInfo("vtkpolydata --> vtkdataset \n ");
if(pointCount==0){
//outpolyData->Delete(); // 释放指针
return false;
}
emit _mainwindow->printMessage(Common::Message::Normal,"PCLStatisticalRemoveFilterAlg successfully!! Point Count : "+QString::number(pointCount));
outpolyData->Delete(); // 释放指针
emit _mainwindow->printMessage(Common::Message::Normal,"PCLGuassFilterAlg successfully!! Point Count : "+QString::number(pointCount));
//outpolyData->Delete(); // 释放指针
return this->saveFilterResultFile(cloud_filtered);
qDebug()<<"WBFZ::PCLGuassFilter::PCLGuassFilterAlg finish !!!";
bool saveflag=this->saveFilterResultFile(cloud_filtered);
qDebug()<<"saveFilterResultFile finish !!!";
return saveflag;
}
bool PCLStatisticalRemoveFilter::filter()
{
return PCLStatisticalRemoveFilterAlg( _componentIds, _MeanK,_StddevThresh);
bool flag = PCLStatisticalRemoveFilterAlg(_componentIds, _MeanK, _StddevThresh);
qDebug()<<"PCLStatisticalRemoveFilter::filter finish !!!";
return flag;
}
PCLStatisticalRemoveFilter::~PCLStatisticalRemoveFilter() {}

View File

@ -45,7 +45,6 @@ namespace WBFZ{
QString _componentIds;
double _MeanK;
double _StddevThresh;
};
}

View File

@ -51,7 +51,7 @@ namespace WBFZ
information = QString("Successful Import Mesh From \"%1\"").arg(_fileName);
msg.type = Common::Message::Normal;
msg.message = information;
qDebug()<<"PointCloudThreadBase::defaultMeshFinished()";
QFileInfo info(_fileName);
QString name = info.fileName();
QString path = info.filePath();
@ -69,7 +69,7 @@ namespace WBFZ
msg.message = information;
}
}
qDebug()<<"emit sign to windows ";
// auto meshdata = MeshData::MeshData::getInstance();
// // meshdata->generateDisplayDataSet();
// const int nk = meshdata->getKernalCount();
@ -88,6 +88,7 @@ namespace WBFZ
}else{}
emit showInformation(information);
emit _mainwindow->printMessageToMessageWindow(msg);
qDebug()<<"filter thread overing !!! ";
}
// emit showInformation(information);
// emit _mainwindow->printMessageToMessageWindow(msg);
@ -121,7 +122,7 @@ namespace WBFZ
}
bool PointCloudThreadBase::filtertaskProcess()
{
return filter();
return filter();
}
bool PointCloudThreadBase::filter()
{
@ -197,5 +198,4 @@ namespace WBFZ
else{}
return false;
}
}

View File

@ -863,27 +863,6 @@ void FEKOResultImportTaskNode::getExcuteTaskResult(FEKOResultImport* obj)
}
// =====================================================================
// FEKOImageSettingTaskNodeClass
//

View File

@ -232,8 +232,8 @@
</message>
<message>
<location line="+56"/>
<source>Canvas %1mm * %2mm </source>
<translation> %1mm * %2mm </translation>
<source>Canvas %1m * %2m </source>
<translation> %1m * %2m </translation>
</message>
</context>
<context>