From 42585a8984517b8f2b910df19e296d63ab34e1fb Mon Sep 17 00:00:00 2001 From: gabryon99 Date: Mon, 5 Apr 2021 12:44:54 +0200 Subject: [PATCH] read verticies inside mesh --- src/meshlabplugins/io_e57/io_e57.cpp | 28 ++++++++++++++++++++++------ src/meshlabplugins/io_e57/io_e57.h | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/meshlabplugins/io_e57/io_e57.cpp b/src/meshlabplugins/io_e57/io_e57.cpp index 05e9f5205..6feab0a81 100755 --- a/src/meshlabplugins/io_e57/io_e57.cpp +++ b/src/meshlabplugins/io_e57/io_e57.cpp @@ -26,8 +26,9 @@ #include #define START_LOADING "Loading E57 File..." -#define DONE_LOADING "Done!" +#define DONE_LOADING "Done!" +#define E57_DEBUG 1 #define E57_WRAPPER(e57f, exceptionMessage) if (!e57f) throw MLException(QString{exceptionMessage}) void debug(const char* message) noexcept; @@ -43,6 +44,8 @@ void E57IOPlugin::initPreOpenParameter(const QString &format, RichParameterList void E57IOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterList &parlst, vcg::CallBackPos* cb) { + // TODO: format exception messages + mask = 0; if (formatName.toUpper() != tr("E57")) { @@ -93,32 +96,45 @@ void E57IOPlugin::open(const QString &formatName, const QString &fileName, MeshM try { unsigned long size; + auto vertexIterator = vcg::tri::Allocator::AddVertices(m.cm, static_cast(numberPointSize)); e57::CompressedVectorReader dataReader = fileReader.SetUpData3DPointsData(scanIndex, buffSize, data3DPointsData); + m.Enable(mask); + while ((size = dataReader.read()) > 0) { - for (unsigned long i = 0; i < size; i++) { + for (unsigned long i = 0; i < size; i++, vertexIterator++) { + + auto vertex = (*vertexIterator).P(); auto x = data3DPointsData.cartesianX[i]; auto y = data3DPointsData.cartesianY[i]; auto z = data3DPointsData.cartesianZ[i]; - std::fprintf(stderr, "Debug::E57(%s) :: {x=%f,y=%f,z=%f}\n", stdFilename.c_str(), x, y, z); + + vertex[0] = x; vertex[1] = y; vertex[2] = z; + + std::fprintf(stderr, "Debug::E57(%s) :: {x=%.3ff,y=%.3ff,z=%.3f}\n", stdFilename.c_str(), x, y, z); } } } catch (const e57::E57Exception& exception) { - std::fprintf(stderr, "Debug::E57(%s) Exception(%s::%s)\n", stdFilename.c_str(), exception.what(), exception.context().c_str()); + if (E57_DEBUG) + std::fprintf(stderr, "Debug::E57(%s) Exception(%s::%s)\n", stdFilename.c_str(), exception.what(), exception.context().c_str()); delete[] data3DPointsData.cartesianX; delete[] data3DPointsData.cartesianY; delete[] data3DPointsData.cartesianZ; + fileReader.Close(); + throw MLException(QString{exception.what()}); } - std::fprintf(stderr, "Debug::E57(%s) :: E57 Root(guid): %s\n", stdFilename.c_str(), e57FileInfo.guid.c_str()); - std::fprintf(stderr, "Debug::E57(%s) :: E57 Root(2D Count): %lld\n", stdFilename.c_str(), fileReader.GetImage2DCount()); + if (E57_DEBUG) { + std::fprintf(stderr, "Debug::E57(%s) :: E57 Root(guid): %s\n", stdFilename.c_str(), e57FileInfo.guid.c_str()); + std::fprintf(stderr, "Debug::E57(%s) :: E57 Root(2D Count): %lld\n", stdFilename.c_str(), fileReader.GetImage2DCount()); + } updateProgress(*cb, 99, DONE_LOADING); diff --git a/src/meshlabplugins/io_e57/io_e57.h b/src/meshlabplugins/io_e57/io_e57.h index 7036253c4..d301eaf3f 100755 --- a/src/meshlabplugins/io_e57/io_e57.h +++ b/src/meshlabplugins/io_e57/io_e57.h @@ -29,6 +29,8 @@ #include #include +typedef typename CMeshO::VertexIterator VertexIterator; + class E57IOPlugin : public QObject, public IOMeshPlugin { Q_OBJECT