10 #include <Utils/cc2sm.h>
11 #include <Utils/sm2cc.h>
13 #include "PclUtils/PCLModules.h"
24 #include <QMainWindow>
31 tr(
"Poisson Reconstruction"),
32 tr(
"Poisson Reconstruction"),
33 tr(
"Poisson Reconstruction from clouds"),
34 ":/toolbar/PclAlgorithms/icons/poisson.png")),
36 m_normalSearchRadius(10),
42 m_solverDivideDepth(8),
44 m_samplesPerNode(3.0f),
45 m_useConfidence(true),
47 m_outputPolygons(false) {}
57 if (have_cloud != 1)
return -11;
87 static_cast<float>(
m_dialog->normalSearchRadius->value());
96 static_cast<float>(
m_dialog->samplesPerNodeSpinbox->value());
107 if (!cloud)
return -1;
110 pcl::PointCloud<pcl::PointNormal>::Ptr cloudWithNormals(
111 new pcl::PointCloud<pcl::PointNormal>);
115 pcl::PointCloud<pcl::PointXYZ>::Ptr xyzCloud =
116 cc2smReader(cloud).getXYZ2();
117 if (!xyzCloud)
return -1;
120 pcl::PointCloud<NormalT>::Ptr
normals(
new pcl::PointCloud<NormalT>);
121 int result = PCLModules::ComputeNormals<pcl::PointXYZ, NormalT>(
124 if (
result < 0)
return -1;
127 pcl::concatenateFields(*xyzCloud, *
normals, *cloudWithNormals);
129 tr(
"[PoissonReconstruction::compute] generate new normals"));
131 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getAsSM();
132 FROM_PCL_CLOUD(*sm_cloud, *cloudWithNormals);
134 tr(
"[PoissonReconstruction::compute] find normals and use the "
142 int result = PCLModules::GetPoissonReconstruction(
146 if (
result < 0)
return -1;
148 PCLCloud out_cloud_sm(mesh.cloud);
149 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
154 ccMesh* out_mesh = pcl2cc::Convert(out_cloud_sm, mesh.polygons);
161 unsigned faceCount = out_mesh->
size();
162 CVLog::Print(tr(
"[Poisson-Reconstruction] %1 points, %2 face(s)")
166 out_mesh->
setName(tr(
"Poisson Reconstruction"));
185 "Selected entity does not have any suitable scalar field "
189 "Wrong Parameters. One or more parameters cannot be "
193 "Poisson Reconstruction does not returned any point. Try "
194 "relaxing your parameters");
Base abstract class for each implemented PCL filter.
int isFirstSelectedCcPointCloud()
Returns 1 if the first selected object is a ccPointCloud.
void newEntity(ccHObject *)
Signal emitted when a new entity is created by the filter.
ecvMainAppInterface * m_app
Associated application interface.
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
static bool Print(const char *format,...)
Prints out a formatted message in console.
virtual int compute()
Performs the actual filter job.
float m_normalSearchRadius
PoissonReconstructionDlg * m_dialog
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual ~PoissonReconstruction()
virtual int openInputDialog()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
virtual int checkParameters()
ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
virtual unsigned size() const override
Returns the number of triangles.
virtual void setName(const QString &name)
Sets object name.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasNormals() const override
Returns whether normals 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.
T getDiagNorm() const
Returns diagonal length.
bool isValid() const
Returns whether bounding box is valid or not.
virtual unsigned size() const =0
Returns the number of points.
virtual QWidget * getActiveWindow()=0