48 QStringList{
"pov"},
"pov",
49 QStringList{
"Clouds + sensor info. [meta][ascii] (*.pov)"},
50 QStringList{
"Clouds + sensor info. [meta][ascii] (*.pov)"},
55 bool& exclusive)
const {
76 std::vector<ccGBLSensor*> sensors;
77 std::vector<ccGenericPointCloud*> clouds;
79 for (
unsigned i = 0; i < hClouds.size(); ++i) {
81 hClouds[i]->filterChildren(cloudSensors,
false,
83 if (!cloudSensors.empty()) {
86 if (cloudSensors.size() > 1)
88 "associated to entity '%1'. Only "
89 "the first will be saved!")
90 .arg(hClouds[i]->getName()));
92 sensors.push_back(
static_cast<ccGBLSensor*
>(cloudSensors[0]));
96 assert(sensors.size() == clouds.size());
103 if (sensors.size() > 1)
107 QString fullBaseName = QFileInfo(
filename).completeBaseName();
110 FILE* mainFile = fopen(qPrintable(
filename),
"wt");
113 if (fprintf(mainFile,
"#CC_POVS_FILE\n") < 0 ||
114 fprintf(mainFile,
"SENSOR_TYPE = %s\n",
117 fprintf(mainFile,
"SENSOR_BASE = 0\n") <
119 || fprintf(mainFile,
"UNITS = IGNORED\n") < 0 ||
120 fprintf(mainFile,
"#END_HEADER\n") < 0) {
127 for (
unsigned i = 0; i < clouds.size(); ++i) {
128 QString thisFilename = fullBaseName + QString(
"_%1.bin").arg(i);
133 clouds[i], thisFilename, parameters,
142 fprintf(mainFile,
"\n#POV %u\nF %s\nT ASC\n", i,
143 qPrintable(QFileInfo(thisFilename).fileName()));
148 result = fprintf(mainFile,
"C %f %f %f\n", C[0], C[1], C[2]);
152 result = fprintf(mainFile,
"X %f %f %f\n", mat[0], mat[1],
154 result = fprintf(mainFile,
"Y %f %f %f\n", mat[4], mat[5],
156 result = fprintf(mainFile,
"Z %f %f %f\n", mat[8], mat[9],
164 if (
result > 0)
result = fprintf(mainFile,
"#END_POV\n");
193 FILE* fp = fopen(qPrintable(
filename),
"rt");
205 if (strcmp(line,
"#CC_POVS_FILE\n") != 0) {
210 char sensorType[256];
211 if (fscanf(fp,
"SENSOR_TYPE = %s\n", sensorType) < 0) {
217 if (strcmp(sensorType,
230 "[PovFilter::loadFile] Unhandled rotation order description! "
239 if (fscanf(fp,
"SENSOR_BASE = %f\n", &base) < 0 ||
240 fscanf(fp,
"UNITS = %s\n", unitsType) < 0 ||
242 strcmp(line,
"#END_HEADER\n") != 0) {
248 "[PovFilter::loadFile] POV FILE [Type %s - base=%f - unit: %s]",
249 sensorType, base, unitsType);
254 char subFileName[256];
255 char subFileType[12];
258 if ((line[0] ==
'#') && (line[1] ==
'P')) {
260 if (fscanf(fp,
"F %s\n", subFileName) < 0) {
265 if (fscanf(fp,
"T %s\n", subFileType) < 0) {
277 "file '%1' (type = '%2')")
278 .arg(subFileName, subFileType));
285 QString(
"%1/%2").arg(
path, subFileName), parameters, filter,
297 else if (line[0] ==
'C') {
299 sscanf(line,
"C %f %f %f\n", C, C + 1, C + 2);
301 }
else if (line[0] ==
'X' || line[0] ==
'Y' ||
304 sscanf(line + 2,
"%f %f %f\n", V, V + 1, V + 2);
307 static_cast<unsigned char>(line[0]) - 88;
308 float* mat = rot.
data();
312 }
else if (line[0] ==
'A') {
313 sscanf(line,
"A %f %f\n", &dTheta, &dPhi);
319 clouds.push_back(entities);
328 for (
size_t i = 0; i < clouds.size(); ++i) {
335 sensorCenter.
x -= base;
351 QString(
"[PovFilter::loadFile] failed to "
352 "create sensor on cloud #%1 (%2)")
367 "[PovFilter::loadFile] File (%s) not found or "
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
const int MAX_ASCII_FILE_LINE_LENGTH
const char CC_SENSOR_ROTATION_ORDER_NAMES[][15]
const char CC_SENSOR_ROTATION_ORDER_OLD_NAMES[][10]
static QString GetFileFilter()
static bool PrintDebug(const char *format,...)
Same as Print, but works only in Debug mode.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static constexpr float DEFAULT_PRIORITY
static CC_FILE_ERROR SaveToFile(ccHObject *entities, const QString &filename, const SaveParameters ¶meters, Shared filter)
static Shared FindBestFilterForExtension(const QString &ext)
Returns the best filter (presumably) to open a given file extension.
QSharedPointer< FileIOFilter > Shared
Shared type.
static ccHObject * LoadFromFile(const QString &filename, LoadParameters ¶meters, Shared filter, CC_FILE_ERROR &result)
Loads one or more entities from a file with a known filter.
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 void setVisible(bool state)
Sets entity visibility.
Ground-based Laser sensor.
ROTATION_ORDER
The order of inner-rotations of the sensor (body/mirrors)
bool computeAutoParameters(cloudViewer::GenericCloud *theCloud)
Computes angular parameters automatically (all but the angular steps!)
PointCoordinateType getPitchStep() const
Returns the lateral pitch step (in radians)
void setYawStep(PointCoordinateType dTheta)
Sets the yaw step.
ROTATION_ORDER getRotationOrder() const
Returns the sensor internal rotations order.
PointCoordinateType getYawStep() const
Returns the yaw step (in radians)
void setPitchStep(PointCoordinateType dPhi)
Sets the pitch step.
T * getTranslation()
Retruns a pointer to internal translation.
T * data()
Returns a pointer to internal data.
ccGLMatrixTpl< T > inverse() const
Returns inverse transformation.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
virtual void toIdentity()
Sets matrix to identity.
Float version of ccGLMatrixTpl.
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.
void detachAllChildren()
Removes a specific child.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
virtual QString getName() const
Returns object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
bool isKindOf(CV_CLASS_ENUM type) const
virtual ccGLMatrix & getRigidTransformation()
virtual void setRigidTransformation(const ccGLMatrix &mat)
static void error(char *msg)
static const std::string path
Generic loading parameters.
Generic saving parameters.
bool alwaysDisplaySaveDialog