Salome HOME
updated copyright message
[plugins/blsurfplugin.git] / tests / quadrangles.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2017-2023  CEA/DEN, EDF R&D
3 #
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.
8 #
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.
13 #
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
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20
21 import sys
22 import salome
23
24 salome.salome_init()
25
26 ###
27 ### GEOM component
28 ###
29
30 import GEOM
31 from salome.geom import geomBuilder
32 import math
33 import SALOMEDS
34
35
36 geompy = geomBuilder.New()
37
38 O = geompy.MakeVertex(0, 0, 0)
39 OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
40 OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
41 OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
42 Face_1 = geompy.MakeFaceHW(100, 100, 1)
43 Disk_1 = geompy.MakeDiskR(20, 1)
44 Partition_1 = geompy.MakePartition([Face_1, Disk_1], Limit=geompy.ShapeType["FACE"])
45 geompy.addToStudy( O, 'O' )
46 geompy.addToStudy( OX, 'OX' )
47 geompy.addToStudy( OY, 'OY' )
48 geompy.addToStudy( OZ, 'OZ' )
49 geompy.addToStudy( Face_1, 'Face_1' )
50 geompy.addToStudy( Disk_1, 'Disk_1' )
51 geompy.addToStudy( Partition_1, 'Partition_1' )
52
53 ###
54 ### SMESH component
55 ###
56
57 import  SMESH, SALOMEDS
58 from salome.smesh import smeshBuilder
59
60 from salome.BLSURFPlugin import BLSURFPluginBuilder
61
62 smesh = smeshBuilder.New()
63 Mesh_1 = smesh.Mesh(Partition_1)
64 MG_CADSurf = Mesh_1.Triangle(algo=smeshBuilder.MG_CADSurf)
65 MG_CADSurf_Parameters_1 = MG_CADSurf.Parameters()
66 MG_CADSurf_Parameters_1.SetPhySize( 10 )
67 MG_CADSurf_Parameters_1.SetMaxSize( 10 )
68 MG_CADSurf_Parameters_1.SetChordalError( -1 )
69
70
71 # Test quadrangle dominant
72 MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.QuadrangleDominant )
73 isDone = Mesh_1.Compute()
74
75 assert Mesh_1.NbQuadrangles() > 0
76 assert Mesh_1.NbTriangles() > 0
77 assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles()
78
79
80 # Test quadrangles only
81 MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Quadrangles )
82 isDone = Mesh_1.Compute()
83
84 assert Mesh_1.NbQuadrangles() > 0
85 assert Mesh_1.NbTriangles() == 0
86
87
88 # Test triangles only
89 MG_CADSurf_Parameters_1.SetElementType( BLSURFPluginBuilder.Triangles )
90 isDone = Mesh_1.Compute()
91
92 assert Mesh_1.NbQuadrangles() == 0
93 assert Mesh_1.NbTriangles() > 0
94
95 # Test quadrangle dominant compatibility (to be deprecated in Salome 9)
96 MG_CADSurf_Parameters_1.SetQuadAllowed( True )
97 isDone = Mesh_1.Compute()
98
99 assert Mesh_1.NbQuadrangles() > 0
100 assert Mesh_1.NbTriangles() > 0
101 assert Mesh_1.NbQuadrangles() > Mesh_1.NbTriangles()
102
103 if salome.sg.hasDesktop():
104   salome.sg.updateObjBrowser()