Skip to content

Commit b5223c8

Browse files
Improvements in point association (#139)
* WIP-UPDATE: Threshold on isoparametric coordinates on mesh face adapted in method IsPointOnFace * WIP-UPDATE: fix angle threshold for segment consideration in segmentation
1 parent 7da61c6 commit b5223c8

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/diffCheck/geometry/DFMesh.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ namespace diffCheck::geometry
129129
double dot11 = v0v1.dot(v0v1);
130130
double dot12 = v0v1.dot(v0p);
131131

132-
// Compute barycentric coordinates
132+
// 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
133133
double invDenom = 1.0 / (dot00 * dot11 - dot01 * dot01);
134134
double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
135135
double v = (dot00 * dot12 - dot01 * dot02) * invDenom;
136136

137137
// Check if point is in triangle
138-
if ((u >= -associationThreshold) && (v >= -associationThreshold) && (u + v <= 1 + associationThreshold))
138+
if ((u >= -associationThreshold / 100) && (v >= -associationThreshold / 100) && (u + v <= 1 + associationThreshold / 100))
139139
{
140140
// Check if the point is close enough to the face
141-
double maxProjectionDistance = std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) ;
141+
double maxProjectionDistance = associationThreshold * std::min({(v1 - v0).norm(), (v2 - v1).norm(), (v0 - v2).norm()}) ;
142142
if ((projectedPoint - point).norm() < maxProjectionDistance)
143143
{
144144
return true;

src/diffCheck/segmentation/DFSegmentation.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,9 @@ namespace diffCheck::segmentation
269269
for (auto normal : segment->Normals){segmentNormal += normal;}
270270
segmentNormal.normalize();
271271
double currentDistance = (faceCenter - segmentCenter).norm();
272+
double currentAngle = std::abs(sin(acos(faceNormal.dot(faceCenter - segmentCenter))));
272273
// if the distance is smaller than the previous one, update the distance and the corresponding segment
273-
if (std::abs(sin(acos(faceNormal.dot(segmentNormal)))) < angleThreshold && currentDistance < faceDistance)
274+
if (std::abs(sin(acos(faceNormal.dot(segmentNormal)))) < angleThreshold && currentDistance < faceDistance && std::abs(1 - currentAngle) < angleThreshold)
274275
{
275276
correspondingSegment = segment;
276277
faceDistance = currentDistance;
@@ -440,7 +441,7 @@ namespace diffCheck::segmentation
440441

441442
double currentDistance = (clusterCenter - faceCenter).norm() * std::abs(std::cos(clusterNormalToJunctionLineAngle))
442443
/ std::min(std::abs(clusterNormal.dot(faceNormal)), 0.05) ;
443-
if (std::abs(sin(acos(faceNormal.dot(clusterNormal)))) < angleThreshold && currentDistance < distance)
444+
if (std::abs(sin(acos(faceNormal.dot(clusterNormal)))) < angleThreshold && currentDistance < distance && std::abs(1 - std::sin(clusterNormalToJunctionLineAngle)) < associationThreshold)
444445
{
445446
goodMeshIndex = meshIndex;
446447
goodFaceIndex = faceIndex;

0 commit comments

Comments
 (0)