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

SAC Models Refactoring: getClassName() #1071

Merged
merged 3 commits into from
Jan 10, 2015

Conversation

taketwo
Copy link
Member

@taketwo taketwo commented Jan 8, 2015

I have came across a bug in SAC Sphere model. While investigating how to fix it I have dug in the model sources and was surprised by a large amount of code repetition. Therefore, I decided to do a bit of refactoring together with fixing the bug. I will submit the changes in a series of pull request to simplify review process.

This pull request adds getClassName() function to all SAC models. (The same kind of function is contained in many other PCL classes such as Filter, Registration, Feature, etc.). It comes in handy e.g. when logging errors.

The same kind of function is contained in many other PCL classes (e.g.
Filter, Registration, Feature).
The function is obsoleted by getClassName().
@jspricke
Copy link
Member

jspricke commented Jan 8, 2015

I'm a little biased here. Isn't it the same as typeid().name()? On the other side, a consistent API is nice as well.

@taketwo
Copy link
Member Author

taketwo commented Jan 9, 2015

Isn't it the same as typeid().name()?

No, it is different. typeid produces a mangled name, e.g.:

 std::cout << typeid(pcl::SampleConsensusModelLine<pcl::PointXYZ>).name()

Will output something like N3pcl24SampleConsensusModelLineINS_8PointXYZEEE. I guess this is precisely the reason why other PCL classes have such getClassName() function.

By the way, recent versions of Boost feature new "TypeIndex" library, which provides desired output:

std::cout << boost::typeindex::type_id<pcl::SampleConsensusModelLine<pcl::PointXYZ>>().pretty_name()

gives pcl::SampleConsensusModelLine<pcl::PointXYZ> (at least on clang). But it is just too new for us anyways.

@jspricke
Copy link
Member

jspricke commented Jan 9, 2015

Just pipe it thought c++filt ;).

@taketwo
Copy link
Member Author

taketwo commented Jan 10, 2015

@jspricke I'm not sure if I understood your comment. If this is a joke, then can we merge and move on? If it's not, then could you please elaborate on what exactly you propose?

@jspricke
Copy link
Member

Sorry, that wasn't meant as an offense. c++filt is part of binutils and can unmangle the type name:
$ c++filt -t N3pcl24SampleConsensusModelLineINS_8PointXYZEEE pcl::SampleConsensusModelLine<pcl::PointXYZ>
But I guess it's not so well known, so I would be ok with merging this.

@taketwo
Copy link
Member Author

taketwo commented Jan 10, 2015

I know what c++filt is, it's just that I do not understand how it is relevant here. A typical usage for getClassName() would be (this example is taken from Feature class):

PCL_ERROR ("[pcl::%s::initCompute] No input dataset containing normals was given!\n", getClassName ().c_str ());

Of course, we can print mangled name here, but then the user will get nonsense messages unless he manually pipes program output through c++filt. (Also, what about Windows users?)

No offense taken, I simply didn't understand your idea :)

jspricke added a commit that referenced this pull request Jan 10, 2015
SAC Models Refactoring: getClassName()
@jspricke jspricke merged commit eb3fafa into PointCloudLibrary:master Jan 10, 2015
@jspricke
Copy link
Member

I don't care about Windows users ;)

@taketwo taketwo deleted the sac-refactoring-1 branch January 10, 2015 18:09
@SergioRAgostinho SergioRAgostinho mentioned this pull request Dec 12, 2015
7 tasks
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.

2 participants