Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
huxingyi committed Feb 19, 2019
1 parent 4bdbdd4 commit 3e1fde4
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 48 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------
Expand Down
4 changes: 2 additions & 2 deletions dust3d.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/meshgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <QGuiApplication>
#include <nodemesh/builder.h>
#include <nodemesh/modifier.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <nodemesh/recombiner.h>
#include "meshgenerator.h"
#include "util.h"
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/nodemesh/nodemesh/box.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nodemesh/box.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <nodemesh/cgalmesh.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/subdivision_method_3.h>
Expand Down
8 changes: 4 additions & 4 deletions thirdparty/nodemesh/nodemesh/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <nodemesh/stitcher.h>
#include <nodemesh/box.h>
#include <nodemesh/combiner.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>

#define WRAP_STEP_BACK_FACTOR 0.1 // 0.1 ~ 0.9
#define WRAP_WELD_FACTOR 0.01 // Allowed distance: WELD_FACTOR * radius
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/nodemesh/nodemesh/combiner.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nodemesh/combiner.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <nodemesh/positionkey.h>
#include <nodemesh/cgalmesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <cmath>
#include <QFile>
#include <QTextStream>
#include <QDebug>
#include <unordered_set>
#include <unordered_map>

namespace nodemesh
{
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif

using namespace nodemesh;

float radianToDegree(float r)
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);
Expand All @@ -34,7 +37,7 @@ float degreeBetweenIn360(const QVector3D &a, const QVector3D &b, const QVector3D
return angle;
}

QVector3D polygonNormal(const std::vector<QVector3D> &vertices, const std::vector<size_t> &polygon)
QVector3D nodemesh::polygonNormal(const std::vector<QVector3D> &vertices, const std::vector<size_t> &polygon)
{
QVector3D normal;
for (size_t i = 0; i < polygon.size(); ++i) {
Expand All @@ -48,7 +51,7 @@ QVector3D polygonNormal(const std::vector<QVector3D> &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;
Expand All @@ -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<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, std::vector<std::vector<size_t>> &triangles)
void nodemesh::triangulate(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, std::vector<std::vector<size_t>> &triangles)
{
std::vector<std::vector<size_t>> rings;
for (const auto &face: faces) {
Expand Down Expand Up @@ -129,7 +132,7 @@ void triangulate(const std::vector<QVector3D> &vertices, const std::vector<std::
}
}

void exportMeshAsObj(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, const QString &filename, const std::set<size_t> *excludeFacesOfVertices)
void nodemesh::exportMeshAsObj(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, const QString &filename, const std::set<size_t> *excludeFacesOfVertices)
{
QFile file(filename);
if (file.open(QIODevice::WriteOnly)) {
Expand Down Expand Up @@ -157,7 +160,7 @@ void exportMeshAsObj(const std::vector<QVector3D> &vertices, const std::vector<s
}
}

void exportMeshAsObjWithNormals(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, const QString &filename,
void nodemesh::exportMeshAsObjWithNormals(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &faces, const QString &filename,
const std::vector<QVector3D> &triangleVertexNormals)
{
QFile file(filename);
Expand All @@ -182,14 +185,14 @@ void exportMeshAsObjWithNormals(const std::vector<QVector3D> &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<QVector3D> &vertices,
void nodemesh::angleSmooth(const std::vector<QVector3D> &vertices,
const std::vector<std::vector<size_t>> &triangles,
const std::vector<QVector3D> &triangleNormals,
float thresholdAngleDegrees,
Expand Down Expand Up @@ -247,7 +250,7 @@ void angleSmooth(const std::vector<QVector3D> &vertices,
item.normalize();
}

void recoverQuads(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &triangles, const std::set<std::pair<PositionKey, PositionKey>> &sharedQuadEdges, std::vector<std::vector<size_t>> &triangleAndQuads)
void nodemesh::recoverQuads(const std::vector<QVector3D> &vertices, const std::vector<std::vector<size_t>> &triangles, const std::set<std::pair<PositionKey, PositionKey>> &sharedQuadEdges, std::vector<std::vector<size_t>> &triangleAndQuads)
{
std::vector<PositionKey> verticesPositionKeys;
for (const auto &position: vertices) {
Expand Down Expand Up @@ -293,7 +296,7 @@ void recoverQuads(const std::vector<QVector3D> &vertices, const std::vector<std:
}
}

size_t weldSeam(const std::vector<QVector3D> &sourceVertices, const std::vector<std::vector<size_t>> &sourceTriangles,
size_t nodemesh::weldSeam(const std::vector<QVector3D> &sourceVertices, const std::vector<std::vector<size_t>> &sourceTriangles,
float allowedSmallestDistance, const std::set<PositionKey> &excludePositions,
std::vector<QVector3D> &destVertices, std::vector<std::vector<size_t>> &destTriangles)
{
Expand Down Expand Up @@ -421,7 +424,7 @@ size_t weldSeam(const std::vector<QVector3D> &sourceVertices, const std::vector<
return weldedCount;
}

bool isManifold(const std::vector<std::vector<size_t>> &faces)
bool nodemesh::isManifold(const std::vector<std::vector<size_t>> &faces)
{
std::set<std::pair<size_t, size_t>> halfEdges;
for (const auto &face: faces) {
Expand All @@ -439,7 +442,7 @@ bool isManifold(const std::vector<std::vector<size_t>> &faces)
return true;
}

void trim(std::vector<QVector3D> *vertices, bool normalize)
void nodemesh::trim(std::vector<QVector3D> *vertices, bool normalize)
{
float xLow = std::numeric_limits<float>::max();
float xHigh = std::numeric_limits<float>::lowest();
Expand Down Expand Up @@ -488,5 +491,3 @@ void trim(std::vector<QVector3D> *vertices, bool normalize)
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef NODEMESH_UTIL_H
#define NODEMESH_UTIL_H
#ifndef NODEMESH_MISC_H
#define NODEMESH_MISC_H
#include <QVector3D>
#include <vector>
#include <set>
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/nodemesh/nodemesh/recombiner.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <nodemesh/recombiner.h>
#include <nodemesh/positionkey.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <nodemesh/wrapper.h>
#include <set>
#include <QDebug>
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/nodemesh/nodemesh/stitcher.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nodemesh/stitcher.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <memory>
#include <QDebug>

Expand Down
34 changes: 20 additions & 14 deletions thirdparty/nodemesh/nodemesh/wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <nodemesh/wrapper.h>
#include <nodemesh/util.h>
#include <nodemesh/misc.h>
#include <cmath>
#include <set>

Expand Down Expand Up @@ -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)
Expand All @@ -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<size_t, bool> 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};
Expand All @@ -129,7 +135,7 @@ std::pair<size_t, bool> 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;
Expand Down Expand Up @@ -187,8 +193,8 @@ std::pair<size_t, bool> 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)
Expand Down Expand Up @@ -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);
Expand All @@ -255,7 +261,7 @@ std::pair<size_t, bool> Wrapper::findPairFace3(const Face3 &f, std::map<size_t,
for (size_t i = 0; i < indices.size(); ++i) {
auto j = (i + 1) % indices.size();
auto k = (i + 2) % indices.size();
auto findPairedFace3Id = m_generatedFaceEdgesMap.find(WrapItemKey {.p1 = indices[j], .p2 = indices[i]});
auto findPairedFace3Id = m_generatedFaceEdgesMap.find(WrapItemKey {indices[j], indices[i]});
if (findPairedFace3Id != m_generatedFaceEdgesMap.end() && findPairedFace3Id->second.second) {
auto pairedFace3Id = findPairedFace3Id->second.first;
if (usedIds.find(pairedFace3Id) != usedIds.end())
Expand All @@ -264,7 +270,7 @@ std::pair<size_t, bool> Wrapper::findPairFace3(const Face3 &f, std::map<size_t,
if (!almostEqual(pairedFace3.normal, f.normal))
continue;
auto anotherIndex = anotherVertexIndexOfFace3(pairedFace3, indices[j], indices[i]);
auto mergedF = Face4 {.p1 = indices[i], .p2 = anotherIndex, .p3 = indices[j], .p4 = indices[k]};
auto mergedF = Face4 {indices[i], anotherIndex, indices[j], indices[k]};
q.push_back(mergedF);
return {pairedFace3Id, true};
}
Expand Down

0 comments on commit 3e1fde4

Please sign in to comment.