Home › Forum › SOFA › Using SOFA › Voxelization of meshes
Tagged: Linux_ubuntu, SOFA_2106, voxelization
- This topic has 4 replies, 3 voices, and was last updated 3 years, 1 month ago by psomers.
-
AuthorPosts
-
19 September 2021 at 11:13 #20375mikhailBlocked
Dear community,
For my application, I need to voxelize tetrahedral volumetric meshes in order to use the extracted (numpy) arrays for X-ray simulations.
My meshes are rather large (about 20k-80k vertices) and they are multilabeled, so that each label corresponds to a different tissue. I am using the .vtu format to work with meshes. The voxelized meshes must then also be multilabeled.
What would be the best way to perform this task? Could you point me out to some examples on GitHub if it has been done before using Sofa or recommend other software for voxelization.
Usually, in this sort of applications, one extracts motion vector field and then uses it to transform the volumetric representation of an object at the initial state. Is there a way to do it in Sofa?
Any help would be appreciated.
19 September 2021 at 11:56 #20376Pasquale94BlockedHello @mikhail,
In Sofa Is possible to use Hexahedral meshes (cubes).
You Need Just to modify the code that generate volumetric meshes from a surface One.Cheers
19 September 2021 at 18:32 #20377mikhailBlockedDear @Pasquale94,
thank you for the suggestion. If I understand it correctly, the use of hexahedral meshes makes transformation back to voxels obsolete.
Could you please provide a code example. I tried to search for one but I couldn’t find it. I am particularly interested in how to load and export the mesh.
20 September 2021 at 10:42 #20378Pasquale94BlockedHello @mikhail,
here my code to retrieve a volumetric mesh:
import SofaRuntime SofaRuntime.importPlugin("SofaComponentAll") # to add elements like Node or objects import Sofa.Core import os path = os.path.dirname(os.path.abspath(__file__))+'/design/' def createScene(rootNode): rootNode.addObject('RequiredPlugin' ,pluginName='SofaExporter') rootNode.addObject('VisualStyle',displayFlags="hideVisual") rootNode.addObject('RequiredPlugin', pluginName="CGALPlugin") rootNode.addObject('RequiredPlugin', name="SofaOpenglVisual") rootNode.addObject('MeshObjLoader', name="loader", filename="design/BSPA_New_Design_Outer.obj") rootNode.addObject('MechanicalObject', name="dofs", position="@loader.position") #rootNode.addObject('TriangleSetTopologyContainer', name="topo", triangles="@loader.triangles") #rootNode.addObject('TriangleSetTopologyModifier' , name="Modifier") #rootNode.addObject('TriangleSetTopologyAlgorithms', name="TopoAlgo", template="Vec3d") #rootNode.addObject('TriangleSetGeometryAlgorithms', template="Vec3d" ,name="GeomAlgo", drawTriangles="1") rootNode.addObject('MeshGenerationFromPolyhedron', name="gen", inputPoints="@loader.position", inputTriangles="@loader.triangles",facetSize="0.75",facetApproximation="1",cellRatio="2", cellSize="2") rootNode.addObject('Mesh', name ='topo', position='@gen.outputPoints', tetrahedra='@gen.outputTetras') rootNode.addObject('VTKExporter', filename='finger',src = '@topo', edges='0', exportAtBegin='1') rootNode.addObject('OglModel', color=[0.3, 0.2, 0.2, 0.6]) return rootNode
here i produce from triangles, the tetrahedrons.
You have to produce from quads, hexahedrons.
Anyway, if you have blender, is also easier to voxelize or produce an hexahedral mesh.
I hope this helps you.
Cheers.20 September 2021 at 11:20 #20380psomersBlockedI don’t think the problem here is how to get a hexahedral mesh. I think the end goal is to have a voxelized cube “image” of the simulation environment as if it was a MRI image, correct? In that case, maybe take a look at this project:
or this one
They may do something similar.
As a side note: I apologize if my answer pops up twice. That seems to happen a lot when I post a link here. -
AuthorPosts
- You must be logged in to reply to this topic.