forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[geometry] Add zero_simplex_manual_test (RobotLocomotion#20323)
This is a developer convenience for quick evaluation of volume meshes.
- Loading branch information
1 parent
47cd611
commit 7cb258c
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <gflags/gflags.h> | ||
|
||
#include "drake/common/text_logging.h" | ||
#include "drake/geometry/proximity/detect_zero_simplex.h" | ||
#include "drake/geometry/proximity/vtk_to_volume_mesh.h" | ||
|
||
DEFINE_bool(expect_fail, false, | ||
"expect to find zero simplices; reverses the success/fail logic"); | ||
|
||
namespace drake { | ||
namespace geometry { | ||
namespace internal { | ||
namespace { | ||
|
||
int do_main(int argc, char* argv[]) { | ||
gflags::SetUsageMessage( | ||
"[INPUT-VTK-FILE]\n" | ||
"Run zero simplex checks; summarize zero simplices;" | ||
" fail if any are found unless --expect_fail is set"); | ||
gflags::ParseCommandLineFlags(&argc, &argv, true); | ||
if (argc < 2) { | ||
drake::log()->error("missing input filename"); | ||
return 1; | ||
} | ||
|
||
auto mesh = ReadVtkToVolumeMesh(argv[1]); | ||
auto bad_tets = DetectTetrahedronWithAllBoundaryVertices(mesh); | ||
auto bad_triangles = DetectInteriorTriangleWithAllBoundaryVertices(mesh); | ||
auto bad_edges = DetectInteriorEdgeWithAllBoundaryVertices(mesh); | ||
|
||
drake::log()->info( | ||
"Found {} bad tetrahedra, {} bad triangles, and {} bad " | ||
"edges from total {} tetrahedra.", | ||
bad_tets.size(), bad_triangles.size(), bad_edges.size(), | ||
mesh.num_elements()); | ||
bool found_bad = | ||
(!bad_tets.empty() || !bad_triangles.empty() || !bad_edges.empty()); | ||
return found_bad ^ FLAGS_expect_fail; | ||
} | ||
|
||
} // namespace | ||
} // namespace internal | ||
} // namespace geometry | ||
} // namespace drake | ||
|
||
int main(int argc, char* argv[]) { | ||
return drake::geometry::internal::do_main(argc, argv); | ||
} |