19 #include <QInputDialog>
20 #include <QMainWindow>
21 #include <QMessageBox>
22 #include <QProgressDialog>
23 #include <QtConcurrentRun>
28 #if defined(CV_WINDOWS)
156 std::tuple<std::shared_ptr<ccMesh>, std::vector<double>>
result =
164 s_mesh->CreateInternalCloud();
175 : QDialog(parent, Qt::Tool),
176 Ui::PoissonReconParamDialog(),
178 m_applyAllClouds(false) {
181 m_normalsMask.clear();
187 bool cloudHasColors = cloud->
hasColors();
188 importColorsCheckBox->setVisible(cloudHasColors);
190 depthRadioButton->setChecked(
true);
192 resolutionRadioButton->setChecked(
true);
204 boundaryComboBox->setCurrentIndex(0);
207 boundaryComboBox->setCurrentIndex(1);
210 boundaryComboBox->setCurrentIndex(2);
213 boundaryComboBox->setCurrentIndex(3);
225 QProgressDialog pDlg(tr(
"Initialization"), QString(), 0, 0, m_app);
226 pDlg.setWindowTitle(tr(
"Poisson Reconstruction"));
231 QString progressLabel(tr(
"Reconstruction for [%1] in progress\n")
239 pDlg.setLabelText(progressLabel);
240 QApplication::processEvents();
247 while (!future.isFinished()) {
248 #if defined(CV_WINDOWS)
254 pDlg.setValue(pDlg.value() + 1);
255 QApplication::processEvents();
263 QApplication::processEvents();
272 m_clouds.push_back(ent);
274 m_normalsMask.push_back(
static_cast<ccPointCloud*
>(ent)->hasNormals());
276 m_normalsMask.push_back(
false);
286 int nCount =
std::count(m_normalsMask.begin(), m_normalsMask.end(),
false);
287 bool updateNormals =
false;
290 (QMessageBox::question(
291 m_app, tr(
"Some clouds have no normals?"),
292 tr(
"Clouds must have normals before poisson "
293 "reconstruction. Do you want to compute normals?"),
295 QMessageBox::No) == QMessageBox::Yes);
296 if (!updateNormals) {
298 tr(
"m_clouds must have normals before poisson "
302 assert(m_normalsMask.size() == m_clouds.size());
304 for (
size_t i = 0; i < m_normalsMask.size(); ++i) {
305 if (!m_normalsMask[i])
306 toBeEstimateNormals.push_back(m_clouds[i]);
315 m_applyAllClouds =
false;
316 for (
size_t i = 0; i < m_clouds.size(); ++i) {
324 if (!m_applyAllClouds) {
353 CVLog::Print(tr(
"[PoissonRecon] reconstruction from [%1] (%2 "
354 "triangles, %3 vertices)")
357 .arg(newPC->
size()));
378 "[doActionPoissonReconstruction] density dimension "
382 m_result.push_back(
s_mesh);
386 std::vector<std::vector<ScalarType>> scalarsVector;
387 std::vector<std::vector<double>> tempScalarsvector;
388 std::vector<ccHObject*> tempClouds;
389 tempClouds.push_back(
s_mesh);
391 ccEntityAction::ConvertToScalarType<double>(tempScalarsvector,
396 "[doActionPoissonReconstruction] import sf "
407 m_result.push_back(
s_mesh);
437 static_cast<float>(samplesPerNodeSpinBox->value());
442 switch (boundaryComboBox->currentIndex()) {
460 m_applyAllClouds = applyParamsAllCloudsCheckBox->isChecked();
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
virtual bool colorsShown() const
Returns whether colors are shown or not.
virtual void setVisible(bool state)
Sets entity visibility.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
static ccPointCloud * ToPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccPointCloud.
Hierarchical CLOUDVIEWER Object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
static std::tuple< std::shared_ptr< ccMesh >, std::vector< double > > CreateFromPointCloudPoisson(const ccPointCloud &pcd, size_t depth=8, size_t width=0, float scale=1.1f, bool linear_fit=false, float point_weight=2.f, float samples_per_node=1.5f, int boundary_type=2, int n_threads=-1)
Function that computes a triangle mesh from a oriented PointCloud pcd. This implements the Screened P...
virtual bool IsEmpty() const override
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
virtual unsigned size() const override
Returns the number of triangles.
bool computeNormals(bool perVertex)
Computes normals.
virtual QString getName() const
Returns object name.
bool isA(CV_CLASS_ENUM type) const
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
bool isKindOf(CV_CLASS_ENUM type) const
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void unallocateColors()
Erases the cloud colors.
bool hasColors() const override
Returns whether colors are enabled or not.
virtual void setGlobalScale(double scale)
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
double getDiagNormd() const
Returns diagonal length (double precision)
unsigned size() const override
void adjustParams(ccPointCloud *cloud)
ecvPoissonReconDlg(QWidget *parent=0)
ccHObject::Container & getReconstructions()
bool addEntity(ccHObject *ent)
static std::vector< double > s_density
static Parameters s_params
static ccPointCloud * s_cloud
static double s_defaultResolution
bool importToSF(const ccHObject::Container &selectedEntities, const std::vector< std::vector< ScalarType >> &scalarsVector, const std::string &name)
bool computeNormals(const ccHObject::Container &selectedEntities, QWidget *parent)
void Sleep(int milliseconds)
int baseVCycles
Coarse MG solver v-cycles.
float colorPullFactor
Data pull factor.
float cgAccuracy
This flag specifies the accuracy cut-off to be used for CG.
BoundaryType
Boundary types.
Parameters()=default
Default initializer.
float normalConfidence
Normal confidence exponent.
BoundaryType boundary
Boundary type for the finite elements.
int fullDepth
The depth beyond which the octree will be adapted.
float normalConfidenceBias
Normal confidence bias exponent.
int iters
The number of solver iterations.
int baseDepth
Coarse MG solver depth.