ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvCommandLineInterface.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "CVPluginAPI.h"
11 
12 // qCC_db
13 #include <ecvPointCloud.h>
14 
15 // qCC_io
16 #include <FileIOFilter.h>
17 
18 // Qt
19 #include <QSharedPointer>
20 #include <QString>
21 #include <QStringList>
22 
23 // System
24 #include <vector>
25 
26 class ccGenericMesh;
27 class ecvProgressDialog;
28 
29 class QDialog;
30 
31 enum class CL_ENTITY_TYPE { GROUP, CLOUD, MESH };
32 
35  QString basename;
36  QString path;
38 
39  CLEntityDesc(const QString& name);
40  CLEntityDesc(const QString& filename, int _indexInFile);
41  CLEntityDesc(const QString& _basename,
42  const QString& _path,
43  int _indexInFile = -1);
44 
45  virtual ~CLEntityDesc() = default;
46 
47  virtual ccHObject* getEntity() = 0;
48  virtual const ccHObject* getEntity() const = 0;
49  virtual CL_ENTITY_TYPE getCLEntityType() const = 0;
50 };
51 
55 
56  CLGroupDesc(ccHObject* group,
57  const QString& basename,
58  const QString& path = QString());
59 
60  ~CLGroupDesc() override = default;
61 
62  ccHObject* getEntity() override;
63  const ccHObject* getEntity() const override;
64  CL_ENTITY_TYPE getCLEntityType() const override;
65 };
66 
70 
71  CLCloudDesc();
72 
74  const QString& filename = QString(),
75  int index = -1);
76 
78  const QString& basename,
79  const QString& path,
80  int index = -1);
81 
82  ~CLCloudDesc() override = default;
83 
84  ccHObject* getEntity() override;
85  const ccHObject* getEntity() const override;
86  CL_ENTITY_TYPE getCLEntityType() const override;
87 };
88 
92 
93  CLMeshDesc();
94 
96  const QString& filename = QString(),
97  int index = -1);
98 
100  const QString& basename,
101  const QString& path,
102  int index = -1);
103 
104  ~CLMeshDesc() override = default;
105 
106  ccHObject* getEntity() override;
107  const ccHObject* getEntity() const override;
108  CL_ENTITY_TYPE getCLEntityType() const override;
109 };
110 
113 public: // constructor
116 
117  virtual ~ccCommandLineInterface() = default;
118 
119  enum class ExportOption {
120  NoOptions = 0x0,
121  ForceCloud = 0x1,
122  ForceMesh = 0x2,
123  ForceHierarchy = 0x4,
124  ForceNoTimestamp = 0x8
125  };
126  Q_DECLARE_FLAGS(ExportOptions, ExportOption)
127 
128 public: // commands
132  using Shared = QSharedPointer<Command>;
133 
135  Command(const QString& name, const QString& keyword);
136 
137  virtual ~Command() = default;
138 
140  virtual bool process(ccCommandLineInterface& cmd) = 0;
141 
143  QString m_name;
145  QString m_keyword;
146  };
147 
149  static bool IsCommand(const QString& token, const char* command);
150 
151 public: // virtual methods
153 
155  virtual bool registerCommand(Command::Shared command) = 0;
156 
158  virtual QString getExportFilename(const CLEntityDesc& entityDesc,
159  QString extension = QString(),
160  QString suffix = QString(),
161  QString* baseOutputFilename = nullptr,
162  bool forceNoTimestamp = false) const = 0;
163 
165 
167  virtual QString exportEntity(CLEntityDesc& entityDesc,
168  const QString& suffix = QString(),
169  QString* outputFilename = nullptr,
170  ccCommandLineInterface::ExportOptions options =
171  ExportOption::NoOptions) = 0;
172 
174 
178  virtual bool saveClouds(QString suffix = QString(),
179  bool allAtOnce = false,
180  const QString* allAtOnceFileName = nullptr) = 0;
181 
183 
187  virtual bool saveMeshes(QString suffix = QString(),
188  bool allAtOnce = false,
189  const QString* allAtOnceFileName = nullptr) = 0;
190 
192  virtual void removeClouds(bool onlyLast = false) = 0;
193 
195  virtual void removeMeshes(bool onlyLast = false) = 0;
196 
198  virtual QStringList& arguments() = 0;
200  virtual const QStringList& arguments() const = 0;
201 
203  virtual ecvProgressDialog* progressDialog();
205  virtual QDialog* widgetParent();
206 
207 public: // file I/O
208  // Extended file loading parameters
212 
215  };
216 
218  virtual CLLoadParameters& fileLoadingParams();
219 
222  enum Mode {
226  CUSTOM_GLOBAL_SHIFT
227  };
228 
229  Mode mode = NO_GLOBAL_SHIFT;
231  };
232 
234 
237  virtual bool importFile(
238  QString filename,
239  const GlobalShiftOptions& globalShiftOptions,
240  FileIOFilter::Shared filter = FileIOFilter::Shared(nullptr)) = 0;
241 
243  virtual QString cloudExportFormat() const = 0;
245  virtual QString cloudExportExt() const = 0;
246 
248  virtual QString meshExportFormat() const = 0;
250  virtual QString meshExportExt() const = 0;
251 
253  virtual QString hierarchyExportFormat() const = 0;
256  virtual QString hierarchyExportExt() const = 0;
257 
259  virtual void setCloudExportFormat(QString format, QString ext) = 0;
261  virtual void setMeshExportFormat(QString format, QString ext) = 0;
263  virtual void setHierarchyExportFormat(QString format, QString ext) = 0;
264 
265 public: // logging
266  // logging
267  virtual void print(const QString& message) const = 0;
268  virtual void warning(const QString& message) const = 0;
269  virtual bool error(
270  const QString& message) const = 0; // must always return false!
271 
272 public: // access to data
274  virtual std::vector<CLCloudDesc>& clouds();
276  virtual const std::vector<CLCloudDesc>& clouds() const;
277 
279  virtual std::vector<CLMeshDesc>& meshes();
281  virtual const std::vector<CLMeshDesc>& meshes() const;
282 
284 
285  void toggleSilentMode(bool state);
287  bool silentMode() const;
288 
291  void toggleAutoSaveMode(bool state);
294  bool autoSaveMode() const;
295 
298  void toggleAddTimestamp(bool state);
301  bool addTimestamp() const;
302 
304  void setNumericalPrecision(int p);
306  int numericalPrecision() const;
307 
308 public: // Global shift management
310  bool nextCommandIsGlobalShift() const;
311 
315 
318  bool processGlobalShiftCommand(GlobalShiftOptions& options);
319 
320 protected: // members
322  std::vector<CLCloudDesc> m_clouds;
323 
325  std::vector<CLMeshDesc> m_meshes;
326 
329 
332 
335 
338 
341 };
ccCommandLineInterface::GlobalShiftOptions::FIRST_GLOBAL_SHIFT
@ FIRST_GLOBAL_SHIFT
Definition: ecvCommandLineInterface.h:225
filename
std::string filename
Definition: PointCloudIO.cpp:47
CVPluginAPI.h
ccCommandLineInterface::GlobalShiftOptions::customGlobalShift
CCVector3d customGlobalShift
Definition: ecvCommandLineInterface.h:230
CVPLUGIN_LIB_API
#define CVPLUGIN_LIB_API
Definition: CVPluginAPI.h:15
format
filament::Texture::InternalFormat format
Definition: FilamentResourceManager.cpp:181
ccCommandLineInterface::m_loadingParameters
CLLoadParameters m_loadingParameters
File loading parameters.
Definition: ecvCommandLineInterface.h:340
ccCommandLineInterface::ExportOption
ExportOption
Definition: ecvCommandLineInterface.h:119
CL_ENTITY_TYPE
CL_ENTITY_TYPE
Definition: ecvCommandLineInterface.h:31
CLCloudDesc::pc
ccPointCloud * pc
Definition: ecvCommandLineInterface.h:69
CL_ENTITY_TYPE::GROUP
@ GROUP
CLEntityDesc::basename
QString basename
Definition: ecvCommandLineInterface.h:35
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
FileIOFilter::LoadParameters
Generic loading parameters.
Definition: FileIOFilter.h:51
ccCommandLineInterface::GlobalShiftOptions
Global Shift options.
Definition: ecvCommandLineInterface.h:221
ccCommandLineInterface::Command::m_keyword
QString m_keyword
Command keyword.
Definition: ecvCommandLineInterface.h:145
Vector3Tpl< double >
cloudViewer::t::geometry::path
static const std::string path
Definition: PointCloud.cpp:59
ccCommandLineInterface::Command::Shared
QSharedPointer< Command > Shared
Shared type.
Definition: ecvCommandLineInterface.h:132
CLEntityDesc::path
QString path
Definition: ecvCommandLineInterface.h:36
ccCommandLineInterface::Command::m_name
QString m_name
Command name.
Definition: ecvCommandLineInterface.h:143
ccCommandLineInterface::CLLoadParameters::m_coordinatesShiftEnabled
bool m_coordinatesShiftEnabled
Definition: ecvCommandLineInterface.h:213
ccCommandLineInterface::m_autoSaveMode
bool m_autoSaveMode
Whether files should be automatically saved (after each process) or not.
Definition: ecvCommandLineInterface.h:331
ecvProgressDialog
Graphical progress indicator (thread-safe)
Definition: ecvProgressDialog.h:27
CLEntityDesc
Loaded entity description.
Definition: ecvCommandLineInterface.h:34
CL_ENTITY_TYPE::CLOUD
@ CLOUD
FileIOFilter.h
ccCommandLineInterface::m_addTimestamp
bool m_addTimestamp
Whether a timestamp should be automatically added to output files or not.
Definition: ecvCommandLineInterface.h:334
ccGenericMesh
Generic mesh interface.
Definition: ecvGenericMesh.h:28
CLEntityDesc::indexInFile
int indexInFile
Definition: ecvCommandLineInterface.h:37
ccCommandLineInterface::Command
Generic command interface.
Definition: ecvCommandLineInterface.h:130
ccCommandLineInterface::GlobalShiftOptions::AUTO_GLOBAL_SHIFT
@ AUTO_GLOBAL_SHIFT
Definition: ecvCommandLineInterface.h:224
ccCommandLineInterface::GlobalShiftOptions::NO_GLOBAL_SHIFT
@ NO_GLOBAL_SHIFT
Definition: ecvCommandLineInterface.h:223
CLEntityDesc::getCLEntityType
virtual CL_ENTITY_TYPE getCLEntityType() const =0
ccCommandLineInterface::CLLoadParameters::m_coordinatesShift
CCVector3d m_coordinatesShift
Definition: ecvCommandLineInterface.h:214
CL_ENTITY_TYPE::MESH
@ MESH
ccCommandLineInterface
Command line interface.
Definition: ecvCommandLineInterface.h:112
ccCommandLineInterface::m_precision
int m_precision
Default numerical precision for ASCII output.
Definition: ecvCommandLineInterface.h:337
CLCloudDesc
Loaded cloud description.
Definition: ecvCommandLineInterface.h:68
ccCommandLineInterface::CLLoadParameters
Definition: ecvCommandLineInterface.h:209
FileIOFilter::Shared
QSharedPointer< FileIOFilter > Shared
Shared type.
Definition: FileIOFilter.h:97
ccCommandLineInterface::GlobalShiftOptions::Mode
Mode
Definition: ecvCommandLineInterface.h:222
CLMeshDesc::mesh
ccGenericMesh * mesh
Definition: ecvCommandLineInterface.h:91
CLGroupDesc
Loaded group description.
Definition: ecvCommandLineInterface.h:53
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
CLMeshDesc
Loaded mesh description.
Definition: ecvCommandLineInterface.h:90
ccCommandLineInterface::m_clouds
std::vector< CLCloudDesc > m_clouds
Currently opened point clouds and their filename.
Definition: ecvCommandLineInterface.h:322
CLEntityDesc::getEntity
virtual ccHObject * getEntity()=0
ccCommandLineInterface::m_meshes
std::vector< CLMeshDesc > m_meshes
Currently opened meshes and their filename.
Definition: ecvCommandLineInterface.h:325
ecvPointCloud.h
CLGroupDesc::groupEntity
ccHObject * groupEntity
Definition: ecvCommandLineInterface.h:54
name
std::string name
Definition: FileIOFactory.cpp:129
ccCommandLineInterface::m_silentMode
bool m_silentMode
Silent mode.
Definition: ecvCommandLineInterface.h:328