| 15 | namespace mesh { |
| 16 | |
| 17 | void meshPostProcessing(Mesh*& inout_mesh, |
| 18 | StaticVector<StaticVector<int>>& inout_ptsCams, |
| 19 | mvsUtils::MultiViewParams& mp, |
| 20 | const std::string& debugFolderName, |
| 21 | StaticVector<Point3d>* hexahsToExcludeFromResultingMesh, |
| 22 | Point3d* hexah) |
| 23 | { |
| 24 | long timer = std::clock(); |
| 25 | ALICEVISION_LOG_INFO("Mesh post-processing."); |
| 26 | |
| 27 | bool exportDebug = (float)mp.userParams.get<bool>("delaunaycut.exportDebugGC", false); |
| 28 | |
| 29 | if (exportDebug) |
| 30 | inout_mesh->save(debugFolderName + "rawGraphCut"); |
| 31 | |
| 32 | // copy ptsCams |
| 33 | { |
| 34 | StaticVector<StaticVector<int>> ptsCamsOld = inout_ptsCams; |
| 35 | StaticVector<int> ptIdToNewPtId; |
| 36 | |
| 37 | bool doRemoveTrianglesInhexahsToExcludeFromResultingMesh = |
| 38 | (bool)mp.userParams.get<bool>("LargeScale.doRemoveTrianglesInhexahsToExcludeFromResultingMesh", false); |
| 39 | if (doRemoveTrianglesInhexahsToExcludeFromResultingMesh && hexahsToExcludeFromResultingMesh) |
| 40 | { |
| 41 | inout_mesh->removeTrianglesInHexahedrons(hexahsToExcludeFromResultingMesh); |
| 42 | } |
| 43 | |
| 44 | inout_mesh->removeFreePointsFromMesh(ptIdToNewPtId); |
| 45 | |
| 46 | // remap visibilities |
| 47 | inout_ptsCams.resize(inout_mesh->pts.size()); |
| 48 | for (int i = 0; i < ptIdToNewPtId.size(); ++i) |
| 49 | { |
| 50 | int newId = ptIdToNewPtId[i]; |
| 51 | if (newId > -1) |
| 52 | { |
| 53 | StaticVector<int>& ptCamsNew = inout_ptsCams[newId]; |
| 54 | ptCamsNew.clear(); |
| 55 | ptCamsNew.reserve(sizeOfStaticVector<int>(ptsCamsOld[i])); |
| 56 | for (int j = 0; j < sizeOfStaticVector<int>(ptsCamsOld[i]); ++j) |
| 57 | { |
| 58 | ptCamsNew.push_back(ptsCamsOld[i][j]); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | if (true) // TODO: how to remove it? |
| 65 | { |
| 66 | ALICEVISION_LOG_INFO("Mesh Cleaning."); |
| 67 | |
| 68 | MeshEnergyOpt meOpt(&mp); |
| 69 | meOpt.addMesh(*inout_mesh); |
| 70 | delete inout_mesh; |
| 71 | |
| 72 | meOpt.init(); |
| 73 | meOpt.cleanMesh(10); |
| 74 |
no test coverage detected