11 #include <Utils/cc2sm.h>
12 #include <Utils/sm2cc.h>
14 #include "PclUtils/PCLModules.h"
24 #include <QMainWindow>
28 tr(
"Projection Filter"),
29 tr(
"Projection Filter"),
30 tr(
"Projection Filter for the selected entity"),
31 ":/toolbar/PclAlgorithms/icons/filter_projection.png")),
33 m_projectionMode(true),
38 m_useVoxelGrid(false),
42 m_normalSearchRadius(0.01f),
43 m_boundarySearchRadius(0.05f),
44 m_boundaryAngleThreshold(90.0f) {}
64 switch (
m_dialog->tab->currentIndex()) {
81 static_cast<float>(
m_dialog->normalSearchRadius->value());
84 m_dialog->boundaryAngleThresholdSpinBox->value());
96 if (!cloud)
return -1;
98 PointCloudT::Ptr xyzCloud = cc2smReader(cloud).getXYZ2();
99 if (!xyzCloud)
return -1;
102 PCLCloud::Ptr out_cloud_sm(
new PCLCloud);
103 PointCloudT::Ptr outCloudxyz(
new PointCloudT);
109 pcl::ModelCoefficients::Ptr coefficients(
new pcl::ModelCoefficients());
110 coefficients->values.resize(4);
116 if (!PCLModules::GetProjection(xyzCloud, outCloudxyz, coefficients, 0))
123 PointCloudT::Ptr tempCloud(
new PointCloudT);
124 if (!PCLModules::VoxelGridFilter<PointT>(xyzCloud, tempCloud,
129 xyzCloud = tempCloud;
133 pcl::PointCloud<NormalT>::Ptr
normals(
new pcl::PointCloud<NormalT>);
137 int result = PCLModules::ComputeNormals<PointT, NormalT>(
141 if (
result < 0)
return -1;
143 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getNormals();
144 FROM_PCL_CLOUD(*sm_cloud, *
normals);
149 float resolution =
static_cast<float>(
150 PCLModules::ComputeCloudResolution<PointT>(xyzCloud));
151 if (resolution > 0) {
156 if (!PCLModules::GetBoundaryCloud<PointT, NormalT>(
164 if (outCloudxyz->width * outCloudxyz->height == 0) {
168 TO_PCL_CLOUD(*outCloudxyz, *out_cloud_sm);
169 ccPointCloud* out_cloud_cc = pcl2cc::Convert(*out_cloud_sm);
179 out_cloud_cc->
showSF(
false);
200 "Selected entity does not have any suitable scalar field "
201 "or RGB. Intensity scalar field or RGB are needed for "
205 "Wrong Parameters. One or more parameters cannot be "
209 "Projection extraction does not returned any point. Try "
210 "relaxing your parameters");
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.
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.
virtual int openInputDialog()
virtual int checkParameters()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
float m_boundaryAngleThreshold
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int compute()
Performs the actual filter job.
ProjectionFilterDlg * m_dialog
virtual ~ProjectionFilter()
float m_normalSearchRadius
float m_boundarySearchRadius
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
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.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasNormals() const override
Returns whether normals are enabled or not.
bool setRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Set a unique color for the whole cloud (shortcut)
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.
static Rgb Random(bool lightOnly=true)
Generates a random color.
virtual QWidget * getActiveWindow()=0