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

[SofaBaseMechanics] Clean barycentric mapping #797

Merged
merged 17 commits into from
Dec 5, 2018

Conversation

EulalieCoevoet
Copy link
Contributor

@EulalieCoevoet EulalieCoevoet commented Oct 23, 2018

Cleaning and refactoring in BarycentricMapping (only for topology container)

description from comment below:

Sure, sorry. So I wanted to optimize the initialization of BarycentricMapping, see issue #784 for clear description of the problem.

To avoid more duplication of code, and to allow the optimization to be available for a maximum of topology types, I needed the code to be refactored.

So:

  1. I created an abstract class (BarycentricMapperTopologyContainer) that gather the shared implementations of BarycentricMapperEdgeSetTopology, BarycentricMapperTriangleSetTopology, BarycentricMapperQuadSetTopology, BarycentricMapperTetrahedronSetTopology, and BarycentricMapperHexahedronSetTopology.

  2. Enabeling to refactor the apply(), applyJ(), applyJT(), getJ(), draw() functions and more importantly the function I want to optimize, init().

The PR also include some cleaning, in particular the renaming of variables. That could indeed break not updated code.

What I couldn't do, is to also refactor the code of BarycentricMapperMeshTopology...


This PR:

  • builds with SUCCESS for all platforms on the CI.
  • does not generate new warnings.
  • does not generate new unit test failures.
  • does not generate new scene test failures.
  • does not break API compatibility.
  • is more than 1 week old (or has fast-merge label).

Reviewers will merge only if all these checks are true.

…opologyContainer part)

1-variable renaming with sofa prefix
2-added parent class (BarycentricMapperTopologyContainer) to gather duplicated codes
3-added templates
…opologyContainer part)

Major refactoring:
1-added template on element type
2-removed apply, applyJ, applyJT, getJ, draw and init functions from child to BarycentricMapperTopologyContainer
@EulalieCoevoet EulalieCoevoet added the pr: clean Cleaning the code label Oct 23, 2018
@EulalieCoevoet EulalieCoevoet added the refactoring Refactor code label Oct 23, 2018
@damienmarchal damienmarchal added the pr: status to review To notify reviewers to review this pull-request label Oct 23, 2018
@guparan
Copy link
Contributor

guparan commented Oct 24, 2018

Thanks for this massive PR @EulalieCoevoet 👍

Here is the error output for CentOS build:

In file included from /usr/include/boost/intrusive_ptr.hpp:16:
/usr/include/boost/smart_ptr/intrusive_ptr.hpp:68:34: error: use of undeclared identifier 'intrusive_ptr_add_ref'
        if( px != 0 && add_ref ) intrusive_ptr_add_ref( px );
                                 ^
/builds/workspace/sofa-framework/PR-798/centos_clang-3.4_options_release/src/SofaKernel/framework/sofa/core/../../sofa/core/objectmodel/SPtr.h:56:28: note: in instantiation of member function 'boost::intrusive_ptr<sofa::component::mapping::BarycentricMapperEdgeSetTopology<Vec3dTypes, ExtVec3fTypes> >::intrusive_ptr' requested here
    New(Args&& ... args) : SPtr( new T(std::forward<Args>(args)...) ) { }
                           ^
/builds/workspace/sofa-framework/PR-798/centos_clang-3.4_options_release/src/SofaKernel/SofaBase/../modules/SofaBaseMechanics/BarycentricMapping.inl:973:40: note: in instantiation of function template specialization 'sofa::core::objectmodel::New<sofa::component::mapping::BarycentricMapperEdgeSetTopology<Vec3dTypes, ExtVec3fTypes> >::New<sofa::component::topology::EdgeSetTopologyContainer *&, sofa::component::topology::PointSetTopologyContainer *&>' requested here
                            m_mapper = sofa::core::objectmodel::New<EdgeSetMapper>(t5, toTopoCont);
                                       ^

SofaCUDA seems also to be a problem on Linux build.

@guparan
Copy link
Contributor

guparan commented Oct 24, 2018

