1 # -*- coding: utf-8 -*-
10 ## Compute the minimum area of the faces of the mesh
12 faces = mesh.GetElementsByType(SMESH.FACE)
13 areas = [mesh.GetArea(face) for face in faces]
21 from salome.geom import geomBuilder
26 geompy = geomBuilder.New()
28 O = geompy.MakeVertex(0, 0, 0)
29 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
30 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
31 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
34 Cylinder_1 = geompy.MakeCylinderRH(radius, height)
36 p_half_height = geompy.MakeVertex(0, 0, height/2.)
37 plane_z = geompy.MakePlane(p_half_height, OZ, 2.5*radius)
39 Part_1 = geompy.MakePartition([Cylinder_1], [plane_z], Limit=geompy.ShapeType["FACE"])
42 geompy.addToStudy( O, 'O' )
43 geompy.addToStudy( OX, 'OX' )
44 geompy.addToStudy( OY, 'OY' )
45 geompy.addToStudy( OZ, 'OZ' )
46 geompy.addToStudy( Part_1, 'Part_1' )
49 p_edge_vert_opp_1 = geompy.MakeVertex(-radius, 0, 0)
50 geompy.addToStudy( p_edge_vert_opp_1, 'p_edge_vert_opp_1' )
52 edge_vert_opp_1 = geompy.MakePrismVecH(p_edge_vert_opp_1, OZ, height/2.)
53 geompy.addToStudy( edge_vert_opp_1, 'edge_vert_opp_1' )
55 p_edge_vert_opp_2 = geompy.MakeVertex(-radius, 0, height/4.)
56 geompy.addToStudy( p_edge_vert_opp_2, 'p_edge_vert_opp_2' )
58 p_face_cyl_1 = geompy.MakeVertex(0, radius, height/4.)
59 p_face_cyl_2 = geompy.MakeVertex(0, radius, 3*height/4.)
61 face_1 = geompy.GetFaceNearPoint(Part_1, p_face_cyl_1)
62 face_2 = geompy.GetFaceNearPoint(Part_1, p_face_cyl_2)
64 geompy.addToStudyInFather(Part_1, face_1, "face_1")
65 geompy.addToStudyInFather(Part_1, face_2, "face_2")
71 from salome.smesh import smeshBuilder
73 smesh = smeshBuilder.New()
74 Mesh_1 = smesh.Mesh(Part_1)
75 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
76 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
77 MG_CADSurf_Parameters_1.SetPhySize( 14.1421 )
78 MG_CADSurf_Parameters_1.SetMinSize( 0.141421 )
79 MG_CADSurf_Parameters_1.SetMaxSize( 28.2843 )
80 MG_CADSurf_Parameters_1.SetChordalError( 7.07107 )
81 #MG_CADSurf_Parameters_1.SetAttractorGeom( sub_Face_1, Edge_1, 1, 14.1421, 5, 5 )
86 raise Exception("Mesh not computed")
88 min_area_without_attractor = getMinArea(Mesh_1)
90 print("min_area_without_attractor: ", min_area_without_attractor)
92 MG_CADSurf_Parameters_1.SetAttractorGeom( face_1, edge_vert_opp_1, 1, 14.1421, 5, 5 )
93 # the attractor is not on the face. It is done on purpose to test this out of bounds case.
94 MG_CADSurf_Parameters_1.SetAttractorGeom( face_2, p_edge_vert_opp_2, 1, 14.1421, 5, 5 )
99 raise Exception("Mesh with attractors not computed")
101 min_area_with_attractor = getMinArea(Mesh_1)
103 print("min_area_with_attractor: ", min_area_with_attractor)
105 assert min_area_with_attractor < min_area_without_attractor
107 assert min_area_with_attractor < 1
109 if salome.sg.hasDesktop():
110 salome.sg.updateObjBrowser(True)