35 if (cmd.
clouds().size() < 1) {
36 cmd.
error(
"No cloud loaded (1 is expected)");
47 }
catch (
const std::bad_alloc&) {
48 return cmd.
error(
"Not enough memory!");
51 for (
unsigned i = 0; i <
count; i++) {
57 csfPC.push_back(tmpPoint);
61 bool csfPostprocessing =
false;
62 double clothResolution = 2;
63 double classThreshold = 0.5;
65 int maxIteration = 500;
66 bool exportGround =
false;
67 bool exportOffground =
false;
70 const QString& ARGUMENT = cmd.
arguments().front();
75 QString scene = cmd.
arguments().takeFirst();
77 cmd.
print(
"Set scene to steep slope");
80 cmd.
print(
"Set scene to relief");
83 cmd.
print(
"Set scene to flat");
86 cmd.
error(
"Unknown scene parameter. Defaulting to relief");
92 cmd.
print(
"Slope processing turned on");
93 csfPostprocessing =
true;
98 clothResolution = cmd.
arguments().takeFirst().toDouble(&conv);
102 "Invalid parameter: value after \"-%1\"")
105 cmd.
print(QString(
"Custom cloth resulution set: %1")
106 .arg(clothResolution));
111 maxIteration = cmd.
arguments().takeFirst().toInt(&conv);
115 "Invalid parameter: value after \"-%1\"")
118 cmd.
print(QString(
"Custom max iteration set: %")
124 classThreshold = cmd.
arguments().takeFirst().toDouble(&conv);
128 "Invalid parameter: value after \"-%1\"")
131 cmd.
print(QString(
"Custom class threshold set: %1")
132 .arg(classThreshold));
136 cmd.
print(
"Ground will be exported");
141 cmd.
print(
"Off-ground will be exported");
142 exportOffground =
true;
144 cmd.
print(
"Set all parameters");
161 std::vector<int> groundIndexes;
162 std::vector<int> offGroundIndexes;
163 ccMesh* clothMesh =
nullptr;
164 if (!csf.
do_filtering(groundIndexes, offGroundIndexes,
false, clothMesh,
166 return cmd.
error(
"Process failed");
169 cmd.
print(QString(
"[CSF] %1% of points classified as ground points")
170 .arg((groundIndexes.size() * 100.0) /
count, 0,
'f',
177 if (groundpc.
reserve(
static_cast<unsigned>(groundIndexes.size()))) {
178 for (
unsigned j = 0; j < groundIndexes.size(); ++j) {
186 "Failed to extract the ground subset (not enough memory)");
193 static_cast<unsigned>(offGroundIndexes.size()))) {
194 for (
unsigned k = 0; k < offGroundIndexes.size(); ++k) {
200 if (!offgroundpoint) {
202 "Failed to extract the off-ground subset (not enough "
209 QString baseName = cmd.
clouds()[0].basename;
215 baseName + QObject::tr(
"_ground_points"),
217 cmd.
clouds().push_back(groundDesc);
220 groundDesc, QString(),
nullptr,
222 if (!errorStr.isEmpty()) {
228 if (offgroundpoint) {
230 offgroundpoint, baseName + QObject::tr(
"_offground_points"),
232 cmd.
clouds().push_back(offgroundDesc);
233 if (exportOffground) {
235 offgroundDesc, QString(),
nullptr,
237 if (!errorStr.isEmpty()) {
bool do_filtering(std::vector< int > &groundIndexes, std::vector< int > &offGroundIndexes, bool exportClothMesh, ccMesh *&clothMesh, ecvMainAppInterface *app=0, QWidget *parent=0)
virtual QStringList & arguments()=0
Returns the list of arguments.
virtual void print(const QString &message) const =0
virtual bool error(const QString &message) const =0
static bool IsCommand(const QString &token, const char *command)
Test whether a command line token is a valid command keyword or not.
virtual QString exportEntity(CLEntityDesc &entityDesc, const QString &suffix=QString(), QString *outputFilename=nullptr, ccCommandLineInterface::ExportOptions options=ExportOption::NoOptions)=0
Exports a cloud or a mesh.
virtual void removeClouds(bool onlyLast=false)=0
Removes all clouds (or only the last one ;)
virtual QDialog * widgetParent()
Returns a (widget) parent (if any is available)
virtual std::vector< CLCloudDesc > & clouds()
Currently opened point clouds and their filename.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
ccPointCloud * partialClone(const cloudViewer::ReferenceCloud *selection, int *warnings=nullptr, bool withChildEntities=true) const
Creates a new point cloud object from a ReferenceCloud (selection)
unsigned size() const override
const CCVector3 * getPoint(unsigned index) const override
A very simple point cloud (no point duplication)
virtual bool addPointIndex(unsigned globalIndex)
Point global index insertion mechanism.
virtual bool reserve(unsigned n)
Reserves some memory for hosting the point references.
static const char COMMAND_CSF_EXPORT_OFFGROUND[]
static const char COMMAND_CSF_SCENE[]
static const char COMMAND_CSF_MAX_ITERATION[]
static const char COMMAND_CSF[]
static const char COMMAND_CSF_SCENE_SLOPE[]
static const char COMMAND_CSF_CLOTH_RESOLUTION[]
static const char COMMAND_CSF_SCENE_RELIEF[]
static const char COMMAND_CSF_SCENE_FLAT[]
static const char COMMAND_CSF_EXPORT_GROUND[]
static const char COMMAND_CSF_PROC_SLOPE[]
static const char COMMAND_CSF_CLASS_THRESHOLD[]
Loaded cloud description.
virtual bool process(ccCommandLineInterface &cmd) override
Main process.
Generic command interface.
Command(const QString &name, const QString &keyword)
Default constructor.