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

[Topology] Check indices out-of-bound in TriangleSetTopologyContainer #4242

Merged
merged 2 commits into from
Dec 12, 2023

Conversation

olivier-goury
Copy link
Contributor

Check that triangles index match the size of the triangleAroundVertexArray (Like it is done in EdgeSetTopologyContainer for EdgeAroundVertexArray)


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

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

@github-actions
Copy link

⚠️ ⚠️ ⚠️
@sofa-framework your PR title is not following the required format ✏️
- PR title should provide a prefix scope, e.g. [MechanicalLoad]
⚠️ ⚠️ ⚠️

@github-actions
Copy link

⚠️ ⚠️ ⚠️
@sofa-framework your PR does not include any status label 🏷️
Make sure to add one (wip, to review or ready).
⚠️ ⚠️ ⚠️

1 similar comment
@github-actions
Copy link

⚠️ ⚠️ ⚠️
@sofa-framework your PR does not include any status label 🏷️
Make sure to add one (wip, to review or ready).
⚠️ ⚠️ ⚠️

@alxbilger alxbilger added the pr: status to review To notify reviewers to review this pull-request label Oct 18, 2023
@olivier-goury olivier-goury changed the title Fix TriangleSetTopologyContainer [Topology] Fix TriangleSetTopologyContainer Oct 18, 2023
@hugtalbot hugtalbot changed the title [Topology] Fix TriangleSetTopologyContainer [Topology] Fix indices out-of-bound in TriangleSetTopologyContainer Oct 18, 2023
@hugtalbot hugtalbot changed the title [Topology] Fix indices out-of-bound in TriangleSetTopologyContainer [Topology] Check indices out-of-bound in TriangleSetTopologyContainer Oct 18, 2023
{
msg_warning() << "trianglesAroundVertex creation failed, Triangle buffer is not concistent with number of points: Triangle: " << m_triangle[i] << " for: " << getNbPoints() << " points.";
continue;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should the componentState be invalid then?

Copy link
Contributor

Choose a reason for hiding this comment

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

should it not break the loop ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could yes! I just copy-pasted (included the typo on consistent!) what was done from EdgeSetTopologyContainer where there is exactly the same loop but for edges.

Copy link
Contributor

Choose a reason for hiding this comment

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

glups..

Copy link
Contributor

Choose a reason for hiding this comment

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

what? My télor is riche! 😆

Copy link
Contributor

@epernod epernod left a comment

Choose a reason for hiding this comment

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

Ok for me, but could you explain in which case you have this problem?
Setting the component to invalid is a good idea. Breaking the loop might create some bigger issue in components using the topology as it won't be set.

@olivier-goury
Copy link
Contributor Author

Ok for me, but could you explain in which case you have this problem? Setting the component to invalid is a good idea. Breaking the loop might create some bigger issue in components using the topology as it won't be set.

We have this problem when using subtopologies defined using BoxROIs. The subTopo has fewer points than the original topology (Since it is a subset of it) but the triangles in that subtopo refer to nodes indexed with the numbering in the original topology that are out of bounds within the subtopo world. Not sure that is clear!

@olivier-goury
Copy link
Contributor Author

But for the component state set to invalid, I would actually leave it valid.
Indeed, it is just that the m_trianglesAroundVertex array won't be fully created, but the rest of the component remains valid and for example a forcefield can be defined on this container.

@epernod
Copy link
Contributor

epernod commented Oct 20, 2023

Ok for me, but could you explain in which case you have this problem? Setting the component to invalid is a good idea. Breaking the loop might create some bigger issue in components using the topology as it won't be set.

We have this problem when using subtopologies defined using BoxROIs. The subTopo has fewer points than the original topology (Since it is a subset of it) but the triangles in that subtopo refer to nodes indexed with the numbering in the original topology that are out of bounds within the subtopo world. Not sure that is clear!

There is something un-catholic there... So if I understand well, you have triangle in your topology that refer to point out of bound to your current node mechanicalObject?
I don't understand how it can work. It will crash as soon as a component will try to access a dof passing through the topology no?

@hugtalbot
Copy link
Contributor

hugtalbot commented Oct 25, 2023

Small up regarding Erik's question @olivier-goury

your answer will help us deciding whether we pass the component as invalid or not in the loop

@hugtalbot
Copy link
Contributor

@olivier-goury could you try using a SubSetTopologyMapping to ignore out of the box triangles?
See the SubSetTopologyMapping scene example

@epernod epernod 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 Nov 3, 2023
@olivier-goury
Copy link
Contributor Author

Ok for me, but could you explain in which case you have this problem? Setting the component to invalid is a good idea. Breaking the loop might create some bigger issue in components using the topology as it won't be set.

We have this problem when using subtopologies defined using BoxROIs. The subTopo has fewer points than the original topology (Since it is a subset of it) but the triangles in that subtopo refer to nodes indexed with the numbering in the original topology that are out of bounds within the subtopo world. Not sure that is clear!

There is something un-catholic there... So if I understand well, you have triangle in your topology that refer to point out of bound to your current node mechanicalObject? I don't understand how it can work. It will crash as soon as a component will try to access a dof passing through the topology no?

Sorry for the late reply!
So it is a case where the node where the subtopology is defined does not contain a MechanicalObject. It is only defined to add a ForceField applying onto a subpart of the node of the MechanicalObject. An example is in this scene: https://github.com/SofaDefrost/ModelOrderReduction/blob/master/tools/test/sofa_test_scene/quadruped.py

@alxbilger alxbilger 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 11, 2023
@alxbilger
Copy link
Contributor

I switched this PR back to "to review". It was in WIP, that's why the lack of activity. @epernod can you take a look on @olivier-goury 's answer?

@hugtalbot hugtalbot added the pr: backport todo This PR will be backported into the release preceeding its milestone. label Dec 11, 2023
@hugtalbot hugtalbot added this to the v23.12 milestone Dec 11, 2023
@epernod
Copy link
Contributor

epernod commented Dec 11, 2023

ok for me if it fix your case and it had a warning if we encounter the wrong behavior.

@epernod epernod removed the pr: status to review To notify reviewers to review this pull-request label Dec 11, 2023
@epernod epernod added the pr: status ready Approved a pull-request, ready to be squashed label Dec 11, 2023
@epernod
Copy link
Contributor

epernod commented Dec 11, 2023

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

…Array (Like it is done in EdgeSetTopologyContainer for EdgeAroundVertexArray)
@alxbilger alxbilger force-pushed the fix_TriangleSetTopologyContainer branch from 390f842 to 575c4c7 Compare December 12, 2023 08:02
@epernod epernod merged commit 3249be8 into master Dec 12, 2023
10 checks passed
@epernod epernod deleted the fix_TriangleSetTopologyContainer branch December 12, 2023 09:15
bakpaul pushed a commit that referenced this pull request Feb 19, 2024
…#4242)

* Check that triangles index match the size of the triangleAroundVertexArray (Like it is done in EdgeSetTopologyContainer for EdgeAroundVertexArray)

* Fix some typos
@bakpaul bakpaul added pr: backport done This PR has been backported into the release before its milestone. and removed pr: backport todo This PR will be backported into the release preceeding its milestone. labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: backport done This PR has been backported into the release before its milestone. pr: fix Fix a bug pr: status ready Approved a pull-request, ready to be squashed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants