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

get rid of dynamic_cast #143

Merged
merged 1 commit into from
May 23, 2020

Conversation

v4hn
Copy link
Contributor

@v4hn v4hn commented May 21, 2020

This library does not need RTTI as all bodies & shapes are marked with type.

The EXPECT_TRUE in the test degenerates to true for all minimally-optimizing compilers.
Replaced it with something meaningful.

should be backported to melodic.

@@ -160,9 +160,11 @@ void bodies::computeBoundingSphere(const std::vector<const bodies::Body*>& bodie
unsigned int vertex_count = 0;
for (auto body : bodies)
{
const bodies::ConvexMesh* conv = dynamic_cast<const bodies::ConvexMesh*>(body);
if (!conv)
if (body->type != MESH)
Copy link
Contributor

Choose a reason for hiding this comment

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

First test if body != nullptr. The old check would rule such cases out, whether the suggested change would segfault.

@v4hn v4hn force-pushed the pr-noetic-no-dynamic-cast branch from 2fceb43 to 4dedda8 Compare May 22, 2020 19:16
@v4hn
Copy link
Contributor Author

v4hn commented May 22, 2020 via email

@rhaschke
Copy link
Contributor

@v4hn, have you seen that your code is broken? For example, you need to use type_ instead of type.

This library does not need RTTI as all bodies & shapes are marked with `type`.

The EXPECT_TRUE in the test degenerates to true for all minimally-optimizing compilers.
Replaced it with something meaningful.
@v4hn v4hn force-pushed the pr-noetic-no-dynamic-cast branch from 4dedda8 to 25d35aa Compare May 23, 2020 12:15
@v4hn
Copy link
Contributor Author

v4hn commented May 23, 2020 via email

@codecov-commenter
Copy link

Codecov Report

Merging #143 into noetic-devel will increase coverage by 7.59%.
The diff coverage is 25.00%.

Impacted file tree graph

@@               Coverage Diff                @@
##           noetic-devel     #143      +/-   ##
================================================
+ Coverage         48.01%   55.60%   +7.59%     
================================================
  Files                11       11              
  Lines              1689     1721      +32     
================================================
+ Hits                811      957     +146     
+ Misses              878      764     -114     
Impacted Files Coverage Δ
src/body_operations.cpp 47.47% <25.00%> (+25.08%) ⬆️
include/geometric_shapes/bodies.h 84.90% <0.00%> (ø)
src/bodies.cpp 69.79% <0.00%> (+1.19%) ⬆️
src/mesh_operations.cpp 43.77% <0.00%> (+12.79%) ⬆️
src/shape_operations.cpp 33.33% <0.00%> (+17.59%) ⬆️
src/shape_to_marker.cpp 56.14% <0.00%> (+54.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a40825a...25d35aa. Read the comment docs.

@rhaschke rhaschke merged commit f1f81a5 into moveit:noetic-devel May 23, 2020
rhaschke pushed a commit to rhaschke/geometric_shapes that referenced this pull request May 25, 2020
This library does not need RTTI as all bodies & shapes are marked with a `type`.
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.

4 participants