-
Notifications
You must be signed in to change notification settings - Fork 35
Mesh distance symmetric #2041
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
base: master
Are you sure you want to change the base?
Mesh distance symmetric #2041
Changes from all commits
9bd0e2d
6bff57e
6e04dbe
5774a01
ef0ba1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -680,6 +680,42 @@ std::vector<Field> Mesh::distance(const Mesh& target, const DistanceMethod metho | |
| } | ||
| } break; | ||
|
|
||
| case SymmetricPointToCell: { | ||
| /* | ||
| referenceMesh (point) -> targetMesh (cell) (and get closestPoint) | ||
| referenceMesh (cell) -> targetMesh (closestPoint) | ||
| */ | ||
| auto targetCellLocator = vtkSmartPointer<vtkCellLocator>::New(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vtkStaticCellLocator as above |
||
| refCellLocator->SetDataSet(poly_data_); | ||
| refCellLocator->BuildLocator(); | ||
|
|
||
| double dist2_target, dist2_ref; | ||
| auto cell_target = vtkSmartPointer<vtkGenericCell>::New(); | ||
| auto cell_ref = vtkSmartPointer<vtkGenericCell>::New(); | ||
| vtkIdType cellId_target, cellId_ref; | ||
| int subId_target, subId_ref; | ||
| Point3 closestPoint_target, closestPoint_ref; | ||
|
|
||
|
|
||
| for (int i = 0; i < numPoints(); i++) { | ||
| poly_data_->GetPoint(i, currentPoint.GetDataPointer()); // ref point | ||
| // ref mesh point -> target mesh cell | ||
| targetCellLocator->FindClosestPoint(currentPoint.GetDataPointer(), closestPoint_target.GetDataPointer(), cell_target, cellId_target, | ||
| subId_target, dist2_target); | ||
| // target mesh closest point -> ref mesh cell | ||
| refCellLocator->FindClosestPoint(closestPoint_target.GetDataPointer(), closestPoint_ref.GetDataPointer(), cell_ref, cellId_ref, | ||
| subId_ref, dist2_ref); | ||
|
|
||
| ids->SetValue(i, cellId_target); | ||
| auto mean_sym_dist = (std::sqrt(dist2_target) + std::sqrt(dist2_ref))/2; | ||
| distance->SetValue(i, mean_sym_dist); | ||
| } | ||
| } break; | ||
|
|
||
| default: | ||
| throw std::invalid_argument("invalid distance method"); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -734,7 +734,9 @@ void Viewer::display_shape(std::shared_ptr<Shape> shape) { | |
| } | ||
|
|
||
| Mesh m2(compare_poly_data); | ||
| 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; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| m.setField("distance", field, Mesh::Point); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
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 ?