28 #include <QFileDialog> 39 #if defined CUDA_FOUND 45 #elif defined OPENCL_FOUND 57 m_pc(pc), m_parent(parent), m_treeWidget(treeWidget), m_renderWindow(window)
63 m_dialog =
new EstimateNormalsDialog;
70 dialog->activateWindow();
78 QList<LVRPointCloudItem*> pc_items,
79 QList<QTreeWidgetItem*> parents,
80 QTreeWidget* treeWidget,
81 vtkRenderWindow* renderer
90 m_dialog =
new EstimateNormalsDialog;
97 dialog->activateWindow();
118 QSpinBox* spinBox_kn =
m_dialog->spinBox_kn;
119 if(state == Qt::Checked)
121 spinBox_kn->setEnabled(
false);
125 spinBox_kn->setEnabled(
true);
131 QSpinBox* spinBox_ki =
m_dialog->spinBox_ki;
132 if(state == Qt::Checked)
134 spinBox_ki->setEnabled(
false);
138 spinBox_ki->setEnabled(
true);
144 std::string alog_str = current_text.toStdString();
145 if(alog_str ==
"GPU")
147 m_dialog->label_fp->setVisible(
true);
148 m_dialog->doubleSpinBox_fp_x->setVisible(
true);
149 m_dialog->doubleSpinBox_fp_y->setVisible(
true);
150 m_dialog->doubleSpinBox_fp_z->setVisible(
true);
152 m_dialog->label_fp->setVisible(
false);
153 m_dialog->doubleSpinBox_fp_x->setVisible(
false);
154 m_dialog->doubleSpinBox_fp_y->setVisible(
false);
155 m_dialog->doubleSpinBox_fp_z->setVisible(
false);
164 bool autoKn =
m_dialog->checkBox_kn_auto->isChecked();
165 bool autoKi =
m_dialog->checkBox_ki_auto->isChecked();
166 bool genNew =
m_dialog->checkBox_new_item->isChecked();
168 int kn =
m_dialog->spinBox_kn->value();
169 int ki =
m_dialog->spinBox_ki->value();
171 QString algo =
m_dialog->comboBox_algo_select->currentText();
172 std::string algo_str = algo.toStdString();
175 std::cout <<
"NORMAL ESTIMATION SETTINGS: " << std::endl;
178 std::cout <<
"-- kn: auto" << std::endl;
180 std::cout <<
"-- kn: " << kn << std::endl;
185 std::cout <<
"-- ki: auto" << std::endl;
187 std::cout <<
"-- ki: " << ki << std::endl;
190 std::cout <<
"-- algo: " << algo_str << std::endl;
192 for(
int pc_id = 0; pc_id <
m_pcs.size(); pc_id++)
195 QTreeWidgetItem* parent =
m_parents[pc_id];
202 floatArr old_pts = pc->getPointArray();
204 floatArr points(
new float[3 * numPoints]);
207 std::copy(old_pts.get(), old_pts.get() + numPoints*3, points.get());
210 pc->setPointArray(points, numPoints);
215 if(algo_str ==
"STANN" || algo_str ==
"FLANN" || algo_str ==
"NABO" || algo_str ==
"NANOFLANN")
217 surface = std::make_shared<AdaptiveKSearchSurface<Vec> >(
218 pc, algo_str, kn, ki, 20, false
220 }
else if(algo_str ==
"GPU") {
221 surface = std::make_shared<AdaptiveKSearchSurface<Vec> >(
222 pc,
"FLANN", kn, ki, 20, false
233 kn =
static_cast<int>(
234 sqrt(static_cast<double>(numPoints)) / V * 400.0);
235 std::cout <<
"-- auto kn: " << kn << std::endl;
240 ki =
static_cast<int>(
241 sqrt(static_cast<double>(numPoints)) / V * 400.0);
243 std::cout <<
"-- auto ki: " << ki << std::endl;
248 if(algo_str ==
"GPU")
252 float fpx =
static_cast<float>(
m_dialog->doubleSpinBox_fp_x->value());
253 float fpy =
static_cast<float>(
m_dialog->doubleSpinBox_fp_y->value());
254 float fpz =
static_cast<float>(
m_dialog->doubleSpinBox_fp_z->value());
256 std::vector<float> flipPoint = {fpx, fpy, fpz};
257 size_t num_points = pc->numPoints();
258 floatArr points = pc->getPointArray();
260 std::cout <<
timestamp <<
"Generate GPU kd-tree..." << std::endl;
263 gpu_surface.setKn(kn);
264 gpu_surface.setKi(ki);
265 gpu_surface.setFlippoint(flipPoint[0], flipPoint[1], flipPoint[2]);
267 std::cout <<
timestamp <<
"Calculated normals..." << std::endl;
268 gpu_surface.calculateNormals();
269 gpu_surface.getNormals(normals);
271 pc->setNormalArray(normals, num_points);
272 gpu_surface.freeGPU();
275 std::cout <<
"ERROR: GPU Driver not installed, using FLANN instead" << std::endl;
276 surface->calculateSurfaceNormals();
279 surface->calculateSurfaceNormals();
287 vtkSmartPointer<vtkRenderer> renderer =
m_renderWindow->GetRenderers()->GetFirstRenderer();
288 bridge->addActors(renderer);
294 base = model_item->
getName() +
" (w. normals)";
301 base = sd_item->
getName() +
" (w. normals)";
317 vtkSmartPointer<vtkRenderer> renderer =
m_renderWindow->GetRenderers()->GetFirstRenderer();
327 std::cout <<
timestamp <<
"Finished." << std::endl;
A class to handle point information with an arbitrarily large number of attribute channels...
Datastructures for holding loaded data.
QList< LVRPointCloudItem * > m_pcs
PointBufferPtr getPointBuffer()
static Timestamp timestamp
A global time stamp object for program runtime measurement.
BaseVecT::CoordType getZSize() const
Returns the z-size of the bounding box.
BaseVecT::CoordType getYSize() const
Returns the y-size of the bounding box.
virtual ~LVREstimateNormalsDialog()
std::shared_ptr< PointBuffer > PointBufferPtr
A dynamic bounding box class.
Main class for conversion of LVR model instances to vtk actors. This class parses the internal model ...
EstimateNormalsDialog * m_dialog
void toggleAutoNormalEstimation(int state)
boost::shared_ptr< LVRModelBridge > ModelBridgePtr
void toggleSpecialOptions(QString current_text)
boost::shared_array< float > floatArr
void toggleAutoNormalInterpolation(int state)
QList< QTreeWidgetItem * > m_parents
LVREstimateNormalsDialog(LVRPointCloudItem *pc_item, QTreeWidgetItem *parent, QTreeWidget *treeWidget, vtkRenderWindow *renderer)
QTreeWidget * m_treeWidget
void connectSignalsAndSlots()
std::shared_ptr< Model > ModelPtr
PointBufferBridgePtr getPointBufferBridge()
LVRModelItem * m_pointCloudWithNormals
BaseVecT::CoordType getXSize() const
Returns the x-size of the bounding box.
void setPose(const Pose &pose)
std::shared_ptr< PointsetSurface< BaseVecT > > PointsetSurfacePtr
vtkRenderWindow * m_renderWindow