Repository navigation
Conversation
…e to a mesh AABB tree built once, queried from all threads without the GIL. Side from Side_of_triangle_mesh (exact predicates): a query on the mesh is at distance exactly zero and takes the angle-weighted pseudonormal of its feature.
Faces are sorted to the isovalues they cross in one pass; refine_mesh_at_isolevel runs per isovalue on those faces only. Each polyline comes with the index of its isovalue. Also loads the bound vector types in the module itself.
A face with its three vertices on one line has no normal: the gradient of a query on it came back NaN, and the mesh was accepted. The constructor now refuses it, decided with CGAL's exact predicate (PMP::is_degenerate_triangle_face), so a face whose cross product rounds off zero in floats is found too.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed distance to a mesh, and isolines for many isovalues
Two additions for querying one mesh many times. Existing functions are unchanged.
compas_cgal.distance.MeshDistance(new module)closest(points)returns the closest points and the face each lies on;signed_distance(points)returns the distance (negative inside), the closest point, the face and the gradient. Numpy arrays in and out.AABB_treeis built once in the constructor and shared by every query.Side_of_triangle_mesh, with exact predicates and independently of the closest point. A query on the mesh is at distance exactly zero, and its gradient is the angle-weighted pseudonormal of the face, edge or vertex it lies on (the faces containing it are found withall_intersected_primitives).num_threads) and release the GIL. The result is the same, bit for bit, whatever the number of threads.compas_cgal.isolines.isolines_with_indices(vertices, faces), a scalar per vertex and a list of isovalues; returns the polylines and, for each, the index of its isovalue.isolinesrebuilds the whole mesh for every isovalue: an isovalue that crosses no face still costs 27 ms on the mesh below. Here the faces are sorted to the isovalues they cross in one pass, andrefine_mesh_at_isolevelruns per isovalue on those faces only.isolinesreturns, bit for bit. Where a closed polyline starts, its direction, and the order of the polylines of one isovalue may differ.Validation
isolines_with_indicesagainstisolines, isovalue by isovalue: on a sphere, and on an open grid whose isovalues run through whole columns of vertices.Performance
Apple M1 Max, 10 hardware threads; CGAL 6.1.1, Apple clang 17, the repository's build flags. Mesh: closed, genus 4, 58,060 vertices, 116,132 faces.
Near the surface
MeshDistanceis 1.7x faster than libigl; far from it libigl is 1.35x faster, and there the closest-point search is nearly all of the time (2.55 of 2.68 us).Notes
_distanceis compiled withCGAL_HAS_THREADSand linked against the platform's thread library, so that CGAL guards what it builds lazily. The other modules' flags are unchanged.compas_cgal.isolinesraisedTypeError: incompatible function argumentsfor a list of isovalues unless a module that loads the bound vector types (compas_cgal.geodesics, for one) had been imported first. It now loads them itself; a test imports the module alone in a fresh interpreter.signed_distancehas to be closed, manifold, free of self-intersections and without degenerate faces. Closedness and manifoldness are checked; the other two are not.-O3in place of the-Osthat nanobind applies changed the query times by about 5%.