Home › Forum › SOFA › Using SOFA › [SOLVED] Problems generating mesh with CGALPlugin and TetrahedronSetTopologyContainer
Tagged: 64_bits, CGAL, CGALplugin, Linux_ubuntu, Mesh, mesh generating, SOFA_other
- This topic has 7 replies, 2 voices, and was last updated 6 years, 9 months ago by Hugo.
-
AuthorPosts
-
15 March 2018 at 20:45 #10650AnonymousInactive
Hi,
I’ve been trying to generate a mesh from a stl or obj file and when I try to open it in runSofa, it stops running and exits because of a “segment fault (core)”. I’m using the master version (because I needed the SoftRobotics plugin that follows this version) on Ubuntu 16.04.The first option I tried to get the mesh was with TetrahedronSetTopologyContainer asi it follows:
<?xml version="1.0"?> <Node name="Root" dt="0.02" > <VisualStyle name="visualStyle1" displayFlags="showAll" /> <RequiredPlugin name="requiredPlugin8" printLog="1" pluginName="requiredPlugin8" /> <FreeMotionAnimationLoop name="freeMotionAnimationLoop9" /> <GenericConstraintSolver name="genericConstraintSolver10" /> <DefaultVisualManagerLoop name="defaultVisualManagerLoop11" /> <Node name="objeto" > <EulerImplicitSolver name="eulerImplicitSolver12" /> <SparseLDLSolver template="CompressedRowSparseMatrix3f" name="sparseLDLSolver13" /> <MeshSTLLoader name="loader" filename="/home/montse/sofa/#TFG/kyma/disco.stl" /> <TetrahedronSetTopologyContainer name="container" position="@loader.position" edges="@loader.edges" triangles="@loader.triangles" tetrahedra="@loader.tetras" /> <MechanicalObject template="Vec3d" name="tetras" position="0 0 0" velocity="0 0 0" force="0 0 0" externalForce="0 0 0" size="1" /> <UniformMass template="Vec3d" name="uniformMass17" filename="unused" /> <TetrahedronFEMForceField template="Vec3d" name="tetrahedronFEMFF18" gatherPt=" " gatherBsize=" " /> <BoxROI template="Vec3d" name="ROI1" box="0 0 0 1 1 1" position="@tetras.rest_position" indices="0" drawBoxes="1" /> <RestShapeSpringsForceField template="Vec3d" name="restShapeSpringsFF20" points="@ROI1.indices" springColor="0 1 0 1" /> <LinearSolverConstraintCorrection template="Vec3d" name="linearSolverConstraintCorrection21" /> <Node name="visu" > <OglModel template="ExtVec3f" name="oglModel22" fileMesh="/home/montse/sofa/#TFG/kyma/disco.stl" material="Default Diffuse 1 0.74902 0.74902 0.74902 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 " primitiveType="DEFAULT" blendEquation="GL_FUNC_ADD" sfactor="GL_SRC_ALPHA" dfactor="GL_ONE_MINUS_SRC_ALPHA" /> <BarycentricMapping template="Vec3d,ExtVec3f" name="barycentricMap23" input="@../" output="@./" /> </Node> </Node> </Node>
I don’t know what is wrong with this code in order to do a “segment fault”.
My next option was using the CGALPlugin as described here:
But instead of python I used the Modeler and got this xml code:<?xml version="1.0"?> <Node name="Root" dt="0.02" > <VisualStyle name="visualStyle1" displayFlags="showAll" /> <DefaultPipeline name="DefaultCollisionPipeline" verbose="0" draw="0" depth="6" /> <BruteForceDetection name="Detection" /> <MinProximityIntersection name="Proximity" alarmDistance="0.3" contactDistance="0.2" /> <DefaultContactManager name="Response" response="default" /> <RequiredPlugin name="requiredPlugin0" printLog="1" pluginName="CGALPlugin" /> <Node name="node3" > <MeshSTLLoader name="mesh" filename="/home/montse/sofa/src/share/mesh/dragon.stl" /> <MeshGenerationFromPolyhedron template="Vec3d" name="gen" inputPoints="@mesh.position" inputTriangles="@mesh.triangles" facetAngle="30" facetSize="4" facetApproximation="1" cellRatio="2" cellSize="10" drawTetras="1" /> <MeshTopology name="MeshTop" position="@gen.outputPoints" tetrahedra="@gen.outputTetras" /> <OglModel template="ExtVec3f" name="oglModel4" fileMesh="/home/montse/sofa/src/share/mesh/dragon.stl" material="Default Diffuse 1 0.74902 0.74902 0.74902 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 " primitiveType="DEFAULT" blendEquation="GL_FUNC_ADD" sfactor="GL_SRC_ALPHA" dfactor="GL_ONE_MINUS_SRC_ALPHA" /> </Node> </Node>
However, I get the same error (segment fault) and I don’t know why this happens.
16 March 2018 at 10:01 #10652HugoKeymasterHey @montsediaz !
Thank you for joining the SOFA forum!
Is there any way for you to share the mesh with us ? I always prefer to run the scenes locally.For the first scene case, try to change the Uniform mass with:
<UniformMass template="Vec3d" name="uniformMass17" totalmass="1" />
(set the value of total mass that you want instead of 1)
For the example using CGAL did you downloaded and installed CGAL and then compiled the CGAL SOFA plugin ?
Best
Hugo
16 March 2018 at 10:15 #10654AnonymousInactiveHi! Thanks for the quick answer.
I set the total mass to 1 in the first example and it does the same thing. The stl I’m using is: this one. I was trying also with some of the files in the sofa/src/share/mesh and getting the same result.
For the second one, yes, I did install and compile CGAL. When compiling the SOFA plugin it gave me an error with “mesh generation from image” but it compiled anyway so I don’t think there’s any problems with the rest of the elements (like mesh generation from polyhedron).
Thank you again!
16 March 2018 at 10:42 #10655HugoKeymasterOK @montsediaz
I am looking at your first scene.
Several things are missing:- 5first of all your mesh is a surface mesh, therefore no tetrahedron are available and the FEM component cannot work properly. You need to create a 3D volumetric mesh (including triangles AND tetrahedra) from your surface mesh.
- moreover, you are missing a TetrahedronSetGeometryAlgorithms
Here is a fixed scene:
<?xml version="1.0"?> <Node name="Root" dt="0.02" > <VisualStyle name="visualStyle1" displayFlags="showVisualModel" /> <RequiredPlugin name="requiredPlugin8" printLog="1" pluginName="requiredPlugin8" /> <FreeMotionAnimationLoop name="freeMotionAnimationLoop9" /> <GenericConstraintSolver name="genericConstraintSolver10" maxIterations="1000" tolerance="0.001"/> <DefaultVisualManagerLoop name="defaultVisualManagerLoop11" /> <Node name="fromSurfaceToVolumetricMesh" > <MeshSTLLoader name="surface" filename="Kyma.stl" /> <MeshTetraStuffing name="stuffing" snapPoints="true" splitTetras="true" draw="false" size="3" alphaLong="0.25" alphaShort="0.4" inputPoints="@surface.position" inputTriangles="@surface.triangles" /> </Node> <Node name="objeto" > <EulerImplicitSolver name="eulerImplicitSolver12" /> <SparseLDLSolver template="CompressedRowSparseMatrix3f" name="sparseLDLSolver13" /> <TetrahedronSetTopologyContainer name="container" position="@../fromSurfaceToVolumetricMesh/stuffing.outputPoints" tetrahedra="@../fromSurfaceToVolumetricMesh/stuffing.outputTetras" /> <MechanicalObject template="Vec3d" name="tetras" position="0 0 0" velocity="0 0 0" force="0 0 0" externalForce="0 0 0" size="1" showObject="1" /> <TetrahedronSetGeometryAlgorithms template="Vec3d" name="GeomAlgo" /> <UniformMass template="Vec3d" name="uniformMass17" totalmass="1"/> <TetrahedronFEMForceField template="Vec3d" name="tetrahedronFEMFF18" poissonRatio="0.45" youngModulus="5000"/> <BoxROI template="Vec3d" name="ROI1" box="0 0 0 1 1 1" position="@tetras.rest_position" indices="0" drawBoxes="0" /> <RestShapeSpringsForceField template="Vec3d" name="restShapeSpringsFF20" points="@ROI1.indices" springColor="0 1 0 1" /> <LinearSolverConstraintCorrection template="Vec3d" name="linearSolverConstraintCorrection21" /> <Node name="NewMeshVisualization" > <OglModel template="ExtVec3f" name="oglModel22" color="green" /> <IdentityMapping template="Vec3d,ExtVec3f" name="barycentricMap23" input="@../" output="@./" /> </Node> </Node> <Node name="visuOriginalMesh" > <OglModel template="ExtVec3f" name="oglModel22" fileMesh="Kyma.stl" material="Default Diffuse 1 0.74902 0.74902 0.74902 1 Ambient 1 0.2 0.2 0.2 1 Specular 0 1 1 1 1 Emissive 0 0 0 0 0 Shininess 0 45 " primitiveType="DEFAULT" blendEquation="GL_FUNC_ADD" sfactor="GL_SRC_ALPHA" dfactor="GL_ONE_MINUS_SRC_ALPHA" /> </Node> </Node>
But you should really find a way to create your volumetric mesh in a proper meshing software (CGAL or other like MeshLab). The MeshTetraStuffing does only roughly the job.
I hope this helps
Hugo
16 March 2018 at 12:34 #10656AnonymousInactiveSo the problem is with the file? Does this happens with all STLs? I understand I need to generate the file with a special software like MeshLab so when I import it to Sofa it’s not “empty”, is that right?
The CGAL plugin converts the file I’m trying to model into a mesh, I imagine. So I imagine I can import the stl to Sofa and then CGAL does the work OR I can generate the mesh file with MeshLab and then import it to Sofa. I don’t know much about this topic so excuse me if I’m making some obvious mistake.
Thank you!
16 March 2018 at 14:22 #10665HugoKeymasterHey,
I think I was not perfectly clear.
STL format is a format dedicated to surface (only) mesh. You can’t therefore have a volumetric mesh, in other words a STL file never defines tetrahedron or hexahedron information.From your STL file, you need to generate a volumetric mesh (VTK, gmsh …). CGAL does this step surface -> to volumetric mesh. The process that you describe with CGAL works.
Best regards,
Hugo
16 March 2018 at 14:27 #10666AnonymousInactiveThat explains so much of what I’ve been having trouble with. Thank you once again for your help.
16 March 2018 at 14:53 #10667HugoKeymasterYou’re very welcome @montsediaz
-
AuthorPosts
- You must be logged in to reply to this topic.