Remove comments.
parent
cbaccb0116
commit
ae32a4693b
|
@ -348,7 +348,7 @@ void Builder::insertCutVertices(const std::vector<QVector3D> &cut, std::vector<s
|
||||||
bool Builder::generateCutsForNode(size_t nodeIndex)
|
bool Builder::generateCutsForNode(size_t nodeIndex)
|
||||||
{
|
{
|
||||||
if (m_swallowedNodes.find(nodeIndex) != m_swallowedNodes.end()) {
|
if (m_swallowedNodes.find(nodeIndex) != m_swallowedNodes.end()) {
|
||||||
qDebug() << "node" << nodeIndex << "ignore cuts generating because of been swallowed";
|
//qDebug() << "node" << nodeIndex << "ignore cuts generating because of been swallowed";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,9 +380,9 @@ bool Builder::generateCutsForNode(size_t nodeIndex)
|
||||||
size_t tries = 0;
|
size_t tries = 0;
|
||||||
do {
|
do {
|
||||||
offsetChanged = false;
|
offsetChanged = false;
|
||||||
qDebug() << "Try wrap #" << tries;
|
//qDebug() << "Try wrap #" << tries;
|
||||||
if (tryWrapMultipleBranchesForNode(nodeIndex, offsets, offsetChanged)) {
|
if (tryWrapMultipleBranchesForNode(nodeIndex, offsets, offsetChanged)) {
|
||||||
qDebug() << "Wrap succeed";
|
//qDebug() << "Wrap succeed";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
++tries;
|
++tries;
|
||||||
|
@ -422,7 +422,7 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector<float
|
||||||
float finalDistance = node.radius + offsetDistance;
|
float finalDistance = node.radius + offsetDistance;
|
||||||
if (finalDistance >= distance) {
|
if (finalDistance >= distance) {
|
||||||
if (swallowEdgeForNode(nodeIndex, i)) {
|
if (swallowEdgeForNode(nodeIndex, i)) {
|
||||||
qDebug() << "Neighbor too near to wrap, swallow it";
|
//qDebug() << "Neighbor too near to wrap, swallow it";
|
||||||
offsets[i] = 0;
|
offsets[i] = 0;
|
||||||
offsetsChanged = true;
|
offsetsChanged = true;
|
||||||
directSwallowed = true;
|
directSwallowed = true;
|
||||||
|
@ -456,13 +456,13 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector<float
|
||||||
if (stitchSucceed) {
|
if (stitchSucceed) {
|
||||||
stitchSucceed = nodemesh::isManifold(testFaces);
|
stitchSucceed = nodemesh::isManifold(testFaces);
|
||||||
if (!stitchSucceed) {
|
if (!stitchSucceed) {
|
||||||
qDebug() << "Mesh stitch but not manifold";
|
//qDebug() << "Mesh stitch but not manifold";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (stitchSucceed) {
|
if (stitchSucceed) {
|
||||||
nodemesh::Combiner::Mesh mesh(m_generatedVertices, testFaces, false);
|
nodemesh::Combiner::Mesh mesh(m_generatedVertices, testFaces, false);
|
||||||
if (mesh.isNull()) {
|
if (mesh.isNull()) {
|
||||||
qDebug() << "Mesh stitched but not not pass test";
|
//qDebug() << "Mesh stitched but not not pass test";
|
||||||
//nodemesh::exportMeshAsObj(m_generatedVertices, testFaces, "/Users/jeremy/Desktop/test.obj");
|
//nodemesh::exportMeshAsObj(m_generatedVertices, testFaces, "/Users/jeremy/Desktop/test.obj");
|
||||||
stitchSucceed = false;
|
stitchSucceed = false;
|
||||||
for (size_t i = 0; i < node.edges.size(); ++i) {
|
for (size_t i = 0; i < node.edges.size(); ++i) {
|
||||||
|
@ -484,7 +484,7 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector<float
|
||||||
for (const auto &edgeLoop: failedEdgeLoops) {
|
for (const auto &edgeLoop: failedEdgeLoops) {
|
||||||
if (offsets[edgeLoop] + WRAP_STEP_BACK_FACTOR >= 1.0) {
|
if (offsets[edgeLoop] + WRAP_STEP_BACK_FACTOR >= 1.0) {
|
||||||
if (swallowEdgeForNode(nodeIndex, edgeLoop)) {
|
if (swallowEdgeForNode(nodeIndex, edgeLoop)) {
|
||||||
qDebug() << "No offset to step back, swallow neighbor instead";
|
//qDebug() << "No offset to step back, swallow neighbor instead";
|
||||||
offsets[edgeLoop] = 0;
|
offsets[edgeLoop] = 0;
|
||||||
offsetsChanged = true;
|
offsetsChanged = true;
|
||||||
break;
|
break;
|
||||||
|
@ -509,7 +509,7 @@ bool Builder::tryWrapMultipleBranchesForNode(size_t nodeIndex, std::vector<float
|
||||||
for (const auto &u: first.first) {
|
for (const auto &u: first.first) {
|
||||||
for (const auto &v: second.first) {
|
for (const auto &v: second.first) {
|
||||||
if ((m_generatedVertices[u] - m_generatedVertices[v]).lengthSquared() < allowedMinDist2) {
|
if ((m_generatedVertices[u] - m_generatedVertices[v]).lengthSquared() < allowedMinDist2) {
|
||||||
qDebug() << "Weld" << v << "to" << u;
|
//qDebug() << "Weld" << v << "to" << u;
|
||||||
m_weldMap.insert({v, u});
|
m_weldMap.insert({v, u});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -532,18 +532,18 @@ bool Builder::swallowEdgeForNode(size_t nodeIndex, size_t edgeOrder)
|
||||||
auto &node = m_nodes[nodeIndex];
|
auto &node = m_nodes[nodeIndex];
|
||||||
size_t edgeIndex = node.edges[edgeOrder];
|
size_t edgeIndex = node.edges[edgeOrder];
|
||||||
if (m_swallowedEdges.find(edgeIndex) != m_swallowedEdges.end()) {
|
if (m_swallowedEdges.find(edgeIndex) != m_swallowedEdges.end()) {
|
||||||
qDebug() << "No more edge to swallow";
|
//qDebug() << "No more edge to swallow";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
size_t neighborIndex = m_edges[edgeIndex].neiborOf(nodeIndex);
|
size_t neighborIndex = m_edges[edgeIndex].neiborOf(nodeIndex);
|
||||||
const auto &neighbor = m_nodes[neighborIndex];
|
const auto &neighbor = m_nodes[neighborIndex];
|
||||||
if (neighbor.edges.size() != 2) {
|
if (neighbor.edges.size() != 2) {
|
||||||
qDebug() << "Neighbor is not a simple two edges node to swallow, edges:" << neighbor.edges.size() << "neighbor:" << neighborIndex << "node" << nodeIndex;
|
//qDebug() << "Neighbor is not a simple two edges node to swallow, edges:" << neighbor.edges.size() << "neighbor:" << neighborIndex << "node" << nodeIndex;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
size_t anotherEdgeIndex = neighbor.anotherEdge(edgeIndex);
|
size_t anotherEdgeIndex = neighbor.anotherEdge(edgeIndex);
|
||||||
if (m_swallowedEdges.find(anotherEdgeIndex) != m_swallowedEdges.end()) {
|
if (m_swallowedEdges.find(anotherEdgeIndex) != m_swallowedEdges.end()) {
|
||||||
qDebug() << "Desired edge already been swallowed";
|
//qDebug() << "Desired edge already been swallowed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
node.edges[edgeOrder] = anotherEdgeIndex;
|
node.edges[edgeOrder] = anotherEdgeIndex;
|
||||||
|
@ -556,7 +556,7 @@ bool Builder::swallowEdgeForNode(size_t nodeIndex, size_t edgeOrder)
|
||||||
// qDebug() << it;
|
// qDebug() << it;
|
||||||
m_swallowedEdges.insert(edgeIndex);
|
m_swallowedEdges.insert(edgeIndex);
|
||||||
m_swallowedNodes.insert(neighborIndex);
|
m_swallowedNodes.insert(neighborIndex);
|
||||||
qDebug() << "Swallow edge" << edgeIndex << "for node" << nodeIndex << "neighbor" << neighborIndex << "got eliminated, choosen edge" << anotherEdgeIndex;
|
//qDebug() << "Swallow edge" << edgeIndex << "for node" << nodeIndex << "neighbor" << neighborIndex << "got eliminated, choosen edge" << anotherEdgeIndex;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ void Builder::applyWeld()
|
||||||
newIndices.push_back(newIndex);
|
newIndices.push_back(newIndex);
|
||||||
}
|
}
|
||||||
if (newIndices.size() < 3) {
|
if (newIndices.size() < 3) {
|
||||||
qDebug() << "Face been welded";
|
//qDebug() << "Face been welded";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newFaces.push_back(newIndices);
|
newFaces.push_back(newIndices);
|
||||||
|
|
|
@ -21,7 +21,7 @@ Combiner::Mesh::Mesh(const std::vector<QVector3D> &vertices, const std::vector<s
|
||||||
triangulate(vertices, faces, triangles);
|
triangulate(vertices, faces, triangles);
|
||||||
cgalMesh = buildCgalMesh<ExactKernel>(vertices, triangles);
|
cgalMesh = buildCgalMesh<ExactKernel>(vertices, triangles);
|
||||||
if (!CGAL::is_valid_polygon_mesh(*cgalMesh)) {
|
if (!CGAL::is_valid_polygon_mesh(*cgalMesh)) {
|
||||||
qDebug() << "Mesh is not valid polygon";
|
//qDebug() << "Mesh is not valid polygon";
|
||||||
delete cgalMesh;
|
delete cgalMesh;
|
||||||
cgalMesh = nullptr;
|
cgalMesh = nullptr;
|
||||||
} else if (CGAL::Polygon_mesh_processing::does_self_intersect(*cgalMesh)) {
|
} else if (CGAL::Polygon_mesh_processing::does_self_intersect(*cgalMesh)) {
|
||||||
|
@ -29,16 +29,16 @@ Combiner::Mesh::Mesh(const std::vector<QVector3D> &vertices, const std::vector<s
|
||||||
m_isSelfIntersected = true;
|
m_isSelfIntersected = true;
|
||||||
if (removeSelfIntersects) {
|
if (removeSelfIntersects) {
|
||||||
if (!CGAL::Polygon_mesh_processing::remove_self_intersections(*cgalMesh)) {
|
if (!CGAL::Polygon_mesh_processing::remove_self_intersections(*cgalMesh)) {
|
||||||
qDebug() << "Mesh does self intersect and cann't remove intersections";
|
//qDebug() << "Mesh does self intersect and cann't remove intersections";
|
||||||
delete cgalMesh;
|
delete cgalMesh;
|
||||||
cgalMesh = nullptr;
|
cgalMesh = nullptr;
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Mesh does self intersect but intersections got removed";
|
//qDebug() << "Mesh does self intersect but intersections got removed";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
delete cgalMesh;
|
delete cgalMesh;
|
||||||
cgalMesh = nullptr;
|
cgalMesh = nullptr;
|
||||||
qDebug() << "Mesh does self intersect";
|
//qDebug() << "Mesh does self intersect";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ bool Recombiner::convertHalfEdgesToEdgeLoops(const std::vector<std::pair<size_t,
|
||||||
for (const auto &halfEdge: halfEdges) {
|
for (const auto &halfEdge: halfEdges) {
|
||||||
auto inserResult = vertexLinkMap.insert(halfEdge);
|
auto inserResult = vertexLinkMap.insert(halfEdge);
|
||||||
if (!inserResult.second) {
|
if (!inserResult.second) {
|
||||||
qDebug() << "Create edge loop from half edge failed, found repeated vertex link" << halfEdge.first << "->" << halfEdge.second << "exist:" << inserResult.first->first << "->" << inserResult.first->second;
|
//qDebug() << "Create edge loop from half edge failed, found repeated vertex link" << halfEdge.first << "->" << halfEdge.second << "exist:" << inserResult.first->first << "->" << inserResult.first->second;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,11 +53,11 @@ bool Recombiner::convertHalfEdgesToEdgeLoops(const std::vector<std::pair<size_t,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!loopBack) {
|
if (!loopBack) {
|
||||||
qDebug() << "Create edge loop from half edge failed, edge doesn't loop back";
|
//qDebug() << "Create edge loop from half edge failed, edge doesn't loop back";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (edgeLoop.size() < 3) {
|
if (edgeLoop.size() < 3) {
|
||||||
qDebug() << "Create edge loop from half edge failed, edge loop size invalid:" << edgeLoop.size();
|
//qDebug() << "Create edge loop from half edge failed, edge loop size invalid:" << edgeLoop.size();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (const auto &vertex: edgeLoop) {
|
for (const auto &vertex: edgeLoop) {
|
||||||
|
@ -107,7 +107,7 @@ bool Recombiner::buildHalfEdgeToFaceMap(std::map<std::pair<size_t, size_t>, size
|
||||||
size_t j = (i + 1) % face.size();
|
size_t j = (i + 1) % face.size();
|
||||||
const auto insertResult = halfEdgeToFaceMap.insert({{face[i], face[j]}, faceIndex});
|
const auto insertResult = halfEdgeToFaceMap.insert({{face[i], face[j]}, faceIndex});
|
||||||
if (!insertResult.second) {
|
if (!insertResult.second) {
|
||||||
qDebug() << "Non manifold edge found:" << face[i] << face[j];
|
//qDebug() << "Non manifold edge found:" << face[i] << face[j];
|
||||||
succeed = false;
|
succeed = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ bool Recombiner::recombine()
|
||||||
}
|
}
|
||||||
std::map<size_t, size_t> seamVertexToIslandMap;
|
std::map<size_t, size_t> seamVertexToIslandMap;
|
||||||
size_t islands = splitSeamVerticesToIslands(seamLink, &seamVertexToIslandMap);
|
size_t islands = splitSeamVerticesToIslands(seamLink, &seamVertexToIslandMap);
|
||||||
qDebug() << "Seam islands:" << islands;
|
//qDebug() << "Seam islands:" << islands;
|
||||||
|
|
||||||
std::map<std::pair<size_t, size_t>, std::pair<size_t, bool>> edgesInSeamArea;
|
std::map<std::pair<size_t, size_t>, std::pair<size_t, bool>> edgesInSeamArea;
|
||||||
for (size_t faceIndex = 0; faceIndex < (*m_faces).size(); ++faceIndex) {
|
for (size_t faceIndex = 0; faceIndex < (*m_faces).size(); ++faceIndex) {
|
||||||
|
@ -182,7 +182,7 @@ bool Recombiner::recombine()
|
||||||
for (auto &it: islandsMap) {
|
for (auto &it: islandsMap) {
|
||||||
for (size_t side = 0; side < 2; ++side) {
|
for (size_t side = 0; side < 2; ++side) {
|
||||||
if (!convertHalfEdgesToEdgeLoops(it.second.halfedges[side], &it.second.edgeLoops[side])) {
|
if (!convertHalfEdgesToEdgeLoops(it.second.halfedges[side], &it.second.edgeLoops[side])) {
|
||||||
qDebug() << "Convert half edges to edge loops for island" << it.first << "side" << side << "failed";
|
//qDebug() << "Convert half edges to edge loops for island" << it.first << "side" << side << "failed";
|
||||||
it.second.edgeLoops[side].clear();
|
it.second.edgeLoops[side].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ bool Recombiner::recombine()
|
||||||
while ((adjustedTriangles=adjustTrianglesFromSeam(edgeLoop, it.first)) > 0) {
|
while ((adjustedTriangles=adjustTrianglesFromSeam(edgeLoop, it.first)) > 0) {
|
||||||
totalAdjustedTriangles += adjustedTriangles;
|
totalAdjustedTriangles += adjustedTriangles;
|
||||||
}
|
}
|
||||||
qDebug() << "Island" << it.first << "side" << side << "edge loop" << i << "adjusted" << totalAdjustedTriangles << "triangles";
|
//qDebug() << "Island" << it.first << "side" << side << "edge loop" << i << "adjusted" << totalAdjustedTriangles << "triangles";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ bool Recombiner::recombine()
|
||||||
copyNonSeamFacesAsRegenerated();
|
copyNonSeamFacesAsRegenerated();
|
||||||
removeReluctantVertices();
|
removeReluctantVertices();
|
||||||
|
|
||||||
qDebug() << "Optimized" << m_goodSeams.size() << "seams";
|
//qDebug() << "Optimized" << m_goodSeams.size() << "seams";
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ bool Recombiner::bridge(const std::vector<size_t> &first, const std::vector<size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "small:" << small->size() << "large:" << large->size() << "matches:" << matchedPairs.size();
|
//qDebug() << "small:" << small->size() << "large:" << large->size() << "matches:" << matchedPairs.size();
|
||||||
|
|
||||||
if (matchedPairs.empty())
|
if (matchedPairs.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -75,7 +75,7 @@ bool Stitcher::stitch(const std::vector<std::pair<std::vector<size_t>, QVector3D
|
||||||
m_wrapper->setVertices(m_positions);
|
m_wrapper->setVertices(m_positions);
|
||||||
m_wrapper->wrap(edgeLoops);
|
m_wrapper->wrap(edgeLoops);
|
||||||
if (!m_wrapper->finished()) {
|
if (!m_wrapper->finished()) {
|
||||||
qDebug() << "Wrapping failed";
|
//qDebug() << "Wrapping failed";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue