Skip to content

Conversation

@magnesj
Copy link
Member

@magnesj magnesj commented Oct 15, 2025

Closes #13022

Replaces assertions with more robust error handling in GeometryTools functions. This prevents unexpected program termination due to assertion failures, especially when dealing with potentially invalid or unexpected input data. Specifically, it adds checks for null pointers and invalid indices,
returning early or using fallback values to maintain program stability.
@magnesj magnesj requested a review from kriben October 15, 2025 08:09
Vec3Type s;
if ( polygon.empty() )
{
return Vec3Type::ZERO;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZERO is not a good choice here, as it also a valid value. Vec3Type::UNDEFINED is better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that is wrong to assert here either, if it is a programmer error?

{
CVF_ASSERT( polygon );
CVF_ASSERT( createdVertexes );
if ( !polygon || !createdVertexes ) return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert was only needed because the original api was wrong.

double tolerance )
{
CVF_ASSERT( polygon );
if ( !polygon ) return false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad api: polygon should be a reference since it is always needed?

@magnesj magnesj marked this pull request as draft October 15, 2025 11:05
@magnesj magnesj closed this Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid assert in geometry calculations

3 participants