24 {
"_Point+Value Filter",
26 QStringList{
"pv"},
"pv", QStringList{
"Point+Value cloud (*.pv)"},
27 QStringList{
"Point+Value cloud (*.pv)"},
Import |
Export}) {}
31 bool& exclusive)
const {
49 CVLog::Warning(
"[PV] This filter can only save one cloud at a time!");
52 unsigned numberOfPoints = theCloud->
size();
54 if (numberOfPoints == 0) {
65 CVLog::Warning(QString(
"[PVFilter::save] Can't recenter or rescale "
66 "cloud '%1' when saving it in a PN file!")
77 CVLog::Warning(QString(
"[PVFilter::save] Cloud '%1' has no displayed "
78 "scalar field (we will save points with a "
79 "default scalar value)!")
82 float val = std::numeric_limits<float>::quiet_NaN();
85 QScopedPointer<ecvProgressDialog> pDlg(0);
89 pDlg->setMethodTitle(QObject::tr(
"Save PV file"));
90 pDlg->setInfo(QObject::tr(
"Points: %L1").arg(numberOfPoints));
97 for (
unsigned i = 0; i < numberOfPoints; i++) {
103 float wBuff[3] = {(float)P->
x, (
float)P->
y, (float)P->
z};
104 if (out.write((
const char*)wBuff, 3 *
sizeof(float)) < 0) {
112 if (out.write((
const char*)&val,
sizeof(float)) < 0) {
117 if (pDlg && !nprogress.
oneStep()) {
136 qint64 fileSize = in.size();
137 qint64 singlePointSize = 4 *
sizeof(float);
141 unsigned numberOfPoints =
static_cast<unsigned>(fileSize / singlePointSize);
144 QScopedPointer<ecvProgressDialog> pDlg(0);
148 pDlg->setMethodTitle(QObject::tr(
"Open PV file"));
149 pDlg->setInfo(QObject::tr(
"Points: %L1").arg(numberOfPoints));
156 unsigned chunkIndex = 0;
157 unsigned fileChunkPos = 0;
160 unsigned pointsRead = 0;
163 for (
unsigned i = 0; i < numberOfPoints; i++) {
173 loadedCloud->
showSF(
true);
177 fileChunkPos = pointsRead;
179 std::min<unsigned>(numberOfPoints - pointsRead,
182 QString(
"unnamed - Cloud #%1").arg(++chunkIndex));
187 if (loadedCloud)
delete loadedCloud;
195 if (in.read((
char*)rBuff, 3 *
sizeof(
float)) >= 0) {
207 if (in.read((
char*)rBuff,
sizeof(
float)) >= 0) {
218 if (pDlg && !nprogress.
oneStep()) {
233 loadedCloud->
showSF(
true);
float PointCoordinateType
Type of the coordinates of a (N-D) point.
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 bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static constexpr float DEFAULT_PRIORITY
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.
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 CC_FILE_ERROR loadFile(const QString &filename, ccHObject &container, LoadParameters ¶meters) override
Loads one or more entities from a file.
virtual bool hasDisplayedScalarField() const
Returns whether an active scalar field is available or not.
virtual void showSF(bool state)
Sets active scalarfield visibility.
A 3D cloud interface with associated features (color, normals, octree, etc.)
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 setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
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 ScalarType getPointScalarValue(unsigned pointIndex) const =0
Returns the ith point associated scalar value.
virtual const CCVector3 * getPoint(unsigned index) const =0
Returns the ith point.
bool oneStep()
Increments total progress value of a single unit.
int getCurrentInScalarFieldIndex()
Returns current INPUT scalar field index (or -1 if none)
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
void setPointScalarValue(unsigned pointIndex, ScalarType value) override
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
bool enableScalarField() override
A simple scalar field (to be associated to a point cloud)
virtual void computeMinAndMax()
Determines the min and max values.
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)