Home › Forum › SOFA › Using SOFA › [SOLVED] How to extract the surface of a volumeyric mesh
Tagged: 64_bits, SOFA_1612, Windows_10
- This topic has 21 replies, 5 voices, and was last updated 6 years, 4 months ago by Zahra.
-
AuthorPosts
-
9 August 2018 at 11:28 #11647ZahraBlocked
Hi,
How can I extract the surface of a volumetric mesh?Best,
Zahra10 August 2018 at 12:18 #11649Bruno MarquesBlockedHi Zahra,
You might want to look at the “Tetra2TriangleTopologicalMapping” component.
You can find an example in the scene “examples/Components/topology/Tetra2TriangleTopologicalMapping.scn”11 August 2018 at 13:04 #11650ZahraBlockedHi Bruno,
Thank you for your help. I tried the Tetra2TriangleTopologicalMapping.scn, but when I add a meshexporter to the “T” node of the aforementioned example to extract the surface, it still extracts the triangles of the whole volume, not just the surface. DO you have any idea why?
12 August 2018 at 11:24 #1165213 August 2018 at 11:54 #11656jnbrunetModeratorHi @Zahra
I’m not sure why you’re getting the whole volume’s triangle set. I just tried adding the mesh exporter to the “T” node and it works fine on my side. I disabled the edges export to really get only the positions and triangle indices:
<?xml version="1.0" ?> <Node name="root" dt="0.05" showBoundingTree="0" gravity="0 0 0"> <VisualStyle displayFlags="showBehaviorModels showVisual" /> <CollisionPipeline verbose="0" /> <BruteForceDetection name="N2" /> <CollisionResponse response="default" /> <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" /> <CollisionGroup /> <Node name="TT"> <EulerImplicit name="cg_odesolver" printLog="false" rayleighStiffness="0.1" rayleighMass="0.1" /> <CGLinearSolver iterations="25" name="linear solver" tolerance="1.0e-9" threshold="1.0e-9" /> <MeshGmshLoader name="loader" filename="mesh/cylinder.msh" /> <MechanicalObject src="@loader" name="Volume" /> <include href="Objects/TetrahedronSetTopology.xml" src="@loader" tags=" " /> <DiagonalMass massDensity="0.5" /> <FixedPlaneConstraint direction="0 0 1" dmin="-0.1" dmax="0.1" /> <FixedConstraint indices="0" /> <TetrahedralCorotationalFEMForceField name="FEM" youngModulus="360" poissonRatio="0.3" method="large" /> <Node name="T"> <MeshExporter format="vtk" filename="cylinder_surface" exportAtBegin="true" edges="false"/> <include href="Objects/TriangleSetTopology.xml" src="@" tags=" " /> <Tetra2TriangleTopologicalMapping input="@../Container" output="@Container" /> <TriangularFEMForceField name="FEM" youngModulus="60" poissonRatio="0.3" method="large" /> <TriangularBendingSprings name="FEM-Bend" stiffness="300" damping="1.0" /> <TrianglePressureForceField normal="0 0 1" dmin="0.9" dmax="1.1" pressure="0.4 0 0" /> <TriangleSet /> <Node name="Visu"> <OglModel name="Visual" color="blue" /> <IdentityMapping input="@../../Volume" output="@Visual" /> </Node> </Node> </Node> </Node>
Let me know if you’re still having difficulties to get it right.
13 August 2018 at 17:56 #11661HugoKeymasterHi Zahra,
The Tetra2TriangleTopologicalMapping creates indeed a triangle topology from a tetrahedral one. Therefore is not supposed to remove the triangles within the volume. As Binesh suggested the ObjExporter does the job.
But a nice thing would be to create a new class Tetra2SurfaceTriangleTopologicalMapping inheriting from Tetra2TriangleTopologicalMapping and selecting only triangles on the border.
Hugo
13 August 2018 at 18:06 #11662jnbrunetModeratorHey @Hugo
Tetra2TriangleTopologicalMapping
will be able to retrieve the surface mesh. In fact, it will retrieve the triangles that only got one tangent tetrahedron. If this is your case,
Tetra2TriangleTopologicalMapping
is good enough to get the surface representation. TheMeshExporter
will then find the mesh topology in the context of the exporter’s object. You can then toggle which elements you want exported.As for the
ObjExporter
, it will export the triangles only if aVisualModel
can be found. I don’t think there is one better than the other, they both inherits from the same base exporter. It really depends on your application.Jean-Nicolas
14 August 2018 at 11:37 #11665ZahraBlockedHi @jnbrunet,
Thank you for your comment. I ran your code, I am not that much familiar with vtk format (I use gmsh), however, I guess it still extracts the whole volume. I see the number of nodes are 510 which is the same number of nodes in the cylinderical volume. If it extract the surface, the number of the nodes should be less than that.
Best,
Zahra
14 August 2018 at 12:03 #11666ZahraBlockedHi @Binesh,
I tried ObjExporter, here is the .scn file:
https://gist.github.com/zbounik/d3bc51ade6b27f04fa38b38e6b8fcdf7
It causes this error which I can not figure out:
https://gist.github.com/zbounik/328f316a4e8616dd053f9a30b5f68ec5
Best,
Zahra
14 August 2018 at 12:36 #11667ZahraBlockedDear Hugo,
As I have mentioned to Binesh, ObjExporter causes an error.
The idea of creating a new class Tetra2SurfaceTriangleTopologicalMapping is appealing, however, I never accomplished such a code in SOFA before (my programming skill is to the level of MATLAB). I have recently learned python but I still have problems with python scripting in sofa
Is it possible that you kindly give me some guiding steps to know how to create Tetra2SurfaceTriangleTopologicalMapping class?
How only the triangles on the border should be selected?
I am sorry if I am asking too many questions π
Best,
Zahra
14 August 2018 at 13:49 #11669HugoKeymasterHi,
This scene is working fine for me. I am using the master branch of SOFA.
Which version of SOFA are you using Zahra ?Jean Nico is right:
– Tetra2TriangleTopologicalMapping is good enough to get the surface representation
– ObjExporter must be carefully used since it uses the visual model and exports it, VTKExporter is always a good solution and works fine also in your case.Hugo
14 August 2018 at 14:35 #11671ZahraBlockedHi Hugo,
I am using the stable branch of SOFA now v17.06.
Zahra
14 August 2018 at 14:51 #11672HugoKeymasterHi Zahra,
I guess you behavior has been fixed since the PR#372
That explains your problem. JeanNicolas and my advices might whatever help you in overcome this issue. Keep us updated.Hugo
14 August 2018 at 15:03 #11673ZahraBlockedThank you for leading me to this point. You are right, by using Tetra2TriangleTopologicalMapping and MeshExporter I can get the surface mesh.
What misleaded me was that the number of nodes of both surface and volume meshes remained the same, however, I recognized that the inner nodes become disconnected (the number of elements are reduced in the surface mesh).
I really appreciate your time.
Best regards,
Zahra
14 August 2018 at 15:24 #11674BineshBlockedHi @zahra
Try this scene :<?xml version="1.0"?> <Node name="root" gravity="0 0 0" dt="0.05" > <VisualStyle name="visualStyle1" displayFlags="showVisual showBehaviorModels" /> <DefaultPipeline name="defaultPipeline1" verbose="0" /> <BruteForceDetection name="N2" /> <DefaultContactManager name="defaultContactManager1" response="default" /> <MinProximityIntersection name="Proximity" alarmDistance="0.8" contactDistance="0.5" /> <DefaultCollisionGroupManager name="defaultCollisionGroupManager1" /> <Node name="TT" > <EulerImplicitSolver name="cg_odesolver" printLog="0" /> <CGLinearSolver template="GraphScattered" name="linear solver" iterations="25" tolerance="1e-09" threshold="1e-09" /> <MeshGmshLoader name="loader" filename="mesh/cylinder.msh" tetrahedraGroups=" -1 0 2430" /> <MechanicalObject template="Vec3d" name="Volume" position="@loader.position" velocity="0 0 0" force="0 0 0" externalForce="0 0 0" restScale="1" size="1" /> <TetrahedronSetTopologyContainer name="Container" position="@loader.position" edges="@loader.edges" triangles="@loader.triangles" tetrahedra="@loader.tetras" /> <TetrahedronSetTopologyModifier name="Modifier" /> <TetrahedronSetTopologyAlgorithms template="Vec3d" name="TopoAlgo" /> <TetrahedronSetGeometryAlgorithms template="Vec3d" name="GeomAlgo" /> <DiagonalMass template="Vec3d" name="diagonalMass1" massDensity="0.5" /> <FixedPlaneConstraint template="Vec3d" name="fixedPlaneConstraint1" direction="0 0 1" dmin="-0.1" dmax="0.1" /> <FixedConstraint template="Vec3d" name="fixedConstraint1" indices="0" /> <TetrahedralCorotationalFEMForceField template="Vec3d" name="FEM" method="large" poissonRatio="0.3" youngModulus="360" /> <Node name="T" > <TriangleSetTopologyContainer name="Container" position="@.position" nbPoints="@.nbPoints" edges="@.edges" checkConnexity="@.checkConnexity" triangles="@.triangles" /> <TriangleSetTopologyModifier name="Modifier" /> <TriangleSetTopologyAlgorithms template="Vec3d" name="TopoAlgo" /> <TriangleSetGeometryAlgorithms template="Vec3d" name="GeomAlgo" /> <Tetra2TriangleTopologicalMapping name="tetra2TriangleTopologicalMapping1" input="@../Container" output="@Container" /> <TriangularFEMForceField template="Vec3d" name="FEM" method="large" poissonRatio="0.3" youngModulus="60" /> <TriangularBendingSprings template="Vec3d" name="FEM-Bend" stiffness="300" damping="1" /> <TrianglePressureForceField template="Vec3d" name="trianglePressureFF1" pressure="0.4 0 0" normal="0 0 1" dmin="0.9" dmax="1.1" /> <TTriangleModel template="Vec3d" name="tTriangleModel1" /> <OBJExporter name="oBJExporter0" listening="1" filename="/home/behnam/Export/Surface" exportEveryNumberOfSteps="1" exportAtBegin="0" exportAtEnd="0" /> <Node name="Visu" > <OglModel template="ExtVec3f" name="Visual" material="Default Diffuse 1 0 0 1 1 Ambient 1 0 0 0.2 1 Specular 0 0 0 1 1 Emissive 0 0 0 1 1 Shininess 0 45 " primitiveType="DEFAULT" blendEquation="GL_FUNC_ADD" sfactor="GL_SRC_ALPHA" dfactor="GL_ONE_MINUS_SRC_ALPHA" /> <IdentityMapping template="Vec3d,ExtVec3f" name="identityMap1" input="@../../Volume" output="@Visual" /> </Node> </Node> </Node> </Node>
14 August 2018 at 15:30 #11675BineshBlocked14 August 2018 at 16:44 #11676HugoKeymasterGood to hear Zahra!
Binesh, it appears thatTetra2TriangleTopologicalMapping
will indeed be able to retrieve the surface mesh. So there might not be a need for theTetra2SurfaceTriangleMapping
Thanks you all for the collaboration!
14 August 2018 at 16:52 #11677ZahraBlockedHi @Binesh,
Thank you for your explanation. As Hugo mentioned, I think there is no need for implementing “Tetra2SurfaceTriangleMapping”.
Regarding the scene you have mentioned, I tried it: No .Obj file is created, and finally I receive this error:
FROM SOFA [ERR] >>
########## SIG 11 – SIGSEGV: segfault ##########Best,
Zahra
15 August 2018 at 11:05 #1168016 August 2018 at 07:02 #11682ZahraBlockedHi @Binesh,
I know, I have changed it and I got that error.
BTW, as I have mentioned, my problem with extracting the surface has been resolved. I am now trying to figure out why the same code works for others and gives me the “SIG 11 β SIGSEGV: segfault” error. I encountered this error previously and I have thought it is because of my code. I may start a new topic about it as soon as I collect more evidences.
Best,
Zahra
16 August 2018 at 09:10 #1168416 August 2018 at 12:16 #11686ZahraBlockedThank you @Binesh, I have started a new topic regarding this error:
I appreciate your help and deeply wish you have a good luck with this error π
-
AuthorPosts
- You must be logged in to reply to this topic.