24 #include <QMainWindow>
33 tr(
"DoN Segmentation"),
34 tr(
"DoN Segmentation from clouds"),
35 ":/toolbar/PclAlgorithms/icons/DoN.png")),
37 m_comparisonField(
"curvature"),
38 m_comparisonTypes(
"GT"),
41 m_minDonMagnitude(0.3f),
42 m_maxDonMagnitude(1.3f),
43 m_clusterTolerance(0.02f),
44 m_minClusterSize(100),
45 m_maxClusterSize(25000),
46 m_randomClusterColor(false) {}
56 if (have_cloud != 1)
return -11;
79 static_cast<float>(
m_dialog->minDonMagnitudeSpinBox->value());
81 static_cast<float>(
m_dialog->maxDonMagnitudeSpinBox->value());
87 static_cast<float>(
m_dialog->clusterToleranceSpinBox->value());
103 if (!cloud)
return -1;
107 if (!xyzCloud)
return -1;
109 std::vector<int> dummy;
110 PCLModules::RemoveNaN<PointT>(xyzCloud, xyzCloud, dummy);
113 double cloudReolution =
114 PCLModules::ComputeCloudResolution<PointT>(xyzCloud);
126 xyzCloud, normals_small_scale,
m_smallScale,
false,
true)) {
131 xyzCloud, normals_large_scale,
m_largeScale,
false,
true)) {
138 pcl::copyPointCloud<PointT, PointNT>(*xyzCloud, *doncloud);
140 xyzCloud, normals_small_scale, normals_large_scale, doncloud)) {
151 ConditionType::CONDITION_OR;
154 ConditionType::CONDITION_AND;
160 PCLModules::ConditionParameters::ComparisonType::GT;
161 }
else if (
type ==
"GE") {
163 PCLModules::ConditionParameters::ComparisonType::GE;
164 }
else if (
type ==
"LT") {
166 PCLModules::ConditionParameters::ComparisonType::LT;
167 }
else if (
type ==
"LE") {
169 PCLModules::ConditionParameters::ComparisonType::LE;
170 }
else if (
type ==
"EQ") {
172 PCLModules::ConditionParameters::ComparisonType::EQ;
182 doncloud, param, doncloud_filtered,
false)) {
185 doncloud = doncloud_filtered;
186 if (doncloud->width * doncloud->height == 0) {
192 std::vector<pcl::PointIndices> cluster_indices;
199 if (cluster_indices.size() == 0 || cluster_indices.size() > 300) {
204 std::vector<std::vector<size_t>> clusterIndices;
205 for (
auto& cluster : cluster_indices) {
206 std::vector<size_t> cs;
207 cs.resize(cluster.indices.size());
208 for (
size_t i = 0; i < cluster.indices.size(); ++i) {
209 cs[i] = (
static_cast<size_t>(cluster.indices[i]));
212 clusterIndices.push_back(cs);
222 tr(
"-Tolerance(%1)-ClusterSize(%2-%3)")
235 "of clusters! Result may be incomplete"),
259 "Selected entity does not have any suitable scalar field "
263 "Wrong Parameters. One or more parameters cannot be "
267 "Difference of Normals Segmentation could not get any "
269 "the clusters are more than 300 for the given dataset. Try "
270 "relaxing your parameters");
272 return tr(
"An error occurred during the generation of clusters!");
pcl::PointCloud< PointNT > PointCloudNormal
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.
void getComparisonTypes(QStringList &types)
const QString getComparisonField()
DONSegmentationDlg * m_dialog
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
virtual ~DONSegmentation()
bool m_randomClusterColor
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int compute()
Performs the actual filter job.
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual int openInputDialog()
QString m_comparisonField
virtual int checkParameters()
QStringList m_comparisonTypes
CC to PCL cloud converter.
pcl::PointCloud< pcl::PointXYZ >::Ptr getXYZ2() const
Hierarchical CLOUDVIEWER Object.
unsigned getChildrenNumber() const
Returns the number of children.
ccHObject * getParent() const
Returns parent object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
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
template int ConditionalRemovalFilter< PointNT >(const PointCloudNormal::ConstPtr inCloud, const ConditionParameters ¶ms, PointCloudNormal::Ptr outCloud, bool keepOrganized)
template int ComputeNormals< PointT, PointNT >(const PointCloudT::ConstPtr inCloud, PointCloudNormal::Ptr outcloud, const float radius, const bool useKnn, bool normalConsistency, int maxThreadCount)
template int EuclideanCluster< PointNT >(const PointCloudNormal::ConstPtr inCloud, std::vector< pcl::PointIndices > &cluster_indices, float clusterTolerance, int minClusterSize, int maxClusterSize)
template int DONEstimation< PointT, PointNT, PointNT >(const PointCloudT::ConstPtr inCloud, const PointCloudNormal::ConstPtr normalsLargeScale, const PointCloudNormal::ConstPtr normalsSmallScale, PointCloudNormal::Ptr outCloud)
ComparisonType comparison_type_
ConditionType condition_type_
std::vector< ComparisonParam > condition_params_