41 QStringList{
"csv"},
"csv",
42 QStringList{
"CSV matrix cloud (*.csv)"}, QStringList(),
56 if (!openDlg.exec()) {
60 if (openDlg.lineEditSeparator->text().isEmpty()) {
65 s_separator = openDlg.lineEditSeparator->text().at(0);
75 QTextStream stream(&file);
77 unsigned lineIndex = 0;
82 while (file.error() == QFile::NoError && !file.atEnd()) {
83 QString line = stream.readLine();
87 if (line.startsWith(
"//"))
continue;
89 if (line.size() == 0) {
91 QString(
"[CSVMatrixFilter] Line %1 is empty (ignored)")
101 width = parts.size();
103 QString(
"[CSVMatrixFilter] Detected width: %1").arg(
width));
104 }
else if (
width != parts.size()) {
105 CVLog::Warning(QString(
"[CSVMatrixFilter] Line %1 has not the same "
106 "width as the previous ones!")
123 for (
int i = 0; i <
width; ++i) {
124 P.
z = parts[i].toDouble(&ok);
132 unsigned rowCount =
static_cast<unsigned>(row);
133 unsigned colCount =
static_cast<unsigned>(
width);
144 unsigned triCount = (colCount - 1) * (rowCount - 1) * 2;
145 if (!mesh->
reserve(triCount)) {
152 for (
unsigned j = 0; j < rowCount - 1; ++j) {
153 unsigned index = j * colCount;
154 for (
unsigned i = 0; i < colCount - 1; ++i) {
157 mesh->
addTriangle(index + i + 1, index + colCount + i,
158 index + colCount + i + 1);
166 QString(
"[CSVMatrixFilter] Failed to compute "
167 "normals on mesh (not enough memory?)"));
174 QString
filename = openDlg.textureFilenameLineEdit->text();
178 "texture from file '%1'")
189 for (
unsigned j = 0; j < rowCount; ++j) {
192 for (
unsigned i = 0; i < colCount; ++i) {
193 coord.
tx =
static_cast<float>(i) /
210 for (
unsigned i = 0; i < mesh->
size(); ++i) {
221 "[CSVMatrixFilter] Not enough memory to map "
222 "the texture on the mesh!");
227 if (texture.width() <
static_cast<int>(colCount) ||
228 texture.height() <
static_cast<int>(rowCount)) {
230 QString(
"[CSVMatrixFilter] To map a texture on "
231 "the cloud, the image size should "
232 "equal or greater than the grid size "
237 for (
unsigned j = 0; j < rowCount; ++j) {
238 for (
unsigned i = 0; i < colCount; ++i) {
239 QRgb col = texture.pixel(
static_cast<int>(i),
240 static_cast<int>(j));
247 "[CSVMatrixFilter] Not enough memory to map "
248 "the texture on the cloud!");
266 QString(
"[CSVMatrixFilter] Number of rows: %1").arg(rowCount));
static bool s_inverseRows
static QChar s_separator(',')
float PointCoordinateType
Type of the coordinates of a (N-D) point.
CC_FILE_ERROR
Typical I/O filter errors.
@ CC_FERR_CANCELED_BY_USER
@ CC_FERR_NOT_ENOUGH_MEMORY
virtual void release()
Decrease counter and deletes object when 0.
virtual CC_FILE_ERROR loadFile(const QString &filename, ccHObject &container, LoadParameters ¶meters)
Loads one or more entities from a file.
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
Array of 2D texture coordinates.
bool reserveSafe(size_t count)
Reserves memory (no exception thrown)
void addElement(const Type &value)
virtual void setVisible(bool state)
Sets entity visibility.
virtual void showColors(bool state)
Sets colors visibility.
void setTranslation(const Vector3Tpl< float > &Tr)
Sets translation (float version)
Float version of ccGLMatrixTpl.
void showNormals(bool state) override
Sets normals visibility.
virtual void showMaterials(bool state)
Sets whether textures should be displayed or not.
Hierarchical CLOUDVIEWER Object.
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
cloudViewer::VerticesIndexes * getTriangleVertIndexes(unsigned triangleIndex) override
Returns the indexes of the vertices of a given triangle.
bool reservePerTriangleMtlIndexes()
Reserves memory to store per-triangle material index.
void addTriangleMtlIndex(int mtlIndex)
Adds triangle material index for next triangle.
bool reserve(std::size_t n)
Reserves the memory to store the vertex indexes (3 per triangle)
void addTriangleTexCoordIndexes(int i1, int i2, int i3)
Adds a triplet of tex coords indexes for next triangle.
void addTriangle(unsigned i1, unsigned i2, unsigned i3)
Adds a triangle to the mesh.
void setTexCoordinatesTable(TextureCoordsContainer *texCoordsTable, bool autoReleaseOldTable=true)
Sets per-triangle texture coordinates array (may be shared)
bool reservePerTriangleTexCoordIndexes()
Reserves memory to store per-triangle triplets of tex coords indexes.
bool computePerVertexNormals()
Computes per-vertex normals.
virtual unsigned size() const override
Returns the number of triangles.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool reserve(unsigned numberOfPoints) override
Reserves memory for all the active features.
bool reserveTheRGBTable()
Reserves memory to store the RGB colors.
void addRGBColor(const ecvColor::Rgb &C)
Pushes an RGB color on stack.
void addPoint(const CCVector3 &P)
Adds a 3D point to the database.
unsigned size() const override
constexpr Qt::SplitBehavior SkipEmptyParts
Rgb FromQRgb(QRgb qColor)
Conversion from QRgb.
Generic loading parameters.
Triangle described by the indexes of its 3 vertices.