11 #include "ui_poissonReconParamDlg.h"
15 #include <QInputDialog>
16 #include <QMainWindow>
17 #include <QtConcurrentRun>
31 #if defined(CV_WINDOWS)
38 template <
typename Real>
46 virtual void getPoint(
size_t index, Real* coords)
const {
53 coords[0] =
static_cast<Real
>(P->
x);
54 coords[1] =
static_cast<Real
>(P->
y);
55 coords[2] =
static_cast<Real
>(P->
z);
58 virtual void getNormal(
size_t index, Real* coords)
const {
66 coords[0] =
static_cast<Real
>(N.
x);
67 coords[1] =
static_cast<Real
>(N.
y);
68 coords[2] =
static_cast<Real
>(N.
z);
71 virtual void getColor(
size_t index, Real* rgb)
const {
79 rgb[0] =
static_cast<Real
>(
color.r);
80 rgb[1] =
static_cast<Real
>(
color.g);
81 rgb[2] =
static_cast<Real
>(
color.b);
88 template <
typename Real>
156 (Real)255,
std::max((Real)0, rgb[0]))),
158 (Real)255,
std::max((Real)0, rgb[1]))),
160 (Real)255,
std::max((Real)0, rgb[2]))));
180 static_cast<unsigned>(i3));
194 public Ui::PoissonReconParamDialog {
197 : QDialog(parent, Qt::Tool),
Ui::PoissonReconParamDialog() {
202 qPoissonRecon::qPoissonRecon(QObject* parent )
207 void qPoissonRecon::onNewSelection(
210 m_action->setEnabled(selectedEntities.size() == 1 &&
214 QList<QAction*> qPoissonRecon::getActions() {
282 static unsigned s_lastEntityID = 0;
292 prpDlg.importColorsCheckBox->setVisible(cloudHasColors);
294 prpDlg.depthRadioButton->setChecked(
true);
296 prpDlg.resolutionRadioButton->setChecked(
true);
308 prpDlg.boundaryComboBox->setCurrentIndex(0);
311 prpDlg.boundaryComboBox->setCurrentIndex(1);
314 prpDlg.boundaryComboBox->setCurrentIndex(2);
321 if (!prpDlg.exec())
return;
324 s_depthMode = prpDlg.depthRadioButton->isChecked();
331 static_cast<float>(prpDlg.samplesPerNodeSpinBox->value());
335 static_cast<float>(prpDlg.weightDoubleSpinBox->value());
337 switch (prpDlg.boundaryComboBox->currentIndex()) {
355 assert(
s_mesh ==
nullptr);
372 QProgressDialog pDlg(
"Initialization", QString(), 0, 0,
374 pDlg.setWindowTitle(
"Poisson Reconstruction");
378 QString progressLabel(
"Reconstruction in progress\n");
386 pDlg.setLabelText(progressLabel);
387 QApplication::processEvents();
401 while (!future.isFinished()) {
402 #if defined(CV_WINDOWS)
408 pDlg.setValue(pDlg.value() + 1);
409 QApplication::processEvents();
419 QApplication::processEvents();
436 QString(
"[PoissonRecon] Job finished (%1 triangles, %2 vertices)")
437 .arg(newMesh->
size())
441 newMesh->
setName(QString(
"Mesh[%1] (level %2)")
447 if (!cloudHasColors) {
virtual void release()
Decrease counter and deletes object when 0.
ccPointCloud & m_vertices
virtual void addVertex(const Real *coords) override
void addTriangle(size_t i1, size_t i2, size_t i3) override
virtual void addNormal(const Real *coords) override
bool checkVertexCapacity()
cloudViewer::ScalarField * m_densitySF
bool isInErrorState() const
MeshWrapper(ccMesh &mesh, ccPointCloud &vertices, cloudViewer::ScalarField *densitySF=nullptr)
virtual void addColor(const Real *rgb) override
virtual void addDensity(double d) override
virtual void getColor(size_t index, Real *rgb) const
virtual void getPoint(size_t index, Real *coords) const
virtual void getNormal(size_t index, Real *coords) const
PointCloudWrapper(const ccPointCloud &cloud)
virtual size_t size() const
const ccPointCloud & m_cloud
virtual bool hasNormals() const
virtual bool hasColors() const
static bool Reconstruct(const Parameters ¶ms, const PoissonReconLib::ICloud< float > &inCloud, PoissonReconLib::IMesh< float > &ouMesh)
Reconstruct a mesh from a point cloud (float version)
PoissonReconParamDlg(QWidget *parent=nullptr)
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
virtual QString getName() const override
Returns (short) name (for menu entry, etc.)
virtual QString getDescription() const override
Returns long name/description (for tooltip, etc.)
virtual QIcon getIcon() const override
Returns icon.
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.
Hierarchical CLOUDVIEWER Object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
bool reserve(std::size_t n)
Reserves the memory to store the vertex indexes (3 per triangle)
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
virtual unsigned size() const override
Returns the number of triangles.
unsigned capacity() const override
Returns max capacity.
bool computeNormals(bool perVertex)
Computes normals.
virtual QString getName() const
Returns object name.
virtual unsigned getUniqueID() const
Returns object unique ID.
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.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
void unallocateColors()
Erases the cloud colors.
void addNorm(const CCVector3 &N)
Pushes a normal vector on stack (shortcut)
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
bool hasNormals() const override
Returns whether normals are enabled or not.
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
bool reserveTheNormsTable()
Reserves memory to store the compressed normals.
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
bool hasColors() const override
Returns whether colors are enabled or not.
const ecvColor::Rgb & getPointColor(unsigned pointIndex) const override
Returns color corresponding to a given point.
const CCVector3 & getPointNormal(unsigned pointIndex) const override
Returns normal corresponding to a given point.
void addRGBColor(const ecvColor::Rgb &C)
Pushes an RGB color on stack.
A scalar field associated to display-related parameters.
void showNaNValuesInGrey(bool state)
void computeMinAndMax() override
Determines the min and max values.
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.
Standard ECV plugin interface.
ecvMainAppInterface * m_app
Main application interface.
double getDiagNormd() const
Returns diagonal length (double precision)
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
unsigned size() const override
unsigned capacity() const
Returns cloud capacity (i.e. reserved size)
const CCVector3 * getPoint(unsigned index) const override
A simple scalar field (to be associated to a point cloud)
void addElement(ScalarType value)
bool reserveSafe(std::size_t count)
Reserves memory (no exception thrown)
virtual void updateUI()=0
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual void refreshAll(bool only2D=false, bool forceRedraw=true)=0
Redraws all GL windows that have the 'refresh' flag on.
virtual const ccHObject::Container & getSelectedEntities() const =0
Returns currently selected entities ("read only")
bool haveOneSelection() const
Checks if we have exactly one selection.
virtual void setSelectedInDB(ccHObject *obj, bool selected)=0
Selects or unselects an entity (in db tree)
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
QAction * m_action
Associated action.
void doAction()
Slot called when associated ation is triggered.
unsigned char ColorCompType
Default color components type (R,G and B)
static double s_defaultResolution
void Sleep(int milliseconds)
static PoissonReconLib::Parameters s_params
static cloudViewer::ScalarField * s_densitySF
static ccPointCloud * s_meshVertices
static ccPointCloud * s_cloud
BoundaryType boundary
Boundary type for the finite elements.