Remove recursively tmp textures folder

This commit is contained in:
matlabbe
2015-08-24 16:06:08 -04:00
parent 45877e7486
commit d57e12023b
3 changed files with 48 additions and 15 deletions

View File

@@ -4542,6 +4542,29 @@ void MainWindow::viewClouds()
} }
} }
bool removeDir(const QString & dirName)
{
bool result = true;
QDir dir(dirName);
if (dir.exists(dirName)) {
Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
if (info.isDir()) {
result = removeDir(info.absoluteFilePath());
}
else {
result = QFile::remove(info.absoluteFilePath());
}
if (!result) {
return result;
}
}
result = dir.rmdir(dirName);
}
return result;
}
bool MainWindow::getExportedClouds( bool MainWindow::getExportedClouds(
std::map<int, pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr> & cloudsWithNormals, std::map<int, pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr> & cloudsWithNormals,
std::map<int, pcl::PolygonMesh::Ptr> & meshes, std::map<int, pcl::PolygonMesh::Ptr> & meshes,
@@ -4639,7 +4662,7 @@ bool MainWindow::getExportedClouds(
pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointXYZRGBNormal>); pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloudWithNormals(new pcl::PointCloud<pcl::PointXYZRGBNormal>);
if(_exportDialog->getMLS()) if(_exportDialog->getMLS())
{ {
_initProgressDialog->appendText(tr("Smoothing (MLS) of the assembled cloud (%1 points)...").arg(iter->second->size())); _initProgressDialog->appendText(tr("Smoothing (MLS) the cloud (%1 points)...").arg(iter->second->size()));
QApplication::processEvents(); QApplication::processEvents();
cloudWithNormals = util3d::mls( cloudWithNormals = util3d::mls(
@@ -4654,7 +4677,7 @@ bool MainWindow::getExportedClouds(
_exportDialog->getMLSDilationIterations()); _exportDialog->getMLSDilationIterations());
// Re-voxelize to make sure to have uniform density // Re-voxelize to make sure to have uniform density
_initProgressDialog->appendText(tr("Voxelize assembled cloud (%1 points, voxel size = %2 m)...") _initProgressDialog->appendText(tr("Voxelize cloud (%1 points, voxel size = %2 m)...")
.arg(cloudWithNormals->size()) .arg(cloudWithNormals->size())
.arg(_exportDialog->getAssemble()?_exportDialog->getAssembleVoxel():_exportDialog->getGenerateVoxel())); .arg(_exportDialog->getAssemble()?_exportDialog->getAssembleVoxel():_exportDialog->getGenerateVoxel()));
QApplication::processEvents(); QApplication::processEvents();
@@ -4667,6 +4690,7 @@ bool MainWindow::getExportedClouds(
else else
{ {
//compute normals //compute normals
_initProgressDialog->appendText(tr("Computing normals (%1 points)...").arg(iter->second->size()));
cloudWithNormals = util3d::computeNormals(iter->second, _exportDialog->getNormalKSearch()); cloudWithNormals = util3d::computeNormals(iter->second, _exportDialog->getNormalKSearch());
} }
@@ -4719,6 +4743,9 @@ bool MainWindow::getExportedClouds(
if(toSave && _exportDialog->getMeshTexture()) if(toSave && _exportDialog->getMeshTexture())
{ {
QDir dir(_preferencesDialog->getWorkingDirectory());
removeDir(_preferencesDialog->getWorkingDirectory()+QDir::separator()+"tmp_textures");
dir.mkdir("tmp_textures");
int i=0; int i=0;
for(std::map<int, pcl::PolygonMesh::Ptr>::iterator iter=meshes.begin(); for(std::map<int, pcl::PolygonMesh::Ptr>::iterator iter=meshes.begin();
iter!= meshes.end(); iter!= meshes.end();
@@ -4766,8 +4793,6 @@ bool MainWindow::getExportedClouds(
} }
if(cameraPoses.size()) if(cameraPoses.size())
{ {
QDir dir(_preferencesDialog->getWorkingDirectory());
dir.mkdir("tmp_textures");
pcl::TextureMesh::Ptr textureMesh = util3d::createTextureMesh( pcl::TextureMesh::Ptr textureMesh = util3d::createTextureMesh(
iter->second, iter->second,
cameraPoses, cameraPoses,
@@ -5240,6 +5265,7 @@ void MainWindow::saveTextureMeshes(const std::map<int, pcl::TextureMesh::Ptr> &
pcl::TextureMesh mesh; pcl::TextureMesh mesh;
mesh.tex_coordinates = meshes.begin()->second->tex_coordinates; mesh.tex_coordinates = meshes.begin()->second->tex_coordinates;
mesh.tex_materials = meshes.begin()->second->tex_materials; mesh.tex_materials = meshes.begin()->second->tex_materials;
removeDir(QFileInfo(path).absoluteDir().absolutePath()+QDir::separator()+QFileInfo(path).baseName());
QDir(QFileInfo(path).absoluteDir().absolutePath()).mkdir(QFileInfo(path).baseName()); QDir(QFileInfo(path).absoluteDir().absolutePath()).mkdir(QFileInfo(path).baseName());
for(unsigned int i=0;i<meshes.begin()->second->tex_materials.size(); ++i) for(unsigned int i=0;i<meshes.begin()->second->tex_materials.size(); ++i)
{ {
@@ -5295,6 +5321,7 @@ void MainWindow::saveTextureMeshes(const std::map<int, pcl::TextureMesh::Ptr> &
pcl::TextureMesh mesh; pcl::TextureMesh mesh;
mesh.tex_coordinates = iter->second->tex_coordinates; mesh.tex_coordinates = iter->second->tex_coordinates;
mesh.tex_materials = iter->second->tex_materials; mesh.tex_materials = iter->second->tex_materials;
QDir(path).rmdir(currentPrefix);
QDir(path).mkdir(currentPrefix); QDir(path).mkdir(currentPrefix);
for(unsigned int i=0;i<iter->second->tex_materials.size(); ++i) for(unsigned int i=0;i<iter->second->tex_materials.size(); ++i)
{ {

View File

@@ -1014,15 +1014,15 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
for(int i=0; i<2; ++i) for(int i=0; i<2; ++i)
{ {
_3dRenderingShowClouds[i]->setChecked(true); _3dRenderingShowClouds[i]->setChecked(true);
_3dRenderingVoxelSize[i]->setValue(i==2?0.005:0.00); _3dRenderingVoxelSize[i]->setValue(0.00);
_3dRenderingDecimation[i]->setValue(i==0?4:i==1?2:1); _3dRenderingDecimation[i]->setValue(i==0?4:2);
_3dRenderingMaxDepth[i]->setValue(i==1?0.0:4.0); _3dRenderingMaxDepth[i]->setValue(i==1?0.0:4.0);
_3dRenderingShowScans[i]->setChecked(true); _3dRenderingShowScans[i]->setChecked(true);
_3dRenderingOpacity[i]->setValue(1.0); _3dRenderingOpacity[i]->setValue(i==0?1.0:0.5);
_3dRenderingPtSize[i]->setValue(i==0?1:2); _3dRenderingPtSize[i]->setValue(2);
_3dRenderingOpacityScan[i]->setValue(1.0); _3dRenderingOpacityScan[i]->setValue(i==0?1.0:0.5);
_3dRenderingPtSizeScan[i]->setValue(1); _3dRenderingPtSizeScan[i]->setValue(2);
} }
_ui->checkBox_showGraphs->setChecked(true); _ui->checkBox_showGraphs->setChecked(true);
@@ -1035,7 +1035,7 @@ void PreferencesDialog::resetSettings(QGroupBox * groupBox)
_ui->checkBox_mls->setChecked(false); _ui->checkBox_mls->setChecked(false);
_ui->doubleSpinBox_mlsRadius->setValue(0.04); _ui->doubleSpinBox_mlsRadius->setValue(0.04);
_ui->checkBox_nodeFiltering->setChecked(true); _ui->checkBox_nodeFiltering->setChecked(false);
_ui->checkBox_subtractFiltering->setChecked(false); _ui->checkBox_subtractFiltering->setChecked(false);
_ui->doubleSpinBox_cloudFilterRadius->setValue(0.1); _ui->doubleSpinBox_cloudFilterRadius->setValue(0.1);
_ui->doubleSpinBox_cloudFilterAngle->setValue(30); _ui->doubleSpinBox_cloudFilterAngle->setValue(30);

View File

@@ -63,9 +63,9 @@
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>-394</y> <y>-542</y>
<width>759</width> <width>755</width>
<height>938</height> <height>1591</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_16"> <layout class="QVBoxLayout" name="verticalLayout_16">
@@ -468,7 +468,7 @@ Show a yellow background when the number of odometry inliers goes under this thr
<string/> <string/>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
@@ -955,6 +955,9 @@ Show a yellow background when the number of odometry inliers goes under this thr
<property name="maximum"> <property name="maximum">
<number>64</number> <number>64</number>
</property> </property>
<property name="value">
<number>2</number>
</property>
</widget> </widget>
</item> </item>
<item row="7" column="1"> <item row="7" column="1">
@@ -965,6 +968,9 @@ Show a yellow background when the number of odometry inliers goes under this thr
<property name="maximum"> <property name="maximum">
<number>64</number> <number>64</number>
</property> </property>
<property name="value">
<number>2</number>
</property>
</widget> </widget>
</item> </item>
<item row="7" column="2"> <item row="7" column="2">