Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exceptions instead of exit(0) in Poisson surface reconstruction #2891

Conversation

daniel-packard
Copy link
Contributor

@daniel-packard daniel-packard commented Mar 5, 2019

fixes #2882

surface/CMakeLists.txt Outdated Show resolved Hide resolved
@@ -443,8 +444,8 @@ namespace pcl
template< int Degree >
void BSplineElements< Degree >::upSample( BSplineElements< Degree >& high ) const
{
fprintf( stderr , "[ERROR] B-spline up-sampling not supported for degree %d\n" , Degree );
exit( 0 );
fprintf (stderr, "[ERROR] B-spline up-sampling not supported for degree %d\n", Degree);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if you want me to remove these fprintf stderr log messages

Copy link
Member

Choose a reason for hiding this comment

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

I'd 👍 removal of stderr messages. Now that there are exceptions, the user can decide what to do. We will miss a bit of debug information around line 230, but I don't think it's important for a user anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in abbe953

Copy link
Member

Choose a reason for hiding this comment

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

We will miss a bit of debug information around line 230, but I don't think it's important for a user anyway.

Well, not necessarily. Exceptions do support messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before, lines ~230 were logging detailed info about each "unindexed corner" (actually only the first.. because of the exit( 0 ); )

Now it's replaced with a single exception message that only reports a count e.g. Found 37 unindexed corner nodes during openMP loop execution. without any info about the specific corners involved.

Are you proposing we build up a string that includes details about every unindexed corner?

Copy link
Member

Choose a reason for hiding this comment

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

I spoke too soon. I agree with your call. It's too much info to put on an exception.

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Some minor comments in situ. Please don't squash or rebase till we finish reviewing.

offsets[t + 1] = offsets[t] + count[t];
}

int paralellExceptionCount = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This should be unsigned.

offsets[t + 1] = offsets[t] + count[t];
}

int paralellExceptionCount = 0;
Copy link
Member

Choose a reason for hiding this comment

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

same comment.

if( d<minDepth ) fprintf( stderr , "[ERROR] Node depth lower than min-depth: %d < %d\n" , d , minDepth ) , exit( 0 );
if (d < minDepth)
{
fprintf (stderr, "[ERROR] Node depth lower than min-depth: %d < %d\n", d, minDepth);
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here.

{
sstream << "in " << file_name << " ";
if (line_number != 0)
sstream << "@ " << line_number << " ";
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

public:
PoissonBadArgumentException (const std::string& error_description,
const char* file_name = NULL,
const char* function_name = NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Same comment on the nullptr use.

public:
PoissonOpenMPException (const std::string& error_description,
const char* file_name = NULL,
const char* function_name = NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Same comment on the nullptr use.

public:
PoissonBadInitException (const std::string& error_description,
const char* file_name = NULL,
const char* function_name = NULL,
Copy link
Member

Choose a reason for hiding this comment

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

Same comment on the nullptr use.

for( int d=minDepth ; d<=maxDepth ; d++ )
for (int t = 0; t < threads; t++)
{

Copy link
Member

Choose a reason for hiding this comment

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

Awkward new line.

@daniel-packard
Copy link
Contributor Author

Addressed comments in cff47e1

Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

This looks great to me. Thank you for your effort Daniel. Shall we discuss, squashing strategy. At first sight and looking at the individual commits I think this one should all go in a single commit.

We can do this from our side, so don't worry.

@taketwo
Copy link
Member

taketwo commented Mar 7, 2019

👍 for single commit.

@daniel-packard
Copy link
Contributor Author

[...] looking at the individual commits I think this one should all go in a single commit

We can do this from our side, so don't worry.

Sounds good to me -- thanks for the detailed review/feedback!

@taketwo taketwo requested review from taketwo and removed request for taketwo March 7, 2019 17:14
@SergioRAgostinho SergioRAgostinho merged commit d923607 into PointCloudLibrary:master Mar 8, 2019
@taketwo taketwo changed the title replace exit( 0 ) in poisson module with exceptions Throw exceptions instead of exit(0) in Poisson surface reconstruction Mar 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to replace exit(0) with more flexible error handling in Poisson surface reconstruction module
3 participants