10 #include <Utils/cc2sm.h>
11 #include <Utils/sm2cc.h>
13 #include "PclUtils/PCLModules.h"
14 #include "Tools/Common/ecvTools.h"
26 #include <QMainWindow>
33 tr(
"Nurbs Surface Triangulation"),
34 tr(
"Nurbs Surface Triangulation"),
35 tr(
"Nurbs Surface Triangulation from clouds"),
36 ":/toolbar/PclAlgorithms/icons/bspline_surface.png")),
40 m_meshResolution(128),
44 m_fitBSplineCurve(true),
45 m_useVoxelGrid(false),
46 m_interiorSmoothness(0.2f),
47 m_interiorWeight(1.0f),
48 m_boundarySmoothness(0.2f),
49 m_boundaryWeight(0.0f) {}
59 if (have_cloud != 1)
return -11;
89 static_cast<float>(
m_dialog->interiorSSpinBox->value());
92 static_cast<float>(
m_dialog->boundarySSpinBox->value());
99 if (!cloud)
return -1;
102 pcl::PointCloud<pcl::PointXYZ>::Ptr xyzCloud = cc2smReader(cloud).getXYZ2();
103 if (!xyzCloud)
return -1;
108 3 * PCLModules::ComputeCloudResolution<PointT>(xyzCloud);
110 PointCloudT::Ptr tempCloud(
new PointCloudT);
111 if (!PCLModules::VoxelGridFilter<PointT>(
112 xyzCloud, tempCloud, leafSize, leafSize, leafSize)) {
115 xyzCloud = tempCloud;
121 PointCloudRGB::Ptr outCurve(
new PointCloudRGB);
122 #if defined(WITH_PCL_NURBS)
124 PCLModules::NurbsParameters nurbsParams;
140 if (!PCLModules::NurbsSurfaceFitting<PointT>(xyzCloud, nurbsParams,
145 if (!PCLModules::NurbsSurfaceFitting<PointT>(xyzCloud, nurbsParams,
152 "[NurbsSurfaceReconstruction] PCL not supported with nurbs, please "
153 "rebuild pcl with -DBUILD_surface_on_nurbs=ON again"));
160 PCLCloud::Ptr curve_sm(
new PCLCloud);
161 TO_PCL_CLOUD(*outCurve, *curve_sm);
162 curvePoly = ecvTools::GetPolylines(curve_sm,
"nurbs-curve",
true);
165 PCLCloud out_cloud_sm(mesh.cloud);
166 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
171 ccMesh* out_mesh = pcl2cc::Convert(out_cloud_sm, mesh.polygons);
178 unsigned faceCount = out_mesh->
size();
179 CVLog::Print(tr(
"[NurbsSurfaceReconstruction] %1 points, %2 face(s)")
207 "Selected entity does not have any suitable scalar field "
211 "Wrong Parameters. One or more parameters cannot be "
215 "Nurbs Surface Triangulation does not returned any point. "
216 "Try 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 void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
NurbsSurfaceDlg * m_dialog
float m_interiorSmoothness
virtual int checkParameters()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
float m_boundarySmoothness
virtual int compute()
Performs the actual filter job.
virtual ~NurbsSurfaceReconstruction()
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual int openInputDialog()
NurbsSurfaceReconstruction()
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.)
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.
virtual unsigned size() const =0
Returns the number of points.
virtual QWidget * getActiveWindow()=0