25 QStringList{
"pn"},
"pn",
26 QStringList{
"Point+Normal cloud (*.pn)"},
27 QStringList{
"Point+Normal cloud (*.pn)"},
32 bool& exclusive)
const {
50 CVLog::Warning(
"[PN] This filter can only save one cloud at a time!");
53 unsigned numberOfPoints = theCloud->
size();
55 if (numberOfPoints == 0) {
66 CVLog::Warning(QString(
"[PNFilter::save] Can't recenter or rescale "
67 "cloud '%1' when saving it in a PN file!")
72 CVLog::Warning(QString(
"[PNFilter::save] Cloud '%1' has no normal (we "
73 "will save points with a default normal)!")
80 QScopedPointer<ecvProgressDialog> pDlg(0);
84 pDlg->setMethodTitle(QObject::tr(
"Save PN file"));
85 pDlg->setInfo(QObject::tr(
"Points: %L1").arg(numberOfPoints));
92 for (
unsigned i = 0; i < numberOfPoints; i++) {
99 if (out.write(
reinterpret_cast<const char*
>(Pfloat.
u),
100 3 *
sizeof(
float)) < 0) {
110 norm[0] =
static_cast<float>(N.
x);
111 norm[1] =
static_cast<float>(N.
y);
112 norm[2] =
static_cast<float>(N.
z);
114 if (out.write(
reinterpret_cast<const char*
>(norm), 3 *
sizeof(float)) <
120 if (pDlg && !nprogress.
oneStep()) {
139 qint64 fileSize = in.size();
140 qint64 singlePointSize = 6 *
sizeof(float);
144 unsigned numberOfPoints =
static_cast<unsigned>(fileSize / singlePointSize);
147 QScopedPointer<ecvProgressDialog> pDlg(0);
151 pDlg->setMethodTitle(QObject::tr(
"Open PN file"));
152 pDlg->setInfo(QObject::tr(
"Points: %L1").arg(numberOfPoints));
159 unsigned chunkIndex = 0;
160 unsigned fileChunkPos = 0;
163 unsigned pointsRead = 0;
166 for (
unsigned i = 0; i < numberOfPoints; i++) {
169 if (loadedCloud) container.
addChild(loadedCloud);
170 fileChunkPos = pointsRead;
172 std::min<unsigned>(numberOfPoints - pointsRead,
175 QString(
"unnamed - Cloud #%1").arg(++chunkIndex));
180 if (loadedCloud)
delete loadedCloud;
189 if (in.read((
char*)rBuff, 3 *
sizeof(
float)) >= 0) {
199 if (in.read((
char*)rBuff, 3 *
sizeof(
float)) >= 0) {
210 if (pDlg && !nprogress.
oneStep()) {
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
CC_FILE_ERROR
Typical I/O filter errors.
@ CC_FERR_CANCELED_BY_USER
@ CC_FERR_BAD_ENTITY_TYPE
@ CC_FERR_NOT_ENOUGH_MEMORY
static const CCVector3 s_defaultNorm(0, 0, 1)
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static constexpr float DEFAULT_PRIORITY
virtual CC_FILE_ERROR loadFile(const QString &filename, ccHObject &container, LoadParameters ¶meters) override
Loads one or more entities from a file.
virtual CC_FILE_ERROR saveToFile(ccHObject *entity, const QString &filename, const SaveParameters ¶meters) override
Saves an entity (or a group of) to a file.
virtual 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 Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
virtual bool hasNormals() const
Returns whether normals are enabled or not.
virtual void showNormals(bool state)
Sets normals visibility.
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual const CCVector3 & getPointNormal(unsigned pointIndex) const =0
Returns normal corresponding to a given point.
static ccGenericPointCloud * ToGenericPointCloud(ccHObject *obj, bool *isLockedVertices=nullptr)
Converts current object to 'equivalent' ccGenericPointCloud.
Hierarchical CLOUDVIEWER 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.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
void addNorm(const CCVector3 &N)
Pushes a normal vector on stack (shortcut)
bool reserveTheNormsTable()
Reserves memory to store the compressed normals.
void shrinkToFit()
Removes unused capacity.
bool reserveThePointsTable(unsigned _numberOfPoints)
Reserves memory to store the points coordinates.
bool isShifted() const
Returns whether the cloud is shifted or not.
virtual unsigned size() const =0
Returns the number of points.
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
bool oneStep()
Increments total progress value of a single unit.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
Graphical progress indicator (thread-safe)
const unsigned CC_MAX_NUMBER_OF_POINTS_PER_CLOUD
#define fileChunkSize(nChunkSize)
Generic loading parameters.
QWidget * parentWidget
Parent widget (if any)
Generic saving parameters.
QWidget * parentWidget
Parent widget (if any)