Skip to content

Conversation

@nawazishkhan1-nk
Copy link
Contributor

@nawazishkhan1-nk nawazishkhan1-nk commented Apr 5, 2023

[WIP] - Do Not Merge

Summary

This PR addresses issue #2040.

Changes Made

  • Non-breaking change: Added a new distance method in Mesh class to compute symmetric point-to-cell distances.
  • Included this method in the ShapeWorks Python API.
  • Temporarily called it in ShapeWorks Studio Viewer when surface-to-surface distance is checked.

Testing Done

  • Tested the new distance method using different meshes.
  • Checked that the ShapeWorks Studio Viewer and API calls run without errors.

Known Issues

  • None at this time.

Screenshots

Symmetric Point-to-cell distance vs. regular Point-to-cell distance
Screen Shot 2023-04-05 at 8 28 20 AM

Copy link
Contributor

@akenmorris akenmorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple minor things.

auto field = m.distance(m2)[0];
auto field = m.distance(m2, Mesh::DistanceMethod::SymmetricPointToCell)[0];
// TODO: disable debug
std::cout << "Debug Mode | Computing distance with SymmetricPointToCell method in Studio Viewer " << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K, let's remove this debug line and I think it's good to go.

referenceMesh (point) -> targetMesh (cell) (and get closestPoint)
referenceMesh (cell) -> targetMesh (closestPoint)
*/
auto targetCellLocator = vtkSmartPointer<vtkCellLocator>::New();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the faster vtkStaticCellLocator

targetCellLocator->SetDataSet(target.poly_data_);
targetCellLocator->BuildLocator();

auto refCellLocator = vtkSmartPointer<vtkCellLocator>::New();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vtkStaticCellLocator as above

@ben2k
Copy link
Contributor

ben2k commented Apr 26, 2023

Hello, I propose also to add the signed point-to-cell metric, I will amend the commit

}
} break;

case SymmetricPointToCell: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a unit test for that case ?

@akenmorris
Copy link
Contributor

@nawazishkhan1-nk , do you have an update on the PR?

@akenmorris
Copy link
Contributor

@nawazishkhan1-nk , any update on this?

@nawazishkhan1-nk nawazishkhan1-nk marked this pull request as draft August 13, 2024 22:44
@ben2k
Copy link
Contributor

ben2k commented Aug 27, 2024

Hello, I propose also to add the signed point-to-cell metric, I will amend the commit

I don't have the time but I suggest we add the signed point-to-cell metric: the sign is defined as follow:

// Determine the signed distance
const Vector normal = in_transfo * in_normals[i]; // get the normal of source mesh for vertex i
const Vector v = closest_point_ref_i - point[i]; // get the vector between the closest point in the reference and the vertex i
signed_distance = sign( dot(v, normal) ) * norm(closest_point_ref_i - point[i]);

@ben2k
Copy link
Contributor

ben2k commented Aug 27, 2024

Additionally, instead of this symmetric distance (that will never be higher than traditional point-to-cell metric), I would propose that we implement the Chamfer Distance (sum of A to B and B to A distances) which is used in numerous publications to compare mesh to mesh.

@akenmorris
Copy link
Contributor

Additionally, instead of this symmetric distance (that will never be higher than traditional point-to-cell metric), I would propose that we implement the Chamfer Distance (sum of A to B and B to A distances) which is used in numerous publications to compare mesh to mesh.

The Chamfer Distance, as far as I can find, is only defined for point sets. Do you propose to use vertices only and not the point to cell distance?

@ben2k
Copy link
Contributor

ben2k commented Aug 28, 2024

Additionally, instead of this symmetric distance (that will never be higher than traditional point-to-cell metric), I would propose that we implement the Chamfer Distance (sum of A to B and B to A distances) which is used in numerous publications to compare mesh to mesh.

The Chamfer Distance, as far as I can find, is only defined for point sets. Do you propose to use vertices only and not the point to cell distance?

Yes from point sets only.

It would be an additional metric along signed and absolute point-to-cell distances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants