ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
AsciiFilter.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 "FileIOFilter.h"
11 
12 // dialogs
13 #include "AsciiOpenDlg.h"
14 #include "AsciiSaveDlg.h"
15 
16 // Qt
17 #include <QByteArray>
18 #include <QTextStream>
19 
22 public:
24 
25  // static accessors
26  static inline QString GetFileFilter() {
27  return "ASCII cloud (*.txt *.asc *.neu *.xyz *.xyzrgb *.xyzn *.pts "
28  "*.csv)";
29  }
30 
31  // inherited from FileIOFilter
33  ccHObject& container,
34  LoadParameters& parameters) override;
36  bool& multiple,
37  bool& exclusive) const override;
39  const QString& filename,
40  const SaveParameters& parameters) override;
41 
43  CC_FILE_ERROR loadAsciiData(const QByteArray& data,
44  QString sourceName,
45  ccHObject& container,
46  LoadParameters& parameters);
47 
48 public: // Default / persistent settings
51 
53  static void SetOutputCoordsPrecision(int prec);
55  static void SetOutputSFPrecision(int prec);
57 
63  static void SetOutputSeparatorIndex(int separatorIndex);
65  static void SaveSFBeforeColor(bool state);
68  static void SaveColumnsNamesHeader(bool state);
71  static void SavePointCountHeader(bool state);
72 
73 protected:
75  CC_FILE_ERROR loadStream(QTextStream& stream,
76  QString filenameOrTitle,
77  qint64 dataSize,
78  ccHObject& container,
79  LoadParameters& parameters);
80 
83  QTextStream& stream,
84  QString filenameOrTitle,
85  ccHObject& container,
86  const AsciiOpenDlg::Sequence& openSequence,
87  char separator,
88  bool commaAsDecimal,
89  unsigned approximateNumberOfLines,
90  qint64 fileSize,
91  unsigned maxCloudSize,
92  unsigned skipLines,
93  LoadParameters& parameters,
94  bool showLabelsIn2D = false);
95 };
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
std::string filename
#define CV_IO_LIB_API
Definition: CV_io.h:15
int count
char type
CC_FILE_ERROR
Typical I/O filter errors.
Definition: FileIOFilter.h:20
ASCII point cloud I/O filter.
Definition: AsciiFilter.h:21
CC_FILE_ERROR loadAsciiData(const QByteArray &data, QString sourceName, ccHObject &container, LoadParameters &parameters)
Loads a cloud from a QByteArray.
CC_FILE_ERROR loadFile(const QString &filename, ccHObject &container, LoadParameters &parameters) override
Loads one or more entities from a file.
CC_FILE_ERROR saveToFile(ccHObject *entity, const QString &filename, const SaveParameters &parameters) override
Saves an entity (or a group of) to a file.
static void SaveColumnsNamesHeader(bool state)
CC_FILE_ERROR loadStream(QTextStream &stream, QString filenameOrTitle, qint64 dataSize, ccHObject &container, LoadParameters &parameters)
Loads an ASCII stream.
CC_FILE_ERROR loadCloudFromFormatedAsciiStream(QTextStream &stream, QString filenameOrTitle, ccHObject &container, const AsciiOpenDlg::Sequence &openSequence, char separator, bool commaAsDecimal, unsigned approximateNumberOfLines, qint64 fileSize, unsigned maxCloudSize, unsigned skipLines, LoadParameters &parameters, bool showLabelsIn2D=false)
Loads an ASCII stream with a predefined format.
static void SavePointCountHeader(bool state)
static void SaveSFBeforeColor(bool state)
Sets whether color and SF should be swapped (default is color then SF)
bool canSave(CV_CLASS_ENUM type, bool &multiple, bool &exclusive) const override
Returns whether this I/O filter can save the specified type of entity.
static void SetOutputSFPrecision(int prec)
Sets the default output scalar values precision (as saving time)
static QString GetFileFilter()
Definition: AsciiFilter.h:26
static void SetOutputSeparatorIndex(int separatorIndex)
Sets the default output separator (as saving time)
static void SetOutputCoordsPrecision(int prec)
Sets the default output coords precision (as saving time)
static void SetDefaultSkippedLineCount(int count)
Sets the default number of skipped lines (at loading time)
std::vector< SequenceItem > Sequence
ASCII open sequence.
Definition: AsciiOpenDlg.h:137
Generic file I/O filter.
Definition: FileIOFilter.h:46
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Generic loading parameters.
Definition: FileIOFilter.h:51
Generic saving parameters.
Definition: FileIOFilter.h:84