Could we have a bit more details about what you did and why you did it please ?

@EulalieCoevoet
Copy link
Contributor Author

EulalieCoevoet commented Oct 24, 2018

Sure, sorry. So I wanted to optimize the initialization of BarycentricMapping, see issue #784 for clear description of the problem.

To avoid more duplication of code, and to allow the optimization to be available for a maximum of topology types, I needed the code to be refactored.

So:

  1. I created an abstract class (BarycentricMapperTopologyContainer) that gather the shared implementations of BarycentricMapperEdgeSetTopology, BarycentricMapperTriangleSetTopology, BarycentricMapperQuadSetTopology, BarycentricMapperTetrahedronSetTopology, and BarycentricMapperHexahedronSetTopology.

  2. Enabeling to refactor the apply(), applyJ(), applyJT(), getJ(), draw() functions and more importantly the function I want to optimize, init().

The PR also include some cleaning, in particular the renaming of variables. That could indeed break not updated code.

What I couldn't do, is to also refactor the code of BarycentricMapperMeshTopology...

@guparan
Copy link
Contributor

guparan commented Nov 14, 2018

@EulalieCoevoet Hi, do you plan to fix the CUDA errors?

@guparan guparan added pr: breaking Change possibly inducing a compilation error pr: status wip Development in the pull-request is still in progress and removed pr: status to review To notify reviewers to review this pull-request labels Nov 14, 2018
@EulalieCoevoet
Copy link
Contributor Author

So,
I've fixed the compile problems with SofaCUDA and clang.
And... I went a bit further with the cleaning, by splitting the 11 classes that where in BarycentricMapping files... into dedicated files. I'm convinced It will easy future development...

- moves the code in .h into .inl
- add #include <sofa/core/visualparams.h>
using SofaTest is bad but we should have working test to have the Barycentricmapping refactoring to work.
@hugtalbot
Copy link
Contributor

The CI still seems angry about the PR

1- added missing includes related to the refactoring of BarycentricMapping into different files
2- removed commented code
@EulalieCoevoet
Copy link
Contributor Author

EulalieCoevoet commented Nov 28, 2018

Hi guys,
I have trouble fixing the windows CI... if someone could help, it would be great (@epernod ).

@damienmarchal
Copy link
Contributor

The compilation problem appears between 7b183a2 and aeb4f8.

@damienmarchal
Copy link
Contributor

@EulalieCoevoet I got the problem. It was because you added SOFA_BASE_MECHANICS_API to the mapper. I suspect the problem is that when you specialize the template in a different dll (like the rigid that is in miscmapping) tthe specialization is of course using SOFA_MISC_MAPPING_API while the base class is using SOFA_BASE_MECHANICS_API.

@EulalieCoevoet
Copy link
Contributor Author

Thanks @damienmarchal !

@EulalieCoevoet EulalieCoevoet added pr: status to review To notify reviewers to review this pull-request and removed pr: status wip Development in the pull-request is still in progress labels Dec 1, 2018
@guparan
Copy link
Contributor

guparan commented Dec 3, 2018

[ci-build][with-all-tests]

@epernod
Copy link
Contributor

epernod commented Dec 4, 2018

@EulalieCoevoet
Thanks for this PR. Just for the record, why ?
What I couldn't do, is to also refactor the code of BarycentricMapperMeshTopology...

@EulalieCoevoet
Copy link
Contributor Author

@epernod lack of time... I guess it wasn't straightforward and I didn't want to spend more time on it.

@guparan guparan added pr: status ready Approved a pull-request, ready to be squashed and removed pr: status to review To notify reviewers to review this pull-request labels Dec 5, 2018
@guparan guparan merged commit 6bb5925 into sofa-framework:master Dec 5, 2018
@damienmarchal damienmarchal deleted the cleanBarycentricMapping branch December 11, 2018 11:09
@guparan guparan added this to the v18.12 milestone Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: breaking Change possibly inducing a compilation error pr: clean Cleaning the code pr: status ready Approved a pull-request, ready to be squashed refactoring Refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants