00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 import math
00024
00025 import geompy
00026 import smesh
00027 import salome
00028 geo = geompy
00029
00030
00031
00032
00033 radius = 50
00034 height = 200
00035
00036
00037
00038
00039 base = geo.MakeVertex(0, 0, 0)
00040 direction = geo.MakeVectorDXDYDZ(0, 0, 1)
00041
00042 cylinder = geo.MakeCylinder(base, direction, radius, height)
00043
00044 geo.addToStudy(cylinder, "cylinder")
00045
00046
00047
00048
00049 size = radius/2.0
00050
00051 box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
00052 box_axis = geo.MakeLine(base, direction)
00053 box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
00054
00055 hole = geo.MakeCut(cylinder, box)
00056
00057 plane_trim = 2000
00058
00059 plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
00060 plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
00061
00062 blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
00063 blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
00064 blocks_all = geo.MakeCompound(blocks_list)
00065 blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
00066
00067 geo.addToStudy(blocks, "cylinder:blocks")
00068
00069
00070
00071
00072 def group(name, shape, type, base=None, direction=None):
00073 t = geo.ShapeType[type]
00074 g = geo.CreateGroup(shape, t)
00075
00076 geo.addToStudy(g, name)
00077 g.SetName(name)
00078
00079 if base!=None:
00080 l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
00081 geo.UnionIDs(g, l)
00082
00083 return g
00084
00085 group_a = group("baseA", blocks, "FACE", base, direction)
00086
00087 base_b = geo.MakeVertex(0, 0, height)
00088 group_b = group("baseB", blocks, "FACE", base_b, direction)
00089
00090 group_1 = group("limit", blocks, "SOLID")
00091 group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
00092 geo.UnionIDs(group_1, group_1_all)
00093 group_1_box = geo.GetBlockNearPoint(blocks, base)
00094 geo.DifferenceList(group_1, [group_1_box])
00095
00096
00097
00098
00099 smesh.SetCurrentStudy(salome.myStudy)
00100
00101 def discretize(x, y, z, n, s=blocks):
00102 p = geo.MakeVertex(x, y, z)
00103 e = geo.GetEdgeNearPoint(s, p)
00104 a = hexa.Segment(e)
00105 a.NumberOfSegments(n)
00106 a.Propagation()
00107
00108 hexa = smesh.Mesh(blocks)
00109
00110 hexa_1d = hexa.Segment()
00111 hexa_1d.NumberOfSegments(1)
00112
00113 discretize(+radius , +radius, 0, 5)
00114 discretize(-radius , +radius, 0, 8)
00115 discretize((radius+size)/2, 0, 0, 10)
00116 discretize( +radius, 0, height/2, 20)
00117
00118 hexa.Quadrangle()
00119 hexa.Hexahedron()
00120
00121 hexa.Compute()
00122
00123 hexa.Group(group_a)
00124 hexa.Group(group_b)
00125 hexa.Group(group_1)