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
00027
00028
00029
00030 import salome
00031 import geompy
00032 import smesh
00033
00034 salome.salome_init()
00035
00036
00037
00038 p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 )
00039 p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 )
00040 p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 )
00041 arc1 = geompy.MakeArc( p1, p2, p3 )
00042
00043 p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 )
00044 seg1 = geompy.MakeVector( p3, p4 )
00045
00046 p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 )
00047 p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 )
00048 arc2 = geompy.MakeArc( p4, p5, p6 )
00049
00050 p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 )
00051 arc3 = geompy.MakeArc( p6, p7, p1 )
00052
00053
00054 List1 = []
00055 List1.append( arc1 )
00056 List1.append( seg1 )
00057 List1.append( arc2 )
00058 List1.append( arc3 )
00059
00060 wire1 = geompy.MakeWire( List1 )
00061 Id_wire1 = geompy.addToStudy( wire1, "wire1" )
00062
00063
00064 WantPlanarFace = 1
00065 face1 = geompy.MakeFace( wire1, WantPlanarFace )
00066 Id_face1 = geompy.addToStudy( face1, "face1" )
00067
00068
00069 pO = geompy.MakeVertex( 0.0, 0.0, 0.0 )
00070 pz = geompy.MakeVertex( 0.0, 0.0, 100.0 )
00071 vz = geompy.MakeVector( pO, pz )
00072
00073 prism1 = geompy.MakePrismVecH( face1, vz, 100.0 )
00074 Id_prism1 = geompy.addToStudy( prism1, "prism1" )
00075
00076
00077 pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 )
00078 pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 )
00079
00080 radius = 20.0
00081 height = 180.0
00082 cyl1 = geompy.MakeCylinder( pc1, vz, radius, height )
00083 cyl2 = geompy.MakeCylinder( pc2, vz, radius, height )
00084
00085 Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" )
00086 Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" )
00087
00088
00089 shape = geompy.MakeBoolean( prism1, cyl1, 2 )
00090
00091
00092 mechanic = geompy.MakeBoolean( shape, cyl2, 3 )
00093 Id_mechanic = geompy.addToStudy( mechanic, "mechanic" )
00094
00095
00096 SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"])
00097
00098
00099 sub_face1 = SubFaceL[0]
00100 name = geompy.SubShapeName( sub_face1, mechanic )
00101
00102 Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name )
00103
00104
00105 sub_face2 = SubFaceL[4]
00106 name = geompy.SubShapeName( sub_face2, mechanic )
00107
00108 Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name )
00109
00110
00111 sub_face3 = SubFaceL[5]
00112 name = geompy.SubShapeName( sub_face3, mechanic )
00113
00114 Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name )
00115
00116
00117 sub_face4 = SubFaceL[10]
00118 name = geompy.SubShapeName( sub_face4, mechanic )
00119
00120 Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name )
00121
00122
00123 smesh.SetCurrentStudy(salome.myStudy)
00124
00125
00126 shape_mesh = salome.IDToObject( Id_mechanic )
00127
00128 mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic")
00129
00130 print "-------------------------- NumberOfSegments"
00131
00132 numberOfSegment = 10
00133
00134 algo = mesh.Segment()
00135 hypNbSeg = algo.NumberOfSegments(numberOfSegment)
00136 print hypNbSeg.GetName()
00137 print hypNbSeg.GetId()
00138 print hypNbSeg.GetNumberOfSegments()
00139 smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment))
00140
00141
00142 print "-------------------------- MaxElementArea"
00143
00144 maxElementArea = 25
00145
00146 algo = mesh.Triangle()
00147 hypArea25 = algo.MaxElementArea(maxElementArea)
00148 print hypArea25.GetName()
00149 print hypArea25.GetId()
00150 print hypArea25.GetMaxElementArea()
00151 smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea))
00152
00153
00154
00155
00156
00157
00158 algo = mesh.Quadrangle(sub_face1)
00159 smesh.SetName(algo.GetSubMesh(), "SubMeshFace1")
00160 submesh1 = algo.GetSubMesh()
00161
00162
00163 algo = mesh.Quadrangle(sub_face2)
00164 smesh.SetName(algo.GetSubMesh(), "SubMeshFace2")
00165 submesh2 = algo.GetSubMesh()
00166
00167
00168 algo = mesh.Quadrangle(sub_face3)
00169 smesh.SetName(algo.GetSubMesh(), "SubMeshFace3")
00170 submesh3 = algo.GetSubMesh()
00171
00172
00173 algo = mesh.Quadrangle(sub_face4)
00174 smesh.SetName(algo.GetSubMesh(), "SubMeshFace4")
00175 submesh4 = algo.GetSubMesh()
00176
00177
00178 print "-------------------------- compute the mesh of the mechanic piece"
00179
00180 mesh.Compute()
00181
00182 print "Information about the Mesh_mechanic:"
00183 print "Number of nodes : ", mesh.NbNodes()
00184 print "Number of edges : ", mesh.NbEdges()
00185 print "Number of faces : ", mesh.NbFaces()
00186 print "Number of triangles : ", mesh.NbTriangles()
00187 print "Number of quadrangles : ", mesh.NbQuadrangles()
00188 print "Number of volumes : ", mesh.NbVolumes()
00189 print "Number of tetrahedrons: ", mesh.NbTetras()
00190
00191
00192
00193 mesh.SplitQuadObject(submesh2, 1)
00194
00195
00196 FacesTriToQuad = [ 2391, 2824, 2825, 2826, 2827, 2828, 2832, 2833, 2834, 2835, 2836, 2837, 2838, 2839, 2841, 2844, 2845, 2847, 2854, 2861, 2863, 2922, 2923, 2924, 2925, 2926, 2927, 2928, 2929, 2930, 2931, 2932, 2933, 2934, 2935, 2936, 2937, 2938, 2940, 2941, 2946, 2951, 2970, 2971, 2972, 2973, 2974, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2983, 2984, 2985 ]
00197 GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad)
00198 mesh.TriToQuadObject(GroupTriToQuad, None , 1.57)
00199
00200
00201 point = smesh.PointStruct(0, 0, 5)
00202 vector = smesh.DirStruct(point)
00203 mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5)
00204
00205
00206 mesh.Mirror([], smesh.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0)
00207
00208
00209 point = smesh.PointStruct(10, 10, 10)
00210 vector = smesh.DirStruct(point)
00211 mesh.Translate([], vector, 0)
00212
00213
00214 axisXYZ = smesh.AxisStruct(0, 0, 0, 10, 10, 10)
00215 angle180 = 180*3.141/180
00216 mesh.Rotate([], axisXYZ, angle180, 0)
00217
00218
00219 FacesSmooth = [864, 933, 941, 950, 1005, 1013]
00220 GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", smesh.FACE, FacesSmooth)
00221 mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH)
00222
00223
00224 FacesRotate = [492, 493, 502, 503]
00225 GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", smesh.FACE, FacesRotate)
00226 angle45 = 45*3.141/180
00227 axisXYZ = smesh.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632)
00228 mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
00229
00230
00231 mesh.ReorientObject(submesh1)
00232
00233 salome.sg.updateObjBrowser(1)