10 #include <Utils/cc2sm.h>
11 #include <Utils/sm2cc.h>
13 #include "PclUtils/PCLModules.h"
14 #include "Tools/Common/ecvTools.h"
24 #include <QMainWindow>
32 tr(
"EuclideanCluster Segmentation"),
33 tr(
"EuclideanCluster Segmentation"),
34 tr(
"EuclideanCluster Segmentation from clouds"),
35 ":/toolbar/PclAlgorithms/icons/"
36 "EuclideanClusterSegmentation.png")),
38 m_randomClusterColor(false),
39 m_clusterTolerance(0.02f),
40 m_minClusterSize(100),
41 m_maxClusterSize(25000) {}
51 if (have_cloud != 1)
return -11;
73 static_cast<float>(
m_dialog->clusterToleranceSpinbox->value());
87 if (!cloud)
return -1;
90 PointCloudT::Ptr xyzCloud = cc2smReader(cloud).getXYZ2();
91 if (!xyzCloud)
return -1;
94 std::vector<pcl::PointIndices> cluster_indices;
95 if (!PCLModules::EuclideanCluster<PointT>(
100 if (cluster_indices.size() == 0 || cluster_indices.size() > 300) {
105 std::vector<std::vector<size_t>> clusterIndices;
106 for (
auto& cluster : cluster_indices) {
107 std::vector<size_t> cs;
108 cs.resize(cluster.indices.size());
109 for (
size_t i = 0; i < cluster.indices.size(); ++i) {
110 cs[i] = (
static_cast<size_t>(cluster.indices[i]));
113 clusterIndices.push_back(cs);
123 tr(
"-Tolerance(%1)-ClusterSize(%2-%3)")
130 "where created from cloud '%2'")
131 .arg(cluster_indices.size())
136 "of clusters! Result may be incomplete"),
160 "Selected entity does not have any suitable scalar field "
164 "Wrong Parameters. One or more parameters cannot be "
168 "EuclideanCluster Segmentation could not get any cluster "
170 "the clusters are more than 300 for the given dataset. Try "
171 "relaxing your parameters");
173 return tr(
"An error occurred during the generation of clusters!");
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.
virtual ~EuclideanClusterSegmentation()
virtual int openInputDialog()
EuclideanClusterSegmentation()
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual int checkParameters()
virtual int compute()
Performs the actual filter job.
EuclideanClusterDlg * m_dialog
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
bool m_randomClusterColor
Hierarchical CLOUDVIEWER Object.
unsigned getChildrenNumber() const
Returns the number of children.
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.)
virtual QWidget * getActiveWindow()=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
static void error(char *msg)