1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2017-2024 CEA, EDF
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License, or (at your option) any later version.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 import SMESH, SALOMEDS
28 ## Compute the minimum area of the faces of the mesh
30 faces = mesh.GetElementsByType(SMESH.FACE)
31 areas = [mesh.GetArea(face) for face in faces]
39 from salome.geom import geomBuilder
44 geompy = geomBuilder.New()
46 O = geompy.MakeVertex(0, 0, 0)
47 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
48 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
49 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
50 Face_1 = geompy.MakeFaceHW(100, 100, 1)
51 Box_1 = geompy.MakePrismVecH(Face_1, OZ, -100)
52 # define the edge slightly longer than the face to test out of bounds case.
53 P1 = geompy.MakeVertex(-50.5, 0, 0)
54 P2 = geompy.MakeVertex(50.5, 0, 0)
55 Edge_1 = geompy.MakeEdge(P1, P2)
56 geompy.addToStudy( O, 'O' )
57 geompy.addToStudy( OX, 'OX' )
58 geompy.addToStudy( OY, 'OY' )
59 geompy.addToStudy( OZ, 'OZ' )
60 geompy.addToStudy( Face_1, 'Face_1' )
61 geompy.addToStudy( Box_1, 'Box_1' )
62 geompy.addToStudy( Edge_1, 'Edge_1' )
64 sub_Face_1 = geompy.GetInPlace(Box_1, Face_1)
65 geompy.addToStudyInFather(Box_1, sub_Face_1, "Face_1")
71 from salome.smesh import smeshBuilder
73 smesh = smeshBuilder.New()
74 Mesh_1 = smesh.Mesh(Box_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 )
85 min_area_without_attractor = getMinArea(Mesh_1)
87 print("min_area_without_attractor: ", min_area_without_attractor)
89 MG_CADSurf_Parameters_1.SetAttractorGeom( sub_Face_1, Edge_1, 1, 14.1421, 5, 5 )
93 min_area_with_attractor = getMinArea(Mesh_1)
95 print("min_area_with_attractor: ", min_area_with_attractor)
97 assert min_area_with_attractor < min_area_without_attractor
99 assert min_area_with_attractor < 1
101 if salome.sg.hasDesktop():
102 salome.sg.updateObjBrowser()