11 #include <Utils/cc2sm.h>
12 #include <Utils/sm2cc.h>
14 #include "PclUtils/PCLModules.h"
25 #include <QMainWindow>
27 #ifdef LP_PCL_PATCH_ENABLED
28 #include <Utils/copy.h>
34 tr(
"Smooth using MLS, optionally upsample"),
35 tr(
"Smooth the cloud using Moving Least Sqares algorithm, "
36 "estimate normals and optionally upsample"),
37 ":/toolbar/PclAlgorithms/icons/mls_smoothing.png")),
39 m_dialogHasParent(false),
69 m_dialog->squared_gaussian_parameter->value();
71 int index_now =
m_dialog->upsampling_method->currentIndex();
72 QVariant current_status =
m_dialog->upsampling_method->itemData(index_now);
73 int status = current_status.toInt();
76 (PCLModules::MLSParameters::UpsamplingMethod)status;
87 if (!cloud)
return -1;
91 std::list<std::string> req_fields;
93 req_fields.push_back(
"xyz");
99 }
catch (
const std::bad_alloc&) {
105 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getAsSM(req_fields);
106 if (!sm_cloud)
return -1;
111 int field_index = pcl::getFieldIndex(
113 cc2smReader::GetSimplifiedSFName(
115 if (field_index >= 0) sm_cloud->fields.at(field_index).name =
"scalar";
119 pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_cloud(
120 new pcl::PointCloud<pcl::PointXYZ>);
121 FROM_PCL_CLOUD(*sm_cloud, *pcl_cloud);
124 pcl::PointCloud<pcl::PointNormal>::Ptr
normals(
125 new pcl::PointCloud<pcl::PointNormal>);
126 #ifdef LP_PCL_PATCH_ENABLED
127 pcl::PointIndicesPtr mapping_indices;
128 PCLModules::SmoothMls<pcl::PointXYZ, pcl::PointNormal>(
131 PCLModules::SmoothMls<pcl::PointXYZ, pcl::PointNormal>(
135 PCLCloud::Ptr sm_normals(
new PCLCloud);
136 TO_PCL_CLOUD(*
normals, *sm_normals);
145 QString(
"_smoothed"));
148 #ifdef LP_PCL_PATCH_ENABLED
150 copyScalarFields(cloud, new_cloud, mapping_indices,
true);
152 copyRGBColors(cloud, new_cloud, mapping_indices,
true);
Base abstract class for each implemented PCL filter.
void newEntity(ccHObject *)
Signal emitted when a new entity is created by the filter.
ecvMainAppInterface * m_app
Associated application interface.
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual ~MLSSmoothingUpsampling()
PCLModules::MLSParameters * m_parameters
int compute()
Performs the actual filter job.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
virtual QString getName() const
Returns object name.
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.)
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
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.
const char * getName() const
Returns scalar field name.
virtual QMainWindow * getMainWindow()=0
Returns main window.