11 #include <Utils/cc2sm.h>
12 #include <Utils/sm2cc.h>
14 #include "PclUtils/PCLModules.h"
25 #include <QMainWindow>
29 tr(
"General Filters"),
30 tr(
"General Filters"),
31 tr(
"General Filters for the selected entity"),
32 ":/toolbar/PclAlgorithms/icons/generalFilter.png")),
38 m_extractRemainings(false),
42 m_initialDistance(0.5f),
44 m_comparisonField(
"curvature"),
45 m_comparisonTypes(
"GT"),
70 switch (
m_dialog->tab->currentIndex()) {
97 m_dialog->extractRemainingCheckBox->isChecked();
101 m_dialog->initialDistanceSpinBox->value());
103 static_cast<float>(
m_dialog->maxDistanceSpinBox->value());
133 if (!cloud)
return -1;
136 PCLCloud::Ptr out_cloud_sm(
new PCLCloud);
137 PointCloudT::Ptr xyzCloud(
new PointCloudT);
138 PointCloudRGB::Ptr rgbCloud(
new PointCloudRGB);
140 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getAsSM();
142 FROM_PCL_CLOUD(*sm_cloud, *rgbCloud);
143 if (!rgbCloud)
return -1;
146 FROM_PCL_CLOUD(*sm_cloud, *xyzCloud);
147 if (!xyzCloud)
return -1;
155 PointCloudRGB::Ptr tempCloud(
new PointCloudRGB);
156 if (!PCLModules::PassThroughFilter<PointRGB>(
161 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
163 PointCloudT::Ptr tempCloud(
new PointCloudT);
164 if (!PCLModules::PassThroughFilter<PointT>(
169 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
176 PCLModules::ConditionParameters param;
179 param.condition_type_ = PCLModules::ConditionParameters::
180 ConditionType::CONDITION_OR;
182 param.condition_type_ = PCLModules::ConditionParameters::
183 ConditionType::CONDITION_AND;
186 PCLModules::ConditionParameters::ComparisonParam comparison;
188 comparison.comparison_type_ = PCLModules::
189 ConditionParameters::ComparisonType::GT;
190 }
else if (
type ==
"GE") {
191 comparison.comparison_type_ = PCLModules::
192 ConditionParameters::ComparisonType::GE;
193 }
else if (
type ==
"LT") {
194 comparison.comparison_type_ = PCLModules::
195 ConditionParameters::ComparisonType::LT;
196 }
else if (
type ==
"LE") {
197 comparison.comparison_type_ = PCLModules::
198 ConditionParameters::ComparisonType::LE;
199 }
else if (
type ==
"EQ") {
200 comparison.comparison_type_ = PCLModules::
201 ConditionParameters::ComparisonType::EQ;
206 param.condition_params_.push_back(comparison);
211 PointCloudRGB::Ptr tempCloud(
new PointCloudRGB);
212 if (!PCLModules::ConditionalRemovalFilter<PointRGB>(
213 rgbCloud, param, tempCloud,
true)) {
216 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
218 PointCloudT::Ptr tempCloud(
new PointCloudT);
219 if (!PCLModules::ConditionalRemovalFilter<PointT>(
220 xyzCloud, param, tempCloud,
true)) {
223 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
230 PointCloudRGB::Ptr tempCloud(
new PointCloudRGB);
231 if (!PCLModules::VoxelGridFilter<PointRGB>(
238 if (tempCloud->size() == rgbCloud->size()) {
241 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
243 PointCloudT::Ptr tempCloud(
new PointCloudT);
244 if (!PCLModules::VoxelGridFilter<PointT>(xyzCloud, tempCloud,
250 if (tempCloud->size() == xyzCloud->size()) {
253 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
261 pcl::PointIndicesPtr ground(
new pcl::PointIndices);
262 if (!PCLModules::ProgressiveMpFilter<PointRGB>(
265 ground->indices.size() == 0) {
269 PointCloudRGB::Ptr tempCloud(
new PointCloudRGB);
271 if (!PCLModules::ExtractIndicesFilter<PointRGB>(
272 rgbCloud, ground,
nullptr, tempCloud)) {
276 if (!PCLModules::ExtractIndicesFilter<PointRGB>(
277 rgbCloud, ground, tempCloud,
nullptr)) {
282 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
284 pcl::PointIndicesPtr ground(
new pcl::PointIndices);
285 if (!PCLModules::ProgressiveMpFilter<PointT>(
288 ground->indices.size() == 0) {
292 PointCloudT::Ptr tempCloud(
new PointCloudT);
294 if (!PCLModules::ExtractIndicesFilter<PointT>(
295 xyzCloud, ground,
nullptr, tempCloud)) {
299 if (!PCLModules::ExtractIndicesFilter<PointT>(
300 xyzCloud, ground, tempCloud,
nullptr)) {
305 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
311 PointCloudT::Ptr boundary(
new PointCloudT);
314 boundary->resize(pointNum);
315 for (
unsigned int i = 0; i < pointNum; ++i) {
317 boundary->points[i].
x = p->
x;
318 boundary->points[i].y = p->
y;
319 boundary->points[i].z = p->
z;
323 boundary->resize(pointNum);
324 for (
size_t i = 0; i < pointNum; ++i) {
331 if (boundary->width * boundary->height == 0) {
336 PointCloudRGB::Ptr tempCloud(
new PointCloudRGB);
337 if (!PCLModules::CropHullFilter<PointRGB>(
341 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
343 PointCloudT::Ptr tempCloud(
new PointCloudT);
344 if (!PCLModules::CropHullFilter<PointT>(
348 TO_PCL_CLOUD(*tempCloud, *out_cloud_sm);
359 if (out_cloud_sm->width * out_cloud_sm->height == 0) {
363 ccPointCloud* out_cloud_cc = pcl2cc::Convert(*out_cloud_sm);
374 out_cloud_cc->
showSF(
false);
396 "Selected entity does not have any suitable scalar field "
397 "or RGB. Intensity scalar field or RGB are needed for "
401 "Wrong Parameters. One or more parameters cannot be "
405 "General Filter does not returned any point. Try relaxing "
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.
void refreshPolylineComboBox()
void getComparisonTypes(QStringList &types)
void getContour(std::vector< CCVector3 > &contour)
ccPolyline * getPolyline()
const QString getComparisonField(float &minValue, float &maxValue)
QStringList m_comparisonTypes
virtual int openInputDialog()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
std::vector< CCVector3 > m_boundary
virtual int checkParameters()
QString m_comparisonField
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int compute()
Performs the actual filter job.
GeneralFiltersDlg * m_dialog
virtual ~GeneralFilters()
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.
virtual void setEnabled(bool state)
Sets the "enabled" property.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasColors() const override
Returns whether colors are enabled or not.
bool setRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Set a unique color for the whole cloud (shortcut)
bool hasScalarFields() const override
Returns whether one or more scalar fields are instantiated.
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.
unsigned size() const override
Returns the number of points.
const CCVector3 * getPoint(unsigned index) const override
Returns the ith point.
static Rgb Random(bool lightOnly=true)
Generates a random color.