Update the branch from upstream/master + FIX the memory leaks + preserve SPtr's ownership #1
Open
damienmarchal wants to merge 10 commits intoScheiklP:memory_leakfrom
Open
Update the branch from upstream/master + FIX the memory leaks + preserve SPtr's ownership #1damienmarchal wants to merge 10 commits intoScheiklP:memory_leakfrom
damienmarchal wants to merge 10 commits intoScheiklP:memory_leakfrom
Conversation
…ofa-framework#265) * [Sofa.Core] Adds tests for linkpath in the test file Base.py and BaseData.py * [SofaPython3] Add a LinkPath object in both the binding and plugin. The existing syntax to make links in Sofa is the following one: ```python node.addObject("MeshObjLoader", name="loader") node.addObject("MechanicalObject", position=node.loader.position.getLinkPath()) ``` In addition to be very verbose the getLinkPath() is returning a string (eg: "@/node/loader.position") Representing linkpath with string has drawback as it force the two objects to be part of the same simulation graph which is not always the case. Example of code that does not work as expected: ```python def MyPrefab(target): node = Sofa.Core.Node("MyPrefab") node.addObject("MeshObjLoader", name="loader") node2.addObject("MechanicalObject", position=target) return node def createScene(root): root.addObject("MeshObjLoader", name="loader") root.addChild( MyPrefab(loader.position.getLinkPath()) ) ``` It does not work because getLinkPath is returning a string, this string is then used to makes a path query into the scene-graph to locate the object or the data field to attach to. But in this case as the object issuing the query is not in the same graph the query fails. To solve this issue this PR introduce a LinkPath object which is pointing to a sofa object. This LinkPath object is exposed in python and can be used to make parenting between objects and data without the need of graph to path then path to graph conversion (so it is also much faster.. but we don't really care here right ?). For consistency with the "value" in data field the PR expose this link path with a dedicated "linkpath" attribute. So the code is now the following: ```python root.addObject("MeshObjLoader", name="loader") root.addChild("MechanicalObject", name="p1", position=root.loader.position.value) # Copy the value root.addChild("MechanicalObject", name="p2", position=root.loader.position.linkpath) # Make a link between data without string query root.addObject("Mapping", name="loader", input=p1.linkpath) ``` * [SofaPython3] LinkPath remove not needed condition while setting nullptr on a smart pointer. * [FIXUP] Passager clandestin. * Update bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_Node.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> * Update Binding_Node.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
* [all] fix unused variables * fix sign compare * Update bindings/SofaGui/src/SofaPython3/SofaGui/Module_SofaGui.cpp Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com> Co-authored-by: Alex Bilger <alxbilger@users.noreply.github.com>
# Conflicts: # Plugin/src/SofaPython3/PythonFactory.cpp # bindings/Sofa/src/SofaPython3/Sofa/Core/Data/Binding_DataContainer.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.