--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: utf-8 -*-
+
+ import salome
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ simple = False
+
+ r = 10
+ dist = 10
+
+ p1 = geompy.MakeVertex(0., 0., 0.)
+ p2 = geompy.MakeVertex(100., 100., 100.)
+ box = geompy.MakeBoxTwoPnt(p1, p2)
+ geompy.addToStudy(box, "box")
+
+ p3 = geompy.MakeVertex(25., 5., 25.)
+ sphere1 = geompy.MakeSpherePntR(p3, 15.)
+ geompy.addToStudy(sphere1, "sphere1")
+
+ sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+ geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+ sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0)
+ geompy.addToStudy(sphere1_trans, "sphere1_trans")
+
+ p4 = geompy.MakeVertex(5, 50, 90)
+ sphere2 = geompy.MakeSpherePntR(p4, 20.)
+
+ sphere2_trans = geompy.MakeTranslation(sphere2, 100, 0, 0)
+ geompy.addToStudy(sphere2_trans, "sphere2_trans")
+
+ sphere2_trans2 = geompy.MakeTranslation(sphere2, 0, 0, -100)
+ geompy.addToStudy(sphere2_trans2, "sphere2_trans2")
+
+ sphere2_trans3 = geompy.MakeTranslation(sphere2, 100, 0, -100)
+ geompy.addToStudy(sphere2_trans3, "sphere2_trans3")
+
+ if simple:
+ part = box
+ else:
+ part = geompy.MakePartition([box], [sphere1, sphere1_trans, sphere2, sphere2_trans, sphere2_trans2, sphere2_trans3])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(left, left_faces)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(right, right_faces)
+ geompy.addToStudyInFather(part, right, "right")
+
+ back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON)
+ back = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(back, back_faces)
+ geompy.addToStudyInFather(part, back, "back")
+
+ front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON)
+ front = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(front, front_faces)
+ geompy.addToStudyInFather(part, front, "front")
+
+ bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(bottom, bottom_faces)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(top, top_faces)
+ geompy.addToStudyInFather(part, top, "top")
+
+ sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(sources, left_faces)
+ geompy.UnionList(sources, back_faces)
+ geompy.UnionList(sources, top_faces)
+ geompy.addToStudyInFather(part, sources, "sources")
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+ algo2d.SetVerbosity(1)
+
+ # Periodicity
+ #algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+ algo2d.AddPreCadFacesPeriodicity(left, right)
+ algo2d.AddPreCadFacesPeriodicity(front, back)
+ algo2d.AddPreCadFacesPeriodicity(bottom, top)
+
+ gr_left = Mesh.Group(left)
+ gr_right = Mesh.Group(right)
+ gr_front = Mesh.Group(front)
+ gr_back = Mesh.Group(back)
+ gr_bottom = Mesh.Group(bottom)
+ gr_top = Mesh.Group(top)
+
+ Mesh.Compute()
+
+ left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 0, 100, 0 )), 0, 'left_translated' )
+ front_translated = Mesh.TranslateObjectMakeMesh( gr_front, SMESH.DirStruct( SMESH.PointStruct ( -100, 0, 0 )), 0, 'front_translated' )
+ bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 0, 100 )), 0, 'bottom_translated' )
+
+ def checkProjection(gr, mesh_translated, tol=1e-7):
+ name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+ mesh_source = smesh.CopyMesh(gr, gr.GetName())
+ mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+ ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+ coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+ mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+ mesh_nodes = mesh_check.GetNodesId()
+ if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+ non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+ mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+ raise Exception("Projection failed for %s"%name)
+
+ checkProjection(gr_right, left_translated)
+ checkProjection(gr_back, front_translated)
+ checkProjection(gr_top, bottom_translated)
+
++salome.sg.updateObjBrowser()
+
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ import SMESH, SALOMEDS
+
+ ## Compute the minimum area of the faces of the mesh
+ def getMinArea(mesh):
+ faces = mesh.GetElementsByType(SMESH.FACE)
+ areas = [mesh.GetArea(face) for face in faces]
+ return min(areas)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(100, 100, 1)
+ Circle_1 = geompy.MakeCircle(None, None, 20)
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Face_1, 'Face_1' )
+ geompy.addToStudy( Circle_1, 'Circle_1' )
+
+ ###
+ ### SMESH component
+ ###
+
+ from salome.smesh import smeshBuilder
+
-print "min_area_without_attractor: ", min_area_without_attractor
++smesh = smeshBuilder.New()
+ Mesh_1 = smesh.Mesh(Face_1)
+ MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_1.SetPhySize( 14.1421 )
+ MG_CADSurf_Parameters_1.SetMinSize( 0.141421 )
+ MG_CADSurf_Parameters_1.SetMaxSize( 28.2843 )
+ MG_CADSurf_Parameters_1.SetChordalError( 7.07107 )
+ #MG_CADSurf_Parameters_1.SetAttractorGeom( Face_1, Circle_1, 1, 14.1421, 5, 5 )
+
+ Mesh_1.Compute()
+
+ min_area_without_attractor = getMinArea(Mesh_1)
+
-print "min_area_with_attractor: ", min_area_with_attractor
++print("min_area_without_attractor: ", min_area_without_attractor)
+
+ MG_CADSurf_Parameters_1.SetAttractorGeom( Face_1, Circle_1, 1, 14.1421, 5, 5 )
+
+ Mesh_1.Compute()
+
+ min_area_with_attractor = getMinArea(Mesh_1)
+
++print("min_area_with_attractor: ", min_area_with_attractor)
+
+ assert min_area_with_attractor < min_area_without_attractor
+
+ assert min_area_with_attractor < 1
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ import SMESH, SALOMEDS
+
+ ## Compute the minimum area of the faces of the mesh
+ def getMinArea(mesh):
+ faces = mesh.GetElementsByType(SMESH.FACE)
+ areas = [mesh.GetArea(face) for face in faces]
+ return min(areas)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(100, 100, 1)
+ Box_1 = geompy.MakePrismVecH(Face_1, OZ, -100)
+ # define the edge slightly longer than the face to test out of bounds case.
+ P1 = geompy.MakeVertex(-50.5, 0, 0)
+ P2 = geompy.MakeVertex(50.5, 0, 0)
+ Edge_1 = geompy.MakeEdge(P1, P2)
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Face_1, 'Face_1' )
+ geompy.addToStudy( Box_1, 'Box_1' )
+ geompy.addToStudy( Edge_1, 'Edge_1' )
+
+ sub_Face_1 = geompy.GetInPlace(Box_1, Face_1)
+ geompy.addToStudyInFather(Box_1, sub_Face_1, "Face_1")
+
+ ###
+ ### SMESH component
+ ###
+
+ from salome.smesh import smeshBuilder
+
-print "min_area_without_attractor: ", min_area_without_attractor
++smesh = smeshBuilder.New()
+ Mesh_1 = smesh.Mesh(Box_1)
+ MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_1.SetPhySize( 14.1421 )
+ MG_CADSurf_Parameters_1.SetMinSize( 0.141421 )
+ MG_CADSurf_Parameters_1.SetMaxSize( 28.2843 )
+ MG_CADSurf_Parameters_1.SetChordalError( 7.07107 )
+ #MG_CADSurf_Parameters_1.SetAttractorGeom( sub_Face_1, Edge_1, 1, 14.1421, 5, 5 )
+
+ Mesh_1.Compute()
+
+ min_area_without_attractor = getMinArea(Mesh_1)
+
-print "min_area_with_attractor: ", min_area_with_attractor
++print("min_area_without_attractor: ", min_area_without_attractor)
+
+ MG_CADSurf_Parameters_1.SetAttractorGeom( sub_Face_1, Edge_1, 1, 14.1421, 5, 5 )
+
+ Mesh_1.Compute()
+
+ min_area_with_attractor = getMinArea(Mesh_1)
+
++print("min_area_with_attractor: ", min_area_with_attractor)
+
+ assert min_area_with_attractor < min_area_without_attractor
+
+ assert min_area_with_attractor < 1
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ import SMESH, SALOMEDS
+
+ ## Compute the minimum area of the faces of the mesh
+ def getMinArea(mesh):
+ faces = mesh.GetElementsByType(SMESH.FACE)
+ areas = [mesh.GetArea(face) for face in faces]
+ return min(areas)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ radius = 10
+ height = 100
+ Cylinder_1 = geompy.MakeCylinderRH(radius, height)
+
+ p_half_height = geompy.MakeVertex(0, 0, height/2.)
+ plane_z = geompy.MakePlane(p_half_height, OZ, 2.5*radius)
+
+ Part_1 = geompy.MakePartition([Cylinder_1], [plane_z], Limit=geompy.ShapeType["FACE"])
+
+
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Part_1, 'Part_1' )
+
+
+ p_edge_vert_opp_1 = geompy.MakeVertex(-radius, 0, 0)
+ geompy.addToStudy( p_edge_vert_opp_1, 'p_edge_vert_opp_1' )
+
+ edge_vert_opp_1 = geompy.MakePrismVecH(p_edge_vert_opp_1, OZ, height/2.)
+ geompy.addToStudy( edge_vert_opp_1, 'edge_vert_opp_1' )
+
+ p_edge_vert_opp_2 = geompy.MakeVertex(-radius, 0, height/4.)
+ geompy.addToStudy( p_edge_vert_opp_2, 'p_edge_vert_opp_2' )
+
+ p_face_cyl_1 = geompy.MakeVertex(0, radius, height/4.)
+ p_face_cyl_2 = geompy.MakeVertex(0, radius, 3*height/4.)
+
+ face_1 = geompy.GetFaceNearPoint(Part_1, p_face_cyl_1)
+ face_2 = geompy.GetFaceNearPoint(Part_1, p_face_cyl_2)
+
+ geompy.addToStudyInFather(Part_1, face_1, "face_1")
+ geompy.addToStudyInFather(Part_1, face_2, "face_2")
+
+ ###
+ ### SMESH component
+ ###
+
+ from salome.smesh import smeshBuilder
+
-print "min_area_without_attractor: ", min_area_without_attractor
++smesh = smeshBuilder.New()
+ Mesh_1 = smesh.Mesh(Part_1)
+ MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_1.SetPhySize( 14.1421 )
+ MG_CADSurf_Parameters_1.SetMinSize( 0.141421 )
+ MG_CADSurf_Parameters_1.SetMaxSize( 28.2843 )
+ MG_CADSurf_Parameters_1.SetChordalError( 7.07107 )
+ #MG_CADSurf_Parameters_1.SetAttractorGeom( sub_Face_1, Edge_1, 1, 14.1421, 5, 5 )
+
+ ok = Mesh_1.Compute()
+
+ if not ok:
+ raise Exception("Mesh not computed")
+
+ min_area_without_attractor = getMinArea(Mesh_1)
+
-print "min_area_with_attractor: ", min_area_with_attractor
++print("min_area_without_attractor: ", min_area_without_attractor)
+
+ MG_CADSurf_Parameters_1.SetAttractorGeom( face_1, edge_vert_opp_1, 1, 14.1421, 5, 5 )
+ # the attractor is not on the face. It is done on purpose to test this out of bounds case.
+ MG_CADSurf_Parameters_1.SetAttractorGeom( face_2, p_edge_vert_opp_2, 1, 14.1421, 5, 5 )
+
+ ok = Mesh_1.Compute()
+
+ if not ok:
+ raise Exception("Mesh with attractors not computed")
+
+ min_area_with_attractor = getMinArea(Mesh_1)
+
++print("min_area_with_attractor: ", min_area_with_attractor)
+
+ assert min_area_with_attractor < min_area_without_attractor
+
+ assert min_area_with_attractor < 1
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: utf-8 -*-
+
+ import salome
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ r = 10
+ dist = 10
+ dist_coin = 10.1
+
+ p1 = geompy.MakeVertex(0., 0., 0.)
+ p2 = geompy.MakeVertex(100., 100., 100.)
+ box = geompy.MakeBoxTwoPnt(p1, p2)
+ geompy.addToStudy(box, "box")
+
+ p3 = geompy.MakeVertex(dist_coin, 0, dist_coin)
+ geompy.addToStudy(p3, "p3")
+
+ part = geompy.MakePartition([box], [p3])
+ geompy.addToStudy(part, "part")
+
+ left = geompy.GetFaceNearPoint(box, p3)
+ geompy.addToStudyInFather(box, left, "left")
+
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+
+ algo2d.SetInternalEnforcedVertexAllFaces(True)
+
+ Mesh.Compute()
+
+ id_node = Mesh.FindNodeClosestTo(dist_coin, 0, dist_coin)
+
+ x, y, z = Mesh.GetNodeXYZ(id_node)
+
+ assert("%.2f, %.2f, %.2f"%(x, y, z) == "%.2f, %.2f, %.2f"%(dist_coin, 0, dist_coin))
+
++salome.sg.updateObjBrowser()
+
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: utf-8 -*-
+
+ import salome
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ dist_coin = 10.1
+
+ p1 = geompy.MakeVertex(0., 0., 0.)
+ p2 = geompy.MakeVertex(100., 100., 100.)
+ box = geompy.MakeBoxTwoPnt(p1, p2)
+ geompy.addToStudy(box, "box")
+
+ p3 = geompy.MakeVertex(dist_coin, 0, dist_coin)
+ geompy.addToStudy(p3, "p3")
+
+ left = geompy.GetFaceNearPoint(box, p3)
+ geompy.addToStudyInFather(box, left, "left")
+
+ allEnforcedCoords = []
+ allEnforcedCoords.append(( dist_coin, 0, dist_coin ))
+ allEnforcedCoords.append(( 20, 0, 15.3 ))
+ allEnforcedCoords.append(( 25, 1, 25.3 ))
+ allEnforcedCoords.append(( 35, 1, 45.3 ))
+ allEnforcedCoords.append(( 35, 1, 55.3 ))
+
+ p4 = geompy.MakeVertex( *(allEnforcedCoords[1] ))
+ p5 = geompy.MakeVertex( *(allEnforcedCoords[2] ))
+ pp = geompy.MakeCompound( [p4,p5], theName="p4,p5" )
+ p6 = geompy.MakeVertex( *(allEnforcedCoords[3] ), theName="p6")
+ p7 = geompy.MakeVertex( *(allEnforcedCoords[4] ), theName="p7")
+
+ xyz7 = allEnforcedCoords[4]
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(box, "Mesh")
+
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+
+ algo2d.SetEnforcedVertex(left, dist_coin, 0, dist_coin)
+ algo2d.AddEnforcedVertexGeom( pp )
+ algo2d.AddEnforcedVertexGeom( p6 )
+ algo2d.AddEnforcedVertex( *xyz7 )
+
+ assert Mesh.Compute()
+ assert not Mesh.FindCoincidentNodes( 1e-7 )
+
+ for x,y,z in allEnforcedCoords:
+
+ id_node = Mesh.FindNodeClosestTo( x,y,z )
+ xn, yn, zn = Mesh.GetNodeXYZ( id_node )
+
+ # compare X and Z
+ assert "%.2f, %.2f"%(x, z) == "%.2f, %.2f"%( xn, zn ), \
+ "%.2f, %.2f, %.2f != %.2f, %.2f, %.2f"%( xn, yn, zn, x,y,z )
+
+
++salome.sg.updateObjBrowser()
++
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import os
+ import sys
+ import salome
+ import time
+ import multiprocessing
+
+ salome.salome_init()
-print "Running test on workstation with %d available cores" % cpu_count
+
+ cpu_count = multiprocessing.cpu_count()
+ divider = min(4, cpu_count)/2.
+
-geompy = geomBuilder.New(theStudy)
++print ("Running test on workstation with %d available cores" % cpu_count)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ flight_solid_brep_1 = geompy.ImportBREP(os.path.join(os.getenv("DATA_DIR"),"Shapes/Brep/flight_solid.brep" ))
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( flight_solid_brep_1, 'flight_solid.brep_1' )
+
+ ###
+ ### SMESH component
+ ###
+
+ import SMESH, SALOMEDS
+ from salome.smesh import smeshBuilder
+
-print "Time in multi thread (%d cores): %.3s"%(cpu_count, time_multithread)
++smesh = smeshBuilder.New()
+
+ Mesh_1 = smesh.Mesh(flight_solid_brep_1)
+ MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_1.SetPhySize( 1 )
+ MG_CADSurf_Parameters_1.SetMaxSize( 1 )
+ MG_CADSurf_Parameters_1.SetGradation( 1.05 )
+ MG_CADSurf_Parameters_1.SetAngleMesh( 1 )
+ MG_CADSurf_Parameters_1.SetChordalError( 2.40018 )
+ # 4 procs are used by default
+ # => No need to set an option
+
+ time0 = time.time()
+ isDone = Mesh_1.Compute()
+ time1 = time.time()
+
+ time_multithread = time1-time0
+
-print "Time in single thread (1 proc): %.3s"%(time_singlethread)
++print ("Time in multi thread (%d cores): %.3s"%(cpu_count, time_multithread))
+
+ Mesh_2 = smesh.Mesh(flight_solid_brep_1)
+ MG_CADSurf = Mesh_2.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_2 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_2.SetPhySize( 1 )
+ MG_CADSurf_Parameters_2.SetMaxSize( 1 )
+ MG_CADSurf_Parameters_2.SetGradation( 1.05 )
+ MG_CADSurf_Parameters_2.SetAngleMesh( 1 )
+ MG_CADSurf_Parameters_2.SetChordalError( 2.40018 )
+ # Use only one thread
+ MG_CADSurf_Parameters_2.SetMaxNumberOfThreads( 1 )
+
+ time2 = time.time()
+ isDone = Mesh_2.Compute()
+ time3 = time.time()
+
+ time_singlethread = time3-time2
- print "Warning: cannot validate test - only 1 cpu core is available"
++print ("Time in single thread (1 proc): %.3s"%(time_singlethread))
+
+ if cpu_count == 1:
++ print ("Warning: cannot validate test - only 1 cpu core is available")
+ else:
+ assert time_multithread < time_singlethread/divider
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: iso-8859-1 -*-
+
+ import sys
+ import salome
+
+ ###
+ ### GEOM component
+ ###
+
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(10, 10, 1)
+ geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+ Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 )
+ vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True)
+ Curve_1 = geompy.MakeInterpol(vertices, True, True)
+
+ part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p1 = geompy.MakeVertex(-5, -5, 0)
+ p2 = geompy.MakeVertex(5, 5, 0)
+ left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(left, left_edges)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(right, right_edges)
+ geompy.addToStudyInFather(part, right, "right")
+
+ bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(bottom, bottom_edges)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(top, top_edges)
+ geompy.addToStudyInFather(part, top, "top")
+
+ source_face = geompy.GetFaceNearPoint(part, p1)
+ geompy.addToStudyInFather(part, source_face, "source_face")
+
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
- salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+ #algo2d.SetGradation(1.05)
+
+ # Periodicity
+ #algo2d.SetVerbosity(10)
+ algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+ algo2d.AddPreCadEdgesPeriodicity(left, right)
+ algo2d.AddPreCadEdgesPeriodicity(bottom, top)
+
+
+ Mesh.Compute()
+
+ gr_left = Mesh.Group(left)
+ gr_right = Mesh.Group(right)
+ gr_bottom = Mesh.Group(bottom)
+ gr_top = Mesh.Group(top)
+
+ Mesh.Compute()
+
+ left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' )
+ bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 0, 'bottom_translated' )
+
+ def checkProjection(gr, mesh_translated, tol=1e-7):
+ name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+ mesh_source = smesh.CopyMesh(gr, gr.GetName())
+ mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+ ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+ coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+ mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+ mesh_nodes = mesh_check.GetNodesId()
+ if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+ non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+ mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+ raise Exception("Projection failed for %s"%name)
+
+ checkProjection(gr_right, left_translated)
+ checkProjection(gr_top, bottom_translated)
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: iso-8859-1 -*-
+
+ import sys
+ import salome
+
+ ###
+ ### GEOM component
+ ###
+
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(10, 10, 1)
+ geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+ Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 )
+ vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True)
+ Curve_1 = geompy.MakeInterpol(vertices, True, True)
+
+ part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p1 = geompy.MakeVertex(-5, -5, 0)
+ p2 = geompy.MakeVertex(5, 5, 0)
+ left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(left, left_edges)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(right, right_edges)
+ geompy.addToStudyInFather(part, right, "right")
+
+ bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(bottom, bottom_edges)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(top, top_edges)
+ geompy.addToStudyInFather(part, top, "top")
+
+ source_face = geompy.GetFaceNearPoint(part, p1)
+ geompy.addToStudyInFather(part, source_face, "source_face")
+
+ # To define a rotation, we have to set at least 3 source vertices not aligned.
+ p_bas_gauche = geompy.MakeVertex(-5, -5, 0)
+ geompy.addToStudy(p_bas_gauche, "p_bas_gauche")
+ p_bas_mil = geompy.MakeVertex(0, -4, 0)
+ geompy.addToStudy(p_bas_mil, "p_bas_mil")
+ p_bas_droite = geompy.MakeVertex(5, -5, 0)
+ geompy.addToStudy(p_bas_droite, "p_bas_droite")
+
+ # Target vertices
+ p_mil_droite = geompy.MakeVertex(4, 0, 0)
+ geompy.addToStudy(p_mil_droite, "p_mil_droite")
+ p_haut_droite = geompy.MakeVertex(5, 5, 0)
+ geompy.addToStudy(p_haut_droite, "p_haut_droite")
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
- print "Projection failed for %s"%name
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+ #algo2d.SetGradation(1.05)
+
+ #algo2d.SetOptionValue( 'debug', '1' )
+ #algo2d.SetPreCADOptionValue( 'debug', '1' )
+
+ # Periodicity
+ #algo2d.SetVerbosity(10)
+ algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+ algo2d.AddPreCadEdgesPeriodicity(bottom, right, [p_bas_droite, p_bas_mil, p_bas_gauche], [p_bas_droite, p_mil_droite, p_haut_droite])
+
+
+ Mesh.Compute()
+
+ gr_left = Mesh.Group(left)
+ gr_right = Mesh.Group(right)
+ gr_bottom = Mesh.Group(bottom)
+ gr_top = Mesh.Group(top)
+
+ axe = geompy.MakePrismVecH(p_bas_droite, Vz, 1)
+ bottom_rotated = Mesh.RotateObjectMakeMesh( gr_bottom, axe, -math.pi/2, NewMeshName='bottom_rotated' )
+
+ def checkProjection(gr, mesh_translated, tol=1e-7):
+ name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+ mesh_source = smesh.CopyMesh(gr, gr.GetName())
+ mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+ ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+ coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+ mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+ mesh_nodes = mesh_check.GetNodesId()
+ if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+ non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+ mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+ #raise Exception("Projection failed for %s"%name)
-#salome.myStudyManager.SaveAs("test.hdf", salome.myStudy, 0)
++ print("Projection failed for %s"%name)
+
+ checkProjection(gr_right, bottom_rotated)
+
- salome.sg.updateObjBrowser(True)
++#salome.myStudy.SaveAs("test.hdf", 0, 0)
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
+
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ #!/usr/bin/env python
+ # -*- coding: utf-8 -*-
+
+ import salome
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ simple = False
+
+ r = 10
+ dist = 10
+
+ p1 = geompy.MakeVertex(0., 0., 0.)
+ p2 = geompy.MakeVertex(100., 100., 100.)
+ box = geompy.MakeBoxTwoPnt(p1, p2)
+ geompy.addToStudy(box, "box")
+
+ p3 = geompy.MakeVertex(50., 5., 25.)
+ sphere1 = geompy.MakeSpherePntR(p3, 15.)
+ geompy.addToStudy(sphere1, "sphere1")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p4 = geompy.MakeVertex(100., 0., 0.)
+ axe = geompy.MakePrismVecH(p4, Vz, 1)
+ geompy.addToStudy(axe, "axe")
+
+ sphere1_rota = geompy.MakeRotation(sphere1, axe, -math.pi/2.)
+ geompy.addToStudy(sphere1_rota, "sphere1_rota")
+
+ part = geompy.MakePartition([box], [sphere1, sphere1_rota])
+ geompy.addToStudy(part, "part")
+
+ left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(left, left_faces)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(right, right_faces)
+ geompy.addToStudyInFather(part, right, "right")
+
+ back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON)
+ back = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(back, back_faces)
+ geompy.addToStudyInFather(part, back, "back")
+
+ front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON)
+ front = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(front, front_faces)
+ geompy.addToStudyInFather(part, front, "front")
+
+ bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(bottom, bottom_faces)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(top, top_faces)
+ geompy.addToStudyInFather(part, top, "top")
+
+ p1_rota = geompy.MakeRotation(p1, axe, -math.pi/2.)
+ geompy.addToStudy(sphere1_rota, "sphere1_rota")
+
+ p5 = geompy.MakeVertex(100, 0, 100)
+ geompy.addToStudy(p5, "p5")
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+
+ # Periodicity
+ #algo2d.SetVerbosity(10)
+ #algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+ algo2d.AddPreCadFacesPeriodicity(left, front, [p1, p4, p5], [p1_rota, p4, p5])
+
+
+ gr_left = Mesh.Group(left)
+ gr_right = Mesh.Group(right)
+ gr_front = Mesh.Group(front)
+ gr_back = Mesh.Group(back)
+ gr_bottom = Mesh.Group(bottom)
+ gr_top = Mesh.Group(top)
+
+ Mesh.Compute()
+
+ left_rotated = Mesh.RotateObjectMakeMesh( gr_left, axe, -math.pi/2, NewMeshName='left_rotated' )
+
+ def checkProjection(gr, mesh_translated, tol=1e-7):
+ name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+ mesh_source = smesh.CopyMesh(gr, gr.GetName())
+ mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+ ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+ coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+ mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+ mesh_nodes = mesh_check.GetNodesId()
+ if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+ non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+ mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+ raise Exception("Projection failed for %s"%name)
+
+ checkProjection(gr_front, left_rotated)
+
++salome.sg.updateObjBrowser()
+
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: iso-8859-1 -*-
+
+ import sys
+ import salome
+
+ ###
+ ### GEOM component
+ ###
+
+ import math
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(10, 10, 1)
+ geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+ Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 )
+ vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True)
+ Curve_1 = geompy.MakeInterpol(vertices, True, True)
+
+ part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p1 = geompy.MakeVertex(-5, -5, 0)
+ p2 = geompy.MakeVertex(5, 5, 0)
+ left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(left, left_edges)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(right, right_edges)
+ geompy.addToStudyInFather(part, right, "right")
+
+ bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(bottom, bottom_edges)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(top, top_edges)
+ geompy.addToStudyInFather(part, top, "top")
+
+ source_face = geompy.GetFaceNearPoint(part, p1)
+ geompy.addToStudyInFather(part, source_face, "source_face")
+
+ p_bas_gauche = geompy.MakeVertex(-5, -5, 0)
+ geompy.addToStudy(p_bas_gauche, "p_bas_gauche")
+ p_bas_mil = geompy.MakeVertex(0, -4, 0)
+ geompy.addToStudy(p_bas_mil, "p_bas_mil")
+ p_bas_droite = geompy.MakeVertex(5, -5, 0)
+ geompy.addToStudy(p_bas_droite, "p_bas_droite")
+ p_haut_gauche = geompy.MakeVertex(-5, 5, 0)
+ geompy.addToStudy(p_haut_gauche, "p_haut_gauche")
+ p_haut_mil = geompy.MakeVertex(0, 6, 0)
+ geompy.addToStudy(p_haut_mil, "p_haut_mil")
+ p_haut_droite = geompy.MakeVertex(5, 5, 0)
+ geompy.addToStudy(p_haut_droite, "p_haut_droite")
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
- salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf)
+ algo2d.SetGeometricMesh( 1 )
+ algo2d.SetAngleMesh( 4 )
+ algo2d.SetPhySize( 8 )
+ #algo2d.SetGradation(1.05)
+
+ # Periodicity
+ #algo2d.SetVerbosity(10)
+ algo2d.SetPreCADOptionValue("periodic_tolerance", "1e-2")
+ algo2d.AddPreCadEdgesPeriodicity(bottom, top, [p_bas_gauche, p_bas_mil, p_bas_droite], [p_haut_gauche, p_haut_mil, p_haut_droite])
+
+ # debug
+ #algo2d.SetOptionValue( 'debug', '1' )
+ #algo2d.SetPreCADOptionValue( 'debug', '1' )
+
+ Mesh.Compute()
+
+ gr_left = Mesh.Group(left)
+ gr_right = Mesh.Group(right)
+ gr_bottom = Mesh.Group(bottom)
+ gr_top = Mesh.Group(top)
+
+ Mesh.Compute()
+
+ left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' )
+ bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 0, 'bottom_translated' )
+
+ def checkProjection(gr, mesh_translated, tol=1e-7):
+ name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0]
+ mesh_source = smesh.CopyMesh(gr, gr.GetName())
+ mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name)
+ ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol)
+ coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist]
+ mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes)
+ mesh_nodes = mesh_check.GetNodesId()
+ if len(ll_coincident_nodes) != mesh_translated.NbNodes():
+ non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
+ mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
+ raise Exception("Projection failed for %s"%name)
+
+ checkProjection(gr_top, bottom_translated)
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
+
+
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(salome.myStudy)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
-geompy.init_geom(theStudy)
++geompy = geomBuilder.New()
+
+
-smesh = smeshBuilder.New(salome.myStudy)
++geompy.init_geom()
+
+ 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
- salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+
+ Mesh_1 = smesh.Mesh(Partition_1)
+
+ BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ BLSURF_Parameters = BLSURF_1.Parameters()
+ BLSURF_Parameters.SetPhySize( 5 )
+ BLSURF_Parameters.SetPreCADMergeEdges( True )
+ BLSURF_Parameters.SetPreCADProcess3DTopology( True )
+ BLSURF_Parameters.SetPreCADOptionValue( 'remove_tiny_uv_edges', 'yes' )
+
+ Mesh_1.Compute()
+
+ # 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 = list(set(nodes))
+
+ nodesGroup = Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes)
+
+ assert nodesGroup.Size() == 1, nodesGroup.GetIDs()
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(salome.myStudy)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
-geompy.init_geom(theStudy)
++geompy = geomBuilder.New()
+
+
-smesh = smeshBuilder.New(salome.myStudy)
++geompy.init_geom()
+
+ 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
- salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+
+ Mesh_1 = smesh.Mesh(Partition_1)
+
+ BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ BLSURF_Parameters = BLSURF_1.Parameters()
+ BLSURF_Parameters.SetPhySize( 5 )
+
+ Mesh_1.Compute()
+
+ # Check that vertices are not merged by preCAD preprocessing
+ # when no preprocessing option has been explicitely called
+ nodes = []
+ for p in vertices:
+ x, y, z = geompy.PointCoordinates(p)
+ id_node = Mesh_1.FindNodeClosestTo(x, y, z)
+ nodes.append(id_node)
+
+ nodes = list(set(nodes))
+
+ Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes)
+
+ assert len(nodes) == 3, "We should have 3 nodes. We got %i. => The preprocessing has done something, but we did not ask him to."%len(nodes)
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ # Create a box
+ box = geompy.MakeBoxDXDYDZ(100, 100, 100)
+
+ # Create a sphere near the sides of the box
+ sphere_tmp = geompy.MakeSphereR(5)
+ sphere = geompy.MakeTranslation(sphere_tmp, 6, 6, 50)
+
+ part = geompy.MakePartition([box, sphere])
+ geompy.addToStudy( box, 'box' )
+ geompy.addToStudy( sphere, 'sphere' )
+ geompy.addToStudy( part, 'part' )
+
+ # Create the groups of faces
+ box_faces = geompy.GetShapesOnBox(box, part, geompy.ShapeType["FACE"], GEOM.ST_ON)
+ gr_box_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(gr_box_faces, box_faces)
+ geompy.addToStudyInFather(part, gr_box_faces, "box_faces")
+
+ all_faces = geompy.SubShapeAll(part, geompy.ShapeType["FACE"])
+ gr_all_faces = geompy.CreateGroup(part, geompy.ShapeType["FACE"])
+ geompy.UnionList(gr_all_faces, all_faces)
+
+ gr_spheres_faces = geompy.CutGroups(gr_all_faces, gr_box_faces)
+ geompy.addToStudyInFather(part, gr_spheres_faces, "spheres_faces")
+
+ ###
+ ### SMESH component
+ ###
+
+ import SMESH, SALOMEDS
+ from salome.smesh import smeshBuilder
+
-print "min_area: ", min_area
++smesh = smeshBuilder.New()
+ Mesh_1 = smesh.Mesh(part, "Mesh_part")
+ BLSURF = Mesh_1.Triangle(algo=smeshBuilder.BLSURF)
+ BLSURF_Parameters_1 = BLSURF.Parameters()
+ BLSURF_Parameters_1.SetGradation( 1.2 )
+ BLSURF_Parameters_1.SetGeometricMesh( 1 )
+ BLSURF_Parameters_1.SetPhySize( 20 )
+ #BLSURF_Parameters_1.SetMinSize( 0.1 )
+ BLSURF_Parameters_1.SetMaxSize( 20 )
+ BLSURF_Parameters_1.SetAngleMesh( 8 )
+
+ # Old way to set proximity (Mesh Gems 1.1)
+ #BLSURF_Parameters_1.SetOptionValue( 'proximity', '1' )
+ #BLSURF_Parameters_1.SetOptionValue( 'prox_ratio', '1.2' )
+ #BLSURF_Parameters_1.SetOptionValue( 'prox_nb_layer', '3' )
+
+ # New way to set proximity (Mesh Gems >= 1.3)
+ BLSURF_Parameters_1.SetOptionValue( "volume_gradation", "1.2" )
+
+ isDone = Mesh_1.Compute()
+ if not isDone:
+ raise Exception("Compute mesh ended in error")
+
+ # Create the groups on the mesh
+ gr_mesh_box = Mesh_1.Group(gr_box_faces)
+ gr_mesh_spheres = Mesh_1.Group(gr_spheres_faces)
+
+ # Check the minimal area of the box faces to check the proximity
+ min_area, max_area = Mesh_1.GetMinMax(SMESH.FT_Area, gr_mesh_box)
+
- salome.sg.updateObjBrowser(True)
++print("min_area: ", min_area)
+
+ if min_area > 1.5:
+ raise Exception("Wrong minimal area on box. Proximity has not worked.")
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(theStudy)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
+ import math
+ import SALOMEDS
+
+
-smesh = smeshBuilder.New(theStudy)
++geompy = geomBuilder.New()
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+ Face_1 = geompy.MakeFaceHW(100, 100, 1)
+ Disk_1 = geompy.MakeDiskR(20, 1)
+ Partition_1 = geompy.MakePartition([Face_1, Disk_1], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy( O, 'O' )
+ geompy.addToStudy( OX, 'OX' )
+ geompy.addToStudy( OY, 'OY' )
+ geompy.addToStudy( OZ, 'OZ' )
+ geompy.addToStudy( Face_1, 'Face_1' )
+ geompy.addToStudy( Disk_1, 'Disk_1' )
+ geompy.addToStudy( Partition_1, 'Partition_1' )
+
+ ###
+ ### SMESH component
+ ###
+
+ import SMESH, SALOMEDS
+ from salome.smesh import smeshBuilder
+
+ from salome.BLSURFPlugin import BLSURFPluginBuilder
+
++smesh = smeshBuilder.New()
+ Mesh_1 = smesh.Mesh(Partition_1)
+ MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
+ MG_CADSurf_Parameters_1.SetPhySize( 10 )
+ MG_CADSurf_Parameters_1.SetMaxSize( 10 )
+ MG_CADSurf_Parameters_1.SetChordalError( -1 )
+
+
+ # Test quadrangle dominant
+ MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
+ isDone = Mesh_1.Compute()
+
+ assert Mesh_1.NbQuadrangles() > 0
+ assert Mesh_1.NbTriangles() > 0
+ assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles()
+
+
+ # Test quadrangles only
+ MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Quadrangles )
+ isDone = Mesh_1.Compute()
+
+ assert Mesh_1.NbQuadrangles() > 0
+ assert Mesh_1.NbTriangles() == 0
+
+
+ # Test triangles only
+ MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Triangles )
+ isDone = Mesh_1.Compute()
+
+ assert Mesh_1.NbQuadrangles() == 0
+ assert Mesh_1.NbTriangles() > 0
+
+ # Test quadrangle dominant compatibility (to be deprecated in Salome 9)
+ MG_CADSurf_Parameters_1.SetQuadAllowed( True )
+ isDone = Mesh_1.Compute()
+
+ assert Mesh_1.NbQuadrangles() > 0
+ assert Mesh_1.NbTriangles() > 0
+ assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles()
+
+ if salome.sg.hasDesktop():
+ salome.sg.updateObjBrowser(True)
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: utf-8 -*-
+
+ import salome
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ import math
+
+ area_tolerance = 0.1
+ nb_faces_tolerance = 20
+
+ ## Return the min and max areas of a mesh
+ def getMinMaxArea(mesh):
+ mini, maxi = mesh.GetMinMax(SMESH.FT_Area)
+ return mini, maxi
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ Face_1 = geompy.MakeFaceHW(10, 10, 1)
+ geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+ Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 )
+ vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True)
+ Curve_1 = geompy.MakeInterpol(vertices, True, True)
+
+ p_small = geompy.MakeVertexOnCurve(Curve_1, 0.001)
+ geompy.addToStudy(p_small, "p_small")
+
+ p_small2 = geompy.MakeVertexOnCurve(Curve_1, 0.5)
+ geompy.addToStudy(p_small2, "p_small2")
+
+ p_small3 = geompy.MakeVertexOnCurve(Curve_1, 0.501)
+ geompy.addToStudy(p_small3, "p_small3")
+
+ part = geompy.MakePartition([Face_1], [Curve_1, p_small, p_small2, p_small3], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p1 = geompy.MakeVertex(-5, -5, 0)
+ p2 = geompy.MakeVertex(5, 5, 0)
+ left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(left, left_edges)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(right, right_edges)
+ geompy.addToStudyInFather(part, right, "right")
+
+ bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(bottom, bottom_edges)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(top, top_edges)
+ geompy.addToStudyInFather(part, top, "top")
+
+ faces = geompy.SubShapeAll(part, geompy.ShapeType["FACE"])
+ sub_shapes = []
+ for i, face in enumerate(faces):
+ geompy.addToStudyInFather(part, face, "face_%i"%(i+1))
+ sub_shapes.append(face)
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
- salome.sg.updateObjBrowser(True)
++smesh = smeshBuilder.New()
+
+ # Test gradation with quadrangles
+ Mesh_1 = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh_1.Triangle(algo=smeshBuilder.BLSURF)
+ params = algo2d.Parameters()
+ params.SetGeometricMesh( 1 )
+ params.SetAngleMesh( 4 )
+ params.SetPhySize( 8 )
+ algo2d.SetGradation(1.05)
+ params.SetElementType( True )
+
+ ok = Mesh_1.Compute()
+
+ if not ok:
+ raise Exception("Error when computing Mesh_1")
+
+ # Check the areas of Mesh_1
+ mini_1, maxi_1 = getMinMaxArea(Mesh_1)
+ mini_1_ref = 0.00197
+ maxi_1_ref = 0.530
+
+ if abs(mini_1-mini_1_ref) > area_tolerance:
+ raise Exception("Min area of Mesh_1 incorrect")
+
+ if maxi_1 > maxi_1_ref:
+ raise Exception("Max area of Mesh_1 incorrect")
+
+ # Check the number of faces of Mesh_1
+ nb_faces_1 = Mesh_1.NbFaces()
+ nb_faces_1_ref = 1208
+
+ if nb_faces_1 < nb_faces_1_ref:
+ raise Exception("Number of faces of Mesh_1 incorrect")
+
+
+ # Test no gradation with quadrangles and anisotropy
+ # RQ: this kind of mesh is not suitable for simulation
+ # but gives a coarse mesh like a stl geometry
+ Mesh_2 = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh_2.Triangle(algo=smeshBuilder.BLSURF)
+ params = algo2d.Parameters()
+ params.SetGeometricMesh( 1 )
+ params.SetAngleMesh( 4 )
+ params.SetPhySize( 8 )
+ algo2d.SetGradation(1.05)
+ params.SetElementType( 1 )
+ params.SetAnisotropic(True)
+
+ ok = Mesh_2.Compute()
+
+ if not ok:
+ raise Exception("Error when computing Mesh_2")
+
+ # Check the areas of Mesh_2
+ mini_2, maxi_2 = getMinMaxArea(Mesh_2)
+ mini_2_ref = 0.000408
+ maxi_2_ref = 10.1982
+
+ if abs(mini_2-mini_2_ref) > area_tolerance:
+ raise Exception("Min area of Mesh_2 incorrect")
+
+ if abs(maxi_2-maxi_2_ref) > area_tolerance:
+ raise Exception("Max area of Mesh_2 incorrect")
+
+ # Check the number of faces of Mesh_2
+ nb_faces_2 = Mesh_2.NbFaces()
+ nb_faces_2_ref = 121
+ if abs(nb_faces_2-nb_faces_2_ref) > nb_faces_tolerance:
+ raise Exception("Number of faces of Mesh_2 incorrect")
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
+
+
--- /dev/null
-geompy = geomBuilder.New(salome.myStudy)
+ # -*- coding: utf-8 -*-
+
+ import salome
+
+ import GEOM
+ from salome.geom import geomBuilder
-smesh = smeshBuilder.New(salome.myStudy)
++geompy = geomBuilder.New()
+
+ import math
+
+ tiny_edge_length = 0.1
+
+ O = geompy.MakeVertex(0, 0, 0)
+ OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ Face_1 = geompy.MakeFaceHW(10, 10, 1)
+ geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0)
+ Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 )
+ vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True)
+ Curve_1 = geompy.MakeInterpol(vertices, True, True)
+
+ p_small = geompy.MakeVertexOnCurve(Curve_1, 0.001)
+ geompy.addToStudy(p_small, "p_small")
+
+ part = geompy.MakePartition([Face_1], [Curve_1, p_small], Limit=geompy.ShapeType["FACE"])
+ geompy.addToStudy(part, "part")
+
+ Vx = geompy.MakeVectorDXDYDZ(1, 0, 0)
+ Vy = geompy.MakeVectorDXDYDZ(0, 1, 0)
+ Vz = geompy.MakeVectorDXDYDZ(0, 0, 1)
+
+ p1 = geompy.MakeVertex(-5, -5, 0)
+ p2 = geompy.MakeVertex(5, 5, 0)
+ left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON)
+ left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(left, left_edges)
+ geompy.addToStudyInFather(part, left, "left")
+
+ right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON)
+ right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(right, right_edges)
+ geompy.addToStudyInFather(part, right, "right")
+
+ bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON)
+ bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(bottom, bottom_edges)
+ geompy.addToStudyInFather(part, bottom, "bottom")
+
+ top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON)
+ top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"])
+ geompy.UnionList(top, top_edges)
+ geompy.addToStudyInFather(part, top, "top")
+
+ faces = geompy.SubShapeAll(part, geompy.ShapeType["FACE"])
+ sub_shapes = []
+ for i, face in enumerate(faces):
+ geompy.addToStudyInFather(part, face, "face_%i"%(i+1))
+ sub_shapes.append(face)
+
+ # Mesh
+ # ====
+
+ import SMESH
+ from salome.smesh import smeshBuilder
-print min_length
++smesh = smeshBuilder.New()
+
+ Mesh = smesh.Mesh(part, "Mesh")
+
+ algo2d = Mesh.Triangle(algo=smeshBuilder.BLSURF)
+ params = algo2d.Parameters()
+ params.SetVerbosity(1)
+ #algo2d.SetTopology(smesh.PreCAD)
+ params.SetGeometricMesh( 1 )
+ params.SetAngleMesh( 4 )
+ params.SetPhySize( 8 )
+ #algo2d.SetGradation(1.05)
+ params.SetQuadraticMesh( True )
+ params.SetRemoveTinyEdges( True )
+ params.SetTinyEdgeLength( tiny_edge_length )
+ #params.SetOptionValue( 'rectify_jacobian', '0' )
+
+ Mesh.Compute()
+
+ for sub_shape in sub_shapes:
+ Mesh.Group(sub_shape)
+
+ x0, y0, z0 = geompy.PointCoordinates(p_small)
+ node = Mesh.FindNodeClosestTo(x0, y0, z0)
+
+ elems = Mesh.GetNodeInverseElements(node)
+
+ edges_length = []
+ for elem in elems:
+ if Mesh.GetElementType(elem, True) == SMESH.EDGE:
+ edge_length = Mesh.GetLength(elem)
+ edges_length.append(edge_length)
+
+ min_length = min(edges_length)
+ x1, y1, z1 = Mesh.GetNodeXYZ(node)
+
- salome.sg.updateObjBrowser(True)
++print(min_length)
+
+ if min_length<tiny_edge_length:
+ raise Exception("Small edge has not been removed")
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()
--- /dev/null
-theStudy = salome.myStudy
+ # -*- coding: utf-8 -*-
+
+ import sys
+ import salome
+
+ salome.salome_init()
-geompy = geomBuilder.New(salome.myStudy)
+
+ ###
+ ### GEOM component
+ ###
+
+ import GEOM
+ from salome.geom import geomBuilder
-geompy.init_geom(theStudy)
++geompy = geomBuilder.New()
+
+
-smesh = smeshBuilder.New(salome.myStudy)
++geompy.init_geom()
+
+ sphere = geompy.MakeSphereR(10)
+ geompy.addToStudy( sphere, 'sphere' )
+
+ ###
+ ### SMESH component
+ ###
+
+ import SMESH
+ from salome.smesh import smeshBuilder
- print "Warning: Cannot build volume mesh: MG-Tetra plugin seems to be unavailable"
++smesh = smeshBuilder.New()
+
+
+ Mesh_1 = smesh.Mesh(sphere)
+
+ BLSURF_1 = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
+ BLSURF_Parameters = BLSURF_1.Parameters()
+ BLSURF_Parameters.SetPhySize( 5 )
+ BLSURF_Parameters.SetGeometricMesh( 1 )
+ BLSURF_Parameters.SetAngleMesh( 8 )
+
+ ok = Mesh_1.Compute()
+
+ if not ok:
+ raise Exception("Error when computing surface mesh")
+
+ try:
+ Mesh_1.Tetrahedron(algo=smeshBuilder.MG_Tetra)
+
+ ok = Mesh_1.Compute()
+
+ if not ok:
+ raise Exception("Error when computing volume mesh")
+ except AttributeError:
- salome.sg.updateObjBrowser(True)
++ print("Warning: Cannot build volume mesh: MG-Tetra plugin seems to be unavailable")
+
+ if salome.sg.hasDesktop():
++ salome.sg.updateObjBrowser()