diff --git a/src/diffCheck/geometry/DFMesh.cc b/src/diffCheck/geometry/DFMesh.cc index 0669b56d..875fc254 100644 --- a/src/diffCheck/geometry/DFMesh.cc +++ b/src/diffCheck/geometry/DFMesh.cc @@ -129,16 +129,16 @@ namespace diffCheck::geometry double dot11 = v0v1.dot(v0v1); double dot12 = v0v1.dot(v0p); - // Compute barycentric coordinates + // create u,v isoparametric mapping to the triangle where (u,v) = (1,0) if projectedPoint = v2, (u,v) = (0,1) if projectedPoint = v1 and (u,v) = (0,0) if projectedPoint = v0 double invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01); double u = (dot11 * dot02 - dot01 * dot12) * invDenom; double v = (dot00 * dot12 - dot01 * dot02) * invDenom; // Check if point is in triangle - if ((u >= -associationThreshold) && (v >= -associationThreshold) && (u + v <= 1 + associationThreshold)) + if ((u >= -associationThreshold / 100) && (v >= -associationThreshold / 100) && (u + v <= 1 + associationThreshold / 100)) { // Check if the point is close enough to the face - double maxProjectionDistance = std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) ; + double maxProjectionDistance = associationThreshold * std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) ; if ((projectedPoint - point).norm() < maxProjectionDistance) { return true; diff --git a/src/diffCheck/segmentation/DFSegmentation.cc b/src/diffCheck/segmentation/DFSegmentation.cc index 84a71244..4bbec40d 100644 --- a/src/diffCheck/segmentation/DFSegmentation.cc +++ b/src/diffCheck/segmentation/DFSegmentation.cc @@ -269,8 +269,9 @@ namespace diffCheck::segmentation for (auto normal : segment->Normals){segmentNormal += normal;} segmentNormal.normalize(); double currentDistance = (faceCenter - segmentCenter).norm(); + double currentAngle = std::abs(sin(acos(faceNormal.dot(faceCenter - segmentCenter)))); // if the distance is smaller than the previous one, update the distance and the corresponding segment - if (std::abs(sin(acos(faceNormal.dot(segmentNormal)))) < angleThreshold && currentDistance < faceDistance) + if (std::abs(sin(acos(faceNormal.dot(segmentNormal)))) < angleThreshold && currentDistance < faceDistance && std::abs(1 - currentAngle) < angleThreshold) { correspondingSegment = segment; faceDistance = currentDistance; @@ -440,7 +441,7 @@ namespace diffCheck::segmentation double currentDistance = (clusterCenter - faceCenter).norm() * std::abs(std::cos(clusterNormalToJunctionLineAngle)) / std::min(std::abs(clusterNormal.dot(faceNormal)), 0.05) ; - if (std::abs(sin(acos(faceNormal.dot(clusterNormal)))) < angleThreshold && currentDistance < distance) + if (std::abs(sin(acos(faceNormal.dot(clusterNormal)))) < angleThreshold && currentDistance < distance && std::abs(1 - std::sin(clusterNormalToJunctionLineAngle)) < associationThreshold) { goodMeshIndex = meshIndex; goodFaceIndex = faceIndex;