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] Add topological change in barycentric mapping #1203

Merged
merged 5 commits into from
Nov 14, 2019

Conversation

courtecuisse
Copy link
Contributor

Modify the mapper in tetra barycentric mapping in order to listen for topological changes and only compute the added points. Previously the behaviour was to call reinit and recompute all the barycentric coordinates for the entire mesh at each topological modification.


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.

Copy link
Contributor

@guparan guparan left a comment

Choose a reason for hiding this comment

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

Thanks for your PR @courtecuisse 👍

Is there any reason why you put all your code in headers?
If no, could you please move it to .cpp files?

@guparan guparan changed the title Add topological change in barycentric mapping [SofaBaseMechanics] Add topological change in barycentric mapping Oct 29, 2019
@guparan guparan added enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request labels Oct 29, 2019
void processTopologicalChanges(const typename Out::VecCoord& out, const typename In::VecCoord& in, core::topology::Topology* t) {
using sofa::core::behavior::MechanicalState;

if (t != this->m_toTopology) return;
Copy link
Contributor

@damienmarchal damienmarchal Oct 30, 2019

Choose a reason for hiding this comment

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

Replace the "this" with using Inherit1::m_topology

std::list<const core::topology::TopologyChange *>::const_iterator itBegin = this->m_toTopology->beginChange();
std::list<const core::topology::TopologyChange *>::const_iterator itEnd = this->m_toTopology->endChange();

helper::vector<MappingData>& vectorData = *(d_map.beginEdit());
Copy link
Contributor

Choose a reason for hiding this comment

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

Use WriteAccessor instead of beginEdit()/endEdit() this is shorter to write and more safer with respect to security.

@guparan guparan added 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 Oct 30, 2019
@@ -68,6 +68,107 @@ class BarycentricMapperTetrahedronSetTopology : public BarycentricMapperTopology
void computeDistance(double& d, const Vector3& v) override;
void addPointInElement(const int elementIndex, const SReal* baryCoords) override;

//handle topology changes depending on the topology
Copy link
Contributor

Choose a reason for hiding this comment

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

No code in .h this increase code coupling and thus compilation time.

if ( this->m_toTopology->beginChange() == this->m_toTopology->endChange() )
return;

std::list<const core::topology::TopologyChange *>::const_iterator itBegin = this->m_toTopology->beginChange();
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case the use of "auto" is recommanded.

@damienmarchal
Copy link
Contributor

Hi @guparan, @courtecuisse

If you have no time I will do the polishing of this PR.

@epernod
Copy link
Contributor

epernod commented Nov 9, 2019

@damienmarchal @courtecuisse I have tested the mapping and done the change requested but I'm not able to push the change in mimesis-inria/sofa , any idea why?
If complicated I can recreate a PR...

@guparan
Copy link
Contributor

guparan commented Nov 13, 2019

@epernod Your commits are pushed 👍

@guparan guparan 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 Nov 13, 2019
@epernod
Copy link
Contributor

epernod commented Nov 13, 2019

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

@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 Nov 14, 2019
@guparan guparan merged commit a930977 into sofa-framework:master Nov 14, 2019
@guparan guparan added this to the v19.12 milestone Jan 14, 2020
@courtecuisse courtecuisse deleted the barymapping branch July 20, 2020 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement About a possible enhancement pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants