From 40a696859935617151fda80ad8494a52d727b659 Mon Sep 17 00:00:00 2001 From: Jeremy Hu Date: Sun, 15 Dec 2019 11:44:04 +0930 Subject: [PATCH] Enable three nodes branch on gridded part --- src/gridmeshbuilder.cpp | 6 +++++- src/gridmeshbuilder.h | 2 +- src/meshgenerator.cpp | 3 +-- src/skeletondocument.cpp | 10 +++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/gridmeshbuilder.cpp b/src/gridmeshbuilder.cpp index be97eeb7..e924adfe 100644 --- a/src/gridmeshbuilder.cpp +++ b/src/gridmeshbuilder.cpp @@ -421,14 +421,17 @@ void GridMeshBuilder::setSubdived(bool subdived) m_subdived = subdived; } -void GridMeshBuilder::build() +bool GridMeshBuilder::build() { if (m_subdived) applyModifiers(); prepareNodeVertices(); findCycles(); + if (m_cycles.empty()) + return false; generateFaces(); extrude(); + return true; } void GridMeshBuilder::findCycles() @@ -442,3 +445,4 @@ void GridMeshBuilder::findCycles() cycleFinder.find(); m_cycles = cycleFinder.getCycles(); } + diff --git a/src/gridmeshbuilder.h b/src/gridmeshbuilder.h index 19073743..61eec1b3 100644 --- a/src/gridmeshbuilder.h +++ b/src/gridmeshbuilder.h @@ -25,7 +25,7 @@ public: size_t addNode(const QVector3D &position, float radius); size_t addEdge(size_t firstNodeIndex, size_t secondNodeIndex); void setSubdived(bool subdived); - void build(); + bool build(); const std::vector &getGeneratedPositions(); const std::vector &getGeneratedSources(); const std::vector> &getGeneratedFaces(); diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 6c4b9b00..ee0a3e8a 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -580,8 +580,7 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString, if (subdived) gridMeshBuilder->setSubdived(true); - gridMeshBuilder->build(); - buildSucceed = true; + buildSucceed = gridMeshBuilder->build(); partCache.vertices = gridMeshBuilder->getGeneratedPositions(); partCache.faces = gridMeshBuilder->getGeneratedFaces(); diff --git a/src/skeletondocument.cpp b/src/skeletondocument.cpp index 29ce06bd..a772a7b5 100644 --- a/src/skeletondocument.cpp +++ b/src/skeletondocument.cpp @@ -73,5 +73,13 @@ void SkeletonDocument::findAllNeighbors(QUuid nodeId, std::set &neighbors bool SkeletonDocument::isNodeConnectable(QUuid nodeId) const { - return true; + const auto &node = findNode(nodeId); + if (nullptr == node) + return false; + if (node->edgeIds.size() < 2) + return true; + const SkeletonPart *part = findPart(node->partId); + if (nullptr == part) + return false; + return part->gridded; }