From 3e1fde4260c0812532b2c9f5c90669cae0483b59 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Tue, 19 Feb 2019 20:51:12 +0930 Subject: [PATCH] Fix build --- .travis.yml | 1 + README.md | 2 +- dust3d.pro | 4 +- src/meshgenerator.cpp | 2 +- thirdparty/nodemesh/nodemesh/box.cpp | 2 +- thirdparty/nodemesh/nodemesh/builder.cpp | 8 ++-- thirdparty/nodemesh/nodemesh/combiner.cpp | 2 +- .../nodemesh/nodemesh/{util.cpp => misc.cpp} | 41 ++++++++++--------- .../nodemesh/nodemesh/{util.h => misc.h} | 4 +- thirdparty/nodemesh/nodemesh/recombiner.cpp | 2 +- thirdparty/nodemesh/nodemesh/stitcher.cpp | 2 +- thirdparty/nodemesh/nodemesh/wrapper.cpp | 34 ++++++++------- 12 files changed, 56 insertions(+), 48 deletions(-) rename thirdparty/nodemesh/nodemesh/{util.cpp => misc.cpp} (91%) rename thirdparty/nodemesh/nodemesh/{util.h => misc.h} (97%) diff --git a/.travis.yml b/.travis.yml index 04dff73b..5d209e08 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,6 +49,7 @@ install: # (Mac) Install Qt5 - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_VERBOSE_USING_DOTS=1 brew reinstall --verbose qt; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/qt/bin:$(brew --prefix)/bin:$PATH"; fi # (Linux) Install Qt5 - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install qt59base qt59tools --force-yes; fi diff --git a/README.md b/README.md index 001fadee..b4cb868e 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ If you have done programming code changes, including the example code listed in License ----------- -Dust3D software binaries and source code use MIT License, which means you can use it freely no matter for personal or for commercial purpose. However, Dust3D's UI built on Qt5, the Mesh Union Algorithm based on CGAL library, and there are other algorithms such as Gift Wrapping, Bmesh, and so on which implemented in the meshlite repository, all these, may have other license restrictions. +Dust3D software binaries and source code use MIT License, which means you can use it freely no matter for personal or for commercial purpose. Acknowledgements ------------------- diff --git a/dust3d.pro b/dust3d.pro index 061dc948..00dc941c 100644 --- a/dust3d.pro +++ b/dust3d.pro @@ -305,8 +305,8 @@ HEADERS += thirdparty/nodemesh/nodemesh/builder.h SOURCES += thirdparty/nodemesh/nodemesh/combiner.cpp HEADERS += thirdparty/nodemesh/nodemesh/combiner.h -SOURCES += thirdparty/nodemesh/nodemesh/util.cpp -HEADERS += thirdparty/nodemesh/nodemesh/util.h +SOURCES += thirdparty/nodemesh/nodemesh/misc.cpp +HEADERS += thirdparty/nodemesh/nodemesh/misc.h SOURCES += thirdparty/nodemesh/nodemesh/positionkey.cpp HEADERS += thirdparty/nodemesh/nodemesh/positionkey.h diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 06b26348..8e36273e 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include "meshgenerator.h" #include "util.h" diff --git a/thirdparty/nodemesh/nodemesh/box.cpp b/thirdparty/nodemesh/nodemesh/box.cpp index 6ed4585c..2b9a5265 100644 --- a/thirdparty/nodemesh/nodemesh/box.cpp +++ b/thirdparty/nodemesh/nodemesh/box.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/thirdparty/nodemesh/nodemesh/builder.cpp b/thirdparty/nodemesh/nodemesh/builder.cpp index 4353baaf..3505c4a7 100644 --- a/thirdparty/nodemesh/nodemesh/builder.cpp +++ b/thirdparty/nodemesh/nodemesh/builder.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #define WRAP_STEP_BACK_FACTOR 0.1 // 0.1 ~ 0.9 #define WRAP_WELD_FACTOR 0.01 // Allowed distance: WELD_FACTOR * radius @@ -31,9 +31,9 @@ size_t Builder::addNode(const QVector3D &position, float radius, const std::vect size_t Builder::addEdge(size_t firstNodeIndex, size_t secondNodeIndex) { size_t edgeIndex = m_edges.size(); - m_edges.push_back(Edge { - .nodes = {firstNodeIndex, secondNodeIndex} - }); + Edge edge; + edge.nodes = {firstNodeIndex, secondNodeIndex}; + m_edges.push_back(edge); m_nodes[firstNodeIndex].edges.push_back(edgeIndex); m_nodes[secondNodeIndex].edges.push_back(edgeIndex); //qDebug() << "addEdge" << firstNodeIndex << secondNodeIndex; diff --git a/thirdparty/nodemesh/nodemesh/combiner.cpp b/thirdparty/nodemesh/nodemesh/combiner.cpp index 17b22aa9..72f5be69 100644 --- a/thirdparty/nodemesh/nodemesh/combiner.cpp +++ b/thirdparty/nodemesh/nodemesh/combiner.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/thirdparty/nodemesh/nodemesh/util.cpp b/thirdparty/nodemesh/nodemesh/misc.cpp similarity index 91% rename from thirdparty/nodemesh/nodemesh/util.cpp rename to thirdparty/nodemesh/nodemesh/misc.cpp index 4f5c6e7c..d8b77f77 100644 --- a/thirdparty/nodemesh/nodemesh/util.cpp +++ b/thirdparty/nodemesh/nodemesh/misc.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -6,25 +6,28 @@ #include #include -namespace nodemesh -{ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif -float radianToDegree(float r) +using namespace nodemesh; + +float nodemesh::radianToDegree(float r) { return r * 180.0 / M_PI; } -float angleBetween(const QVector3D &v1, const QVector3D &v2) +float nodemesh::angleBetween(const QVector3D &v1, const QVector3D &v2) { return atan2(QVector3D::crossProduct(v1, v2).length(), QVector3D::dotProduct(v1, v2)); } -float degreeBetween(const QVector3D &v1, const QVector3D &v2) +float nodemesh::degreeBetween(const QVector3D &v1, const QVector3D &v2) { return radianToDegree(angleBetween(v1, v2)); } -float degreeBetweenIn360(const QVector3D &a, const QVector3D &b, const QVector3D &direct) +float nodemesh::degreeBetweenIn360(const QVector3D &a, const QVector3D &b, const QVector3D &direct) { auto angle = radianToDegree(angleBetween(a, b)); auto c = QVector3D::crossProduct(a, b); @@ -34,7 +37,7 @@ float degreeBetweenIn360(const QVector3D &a, const QVector3D &b, const QVector3D return angle; } -QVector3D polygonNormal(const std::vector &vertices, const std::vector &polygon) +QVector3D nodemesh::polygonNormal(const std::vector &vertices, const std::vector &polygon) { QVector3D normal; for (size_t i = 0; i < polygon.size(); ++i) { @@ -48,7 +51,7 @@ QVector3D polygonNormal(const std::vector &vertices, const std::vecto return normal.normalized(); } -bool pointInTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &p) +bool nodemesh::pointInTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c, const QVector3D &p) { auto u = b - a; auto v = c - a; @@ -69,7 +72,7 @@ bool pointInTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c, return r + t <= 1.0; } -void triangulate(const std::vector &vertices, const std::vector> &faces, std::vector> &triangles) +void nodemesh::triangulate(const std::vector &vertices, const std::vector> &faces, std::vector> &triangles) { std::vector> rings; for (const auto &face: faces) { @@ -129,7 +132,7 @@ void triangulate(const std::vector &vertices, const std::vector &vertices, const std::vector> &faces, const QString &filename, const std::set *excludeFacesOfVertices) +void nodemesh::exportMeshAsObj(const std::vector &vertices, const std::vector> &faces, const QString &filename, const std::set *excludeFacesOfVertices) { QFile file(filename); if (file.open(QIODevice::WriteOnly)) { @@ -157,7 +160,7 @@ void exportMeshAsObj(const std::vector &vertices, const std::vector &vertices, const std::vector> &faces, const QString &filename, +void nodemesh::exportMeshAsObjWithNormals(const std::vector &vertices, const std::vector> &faces, const QString &filename, const std::vector &triangleVertexNormals) { QFile file(filename); @@ -182,14 +185,14 @@ void exportMeshAsObjWithNormals(const std::vector &vertices, const st } } -float areaOfTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c) +float nodemesh::areaOfTriangle(const QVector3D &a, const QVector3D &b, const QVector3D &c) { auto ab = b - a; auto ac = c - a; return 0.5 * QVector3D::crossProduct(ab, ac).length(); } -void angleSmooth(const std::vector &vertices, +void nodemesh::angleSmooth(const std::vector &vertices, const std::vector> &triangles, const std::vector &triangleNormals, float thresholdAngleDegrees, @@ -247,7 +250,7 @@ void angleSmooth(const std::vector &vertices, item.normalize(); } -void recoverQuads(const std::vector &vertices, const std::vector> &triangles, const std::set> &sharedQuadEdges, std::vector> &triangleAndQuads) +void nodemesh::recoverQuads(const std::vector &vertices, const std::vector> &triangles, const std::set> &sharedQuadEdges, std::vector> &triangleAndQuads) { std::vector verticesPositionKeys; for (const auto &position: vertices) { @@ -293,7 +296,7 @@ void recoverQuads(const std::vector &vertices, const std::vector &sourceVertices, const std::vector> &sourceTriangles, +size_t nodemesh::weldSeam(const std::vector &sourceVertices, const std::vector> &sourceTriangles, float allowedSmallestDistance, const std::set &excludePositions, std::vector &destVertices, std::vector> &destTriangles) { @@ -421,7 +424,7 @@ size_t weldSeam(const std::vector &sourceVertices, const std::vector< return weldedCount; } -bool isManifold(const std::vector> &faces) +bool nodemesh::isManifold(const std::vector> &faces) { std::set> halfEdges; for (const auto &face: faces) { @@ -439,7 +442,7 @@ bool isManifold(const std::vector> &faces) return true; } -void trim(std::vector *vertices, bool normalize) +void nodemesh::trim(std::vector *vertices, bool normalize) { float xLow = std::numeric_limits::max(); float xHigh = std::numeric_limits::lowest(); @@ -488,5 +491,3 @@ void trim(std::vector *vertices, bool normalize) } } } - -} diff --git a/thirdparty/nodemesh/nodemesh/util.h b/thirdparty/nodemesh/nodemesh/misc.h similarity index 97% rename from thirdparty/nodemesh/nodemesh/util.h rename to thirdparty/nodemesh/nodemesh/misc.h index 6e261f36..53305a02 100644 --- a/thirdparty/nodemesh/nodemesh/util.h +++ b/thirdparty/nodemesh/nodemesh/misc.h @@ -1,5 +1,5 @@ -#ifndef NODEMESH_UTIL_H -#define NODEMESH_UTIL_H +#ifndef NODEMESH_MISC_H +#define NODEMESH_MISC_H #include #include #include diff --git a/thirdparty/nodemesh/nodemesh/recombiner.cpp b/thirdparty/nodemesh/nodemesh/recombiner.cpp index 0c435fbc..fb51c960 100644 --- a/thirdparty/nodemesh/nodemesh/recombiner.cpp +++ b/thirdparty/nodemesh/nodemesh/recombiner.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include diff --git a/thirdparty/nodemesh/nodemesh/stitcher.cpp b/thirdparty/nodemesh/nodemesh/stitcher.cpp index 2c8180e2..38224fda 100644 --- a/thirdparty/nodemesh/nodemesh/stitcher.cpp +++ b/thirdparty/nodemesh/nodemesh/stitcher.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/thirdparty/nodemesh/nodemesh/wrapper.cpp b/thirdparty/nodemesh/nodemesh/wrapper.cpp index 968401a7..0a8d9a58 100644 --- a/thirdparty/nodemesh/nodemesh/wrapper.cpp +++ b/thirdparty/nodemesh/nodemesh/wrapper.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -90,7 +90,7 @@ void Wrapper::addStartup(size_t p1, size_t p2, const QVector3D &baseNormal) { if (m_items.empty()) addItem(p1, p2, baseNormal); - m_generatedFaceEdgesMap.insert({WrapItemKey {.p1 = p2, .p2 = p1}, {0, false}}); + m_generatedFaceEdgesMap.insert({WrapItemKey {p2, p1}, {0, false}}); } QVector3D Wrapper::calculateFaceVector(size_t p1, size_t p2, const QVector3D &baseNormal) @@ -112,14 +112,20 @@ void Wrapper::addItem(size_t p1, size_t p2, const QVector3D &baseNormal) if (isEdgeGenerated(p1, p2) || isEdgeGenerated(p2, p1)) return; auto index = m_items.size(); - m_items.push_back(WrapItem {.p3 = 0, .p1 = p1, .p2 = p2, .baseNormal = baseNormal, .processed = false}); - m_itemsMap.insert({WrapItemKey {.p1 = p1, .p2 = p2}, index}); + WrapItem item; + item.p3 = 0; + item.p1 = p1; + item.p2 = p2; + item.baseNormal = baseNormal; + item.processed = false; + m_items.push_back(item); + m_itemsMap.insert({WrapItemKey {p1, p2}, index}); m_itemsList.push_front(index); } std::pair Wrapper::findItem(size_t p1, size_t p2) { - auto key = WrapItemKey {.p1 = p1, .p2 = p2}; + auto key = WrapItemKey {p1, p2}; auto findResult = m_itemsMap.find(key); if (findResult == m_itemsMap.end()) { return {0, false}; @@ -129,7 +135,7 @@ std::pair Wrapper::findItem(size_t p1, size_t p2) bool Wrapper::isEdgeGenerated(size_t p1, size_t p2) { - auto key = WrapItemKey {.p1 = p1, .p2 = p2}; + auto key = WrapItemKey {p1, p2}; if (m_generatedFaceEdgesMap.find(key) == m_generatedFaceEdgesMap.end()) return false; return true; @@ -187,8 +193,8 @@ std::pair Wrapper::peekItem() bool Wrapper::isEdgeClosed(size_t p1, size_t p2) { - return m_generatedFaceEdgesMap.find(WrapItemKey {.p1 = p1, .p2 = p2}) != m_generatedFaceEdgesMap.end() && - m_generatedFaceEdgesMap.find(WrapItemKey {.p1 = p2, .p2 = p1}) != m_generatedFaceEdgesMap.end(); + return m_generatedFaceEdgesMap.find(WrapItemKey {p1, p2}) != m_generatedFaceEdgesMap.end() && + m_generatedFaceEdgesMap.find(WrapItemKey {p2, p1}) != m_generatedFaceEdgesMap.end(); } bool Wrapper::isVertexClosed(size_t vertexIndex) @@ -223,12 +229,12 @@ void Wrapper::generate() m_sourceVertices[p2].position, m_sourceVertices[p3].position); auto faceIndex = m_generatedFaces.size(); - m_generatedFaces.push_back(Face3 {.p1 = p1, .p2 = p2, .p3 = p3, .normal = baseNormal, .index = faceIndex}); + m_generatedFaces.push_back(Face3 {p1, p2, p3, baseNormal, faceIndex}); addItem(p3, p2, baseNormal); addItem(p1, p3, baseNormal); - m_generatedFaceEdgesMap.insert({WrapItemKey {.p1 = p1, .p2 = p2}, {faceIndex, true}}); - m_generatedFaceEdgesMap.insert({WrapItemKey {.p1 = p2, .p2 = p3}, {faceIndex, true}}); - m_generatedFaceEdgesMap.insert({WrapItemKey {.p1 = p3, .p2 = p1}, {faceIndex, true}}); + m_generatedFaceEdgesMap.insert({WrapItemKey {p1, p2}, {faceIndex, true}}); + m_generatedFaceEdgesMap.insert({WrapItemKey {p2, p3}, {faceIndex, true}}); + m_generatedFaceEdgesMap.insert({WrapItemKey {p3, p1}, {faceIndex, true}}); m_generatedVertexEdgesMap[p1].push_back(p2); m_generatedVertexEdgesMap[p1].push_back(p3); m_generatedVertexEdgesMap[p2].push_back(p3); @@ -255,7 +261,7 @@ std::pair Wrapper::findPairFace3(const Face3 &f, std::mapsecond.second) { auto pairedFace3Id = findPairedFace3Id->second.first; if (usedIds.find(pairedFace3Id) != usedIds.end()) @@ -264,7 +270,7 @@ std::pair Wrapper::findPairFace3(const Face3 &f, std::map