LVRReconstructionExtendedMarchingCubesDialog.cpp
Go to the documentation of this file.
1 
28 #include <QFileDialog>
30 
32 
37 
40 
41 #include "lvr2/io/PointBuffer.hpp"
42 
43 namespace lvr2
44 {
45 
46 LVRReconstructViaExtendedMarchingCubesDialog::LVRReconstructViaExtendedMarchingCubesDialog(string decomposition, LVRPointCloudItem* pc, LVRModelItem* parent, QTreeWidget* treeWidget, vtkRenderWindow* window) :
47  m_decomposition(decomposition),
48  m_pc(pc), m_parent(parent),
49  m_treeWidget(treeWidget),
50  m_renderWindow(window)
51 {
52  // Setup DialogUI and events
53  QDialog* dialog = new QDialog(m_treeWidget);
54  m_dialog = new ReconstructViaExtendedMarchingCubesDialog;
55  m_dialog->setupUi(dialog);
56 
57 
58  dialog->setWindowTitle("Extended Marching Cubes");
59 
61 
62  dialog->show();
63  dialog->raise();
64  dialog->activateWindow();
65 }
66 
68 {
69  // TODO Auto-generated destructor stub
70 }
71 
73 {
74  QObject::connect(m_dialog->comboBox_pcm, SIGNAL(currentIndexChanged(const QString)), this, SLOT(toggleRANSACcheckBox(const QString)));
75  QObject::connect(m_dialog->comboBox_gs, SIGNAL(currentIndexChanged(int)), this, SLOT(switchGridSizeDetermination(int)));
76  QObject::connect(m_dialog->buttonBox, SIGNAL(accepted()), this, SLOT(generateMesh()));
77 }
78 
80 {
81  QCheckBox* ransac_box = m_dialog->checkBox_RANSAC;
82  if(text == "PCL")
83  {
84  ransac_box->setChecked(false);
85  ransac_box->setCheckable(false);
86  }
87  else
88  {
89  ransac_box->setCheckable(true);
90  }
91 }
92 
94 {
95  QComboBox* gs_box = m_dialog->comboBox_gs;
96 
97  QLabel* label = m_dialog->label_below_gs;
98  QDoubleSpinBox* spinBox = m_dialog->spinBox_below_gs;
99 
100  // TODO: Add reasonable default values
101  if(index == 0)
102  {
103  label->setText("Voxel size");
104  spinBox->setMinimum(0);
105  spinBox->setMaximum(2000000);
106  spinBox->setSingleStep(1);
107  spinBox->setValue(10);
108  }
109  else
110  {
111  label->setText("Number of intersections");
112  spinBox->setMinimum(1);
113  spinBox->setMaximum(200000);
114  spinBox->setSingleStep(1);
115  spinBox->setValue(10);
116  }
117 }
118 
120 {
121  using Vec = BaseVector<float>;
122 
123  QComboBox* pcm_box = m_dialog->comboBox_pcm;
124  string pcm = pcm_box->currentText().toStdString();
125  QCheckBox* extrusion_box = m_dialog->checkBox_Extrusion;
126  bool extrusion = extrusion_box->isChecked();
127  QCheckBox* ransac_box = m_dialog->checkBox_RANSAC;
128  bool ransac = ransac_box->isChecked();
129  QSpinBox* kn_box = m_dialog->spinBox_kn;
130  int kn = kn_box->value();
131  QSpinBox* kd_box = m_dialog->spinBox_kd;
132  int kd = kd_box->value();
133  QSpinBox* ki_box = m_dialog->spinBox_ki;
134  int ki = ki_box->value();
135  QCheckBox* reNormals_box = m_dialog->checkBox_renormals;
136  bool reestimateNormals = reNormals_box->isChecked();
137  QComboBox* gridMode_box = m_dialog->comboBox_gs;
138  bool useVoxelsize = (gridMode_box->currentIndex() == 0) ? true : false;
139  QDoubleSpinBox* gridSize_box = m_dialog->spinBox_below_gs;
140  float resolution = (float)gridSize_box->value();
141 
142  float sf = m_dialog->doubleSpinBox_sf->value();
143  float sc = m_dialog->doubleSpinBox_sc->value();
144 
145 
146  PointBufferPtr pc_buffer = m_pc->getPointBuffer();
147 
148  PointsetSurfacePtr<Vec> surface;
149 
150  if(pcm == "STANN" || pcm == "FLANN" || pcm == "NABO" || pcm == "NANOFLANN")
151  {
152  surface = PointsetSurfacePtr<Vec>( new AdaptiveKSearchSurface<Vec>(pc_buffer, pcm, kn, ki, kd, ransac ? 1 : 0) );
153  }
154 
155  if(!surface->pointBuffer()->hasNormals() || reestimateNormals)
156  {
157  surface->calculateSurfaceNormals();
158  }
159 
160  SharpBox<Vec>::m_surface = surface;
163 
164  auto grid = std::make_shared<PointsetGrid<Vec, SharpBox<Vec>>>(
165  resolution,
166  surface,
167  surface->getBoundingBox(),
168  useVoxelsize,
169  extrusion
170  );
171 
172  grid->calcDistanceValues();
173  auto reconstruction = make_unique<FastReconstruction<Vec, SharpBox<Vec>>>(grid);
174 
175  // Create an empty mesh
177  reconstruction->getMesh(mesh);
178 
179  auto faceNormals = calcFaceNormals(mesh);
180 
181  ClusterBiMap<FaceHandle> clusterBiMap = planarClusterGrowing(mesh, faceNormals, 0.85);
182  deleteSmallPlanarCluster(mesh, clusterBiMap, 10);
183 
184  ClusterPainter painter(clusterBiMap);
185  auto clusterColors = DenseClusterMap<Rgb8Color>(painter.simpsons(mesh));
186  auto vertexNormals = calcVertexNormals(mesh, faceNormals, *surface);
187 
188  TextureFinalizer<Vec> finalize(clusterBiMap);
189  finalize.setVertexNormals(vertexNormals);
190  finalize.setClusterColors(clusterColors);
191  Materializer<Vec> materializer(mesh, clusterBiMap, faceNormals, *surface);
192  MaterializerResult<Vec> matResult = materializer.generateMaterials();
193  finalize.setMaterializerResult(matResult);
194  MeshBufferPtr buffer = finalize.apply(mesh);
195 
196 
197  ModelPtr model(new Model(buffer));
198  ModelBridgePtr bridge(new LVRModelBridge(model));
199 
200  vtkSmartPointer<vtkRenderer> renderer = m_renderWindow->GetRenderers()->GetFirstRenderer();
201  bridge->addActors(renderer);
202 
203  QString base = m_parent->getName() + " (mesh)";
204  m_generatedModel = new LVRModelItem(bridge, base);
205 
206  m_treeWidget->addTopLevelItem(m_generatedModel);
207  m_generatedModel->setExpanded(true);
208 }
209 
210 } // namespace lvr2
BaseVector.hpp
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_parent
LVRModelItem * m_parent
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:66
lvr2::planarClusterGrowing
ClusterBiMap< FaceHandle > planarClusterGrowing(const BaseMesh< BaseVecT > &mesh, const FaceMap< Normal< typename BaseVecT::CoordType >> &normals, float minSinAngle)
Algorithm which generates plane clusters from the given mesh.
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::switchGridSizeDetermination
void switchGridSizeDetermination(int index)
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:93
NormalAlgorithms.hpp
lvr2::BaseVector< float >
lvr2::ClusterPainter
Algorithm which generates the same color for all vertices, which are in the same cluster.
Definition: ClusterPainter.hpp:55
lvr2::PointBufferPtr
std::shared_ptr< PointBuffer > PointBufferPtr
Definition: PointBuffer.hpp:130
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_pc
LVRPointCloudItem * m_pc
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:65
lvr2::calcVertexNormals
DenseVertexMap< Normal< typename BaseVecT::CoordType > > calcVertexNormals(const BaseMesh< BaseVecT > &mesh, const FaceMap< Normal< typename BaseVecT::CoordType >> &normals, const PointsetSurface< BaseVecT > &surface)
Calculates a normal for each vertex in the mesh.
lvr2::TextureFinalizer::setClusterColors
void setClusterColors(const ClusterMap< Rgb8Color > &colors)
lvr2::TextureFinalizer
Definition: FinalizeAlgorithms.hpp:105
lvr2::TextureFinalizer::setVertexNormals
void setVertexNormals(const VertexMap< Normal< typename BaseVecT::CoordType >> &normals)
lvr2::LVRPointCloudItem
Definition: LVRPointCloudItem.hpp:45
lvr2::MaterializerResult
Result struct for the materializer.
Definition: FinalizeAlgorithms.hpp:61
lvr2::Model
Definition: Model.hpp:51
HalfEdgeMesh.hpp
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::generateMesh
void generateMesh()
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:119
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_renderWindow
vtkRenderWindow * m_renderWindow
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:69
AdaptiveKSearchSurface.hpp
lvr2::PointsetSurfacePtr
std::shared_ptr< PointsetSurface< BaseVecT > > PointsetSurfacePtr
Definition: PointsetSurface.hpp:161
lvr2::VectorMap
A map with constant lookup overhead using small-ish integer-keys.
Definition: VectorMap.hpp:60
lvr2::ModelBridgePtr
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
Definition: LVRModelBridge.hpp:120
FastReconstruction.hpp
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::~LVRReconstructViaExtendedMarchingCubesDialog
virtual ~LVRReconstructViaExtendedMarchingCubesDialog()
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:67
lvr2::AdaptiveKSearchSurface
A point cloud manager class that uses the STANN nearest neighbor search library to handle the data....
Definition: AdaptiveKSearchSurface.hpp:98
PointBuffer.hpp
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_treeWidget
QTreeWidget * m_treeWidget
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:67
PointsetGrid.hpp
lvr2::LVRPointCloudItem::getPointBuffer
PointBufferPtr getPointBuffer()
Definition: LVRPointCloudItem.cpp:190
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::toggleRANSACcheckBox
void toggleRANSACcheckBox(const QString &text)
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:79
lvr2::LVRModelBridge
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
Definition: LVRModelBridge.hpp:61
lvr2::Materializer::generateMaterials
MaterializerResult< BaseVecT > generateMaterials()
Generates materials.
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
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::SharpBox
Used for extended marching cubes Reconstruction.
Definition: SharpBox.hpp:53
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::LVRReconstructViaExtendedMarchingCubesDialog
LVRReconstructViaExtendedMarchingCubesDialog(string decomposition, LVRPointCloudItem *pc, LVRModelItem *parent, QTreeWidget *treeWidget, vtkRenderWindow *renderer)
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:46
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_dialog
ReconstructViaExtendedMarchingCubesDialog * m_dialog
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:64
lvr2::LVRModelItem::getName
QString getName()
Definition: LVRModelItem.cpp:109
lvr2::TextureFinalizer::apply
MeshBufferPtr apply(const BaseMesh< BaseVecT > &mesh)
lvr2::ClusterPainter::simpsons
DenseClusterMap< Rgb8Color > simpsons(const BaseMesh< BaseVecT > &mesh) const
Assign a pseudo-color to each cluster.
lvr2::TextureFinalizer::setMaterializerResult
void setMaterializerResult(const MaterializerResult< BaseVecT > &materializerResult)
mesh
HalfEdgeMesh< Vec > mesh
Definition: src/tools/lvr2_gs_reconstruction/Main.cpp:26
lvr2::ClusterBiMap
A map of clusters, which also saves a back-reference from handle to cluster.
Definition: ClusterBiMap.hpp:72
lvr2::Materializer
Class for calculating materials for each cluster of a given mesh.
Definition: Materializer.hpp:131
lvr2::calcFaceNormals
DenseFaceMap< Normal< typename BaseVecT::CoordType > > calcFaceNormals(const BaseMesh< BaseVecT > &mesh)
Calculates a normal for each face in the mesh.
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::m_generatedModel
LVRModelItem * m_generatedModel
Definition: LVRReconstructionExtendedMarchingCubesDialog.hpp:68
lvr2::HalfEdgeMesh
Half-edge data structure implementing the BaseMesh interface.
Definition: HalfEdgeMesh.hpp:70
SharpBox.hpp
lvr2::LVRReconstructViaExtendedMarchingCubesDialog::connectSignalsAndSlots
void connectSignalsAndSlots()
Definition: LVRReconstructionExtendedMarchingCubesDialog.cpp:72
LVRReconstructionExtendedMarchingCubesDialog.hpp


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