Include error mesh in final result
parent
40a6968599
commit
745c96eeb9
|
@ -35,8 +35,5 @@ bool LogBrowser::isDialogVisible()
|
||||||
|
|
||||||
void LogBrowser::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line)
|
void LogBrowser::outputMessage(QtMsgType type, const QString &msg, const QString &source, int line)
|
||||||
{
|
{
|
||||||
#ifdef IN_DEVELOPMENT
|
|
||||||
printf("%s\n", msg.toUtf8().constData());
|
|
||||||
#endif
|
|
||||||
emit sendMessage(type, msg, source, line);
|
emit sendMessage(type, msg, source, line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,27 +319,6 @@ void MeshGenerator::cutFaceStringToCutTemplate(const QString &cutFaceString, std
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef IN_DEVELOPMENT
|
|
||||||
#include <QTextStream>
|
|
||||||
#include <QFile>
|
|
||||||
static void exportAsObj(const std::vector<QVector3D> &positions,
|
|
||||||
const std::vector<std::vector<size_t>> &faces,
|
|
||||||
QTextStream *textStream)
|
|
||||||
{
|
|
||||||
auto &stream = *textStream;
|
|
||||||
for (std::vector<QVector3D>::const_iterator it = positions.begin() ; it != positions.end(); ++it) {
|
|
||||||
stream << "v " << (*it).x() << " " << (*it).y() << " " << (*it).z() << endl;
|
|
||||||
}
|
|
||||||
for (std::vector<std::vector<size_t>>::const_iterator it = faces.begin() ; it != faces.end(); ++it) {
|
|
||||||
stream << "f";
|
|
||||||
for (std::vector<size_t>::const_iterator subIt = (*it).begin() ; subIt != (*it).end(); ++subIt) {
|
|
||||||
stream << " " << (1 + *subIt);
|
|
||||||
}
|
|
||||||
stream << endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString, bool *hasError, bool addIntermediateNodes)
|
MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString, bool *hasError, bool addIntermediateNodes)
|
||||||
{
|
{
|
||||||
auto findPart = m_snapshot->parts.find(partIdString);
|
auto findPart = m_snapshot->parts.find(partIdString);
|
||||||
|
@ -427,6 +406,7 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString,
|
||||||
partCache.vertices.clear();
|
partCache.vertices.clear();
|
||||||
partCache.faces.clear();
|
partCache.faces.clear();
|
||||||
partCache.previewTriangles.clear();
|
partCache.previewTriangles.clear();
|
||||||
|
partCache.previewVertices.clear();
|
||||||
partCache.isSucceed = false;
|
partCache.isSucceed = false;
|
||||||
delete partCache.mesh;
|
delete partCache.mesh;
|
||||||
partCache.mesh = nullptr;
|
partCache.mesh = nullptr;
|
||||||
|
@ -765,22 +745,13 @@ MeshCombiner::Mesh *MeshGenerator::combinePartMesh(const QString &partIdString,
|
||||||
if (nullptr != mesh) {
|
if (nullptr != mesh) {
|
||||||
partCache.mesh = new MeshCombiner::Mesh(*mesh);
|
partCache.mesh = new MeshCombiner::Mesh(*mesh);
|
||||||
mesh->fetch(partPreviewVertices, partCache.previewTriangles);
|
mesh->fetch(partPreviewVertices, partCache.previewTriangles);
|
||||||
|
partCache.previewVertices = partPreviewVertices;
|
||||||
partCache.isSucceed = true;
|
partCache.isSucceed = true;
|
||||||
}
|
}
|
||||||
if (partCache.previewTriangles.empty()) {
|
if (partCache.previewTriangles.empty()) {
|
||||||
partPreviewVertices = partCache.vertices;
|
partPreviewVertices = partCache.vertices;
|
||||||
triangulateFacesWithoutKeepVertices(partPreviewVertices, partCache.faces, partCache.previewTriangles);
|
triangulateFacesWithoutKeepVertices(partPreviewVertices, partCache.faces, partCache.previewTriangles);
|
||||||
#ifdef IN_DEVELOPMENT
|
partCache.previewVertices = partPreviewVertices;
|
||||||
{
|
|
||||||
QFile file("/Users/jeremy/Desktop/dust3d_debug.obj");
|
|
||||||
if (file.open(QIODevice::WriteOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
exportAsObj(partPreviewVertices,
|
|
||||||
partCache.previewTriangles,
|
|
||||||
&stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
partPreviewColor = Qt::red;
|
partPreviewColor = Qt::red;
|
||||||
partCache.isSucceed = false;
|
partCache.isSucceed = false;
|
||||||
}
|
}
|
||||||
|
@ -1332,19 +1303,7 @@ void MeshGenerator::generate()
|
||||||
qDebug() << "Total weld affected triangles:" << totalAffectedNum;
|
qDebug() << "Total weld affected triangles:" << totalAffectedNum;
|
||||||
|
|
||||||
recoverQuads(combinedVertices, combinedFaces, componentCache.sharedQuadEdges, m_outcome->triangleAndQuads);
|
recoverQuads(combinedVertices, combinedFaces, componentCache.sharedQuadEdges, m_outcome->triangleAndQuads);
|
||||||
|
|
||||||
#ifdef IN_DEVELOPMENT
|
|
||||||
{
|
|
||||||
QFile file("/Users/jeremy/Desktop/dust3d_debug.obj");
|
|
||||||
if (file.open(QIODevice::WriteOnly)) {
|
|
||||||
QTextStream stream(&file);
|
|
||||||
exportAsObj(combinedVertices,
|
|
||||||
m_outcome->triangleAndQuads,
|
|
||||||
&stream);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
m_outcome->nodes = componentCache.outcomeNodes;
|
m_outcome->nodes = componentCache.outcomeNodes;
|
||||||
m_outcome->nodeVertices = componentCache.outcomeNodeVertices;
|
m_outcome->nodeVertices = componentCache.outcomeNodeVertices;
|
||||||
m_outcome->vertices = combinedVertices;
|
m_outcome->vertices = combinedVertices;
|
||||||
|
@ -1358,8 +1317,7 @@ void MeshGenerator::generate()
|
||||||
// Collect errored parts
|
// Collect errored parts
|
||||||
for (const auto &it: m_cacheContext->parts) {
|
for (const auto &it: m_cacheContext->parts) {
|
||||||
if (!it.second.isSucceed) {
|
if (!it.second.isSucceed) {
|
||||||
auto vertexStartIndex = m_outcome->vertices.size();
|
auto updateVertexIndices = [=](std::vector<std::vector<size_t>> &faces, size_t vertexStartIndex) {
|
||||||
auto updateVertexIndices = [=](std::vector<std::vector<size_t>> &faces) {
|
|
||||||
for (auto &it: faces) {
|
for (auto &it: faces) {
|
||||||
for (auto &subIt: it)
|
for (auto &subIt: it)
|
||||||
subIt += vertexStartIndex;
|
subIt += vertexStartIndex;
|
||||||
|
@ -1367,10 +1325,14 @@ void MeshGenerator::generate()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto errorTriangleAndQuads = it.second.faces;
|
auto errorTriangleAndQuads = it.second.faces;
|
||||||
updateVertexIndices(errorTriangleAndQuads);
|
updateVertexIndices(errorTriangleAndQuads, m_outcome->vertices.size());
|
||||||
|
|
||||||
m_outcome->vertices.insert(m_outcome->vertices.end(), it.second.vertices.begin(), it.second.vertices.end());
|
m_outcome->vertices.insert(m_outcome->vertices.end(), it.second.vertices.begin(), it.second.vertices.end());
|
||||||
m_outcome->triangleAndQuads.insert(m_outcome->triangleAndQuads.end(), errorTriangleAndQuads.begin(), errorTriangleAndQuads.end());
|
m_outcome->triangleAndQuads.insert(m_outcome->triangleAndQuads.end(), errorTriangleAndQuads.begin(), errorTriangleAndQuads.end());
|
||||||
|
|
||||||
|
auto errorTriangles = it.second.previewTriangles;
|
||||||
|
updateVertexIndices(errorTriangles, m_outcome->vertices.size());
|
||||||
|
m_outcome->vertices.insert(m_outcome->vertices.end(), it.second.previewVertices.begin(), it.second.previewVertices.end());
|
||||||
|
m_outcome->triangles.insert(m_outcome->triangles.end(), errorTriangles.begin(), errorTriangles.end());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
std::vector<std::vector<size_t>> faces;
|
std::vector<std::vector<size_t>> faces;
|
||||||
std::vector<OutcomeNode> outcomeNodes;
|
std::vector<OutcomeNode> outcomeNodes;
|
||||||
std::vector<std::pair<QVector3D, std::pair<QUuid, QUuid>>> outcomeNodeVertices;
|
std::vector<std::pair<QVector3D, std::pair<QUuid, QUuid>>> outcomeNodeVertices;
|
||||||
|
std::vector<QVector3D> previewVertices;
|
||||||
std::vector<std::vector<size_t>> previewTriangles;
|
std::vector<std::vector<size_t>> previewTriangles;
|
||||||
OutcomePaintMap outcomePaintMap;
|
OutcomePaintMap outcomePaintMap;
|
||||||
bool isSucceed = false;
|
bool isSucceed = false;
|
||||||
|
|
Loading…
Reference in New Issue