1 # Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 # This is an automation of the cylinder-box object, defined with the coordinates of its center, its radius, and the box's
28 # The pitch ratio is calculated automatically from the minimum of the box dimensions on x and y.
29 # This functions can take a groups input containing the group names of 4 sides in addition to the internal circular boundary
30 # in the following order : [South,North,West,East,Internal].
32 import sys, math, commands
33 CWD = commands.getoutput('pwd')
37 from MacObject import *
38 import Config, GenFunctions
40 def Cylinder (X0 , Y0 , D , DX , DY , LocalMeshing , **args) :
41 if args.__contains__('DLocal') : DLocal = float(args['DLocal'])
42 else : DLocal = float(min(DX,DY))
44 # K is the pitch ratio
45 K = float(D)/(DLocal-D)
46 print "A local pitch ratio of K =", K ," will be used. "
47 NumCuts = 2*GenFunctions.QuarCylParam(K)
48 InternalMeshing = int(math.ceil(math.pi*D/(4*NumCuts*LocalMeshing)))
49 if InternalMeshing == 0 : InternalMeshing = 1 # This sets a minimum meshing condition in order to avoid an error. The user is notified of the value considered for the local meshing
50 print "Possible Local meshing is :", math.pi*D/(4*NumCuts*InternalMeshing), "\nThis value is returned by this function for your convenience.\n"
51 if args.__contains__('groups') :
52 GroupNames = args['groups']
53 else : GroupNames = [None, None, None, None, None]
57 GN1 = [None,GroupNames[1],None,GroupNames[3],GroupNames[4]]
58 GN2 = [None,GroupNames[1],GroupNames[2],None,GroupNames[4]]
59 GN3 = [GroupNames[0],None,GroupNames[2],None,GroupNames[4]]
60 GN4 = [GroupNames[0],None,None,GroupNames[3],GroupNames[4]]
62 GN1 = [None,GroupNames[1],None,None,GroupNames[4]]
63 GN2 = [None,GroupNames[1],None,None,GroupNames[4]]
64 GN3 = [GroupNames[0],None,None,None,GroupNames[4]]
65 GN4 = [GroupNames[0],None,None,None,GroupNames[4]]
67 GN5 = [GroupNames[0],GroupNames[1],None,GroupNames[3]]
68 GN6 = [GroupNames[0],GroupNames[1],GroupNames[2],None]
71 GN1 = [None,None,None,GroupNames[3],GroupNames[4]]
72 GN2 = [None,None,GroupNames[2],None,GroupNames[4]]
73 GN3 = [None,None,GroupNames[2],None,GroupNames[4]]
74 GN4 = [None,None,None,GroupNames[3],GroupNames[4]]
75 GN7 = [GroupNames[0],None,GroupNames[2],GroupNames[3]]
76 GN8 = [None,GroupNames[1],GroupNames[2],GroupNames[3]]
78 GN1 = [None,None,None,None,GroupNames[4]]
79 GN2 = [None,None,None,None,GroupNames[4]]
80 GN3 = [None,None,None,None,GroupNames[4]]
81 GN4 = [None,None,None,None,GroupNames[4]]
83 GN5 = [None,None,None,GroupNames[3]]
84 GN6 = [None,None,GroupNames[2],None]
86 GN9 = [GroupNames[0],None,None,GroupNames[3]]
87 GN10 = [GroupNames[0],None,None,None]
88 GN11 = [GroupNames[0],None,GroupNames[2],None]
90 GN12 = [None,GroupNames[1],None,GroupNames[3]]
91 GN13 = [None,GroupNames[1],None,None]
92 GN14 = [None,GroupNames[1],GroupNames[2],None]
96 Obj.append(MacObject('QuartCyl',[(X0+DLocal/4.,Y0+DLocal/4.),(DLocal/2.,DLocal/2.)],[InternalMeshing,'NE',K], groups = GN1))
97 Obj.append(MacObject('QuartCyl',[(X0-DLocal/4.,Y0+DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','NW',K], groups = GN2))
98 Obj.append(MacObject('QuartCyl',[(X0-DLocal/4.,Y0-DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','SW',K], groups = GN3))
99 Obj.append(MacObject('QuartCyl',[(X0+DLocal/4.,Y0-DLocal/4.),(DLocal/2.,DLocal/2.)],['auto','SE',K], groups = GN4))
102 dX = (DX - DLocal)/2.
103 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0),(dX,DLocal)],['auto'], groups = GN5))
104 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0),(dX,DLocal)],['auto'], groups = GN6))
107 dY = (DY - DLocal)/2.
109 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0-DLocal/2.-dY/2.),(dX,dY)],['auto'], groups = GN9))
110 Obj.append(MacObject('CompBoxF',[(X0,Y0-DLocal/2.-dY/2.),(DLocal,dY)],['auto'], groups = GN10))
111 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0-DLocal/2.-dY/2.),(dX,dY)],['auto'], groups = GN11))
112 Obj.append(MacObject('CompBoxF',[(X0+DLocal/2.+dX/2.,Y0+DLocal/2.+dY/2.),(dX,dY)],['auto'], groups = GN12))
113 Obj.append(MacObject('CompBoxF',[(X0,Y0+DLocal/2.+dY/2.),(DLocal,dY)],['auto'], groups = GN13))
114 Obj.append(MacObject('CompBoxF',[(X0-DLocal/2.-dX/2.,Y0+DLocal/2.+dY/2.),(dX,dY)],['auto'], groups = GN14))
116 Obj.append(MacObject('CompBoxF',[(X0,Y0-DLocal/2.-dY/2.),(DLocal,dY)],['auto'], groups = GN7))
117 Obj.append(MacObject('CompBoxF',[(X0,Y0+DLocal/2.+dY/2.),(DLocal,dY)],['auto'], groups = GN8))