From 1894def1becb4c222fbbe44a5e8a6a860e229e75 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier local Date: Wed, 12 Nov 2014 16:06:24 +0100 Subject: [PATCH] Upgrade to MeshGems 1.3-8: activate PreCad by default without topology modification to allow to mesh shapes with degenerated edges (such as spheres) --- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 7 +- tests/test_precad_intersections.py | 21 +----- tests/test_precad_keep_gaps.py | 65 ++++++++++++++++++ tests/test_sphere.py | 70 ++++++++++++++++++++ 4 files changed, 142 insertions(+), 21 deletions(-) create mode 100644 tests/test_precad_keep_gaps.py create mode 100644 tests/test_sphere.py diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index 1772559..1d998e1 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -363,10 +363,11 @@ public: static bool GetDefaultQuadraticMesh() { return false; } static int GetDefaultVerbosity() { return 3; } - static Topology GetDefaultTopology() { return FromCAD; } + // Since Salome 7.5.0 and MeshGems 1.3, the default behaviour is to use PreCAD with all options at false + static Topology GetDefaultTopology() { return PreCAD; } // PreCAD - static bool GetDefaultPreCADMergeEdges() { return true; } - static bool GetDefaultPreCADProcess3DTopology() { return true; } + static bool GetDefaultPreCADMergeEdges() { return false; } + static bool GetDefaultPreCADProcess3DTopology() { return false; } static bool GetDefaultPreCADDiscardInput() { return false; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} diff --git a/tests/test_precad_intersections.py b/tests/test_precad_intersections.py index 544c71d..1736d1d 100644 --- a/tests/test_precad_intersections.py +++ b/tests/test_precad_intersections.py @@ -1,8 +1,4 @@ -# -*- coding: iso-8859-1 -*- - -### -### This file is generated automatically by SALOME v6.6.0 with dump python functionality -### +# -*- coding: utf-8 -*- import sys import salome @@ -10,10 +6,6 @@ import salome salome.salome_init() theStudy = salome.myStudy -import salome_notebook -notebook = salome_notebook.notebook -sys.path.insert( 0, r'/export/home/bourcier/salome/tests') - ### ### GEOM component ### @@ -25,14 +17,6 @@ geompy = geomBuilder.New(salome.myStudy) geompy.init_geom(theStudy) -geomObj_1 = geompy.MakeBoxDXDYDZ(100, 100, 100) -geomObj_2 = geompy.MakeVertex(-2, 60, 40) -geomObj_3 = geompy.MakeSpherePntR(geomObj_2, 10) -geomObj_4 = geompy.MakeVertex(70, 20, 60) -geomObj_5 = geompy.MakeSpherePntR(geomObj_4, 15) -geomObj_6 = geompy.MakeCompound([geomObj_3, geomObj_5]) -geomObj_7 = geompy.GetInPlaceByHistory(geomObj_6, geomObj_3) -geomObj_8 = geompy.GetInPlaceByHistory(geomObj_6, geomObj_5) Face_1 = geompy.MakeFaceHW(10, 10, 1) Translation_1 = geompy.MakeTranslation(Face_1, 10.0001, 0.0001, 0) Translation_2 = geompy.MakeTranslation(Face_1, 5, -9.99995, 0) @@ -63,7 +47,8 @@ Mesh_1 = smesh.Mesh(Partition_1) BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.BLSURF) BLSURF_Parameters = BLSURF_1.Parameters() BLSURF_Parameters.SetPhySize( 5 ) -BLSURF_Parameters.SetTopology( 3 ) +BLSURF_Parameters.SetPreCADMergeEdges( True ) +BLSURF_Parameters.SetPreCADProcess3DTopology( True ) Mesh_1.Compute() diff --git a/tests/test_precad_keep_gaps.py b/tests/test_precad_keep_gaps.py new file mode 100644 index 0000000..1809f63 --- /dev/null +++ b/tests/test_precad_keep_gaps.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + + +geompy.init_geom(theStudy) + +Face_1 = geompy.MakeFaceHW(10, 10, 1) +Translation_1 = geompy.MakeTranslation(Face_1, 10.0001, 0.0001, 0) +Translation_2 = geompy.MakeTranslation(Face_1, 5, -9.99995, 0) +Partition_1 = geompy.MakePartition([Face_1, Translation_1, Translation_2], [], [], [], geompy.ShapeType["FACE"], 0, [], 0) +geompy.addToStudy( Face_1, 'Face_1' ) +geompy.addToStudy( Translation_1, 'Translation_1' ) +geompy.addToStudy( Translation_2, 'Translation_2' ) +geompy.addToStudy( Partition_1, 'Partition_1' ) + +p_axe = geompy.MakeVertex(5, -5, 0) +axe = geompy.MakePrismDXDYDZ(p_axe, 0, 0, 1) +vertices = geompy.GetShapesOnCylinder(Partition_1, geompy.ShapeType["VERTEX"], axe, 1e-3, GEOM.ST_IN) +gr_vertices = geompy.CreateGroup(Partition_1, geompy.ShapeType["VERTEX"]) +geompy.UnionList(gr_vertices, vertices) +geompy.addToStudyInFather(Partition_1, gr_vertices, "vertices") + +### +### SMESH component +### + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + + +Mesh_1 = smesh.Mesh(Partition_1) + +BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.BLSURF) +BLSURF_Parameters = BLSURF_1.Parameters() +BLSURF_Parameters.SetPhySize( 5 ) + +Mesh_1.Compute() + +# Check that vertices are not merged by preCAD preprocessing +nodes = [] +for p in vertices: + x, y, z = geompy.PointCoordinates(p) + id_node = Mesh_1.FindNodeClosestTo(x, y, z) + nodes.append(id_node) + +nodes = set(nodes) + +assert(len(nodes) == 2) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) diff --git a/tests/test_sphere.py b/tests/test_sphere.py new file mode 100644 index 0000000..4070292 --- /dev/null +++ b/tests/test_sphere.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- + +import sys +import salome + +salome.salome_init() +theStudy = salome.myStudy + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +geompy = geomBuilder.New(salome.myStudy) + + +geompy.init_geom(theStudy) + +sphere = geompy.MakeSphereR(10) +geompy.addToStudy( sphere, 'sphere' ) + +### +### SMESH component +### + +import SMESH +from salome.smesh import smeshBuilder +smesh = smeshBuilder.New(salome.myStudy) + + +Mesh_1 = smesh.Mesh(sphere) + +BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.BLSURF) +BLSURF_Parameters = BLSURF_1.Parameters() +BLSURF_Parameters.SetPhySize( 5 ) +BLSURF_Parameters.SetGeometricMesh( 1 ) +BLSURF_Parameters.SetAngleMesh( 8 ) +# Activate PreCAD +# REMARK: These lines are the default behaviour from Salome 7.5.0 +# => It is not needed to add them +#BLSURF_Parameters.SetTopology( 3 ) +#BLSURF_Parameters.SetPreCADMergeEdges( False ) +#BLSURF_Parameters.SetPreCADProcess3DTopology( False ) + +ok = Mesh_1.Compute() + +if not ok: + raise Exception("Error when computing surface mesh") + +Mesh_1.Tetrahedron(algo=smeshBuilder.MG_Tetra) + +ok = Mesh_1.Compute() + +if not ok: + raise Exception("Error when computing volume mesh") + +## Check that vertices are merged by preCAD preprocessing +#nodes = [] +#for p in vertices: + #x, y, z = geompy.PointCoordinates(p) + #id_node = Mesh_1.FindNodeClosestTo(x, y, z) + #nodes.append(id_node) + +#nodes = set(nodes) + +#assert(len(nodes) == 1) + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser(1) -- 2.39.2