Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bindings/python/src/geometry/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@

namespace geode
{
void define_sign( pybind11::module& module )

Check warning on line 33 in bindings/python/src/geometry/sign.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/geometry/sign.cpp:33:10 [misc-use-internal-linkage]

function 'define_sign' can be made static or moved into an anonymous namespace to enforce internal linkage
{
module.def( "tetrahedron_volume_sign", &tetrahedron_volume_sign );
module.def( "triangle_area_sign2D",
static_cast< Sign ( * )( const Triangle2D& ) >(
static_cast< SIGN ( * )( const Triangle2D& ) >(
&triangle_area_sign ) );
module.def( "triangle_area_sign3D",
static_cast< Sign ( * )( const Triangle3D&, local_index_t ) >(
static_cast< SIGN ( * )( const Triangle3D&, local_index_t ) >(
&triangle_area_sign ) );
}
} // namespace geode
2 changes: 1 addition & 1 deletion include/geode/geometry/information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@

namespace geode
{
enum struct SIDE

Check warning on line 30 in include/geode/geometry/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/information.hpp:30:17 [performance-enum-size]

enum 'SIDE' uses a larger base type ('int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size
{
positive,
negative,
zero
};

using Sign = SIDE;
using SIGN = SIDE;

enum struct POSITION

Check warning on line 39 in include/geode/geometry/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/geometry/information.hpp:39:17 [performance-enum-size]

enum 'POSITION' uses a larger base type ('int', size: 4 bytes) than necessary for its value set, consider using 'std::uint8_t' (1 byte) as the base type to reduce its size
{
// Strictly outside
outside,
Expand Down
10 changes: 5 additions & 5 deletions include/geode/geometry/sign.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ namespace geode
ALIAS_2D( Polygon );
class Tetrahedron;
enum struct SIDE;
using Sign = SIDE;
using SIGN = SIDE;
} // namespace geode

namespace geode
{
/*!
* Return the sign of a tetrahedron volume.
*/
[[nodiscard]] Sign opengeode_geometry_api tetrahedron_volume_sign(
[[nodiscard]] SIGN opengeode_geometry_api tetrahedron_volume_sign(
const Tetrahedron& tetra );

/*!
* Return the sign of a 2D triangle area.
*/
[[nodiscard]] Sign opengeode_geometry_api triangle_area_sign(
[[nodiscard]] SIGN opengeode_geometry_api triangle_area_sign(
const Triangle2D& triangle );

[[nodiscard]] Sign opengeode_geometry_api polygon_area_sign(
[[nodiscard]] SIGN opengeode_geometry_api polygon_area_sign(
const Polygon2D& polygon );

/*!
* Return the sign of a 3D triangle area aligned on X- Y- or Z-axis.
*/
[[nodiscard]] Sign opengeode_geometry_api triangle_area_sign(
[[nodiscard]] SIGN opengeode_geometry_api triangle_area_sign(
const Triangle3D& triangle, local_index_t axis );
} // namespace geode
2 changes: 1 addition & 1 deletion src/geode/geometry/intersection_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
return largest_axis;
}

geode::SegmentSegmentIntersection segment_segment_intersection_detection2D(

Check warning on line 75 in src/geode/geometry/intersection_detection.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/intersection_detection.cpp:75:39 [readability-identifier-naming]

invalid case style for function 'segment_segment_intersection_detection2D'

Check warning on line 75 in src/geode/geometry/intersection_detection.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/intersection_detection.cpp:75:39 [readability-function-cognitive-complexity]

function 'segment_segment_intersection_detection2D' has cognitive complexity of 17 (threshold 10)
const geode::Segment2D& segment0, const geode::Segment2D& segment1 )
{
const auto s0_p0_side =
Expand Down Expand Up @@ -128,7 +128,7 @@
}

geode::SegmentTriangleIntersection
segment_triangle_plane_intersection_detection(

Check warning on line 131 in src/geode/geometry/intersection_detection.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/intersection_detection.cpp:131:9 [readability-function-cognitive-complexity]

function 'segment_triangle_plane_intersection_detection' has cognitive complexity of 17 (threshold 10)
const geode::Segment3D& segment, const geode::Triangle3D& triangle )
{
const auto projection_axis = best_projection_axis( triangle, segment );
Expand Down Expand Up @@ -191,13 +191,13 @@
return result;
}

geode::SegmentSegmentIntersection segment_segment_intersection_detection3D(

Check warning on line 194 in src/geode/geometry/intersection_detection.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/intersection_detection.cpp:194:39 [readability-identifier-naming]

invalid case style for function 'segment_segment_intersection_detection3D'
const geode::Segment3D& segment0, const geode::Segment3D& segment1 )
{
if( geode::tetrahedron_volume_sign( geode::Tetrahedron{
segment0.vertices()[0].get(), segment0.vertices()[1].get(),
segment1.vertices()[0].get(), segment1.vertices()[1].get() } )
!= geode::Sign::zero )
!= geode::SIGN::zero )
{
return { geode::POSITION::outside, geode::POSITION::outside };
}
Expand Down Expand Up @@ -248,7 +248,7 @@
return segment_segment_intersection_detection3D( segment0, segment1 );
}

SegmentSegmentIntersection colinear_segment_segment_intersection_detection(

Check warning on line 251 in src/geode/geometry/intersection_detection.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/intersection_detection.cpp:251:32 [readability-function-cognitive-complexity]

function 'colinear_segment_segment_intersection_detection' has cognitive complexity of 18 (threshold 10)
const Segment2D& segment0, const Segment2D& segment1 )
{
OpenGeodeGeometryException::check_assertion(
Expand Down
12 changes: 6 additions & 6 deletions src/geode/geometry/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

namespace
{
const std::array< std::array< geode::local_index_t, 2 >, 3 > new_axis{

Check warning on line 34 in src/geode/geometry/sign.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/sign.cpp:34:66 [readability-identifier-naming]

invalid case style for global constant 'new_axis'
{ std::array< geode::local_index_t, 2 >{ { 1, 2 } },
std::array< geode::local_index_t, 2 >{ { 2, 0 } },
std::array< geode::local_index_t, 2 >{ { 0, 1 } } }
Expand All @@ -40,39 +40,39 @@

namespace geode
{
Sign tetrahedron_volume_sign( const Tetrahedron& tetra )
SIGN tetrahedron_volume_sign( const Tetrahedron& tetra )
{
const auto& vertices = tetra.vertices();
return internal::side( GEO::PCK::orient_3d(
vertices[0], vertices[1], vertices[2], vertices[3] ) );
}

Sign triangle_area_sign( const Triangle2D& triangle )
SIGN triangle_area_sign( const Triangle2D& triangle )
{
const auto& vertices = triangle.vertices();
return internal::side(
GEO::PCK::orient_2d( vertices[0], vertices[1], vertices[2] ) );
}

Sign polygon_area_sign( const Polygon2D& polygon )
SIGN polygon_area_sign( const Polygon2D& polygon )
{
const auto& polygon_vertices = polygon.vertices();
const auto& p1 = polygon_vertices[0];

Check warning on line 60 in src/geode/geometry/sign.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/geometry/sign.cpp:60:21 [readability-identifier-length]

variable name 'p1' is too short, expected at least 3 characters
for( const auto other_index : LRange{ 1, polygon_vertices.size() - 1 } )
{
const auto& p2 = polygon_vertices[other_index];
const auto& p3 = polygon_vertices[static_cast< local_index_t >(
other_index + 1 )];
const auto sign = triangle_area_sign( { p1, p2, p3 } );
if( sign != Sign::zero )
if( sign != SIGN::zero )
{
return sign;
}
}
return geode::Sign::zero;
return geode::SIGN::zero;
}

Sign triangle_area_sign( const Triangle3D& triangle, local_index_t axis )
SIGN triangle_area_sign( const Triangle3D& triangle, local_index_t axis )
{
const auto axis1 = new_axis[axis][0];
const auto axis2 = new_axis[axis][1];
Expand Down
24 changes: 12 additions & 12 deletions src/geode/mesh/helpers/repair_polygon_orientations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,30 +158,30 @@ namespace
{
polygons_area_sign_info( geode::index_t nb_init,
geode::index_t nb_polygons,
geode::Sign sign_init )
geode::SIGN sign_init )
: nb_bad_polygons{ nb_init }, area_sign{ nb_polygons, sign_init }
{
}

geode::index_t nb_bad_polygons;
std::queue< geode::index_t > queue;
absl::FixedArray< geode::Sign > area_sign;
absl::FixedArray< geode::SIGN > area_sign;
};

polygons_area_sign_info compute_polygon_area_sign(
const geode::SurfaceMesh2D& mesh )
{
polygons_area_sign_info area_sign_info{ 0, mesh.nb_polygons(),
geode::Sign::zero };
geode::SIGN::zero };
for( const auto polygon_id : geode::Range{ mesh.nb_polygons() } )
{
area_sign_info.area_sign[polygon_id] =
geode::polygon_area_sign( mesh.polygon( polygon_id ) );
if( area_sign_info.area_sign[polygon_id] == geode::Sign::negative )
if( area_sign_info.area_sign[polygon_id] == geode::SIGN::negative )
{
area_sign_info.nb_bad_polygons++;
}
else if( area_sign_info.area_sign[polygon_id] == geode::Sign::zero )
else if( area_sign_info.area_sign[polygon_id] == geode::SIGN::zero )
{
area_sign_info.queue.emplace( polygon_id );
}
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace
}
const auto adj = mesh.polygon_adjacent_edge( edge ).value();
if( area_sign_info.area_sign[adj.polygon_id]
== geode::Sign::zero )
== geode::SIGN::zero )
{
continue;
}
Expand All @@ -227,24 +227,24 @@ namespace
break;
}
if( area_sign_info.area_sign[adj.polygon_id]
== geode::Sign::positive )
== geode::SIGN::positive )
{
area_sign_info.area_sign[cur_polygon] =
geode::Sign::negative;
geode::SIGN::negative;
}
else
{
area_sign_info.area_sign[cur_polygon] =
geode::Sign::positive;
geode::SIGN::positive;
}
break;
}
if( area_sign_info.area_sign[cur_polygon] == geode::Sign::zero )
if( area_sign_info.area_sign[cur_polygon] == geode::SIGN::zero )
{
area_sign_info.queue.emplace( cur_polygon );
}
else if( area_sign_info.area_sign[cur_polygon]
== geode::Sign::negative )
== geode::SIGN::negative )
{
area_sign_info.nb_bad_polygons++;
}
Expand All @@ -267,7 +267,7 @@ namespace
geode::index_t count{ 0 };
for( const auto p : geode::Range{ mesh.nb_polygons() } )
{
if( area_sign_info.area_sign[p] == geode::Sign::negative )
if( area_sign_info.area_sign[p] == geode::SIGN::negative )
{
bad_polygons[count++] = p;
}
Expand Down
Loading