-
Notifications
You must be signed in to change notification settings - Fork 54
[Prefabs] Add modifiers #612
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
Open
bakpaul
wants to merge
16
commits into
sofa-framework:25_04_work_on_new_prefabs
Choose a base branch
from
bakpaul:26_03_add_modifiers
base: 25_04_work_on_new_prefabs
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
dd60d77
Start working but need a inheritable base component binding
bakpaul 1e2553c
Node modifiers coming out. Still need to register the modified nodes …
bakpaul c76d9b3
Modifier design close to DONE.
bakpaul 59b663a
Add attachment
bakpaul b652302
Add attachment
bakpaul 0e62193
Fix extract geometry
bakpaul 2360fa5
Clean
bakpaul c8d4b4b
Revert changes made to extract
bakpaul f168808
Now register in entity if node containing mstate is child of entity
bakpaul 68aa1e2
Inherit from component
bakpaul f1435ba
Fix init
bakpaul 8037538
Add default name
bakpaul f09df01
Delete examples/stlib/node_modifier.py.view
EulalieCoevoet 4fa8496
Fix footer
bakpaul b76f2a7
Apply suggestions from code review
bakpaul 87b726f
Include review suggestions
bakpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
bindings/Sofa/src/SofaPython3/Sofa/Core/Binding_BaseComponent.h
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| from stlib.geometries.plane import PlaneParameters | ||
| from stlib.geometries.file import FileParameters | ||
| from stlib.geometries.extract import ExtractParameters | ||
| from stlib.materials.deformable import DeformableBehaviorParameters | ||
| from stlib.collision import Collision, CollisionParameters | ||
| from stlib.entities import Entity, EntityParameters | ||
| from stlib.visual import Visual, VisualParameters | ||
| from splib.core.enum_types import CollisionPrimitive, ElementType, ConstitutiveLaw | ||
| from splib.simulation.headers import setupLagrangianHeader, setupDefaultHeader | ||
| from splib.simulation.ode_solvers import addImplicitODE | ||
| from splib.simulation.linear_solvers import addLinearSolver | ||
| import dataclasses | ||
| import numpy as np | ||
|
|
||
|
|
||
| from stlib.node_modifiers import NodeModifier | ||
| from stlib.node_modifiers.footers import SimulationSolversParameters, SimulationSettingsParameters | ||
| from stlib.node_modifiers.attachments import FixConstraintParameters, AttachmentConstraintParameters | ||
|
|
||
| def createScene(root): | ||
| root.gravity=[0,0,9.81] | ||
| root.dt=0.01 | ||
|
|
||
| ##Environement | ||
| plane1_collisionParams = CollisionParameters() | ||
| plane1_collisionParams.name = "UP" | ||
| plane1_collisionParams.primitives = [CollisionPrimitive.TRIANGLES] | ||
| plane1_collisionParams.kwargs = {"TriangleCollision" : {"moving" : False, "simulated" : False}} | ||
| plane1_collisionParams.geometry = PlaneParameters(center=np.array([15,0,5]), | ||
| normal=np.array([0,0,-1]), | ||
| lengthNormal=np.array([0, 1, 0]), | ||
| lengthNbEdge=1, | ||
| widthNbEdge=2, | ||
| lengthSize=30, | ||
| widthSize=70) | ||
| plane1 = root.add(Collision, parameters = plane1_collisionParams) | ||
| # TODO being able to reuse already loaded geometry of current prefab to add any new sub prefab | ||
| # We need to enable to directly pass a link to an already existing prefab in place of a prefab parameter object | ||
| plane1_visu = plane1.addChild("Visu") | ||
| plane1_visu.addObject("OglModel", name="VisualModel", src="@../Geometry/container") | ||
|
|
||
|
|
||
| ### Logo | ||
| ModelsNode = root.addChild("ModelsNode") | ||
|
|
||
| LogoParams = EntityParameters(name = "Logo1", | ||
| geometry = FileParameters(filename="mesh/SofaScene/Logo.vtk"), | ||
| material = DeformableBehaviorParameters(), | ||
| collision = CollisionParameters(geometry = FileParameters(filename="mesh/SofaScene/LogoColli.sph")), | ||
| visual = VisualParameters(geometry = FileParameters(filename="mesh/SofaScene/LogoVisu.obj"))) | ||
|
|
||
| LogoParams.geometry.elementType = ElementType.TETRAHEDRA | ||
| LogoParams.material.constitutiveLawType = ConstitutiveLaw.ELASTIC | ||
| LogoParams.material.parameters = [200, 0.4] | ||
| LogoParams.material.massDensity = 0.003261 | ||
| LogoParams.collision.primitives = [CollisionPrimitive.SPHERES] | ||
| #TODO make this flawless with spheres. Here collisions elements are not in the topology and a link is to be made between the loader and the collision object | ||
| LogoParams.collision.kwargs = {"SphereCollision" : {"radius" : "@Geometry/loader.listRadius"}} | ||
| LogoParams.visual.color = [0.7, .35, 0, 0.8] | ||
|
|
||
| Logo = ModelsNode.add(Entity, parameters = LogoParams) | ||
|
|
||
|
|
||
|
|
||
| ### S | ||
| SParams = EntityParameters() | ||
| SParams.name = "S" | ||
| SParams.geometry = FileParameters(filename="mesh/SofaScene/S.vtk") | ||
| SParams.geometry.elementType = ElementType.TETRAHEDRA | ||
| SParams.material = DeformableBehaviorParameters() | ||
| SParams.material.constitutiveLawType = ConstitutiveLaw.ELASTIC | ||
| SParams.material.parameters = [200, 0.45] | ||
| SParams.material.massDensity = 0.011021 | ||
| SParams.collision = CollisionParameters() | ||
| SParams.collision.primitives = [CollisionPrimitive.TRIANGLES] | ||
| # # #TODO: to fix link issues for extracted geometry, it might be better to give source geometry relative link + parameters | ||
| ## TODO: not working with static container because the init order is always wrong so that the triangle vector is always empty when initializing the container | ||
| SParams.collision.geometry = ExtractParameters(destinationType=ElementType.TRIANGLES, sourceParameters=SParams.geometry) | ||
| SParams.visual = VisualParameters() | ||
| SParams.visual.geometry = FileParameters(filename="mesh/SofaScene/SVisu.obj") | ||
| SParams.visual.color = [0.7, .7, 0.7, 0.8] | ||
|
|
||
| S = ModelsNode.add(Entity, parameters = SParams) | ||
|
|
||
| #TODO make the name automatically match the modifier type if none is given | ||
| root.add(NodeModifier, on = [ModelsNode], parameters = SimulationSolversParameters(constantSparsity=False)) | ||
|
|
||
| root.add(NodeModifier, on = [root], parameters = SimulationSettingsParameters(displayFlags = ["showVisualModels", "showInteractionForceFields"], | ||
| enableCollisionDetection = True, | ||
| useLagrangian = True, | ||
| parallelComputing = False, | ||
| alarmDistance=0.3, contactDistance=0.02, | ||
| frictionCoef=0.5, tolerance=1.0e-4, maxIterations=20)) | ||
|
|
||
| Logo.add(NodeModifier, on = [Logo], parameters = FixConstraintParameters( boxROIs=[[-1, -2, -13, 3, 2, -7]])) | ||
| Logo.add(NodeModifier, on = [Logo], parameters = FixConstraintParameters( boxROIs=[[-100, -2, -13, -300, 2, -7]])) | ||
| ModelsNode.add(NodeModifier, on = [S, Logo], parameters = AttachmentConstraintParameters(name = "AttachmentConstraintParameters", indices1=[26,20,119,121], indices2=[722,732,574,573], stiffness=0.5, damping=0.0, | ||
| length=[((9.43-9.35)**2 + (-.44-0.48)**2 + (-6.01+6.56)**2)**(0.5) ])) | ||
|
|
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __all__ = ["linear_elasticity","hyperelasticity","fix_points","collision_model","mass"] | ||
| __all__ = ["linear_elasticity","hyperelasticity","attachment","collision_model","mass"] |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.