LVROptimizationPlanarOptimizationDialog.cpp
Go to the documentation of this file.
1 
28 #include <QFileDialog>
30 
36 
39 
40 #include "lvr2/io/Model.hpp"
41 
43 
44 namespace lvr2
45 {
46 
47 LVRPlanarOptimizationDialog::LVRPlanarOptimizationDialog(LVRMeshItem* mesh, LVRModelItem* parent, QTreeWidget* treeWidget, vtkRenderWindow* window) :
48  m_mesh(mesh), m_parent(parent), m_treeWidget(treeWidget), m_renderWindow(window)
49 {
50  // Setup DialogUI and events
51  QDialog* dialog = new QDialog(m_treeWidget);
52  m_dialog = new PlanarOptimizationDialog;
53  m_dialog->setupUi(dialog);
54 
56 
57  dialog->show();
58  dialog->raise();
59  dialog->activateWindow();
60 }
61 
63 {
64  // TODO Auto-generated destructor stub
65 }
66 
68 {
69  QObject::connect(m_dialog->buttonBox, SIGNAL(accepted()), this, SLOT(optimizeMesh()));
70  QObject::connect(m_dialog->checkBox_sr, SIGNAL(stateChanged(int)), this, SLOT(toggleSmallRegionRemoval(int)));
71  QObject::connect(m_dialog->checkBox_rt, SIGNAL(stateChanged(int)), this, SLOT(toggleRetesselation(int)));
72 }
73 
75 {
76  QSpinBox* smallRegionRemoval_box = m_dialog->spinBox_sr;
77  if(state == Qt::Checked)
78  {
79  smallRegionRemoval_box->setEnabled(true);
80  }
81  else
82  {
83  smallRegionRemoval_box->setEnabled(false);
84  }
85 }
86 
88 {
89  QCheckBox* generateTextures_box = m_dialog->checkBox_gt;
90  QDoubleSpinBox* lineSegmentThreshold_box = m_dialog->doubleSpinBox_ls;
91  if(state == Qt::Checked)
92  {
93  generateTextures_box->setEnabled(true);
94  lineSegmentThreshold_box->setEnabled(true);
95  }
96  else
97  {
98  generateTextures_box->setEnabled(false);
99  lineSegmentThreshold_box->setEnabled(false);
100  }
101 }
102 
104 {
105  QSpinBox* planeIterations_box = m_dialog->spinBox_pi;
106  int planeIterations = planeIterations_box->value();
107  QDoubleSpinBox* normalThreshold_box = m_dialog->doubleSpinBox_nt;
108  float normalThreshold = (float)normalThreshold_box->value();
109  QSpinBox* minimalPlaneSize_box = m_dialog->spinBox_mp;
110  int minimalPlaneSize = minimalPlaneSize_box->value();
111  QCheckBox* removeSmallRegions_box = m_dialog->checkBox_sr;
112  bool removeSmallRegions = removeSmallRegions_box->isChecked();
113  QSpinBox* removeSmallRegionThreshold_box = m_dialog->spinBox_sr;
114  int removeSmallRegionThreshold = (removeSmallRegions) ? removeSmallRegionThreshold_box->value() : 0;
115  QCheckBox* fillHoles_box = m_dialog->checkBox_fh;
116  bool fillHoles = fillHoles_box->isChecked();
117  QCheckBox* retesselate_box = m_dialog->checkBox_rt;
118  bool retesselate = retesselate_box->isChecked();
119  QCheckBox* generateTextures_box = m_dialog->checkBox_gt;
120  bool generateTextures = generateTextures_box->isChecked();
121  QDoubleSpinBox* lineSegmentThreshold_box = m_dialog->doubleSpinBox_ls;
122  float lineSegmentThreshold = (float)lineSegmentThreshold_box->value();
123 
124  using Vec = BaseVector<float>;
125 
127 
128  if (fillHoles)
129  {
130  // variable for max_size?
131  // TODO happended in old code right after deletesmallPlanarCluster.
132  //int res = naiveFillSmallHoles(mesh, 1);
133  }
134 
135  auto faceNormals = calcFaceNormals(mesh);
137  mesh,
138  faceNormals,
139  normalThreshold,
140  planeIterations,
141  minimalPlaneSize
142  );
143 
144  if (removeSmallRegions && removeSmallRegionThreshold > 0)
145  {
146  deleteSmallPlanarCluster(mesh, clusterBiMap, removeSmallRegionThreshold);
147  }
148 
149 
150  // TODO idk what the lvr2 equivalent to this is?
151  //mesh.restorePlanes(minimalPlaneSize);
152 
153  // Save triangle mesh
154  if(retesselate)
155  {
156  Tesselator<Vec>::apply(mesh, clusterBiMap, faceNormals, lineSegmentThreshold);
157  }
158 
159  MeshBufferPtr res;
160  if (generateTextures)
161  {
162  // TODO Use TextureFinalizer...
164  res = fin.apply(mesh);
165  }
166  else
167  {
169  res = fin.apply(mesh);
170  }
171 
172  ModelPtr model(new Model(res));
173  ModelBridgePtr bridge(new LVRModelBridge(model));
174  vtkSmartPointer<vtkRenderer> renderer = m_renderWindow->GetRenderers()->GetFirstRenderer();
175  bridge->addActors(renderer);
176 
177  QString base = m_parent->getName() + " (optimized)";
178  m_optimizedModel = new LVRModelItem(bridge, base);
179 
180  m_treeWidget->addTopLevelItem(m_optimizedModel);
181  m_optimizedModel->setExpanded(true);
182 }
183 
184 } // namespace lvr2
BaseVector.hpp
lvr2::LVRPlanarOptimizationDialog::connectSignalsAndSlots
void connectSignalsAndSlots()
Definition: LVROptimizationPlanarOptimizationDialog.cpp:67
lvr2::Tesselator::apply
static void apply(BaseMesh< BaseVecT > &mesh, ClusterBiMap< FaceHandle > &clusters, DenseFaceMap< Normal< typename BaseVecT::CoordType >> &faceNormals, float lineFusionThreshold)
lvr2::LVRPlanarOptimizationDialog::m_renderWindow
vtkRenderWindow * m_renderWindow
Definition: LVROptimizationPlanarOptimizationDialog.hpp:68
NormalAlgorithms.hpp
lvr2::BaseVector< float >
lvr2::LVRPlanarOptimizationDialog::toggleRetesselation
void toggleRetesselation(int state)
Definition: LVROptimizationPlanarOptimizationDialog.cpp:87
lvr2::LVRPlanarOptimizationDialog::m_optimizedModel
LVRModelItem * m_optimizedModel
Definition: LVROptimizationPlanarOptimizationDialog.hpp:65
lvr2::LVRMeshItem
Definition: LVRMeshItem.hpp:45
lvr2::Model
Definition: Model.hpp:51
HalfEdgeMesh.hpp
lvr2::LVRPlanarOptimizationDialog::m_mesh
LVRMeshItem * m_mesh
Definition: LVROptimizationPlanarOptimizationDialog.hpp:64
lvr2::SimpleFinalizer
Definition: FinalizeAlgorithms.hpp:68
lvr2::ModelBridgePtr
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
Definition: LVRModelBridge.hpp:120
lvr2::LVRPlanarOptimizationDialog::LVRPlanarOptimizationDialog
LVRPlanarOptimizationDialog(LVRMeshItem *mesh, LVRModelItem *parent, QTreeWidget *treeWidget, vtkRenderWindow *renderer)
Definition: LVROptimizationPlanarOptimizationDialog.cpp:47
ClusterBiMap.hpp
lvr2::LVRPlanarOptimizationDialog::m_treeWidget
QTreeWidget * m_treeWidget
Definition: LVROptimizationPlanarOptimizationDialog.hpp:67
lvr2::LVRPlanarOptimizationDialog::m_dialog
PlanarOptimizationDialog * m_dialog
Definition: LVROptimizationPlanarOptimizationDialog.hpp:63
FinalizeAlgorithms.hpp
Tesselator.hpp
lvr2::LVRMeshItem::getMeshBuffer
MeshBufferPtr getMeshBuffer()
Definition: LVRMeshItem.cpp:134
LVROptimizationPlanarOptimizationDialog.hpp
Model.hpp
lvr2::LVRPlanarOptimizationDialog::~LVRPlanarOptimizationDialog
virtual ~LVRPlanarOptimizationDialog()
Definition: LVROptimizationPlanarOptimizationDialog.cpp:62
lvr2::iterativePlanarClusterGrowing
ClusterBiMap< FaceHandle > iterativePlanarClusterGrowing(BaseMesh< BaseVecT > &mesh, FaceMap< Normal< typename BaseVecT::CoordType >> &normals, float minSinAngle, int numIterations, int minClusterSize)
Algorithm which generates planar clusters from the given mesh, drags points in clusters into regressi...
lvr2::LVRModelBridge
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
Definition: LVRModelBridge.hpp:61
lvr2::LVRModelItem
Definition: LVRModelItem.hpp:47
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::ModelPtr
std::shared_ptr< Model > ModelPtr
Definition: Model.hpp:80
lvr2::MeshBufferPtr
std::shared_ptr< MeshBuffer > MeshBufferPtr
Definition: MeshBuffer.hpp:217
ClusterAlgorithms.hpp
lvr2::deleteSmallPlanarCluster
void deleteSmallPlanarCluster(BaseMesh< BaseVecT > &mesh, ClusterBiMap< FaceHandle > &clusters, size_t smallClusterThreshold)
Removes all clusters and their cotained faces from the given mesh which are smaller than the given sm...
lvr2::LVRPlanarOptimizationDialog::optimizeMesh
void optimizeMesh()
Definition: LVROptimizationPlanarOptimizationDialog.cpp:103
lvr2::LVRModelItem::getName
QString getName()
Definition: LVRModelItem.cpp:109
mesh
HalfEdgeMesh< Vec > mesh
Definition: src/tools/lvr2_gs_reconstruction/Main.cpp:26
lvr2::LVRPlanarOptimizationDialog::m_parent
LVRModelItem * m_parent
Definition: LVROptimizationPlanarOptimizationDialog.hpp:66
lvr2::ClusterBiMap
A map of clusters, which also saves a back-reference from handle to cluster.
Definition: ClusterBiMap.hpp:72
lvr2::calcFaceNormals
DenseFaceMap< Normal< typename BaseVecT::CoordType > > calcFaceNormals(const BaseMesh< BaseVecT > &mesh)
Calculates a normal for each face in the mesh.
lvr2::SimpleFinalizer::apply
MeshBufferPtr apply(const BaseMesh< BaseVecT > &mesh)
CleanupAlgorithms.hpp
lvr2::LVRPlanarOptimizationDialog::toggleSmallRegionRemoval
void toggleSmallRegionRemoval(int state)
Definition: LVROptimizationPlanarOptimizationDialog.cpp:74
lvr2::HalfEdgeMesh
Half-edge data structure implementing the BaseMesh interface.
Definition: HalfEdgeMesh.hpp:70


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:24