Home › Forum › SOFA › Programming with SOFA › [SOLVED] Apply a visual (.stl) on a beam
Tagged: 64_bits, Linux_ubuntu, Plugin_other, SOFA_1906
- This topic has 8 replies, 4 voices, and was last updated 4 years, 4 months ago by Alex.
-
AuthorPosts
-
30 June 2020 at 18:06 #16756AlexBlocked
Hello,
I would like to add a visual model on a beam
To do so i’ve initially created an object:
model.createObject('MeshSTLLoader', name='surface', filename=#)
Then the MechanicalObject of the beam :
model.createObject('MechanicalObject', template='Rigid3d', name='frame1', position=#)
And finally the link between my visual and the beam :
visu = model.createChild('visu') visu.createObject('OglModel', name='VisualModel', src='@../surface') visu.createObject('IdentityMapping', input='@../frame1', output='@VisualModel')
But my result is not has expected :
I should have a curved cylinder but instead the mesh seems to be all messed up
I’ve also tried with “RigidMapping” without success
What did I miss ?Regards,
7 July 2020 at 23:01 #16825HugoKeymasterHi @alexftw
Could you replace with a RigidMapping instead?
RigidMapping links Rigid3d (beam) and any other type like Vec3d (OglModel).I hope this helps
Hugo
8 July 2020 at 09:12 #16833AlexBlocked8 July 2020 at 21:28 #16840HugoKeymasterHi @alexftw
Beams are different than usual Rigid object.
Could you use the BeamLinearMapping instead? I should have pointed it out in the first place.Best,
Hugo
9 July 2020 at 09:29 #16844AlexBlockedHello @Hugo
It’s getting closer but still not good, maybe is there something wrong with the way I’ve created my beam ?
Result :
The beam :model = solverNode.createChild('model') model.createObject('MeshSTLLoader', name='surface', filename='mesh/#.stl') model.createObject('Mesh', name="meshBeam", position=#, lines=#) model.createObject('MechanicalObject', template='Rigid3d', name='frame1', position=#, printLog=0, translation="0 0 0") model.createObject('BeamInterpolation', dofsAndBeamsAligned='1', straight='1', defaultYoungModulus="1.8e18", radius=radius, name="interpolation") model.createObject('AdaptiveBeamForceFieldAndMass', name="BeamForceField", computeMass="1", massDensity="0.0001") model.createObject('PartialFixedConstraint', indices='0', fixedDirections="1 1 1 1 1 1") model.createObject('BoxROI', name='ROI1', box='5 10 2 -2 -2 2', drawBoxes='true')
Regards,
21 July 2020 at 16:46 #16916HugoKeymasterHi @alexftw
Sorry for the latency, I was away last week.
I think the mapping you are looking for has been implemented in a private plugin (plugin name: BeamAdapter, mapping name: BeamLinearMapping). I can try to get an access to this code for you.
Now some devs handle the rendering part in external tools like Unity.Maybe @remibessard could help us here.
Best wishes,
Hugo
21 July 2020 at 17:10 #16920epernodBlockedHi,
I’m not expert in Rigid and RigidMapping but I think in your case you need to define which indices of your visual mesh is mapped to each rigid dof using the option rigidIndexPerPoint of the RigidMapping.
I think this scene is similar to what you want to do:
https://github.com/sofa-framework/sofa/blob/master/examples/Components/mapping/ArticulatedSystemMapping.scnwhere a set of visual cube meshes are mapped on each rigid dof of the beam.
21 July 2020 at 17:25 #16922remibessardBlockedHi,
Agreed with @epernod, I would also precise these information to the RigidMapping when trying to make it work with this component.
As @Hugo mentionned I am using the BeamLinearMapping to map a collision model to a Beam model, but I think it is accessible in SOFA master without compiling any plugin.
Hope you can also find it and use it on your side.
(I have to say I am not mapping a volume into the beam (only a more discretized description of the same beam), so I don’t know if it will work with your visual volumetric model…)As for me I use it that way in my scene configuration file:
endoCollNode.createObject('BeamLinearMapping', localCoord=False, applyRestPosition=True)
(feel free to play with these 2 parameters to fit your case)Cheers,
Remi
28 July 2020 at 10:58 #16971AlexBlockedHello all,
I’m sorry I’ve completely forgot to answer here
This is the solution that have been given to me :visuNode = model.createChild('visualization') visuNode.createObject('CylinderGridTopology', name='topology', radius=radius, length='25', drawQuads='0', n='3 3 25', axis='1 0 0') visuNode.createObject('MechanicalObject', name='test') visuNode.createObject('AdaptiveBeamMapping', interpolation="@../interpolation", input="@../frame1", output="@test") oglNode = visuNode.createChild('ogl') oglNode.createObject('OglModel', color='0.2 0.2 0.2 1') oglNode.createObject('IdentityMapping')
EDIT : Just noticed that this solution isn’t what I was asking for in my first post, maybe I should have not hit the ‘solved’ button ?
Thanks again!
Regards,
Alex -
AuthorPosts
- You must be logged in to reply to this topic.