diff --git a/include/geode/inspector/criterion/negative_elements/surface_negative_elements.hpp b/include/geode/inspector/criterion/negative_elements/surface_negative_elements.hpp index 4ef1379..ebde0c7 100644 --- a/include/geode/inspector/criterion/negative_elements/surface_negative_elements.hpp +++ b/include/geode/inspector/criterion/negative_elements/surface_negative_elements.hpp @@ -42,7 +42,6 @@ namespace geode class opengeode_inspector_inspector_api SurfaceMeshNegativeElements { OPENGEODE_DISABLE_COPY( SurfaceMeshNegativeElements ); - OPENGEODE_TEMPLATE_ASSERT_2D( dimension ); public: explicit SurfaceMeshNegativeElements( diff --git a/include/geode/inspector/surface_inspector.hpp b/include/geode/inspector/surface_inspector.hpp index 89e4a4b..74507f5 100644 --- a/include/geode/inspector/surface_inspector.hpp +++ b/include/geode/inspector/surface_inspector.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace geode @@ -57,6 +58,9 @@ namespace geode InspectionIssues< std::pair< index_t, index_t > > intersecting_elements{ "Intersection between mesh elements not tested" }; + InspectionIssues< index_t > negative_polygons{ + "Negative polygons not tested" + }; [[nodiscard]] index_t nb_issues() const; @@ -71,6 +75,8 @@ namespace geode * @extends SurfaceMeshDegeneration * @extends SurfaceMeshEdgeManifold * @extends SurfaceMeshVertexManifold + * @extends SurfaceMeshIntersections + * @extends SurfaceMeshNegativeElements */ template < index_t dimension > class SurfaceMeshInspector : public AddInspectors< SurfaceMesh< dimension >, @@ -79,7 +85,8 @@ namespace geode SurfaceMeshDegeneration< dimension >, SurfaceMeshEdgeManifold< dimension >, SurfaceMeshVertexManifold< dimension >, - SurfaceMeshIntersections< dimension > > + SurfaceMeshIntersections< dimension >, + SurfaceMeshNegativeElements< dimension > > { OPENGEODE_DISABLE_COPY( SurfaceMeshInspector ); diff --git a/src/geode/inspector/criterion/negative_elements/surface_negative_elements.cpp b/src/geode/inspector/criterion/negative_elements/surface_negative_elements.cpp index 4774ba1..3e2fb35 100644 --- a/src/geode/inspector/criterion/negative_elements/surface_negative_elements.cpp +++ b/src/geode/inspector/criterion/negative_elements/surface_negative_elements.cpp @@ -44,11 +44,15 @@ namespace geode bool mesh_has_negative_elements() const { - for( const auto polygon_id : Range{ mesh_.nb_polygons() } ) + if constexpr( dimension == 2 ) { - if( polygon_has_negative_area( polygon_id ) ) + for( const auto polygon_id : Range{ mesh_.nb_polygons() } ) { - return true; + if( polygon_area_sign( mesh_.polygon( polygon_id ) ) + == Sign::negative ) + { + return true; + } } } return false; @@ -59,24 +63,21 @@ namespace geode InspectionIssues< index_t > wrong_polygons{ "negative area polygons" }; - for( const auto polygon_id : Range{ mesh_.nb_polygons() } ) + if constexpr( dimension == 2 ) { - if( polygon_has_negative_area( polygon_id ) ) + for( const auto polygon_id : Range{ mesh_.nb_polygons() } ) { - wrong_polygons.add_issue( polygon_id, - absl::StrCat( "negative polygon ", polygon_id ) ); + if( polygon_area_sign( mesh_.polygon( polygon_id ) ) + == Sign::negative ) + { + wrong_polygons.add_issue( polygon_id, + absl::StrCat( "negative polygon ", polygon_id ) ); + } } } return wrong_polygons; } - private: - bool polygon_has_negative_area( index_t polygon_id ) const - { - return polygon_area_sign( mesh_.polygon( polygon_id ) ) - == Sign::negative; - } - private: const SurfaceMesh< dimension >& mesh_; }; @@ -108,4 +109,6 @@ namespace geode template class opengeode_inspector_inspector_api SurfaceMeshNegativeElements< 2 >; + template class opengeode_inspector_inspector_api + SurfaceMeshNegativeElements< 3 >; } // namespace geode diff --git a/src/geode/inspector/surface_inspector.cpp b/src/geode/inspector/surface_inspector.cpp index 01d1869..3b90c8e 100644 --- a/src/geode/inspector/surface_inspector.cpp +++ b/src/geode/inspector/surface_inspector.cpp @@ -37,7 +37,8 @@ namespace geode + degenerated_polygons.nb_issues() + non_manifold_edges.nb_issues() + non_manifold_vertices.nb_issues() - + intersecting_elements.nb_issues(); + + intersecting_elements.nb_issues() + + negative_polygons.nb_issues(); } std::string SurfaceInspectionResult::string() const @@ -45,7 +46,8 @@ namespace geode return absl::StrCat( polygon_edges_with_wrong_adjacency.string(), colocated_points_groups.string(), degenerated_edges.string(), degenerated_polygons.string(), non_manifold_edges.string(), - non_manifold_vertices.string(), intersecting_elements.string() ); + non_manifold_vertices.string(), intersecting_elements.string(), + negative_polygons.string() ); } std::string SurfaceInspectionResult::inspection_type() const @@ -62,7 +64,8 @@ namespace geode SurfaceMeshDegeneration< dimension >, SurfaceMeshEdgeManifold< dimension >, SurfaceMeshVertexManifold< dimension >, - SurfaceMeshIntersections< dimension > >{ mesh } + SurfaceMeshIntersections< dimension >, + SurfaceMeshNegativeElements< dimension > >{ mesh } { } @@ -94,6 +97,9 @@ namespace geode }, [&result, this] { result.intersecting_elements = this->intersecting_elements(); + }, + [&result, this] { + result.negative_polygons = this->negative_polygons(); } ); return result; }