diff --git a/src/meshgenerator.cpp b/src/meshgenerator.cpp index 44985d63..b360593f 100644 --- a/src/meshgenerator.cpp +++ b/src/meshgenerator.cpp @@ -28,6 +28,7 @@ MeshGenerator::~MeshGenerator() delete m_snapshot; delete m_outcome; delete m_cutFaceTransforms; + delete m_nodesCutFaces; } bool MeshGenerator::isSucceed() @@ -68,6 +69,13 @@ std::map *MeshGenerator::takeCutFace return cutFaceTransforms; } +std::map>> *MeshGenerator::takeNodesCutFaces() +{ + auto nodesCutFaces = m_nodesCutFaces; + m_nodesCutFaces = nullptr; + return nodesCutFaces; +} + void MeshGenerator::collectParts() { for (const auto &node: m_snapshot->nodes) { @@ -182,6 +190,7 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt auto target = PartTargetFromString(valueOfKeyInMapOrEmpty(part, "target").toUtf8().constData()); auto base = PartBaseFromString(valueOfKeyInMapOrEmpty(part, "base").toUtf8().constData()); + std::map> cutFaceNodeMap; std::vector cutTemplate; QString cutFaceString = valueOfKeyInMapOrEmpty(part, "cutFace"); QUuid cutFaceLinkedPartId = QUuid(cutFaceString); @@ -191,7 +200,6 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt qDebug() << "Find cut face linked part failed:" << cutFaceString; } else { // Build node info map - std::map> cutFaceNodeMap; for (const auto &nodeIdString: m_partNodeIds[cutFaceString]) { auto findNode = m_snapshot->nodes.find(nodeIdString); if (findNode == m_snapshot->nodes.end()) { @@ -486,8 +494,11 @@ nodemesh::Combiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdSt continue; const QString &nodeIdString = nodeIndexToIdStringMap[node.originNodeIndex]; const nodemesh::Builder::CutFaceTransform *cutFaceTransform = builder->nodeAdjustableCutFaceTransform(builderNodeIndices[i]); - if (nullptr != cutFaceTransform) - m_cutFaceTransforms->insert({QUuid(nodeIdString), *cutFaceTransform}); + if (nullptr != cutFaceTransform) { + QUuid nodeId = QUuid(nodeIdString); + m_cutFaceTransforms->insert({nodeId, *cutFaceTransform}); + m_nodesCutFaces->insert({nodeId, cutFaceNodeMap}); + } } partCache.vertices = builder->generatedVertices(); @@ -982,6 +993,7 @@ void MeshGenerator::generate() m_outcome = new Outcome; m_cutFaceTransforms = new std::map; + m_nodesCutFaces = new std::map>>; bool needDeleteCacheContext = false; if (nullptr == m_cacheContext) { diff --git a/src/meshgenerator.h b/src/meshgenerator.h index 2e0764a8..7b25a892 100644 --- a/src/meshgenerator.h +++ b/src/meshgenerator.h @@ -61,6 +61,7 @@ public: const std::set &generatedPreviewPartIds(); Outcome *takeOutcome(); std::map *takeCutFaceTransforms(); + std::map>> *takeNodesCutFaces(); void generate(); void setGeneratedCacheContext(GeneratedCacheContext *cacheContext); void setSmoothShadingThresholdAngleDegrees(float degrees); @@ -89,6 +90,7 @@ private: bool m_cacheEnabled = false; float m_smoothShadingThresholdAngleDegrees = 60; std::map *m_cutFaceTransforms = nullptr; + std::map>> *m_nodesCutFaces = nullptr; void collectParts(); bool checkIsComponentDirty(const QString &componentIdString);