00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 from geompy import *
00027
00028 import smesh
00029 import geompy
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 sphere_rayon = 100
00040
00041 cube_cote = 200
00042
00043 plan_trim = 1000
00044
00045
00046
00047
00048 sphere_centre = MakeVertex(0, 0, 0)
00049
00050 sphere_pleine = MakeSpherePntR(sphere_centre, sphere_rayon)
00051
00052
00053
00054
00055 boite_cote = sphere_rayon / 2
00056
00057 boite = MakeBox(-boite_cote, -boite_cote, -boite_cote, +boite_cote, +boite_cote, +boite_cote)
00058
00059 blocs = [boite]
00060
00061
00062
00063
00064 sphere_troue = MakeCut(sphere_pleine, boite)
00065
00066
00067
00068
00069
00070
00071
00072 f1 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, 1), plan_trim)
00073 f2 = MakePlane(sphere_centre, MakeVectorDXDYDZ(-1, 1, 0), plan_trim)
00074 f3 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 1, 0), plan_trim)
00075 f4 = MakePlane(sphere_centre, MakeVectorDXDYDZ( 1, 0, -1), plan_trim)
00076
00077
00078
00079
00080 sphere_decoupee = MakePartition([sphere_troue], [f1], [], [], ShapeType["SOLID"])
00081 sphere_decoupee = MakePartition([sphere_decoupee], [f2], [], [], ShapeType["SOLID"])
00082 sphere_decoupee = MakePartition([sphere_decoupee], [f3], [], [], ShapeType["SOLID"])
00083 sphere_decoupee = MakePartition([sphere_decoupee], [f4], [], [], ShapeType["SOLID"])
00084
00085 sphere_partie = geompy.MakeCompound([sphere_decoupee])
00086
00087 sphere_partie = GetBlockNearPoint(sphere_decoupee, MakeVertex(-sphere_rayon, 0, 0))
00088 sphere_bloc = RemoveExtraEdges(sphere_partie)
00089
00090 blocs.append(sphere_bloc)
00091
00092 pi2 = 3.141592653/2
00093
00094 sphere_dir1 = MakeVectorDXDYDZ(0, 1, 0)
00095 sphere_dir2 = MakeVectorDXDYDZ(0, 0, 1)
00096
00097 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, +pi2))
00098 blocs.append(MakeRotation(sphere_bloc, sphere_dir1, -pi2))
00099
00100 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, +pi2))
00101 blocs.append(MakeRotation(sphere_bloc, sphere_dir2, -pi2))
00102
00103 blocs.append(MakeMirrorByPoint(sphere_bloc, sphere_centre))
00104
00105
00106
00107
00108 cube_plein = MakeBox(-cube_cote, -cube_cote, -cube_cote, +cube_cote, +cube_cote, +cube_cote)
00109 cube_trou = MakeCut(cube_plein, sphere_pleine)
00110
00111
00112 cube_decoupe = MakePartition([cube_trou], [f1], [], [], ShapeType["SOLID"])
00113 cube_decoupe = MakePartition([cube_decoupe], [f2], [], [], ShapeType["SOLID"])
00114 cube_decoupe = MakePartition([cube_decoupe], [f3], [], [], ShapeType["SOLID"])
00115 cube_decoupe = MakePartition([cube_decoupe], [f4], [], [], ShapeType["SOLID"])
00116
00117 cube_decoupe = geompy.MakeCompound([cube_decoupe])
00118
00119
00120 cube_partie = GetBlockNearPoint(cube_decoupe, MakeVertex(-cube_cote, 0, 0))
00121 cube_bloc = RemoveExtraEdges(cube_partie)
00122
00123 blocs.append(cube_bloc)
00124
00125 blocs.append(MakeRotation(cube_bloc, sphere_dir1, +pi2))
00126 blocs.append(MakeRotation(cube_bloc, sphere_dir1, -pi2))
00127
00128 blocs.append(MakeRotation(cube_bloc, sphere_dir2, +pi2))
00129 blocs.append(MakeRotation(cube_bloc, sphere_dir2, -pi2))
00130
00131 blocs.append(MakeMirrorByPoint(cube_bloc, sphere_centre))
00132
00133
00134
00135
00136 piece_cpd = MakeCompound(blocs)
00137 piece = MakeGlueFaces(piece_cpd, 1.e-3)
00138
00139 piece_id = addToStudy(piece, "ex19_sphereINcube")
00140
00141
00142
00143
00144
00145
00146
00147 groupe = CreateGroup(piece, ShapeType["SOLID"])
00148
00149 groupe_nom = "ex19_sphereINcube_interieur"
00150 addToStudy(groupe, groupe_nom)
00151 groupe.SetName(groupe_nom)
00152
00153
00154
00155
00156 groupe_sphere = GetShapesOnSphere(piece, ShapeType["SOLID"], sphere_centre, sphere_rayon, GEOM.ST_ONIN)
00157
00158 UnionList(groupe, groupe_sphere)
00159
00160
00161
00162
00163 smesh.SetCurrentStudy(salome.myStudy)
00164
00165
00166
00167
00168 hexa = smesh.Mesh(piece, "ex19_sphereINcube:hexa")
00169
00170 algo = hexa.Segment()
00171 algo.NumberOfSegments(10)
00172
00173 hexa.Quadrangle()
00174
00175 hexa.Hexahedron()
00176
00177
00178
00179
00180 hexa.Compute()
00181
00182
00183
00184
00185 hexa_groupe = hexa.Group(groupe)