Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in point association #139

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/diffCheck/geometry/DFMesh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/diffCheck/segmentation/DFSegmentation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading