00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 """
00024 \namespace smesh
00025 \brief Module smesh
00026 """
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 import salome
00092 import geompyDC
00093
00094 import SMESH
00095 from SMESH import *
00096
00097 import StdMeshers
00098
00099 import SALOME
00100 import SALOMEDS
00101
00102
00103 noNETGENPlugin = 0
00104 try:
00105 import NETGENPlugin
00106 except ImportError:
00107 noNETGENPlugin = 1
00108 pass
00109
00110
00111 noGHS3DPlugin = 0
00112 try:
00113 import GHS3DPlugin
00114 except ImportError:
00115 noGHS3DPlugin = 1
00116 pass
00117
00118
00119 noGHS3DPRLPlugin = 0
00120 try:
00121 import GHS3DPRLPlugin
00122 except ImportError:
00123 noGHS3DPRLPlugin = 1
00124 pass
00125
00126
00127 noHexoticPlugin = 0
00128 try:
00129 import HexoticPlugin
00130 except ImportError:
00131 noHexoticPlugin = 1
00132 pass
00133
00134
00135 noBLSURFPlugin = 0
00136 try:
00137 import BLSURFPlugin
00138 except ImportError:
00139 noBLSURFPlugin = 1
00140 pass
00141
00142
00143
00144
00145
00146 REGULAR = 1
00147 PYTHON = 2
00148 COMPOSITE = 3
00149 SOLE = 0
00150 SIMPLE = 1
00151
00152 MEFISTO = 3
00153 NETGEN = 4
00154 GHS3D = 5
00155 FULL_NETGEN = 6
00156 NETGEN_2D = 7
00157 NETGEN_1D2D = NETGEN
00158 NETGEN_1D2D3D = FULL_NETGEN
00159 NETGEN_FULL = FULL_NETGEN
00160 Hexa = 8
00161 Hexotic = 9
00162 BLSURF = 10
00163 GHS3DPRL = 11
00164 QUADRANGLE = 0
00165 RADIAL_QUAD = 1
00166
00167
00168 POINT = SMESH_MeshEditor.POINT
00169 AXIS = SMESH_MeshEditor.AXIS
00170 PLANE = SMESH_MeshEditor.PLANE
00171
00172
00173 LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
00174 CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
00175
00176
00177 VeryCoarse = 0
00178 Coarse = 1
00179 Moderate = 2
00180 Fine = 3
00181 VeryFine = 4
00182 Custom = 5
00183
00184
00185
00186 None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization = 0,1,2,3
00187
00188 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4
00189
00190
00191 FromCAD, PreProcess, PreProcessPlus = 0,1,2
00192
00193
00194 DefaultSize, DefaultGeom, Custom = 0,0,1
00195
00196 PrecisionConfusion = 1e-07
00197
00198
00199 [TopAbs_IN, TopAbs_OUT, TopAbs_ON, TopAbs_UNKNOWN] = range(4)
00200
00201
00202 Hex_5Tet, Hex_6Tet, Hex_24Tet = 1, 2, 3
00203
00204
00205 for e in StdMeshers.QuadType._items: exec('%s = StdMeshers.%s'%(e,e))
00206
00207
00208 def DegreesToRadians(AngleInDegrees):
00209 from math import pi
00210 return AngleInDegrees * pi / 180.0
00211
00212
00213 var_separator = ":"
00214
00215
00216 class PointStructStr:
00217
00218 x = 0
00219 y = 0
00220 z = 0
00221 xStr = ""
00222 yStr = ""
00223 zStr = ""
00224
00225 def __init__(self, xStr, yStr, zStr):
00226 self.xStr = xStr
00227 self.yStr = yStr
00228 self.zStr = zStr
00229 if isinstance(xStr, str) and notebook.isVariable(xStr):
00230 self.x = notebook.get(xStr)
00231 else:
00232 self.x = xStr
00233 if isinstance(yStr, str) and notebook.isVariable(yStr):
00234 self.y = notebook.get(yStr)
00235 else:
00236 self.y = yStr
00237 if isinstance(zStr, str) and notebook.isVariable(zStr):
00238 self.z = notebook.get(zStr)
00239 else:
00240 self.z = zStr
00241
00242
00243 class PointStructStr6:
00244
00245 x1 = 0
00246 y1 = 0
00247 z1 = 0
00248 x2 = 0
00249 y2 = 0
00250 z2 = 0
00251 xStr1 = ""
00252 yStr1 = ""
00253 zStr1 = ""
00254 xStr2 = ""
00255 yStr2 = ""
00256 zStr2 = ""
00257
00258 def __init__(self, x1Str, x2Str, y1Str, y2Str, z1Str, z2Str):
00259 self.x1Str = x1Str
00260 self.x2Str = x2Str
00261 self.y1Str = y1Str
00262 self.y2Str = y2Str
00263 self.z1Str = z1Str
00264 self.z2Str = z2Str
00265 if isinstance(x1Str, str) and notebook.isVariable(x1Str):
00266 self.x1 = notebook.get(x1Str)
00267 else:
00268 self.x1 = x1Str
00269 if isinstance(x2Str, str) and notebook.isVariable(x2Str):
00270 self.x2 = notebook.get(x2Str)
00271 else:
00272 self.x2 = x2Str
00273 if isinstance(y1Str, str) and notebook.isVariable(y1Str):
00274 self.y1 = notebook.get(y1Str)
00275 else:
00276 self.y1 = y1Str
00277 if isinstance(y2Str, str) and notebook.isVariable(y2Str):
00278 self.y2 = notebook.get(y2Str)
00279 else:
00280 self.y2 = y2Str
00281 if isinstance(z1Str, str) and notebook.isVariable(z1Str):
00282 self.z1 = notebook.get(z1Str)
00283 else:
00284 self.z1 = z1Str
00285 if isinstance(z2Str, str) and notebook.isVariable(z2Str):
00286 self.z2 = notebook.get(z2Str)
00287 else:
00288 self.z2 = z2Str
00289
00290
00291 class AxisStructStr:
00292
00293 x = 0
00294 y = 0
00295 z = 0
00296 dx = 0
00297 dy = 0
00298 dz = 0
00299 xStr = ""
00300 yStr = ""
00301 zStr = ""
00302 dxStr = ""
00303 dyStr = ""
00304 dzStr = ""
00305
00306 def __init__(self, xStr, yStr, zStr, dxStr, dyStr, dzStr):
00307 self.xStr = xStr
00308 self.yStr = yStr
00309 self.zStr = zStr
00310 self.dxStr = dxStr
00311 self.dyStr = dyStr
00312 self.dzStr = dzStr
00313 if isinstance(xStr, str) and notebook.isVariable(xStr):
00314 self.x = notebook.get(xStr)
00315 else:
00316 self.x = xStr
00317 if isinstance(yStr, str) and notebook.isVariable(yStr):
00318 self.y = notebook.get(yStr)
00319 else:
00320 self.y = yStr
00321 if isinstance(zStr, str) and notebook.isVariable(zStr):
00322 self.z = notebook.get(zStr)
00323 else:
00324 self.z = zStr
00325 if isinstance(dxStr, str) and notebook.isVariable(dxStr):
00326 self.dx = notebook.get(dxStr)
00327 else:
00328 self.dx = dxStr
00329 if isinstance(dyStr, str) and notebook.isVariable(dyStr):
00330 self.dy = notebook.get(dyStr)
00331 else:
00332 self.dy = dyStr
00333 if isinstance(dzStr, str) and notebook.isVariable(dzStr):
00334 self.dz = notebook.get(dzStr)
00335 else:
00336 self.dz = dzStr
00337
00338
00339 class DirStructStr:
00340
00341 def __init__(self, pointStruct):
00342 self.pointStruct = pointStruct
00343
00344
00345 def ParsePointStruct(Point):
00346 Parameters = 2*var_separator
00347 if isinstance(Point, PointStructStr):
00348 Parameters = str(Point.xStr) + var_separator + str(Point.yStr) + var_separator + str(Point.zStr)
00349 Point = PointStruct(Point.x, Point.y, Point.z)
00350 return Point, Parameters
00351
00352
00353 def ParseDirStruct(Dir):
00354 Parameters = 2*var_separator
00355 if isinstance(Dir, DirStructStr):
00356 pntStr = Dir.pointStruct
00357 if isinstance(pntStr, PointStructStr6):
00358 Parameters = str(pntStr.x1Str) + var_separator + str(pntStr.x2Str) + var_separator
00359 Parameters += str(pntStr.y1Str) + var_separator + str(pntStr.y2Str) + var_separator
00360 Parameters += str(pntStr.z1Str) + var_separator + str(pntStr.z2Str)
00361 Point = PointStruct(pntStr.x2 - pntStr.x1, pntStr.y2 - pntStr.y1, pntStr.z2 - pntStr.z1)
00362 else:
00363 Parameters = str(pntStr.xStr) + var_separator + str(pntStr.yStr) + var_separator + str(pntStr.zStr)
00364 Point = PointStruct(pntStr.x, pntStr.y, pntStr.z)
00365 Dir = DirStruct(Point)
00366 return Dir, Parameters
00367
00368
00369 def ParseAxisStruct(Axis):
00370 Parameters = 5*var_separator
00371 if isinstance(Axis, AxisStructStr):
00372 Parameters = str(Axis.xStr) + var_separator + str(Axis.yStr) + var_separator + str(Axis.zStr) + var_separator
00373 Parameters += str(Axis.dxStr) + var_separator + str(Axis.dyStr) + var_separator + str(Axis.dzStr)
00374 Axis = AxisStruct(Axis.x, Axis.y, Axis.z, Axis.dx, Axis.dy, Axis.dz)
00375 return Axis, Parameters
00376
00377
00378 def ParseAngles(list):
00379 Result = []
00380 Parameters = ""
00381 for parameter in list:
00382 if isinstance(parameter,str) and notebook.isVariable(parameter):
00383 Result.append(DegreesToRadians(notebook.get(parameter)))
00384 pass
00385 else:
00386 Result.append(parameter)
00387 pass
00388
00389 Parameters = Parameters + str(parameter)
00390 Parameters = Parameters + var_separator
00391 pass
00392 Parameters = Parameters[:len(Parameters)-1]
00393 return Result, Parameters
00394
00395 def IsEqual(val1, val2, tol=PrecisionConfusion):
00396 if abs(val1 - val2) < tol:
00397 return True
00398 return False
00399
00400 NO_NAME = "NoName"
00401
00402
00403 def GetName(obj):
00404 if obj:
00405
00406 if isinstance(obj, SALOMEDS._objref_SObject):
00407
00408 return obj.GetName()
00409 ior = salome.orb.object_to_string(obj)
00410 if ior:
00411
00412 studies = salome.myStudyManager.GetOpenStudies()
00413 for sname in studies:
00414 s = salome.myStudyManager.GetStudyByName(sname)
00415 if not s: continue
00416 sobj = s.FindObjectIOR(ior)
00417 if not sobj: continue
00418 return sobj.GetName()
00419 if hasattr(obj, "GetName"):
00420
00421 return obj.GetName()
00422 else:
00423
00424 return NO_NAME
00425 pass
00426 if hasattr(obj, "GetName"):
00427
00428 return obj.GetName()
00429 pass
00430 raise RuntimeError, "Null or invalid object"
00431
00432
00433 def TreatHypoStatus(status, hypName, geomName, isAlgo):
00434 if isAlgo:
00435 hypType = "algorithm"
00436 else:
00437 hypType = "hypothesis"
00438 pass
00439 if status == HYP_UNKNOWN_FATAL :
00440 reason = "for unknown reason"
00441 elif status == HYP_INCOMPATIBLE :
00442 reason = "this hypothesis mismatches the algorithm"
00443 elif status == HYP_NOTCONFORM :
00444 reason = "a non-conform mesh would be built"
00445 elif status == HYP_ALREADY_EXIST :
00446 if isAlgo: return
00447 reason = hypType + " of the same dimension is already assigned to this shape"
00448 elif status == HYP_BAD_DIM :
00449 reason = hypType + " mismatches the shape"
00450 elif status == HYP_CONCURENT :
00451 reason = "there are concurrent hypotheses on sub-shapes"
00452 elif status == HYP_BAD_SUBSHAPE :
00453 reason = "the shape is neither the main one, nor its subshape, nor a valid group"
00454 elif status == HYP_BAD_GEOMETRY:
00455 reason = "geometry mismatches the expectation of the algorithm"
00456 elif status == HYP_HIDDEN_ALGO:
00457 reason = "it is hidden by an algorithm of an upper dimension, which generates elements of all dimensions"
00458 elif status == HYP_HIDING_ALGO:
00459 reason = "it hides algorithms of lower dimensions by generating elements of all dimensions"
00460 elif status == HYP_NEED_SHAPE:
00461 reason = "Algorithm can't work without shape"
00462 else:
00463 return
00464 hypName = '"' + hypName + '"'
00465 geomName= '"' + geomName+ '"'
00466 if status < HYP_UNKNOWN_FATAL and not geomName =='""':
00467 print hypName, "was assigned to", geomName,"but", reason
00468 elif not geomName == '""':
00469 print hypName, "was not assigned to",geomName,":", reason
00470 else:
00471 print hypName, "was not assigned:", reason
00472 pass
00473
00474
00475 def CheckPlugin(plugin):
00476 if plugin == NETGEN and noNETGENPlugin:
00477 print "Warning: NETGENPlugin module unavailable"
00478 return False
00479 elif plugin == GHS3D and noGHS3DPlugin:
00480 print "Warning: GHS3DPlugin module unavailable"
00481 return False
00482 elif plugin == GHS3DPRL and noGHS3DPRLPlugin:
00483 print "Warning: GHS3DPRLPlugin module unavailable"
00484 return False
00485 elif plugin == Hexotic and noHexoticPlugin:
00486 print "Warning: HexoticPlugin module unavailable"
00487 return False
00488 elif plugin == BLSURF and noBLSURFPlugin:
00489 print "Warning: BLSURFPlugin module unavailable"
00490 return False
00491 return True
00492
00493
00494 def AssureGeomPublished(mesh, geom, name=''):
00495 if not isinstance( geom, geompyDC.GEOM._objref_GEOM_Object ):
00496 return
00497 if not geom.IsSame( mesh.geom ) and not geom.GetStudyEntry():
00498
00499 studyID = mesh.smeshpyD.GetCurrentStudy()._get_StudyId()
00500 if studyID != mesh.geompyD.myStudyId:
00501 mesh.geompyD.init_geom( mesh.smeshpyD.GetCurrentStudy())
00502
00503 if not name and geom.GetShapeType() != geompyDC.GEOM.COMPOUND:
00504
00505 name = mesh.geompyD.SubShapeName(geom, mesh.geom)
00506 if not name:
00507 name = "%s_%s"%(geom.GetShapeType(), id(geom)%10000)
00508
00509 mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
00510 return
00511
00512
00513
00514
00515
00516 class smeshDC(SMESH._objref_SMESH_Gen):
00517
00518
00519
00520 def DumpPython(self, theStudy, theIsPublished=True, theIsMultiFile=True):
00521 return SMESH._objref_SMESH_Gen.DumpPython(self, theStudy, theIsPublished, theIsMultiFile)
00522
00523
00524
00525 def init_smesh(self,theStudy,geompyD):
00526 self.SetCurrentStudy(theStudy,geompyD)
00527
00528
00529
00530
00531
00532
00533
00534 def Mesh(self, obj=0, name=0):
00535 if isinstance(obj,str):
00536 obj,name = name,obj
00537 return Mesh(self,self.geompyD,obj,name)
00538
00539
00540
00541
00542 def EnumToLong(self,theItem):
00543 return theItem._v
00544
00545
00546
00547
00548
00549 def ColorToString(self,c):
00550 val = ""
00551 if isinstance(c, SALOMEDS.Color):
00552 val = "%s;%s;%s" % (c.R, c.G, c.B)
00553 elif isinstance(c, str):
00554 val = c
00555 else:
00556 raise ValueError, "Color value should be of string or SALOMEDS.Color type"
00557 return val
00558
00559
00560
00561
00562
00563 def GetPointStruct(self,theVertex):
00564 [x, y, z] = self.geompyD.PointCoordinates(theVertex)
00565 return PointStruct(x,y,z)
00566
00567
00568
00569
00570
00571 def GetDirStruct(self,theVector):
00572 vertices = self.geompyD.SubShapeAll( theVector, geompyDC.ShapeType["VERTEX"] )
00573 if(len(vertices) != 2):
00574 print "Error: vector object is incorrect."
00575 return None
00576 p1 = self.geompyD.PointCoordinates(vertices[0])
00577 p2 = self.geompyD.PointCoordinates(vertices[1])
00578 pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00579 dirst = DirStruct(pnt)
00580 return dirst
00581
00582
00583
00584
00585
00586 def MakeDirStruct(self,x,y,z):
00587 pnt = PointStruct(x,y,z)
00588 return DirStruct(pnt)
00589
00590
00591
00592
00593
00594 def GetAxisStruct(self,theObj):
00595 edges = self.geompyD.SubShapeAll( theObj, geompyDC.ShapeType["EDGE"] )
00596 if len(edges) > 1:
00597 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00598 vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geompyDC.ShapeType["VERTEX"] )
00599 vertex1 = self.geompyD.PointCoordinates(vertex1)
00600 vertex2 = self.geompyD.PointCoordinates(vertex2)
00601 vertex3 = self.geompyD.PointCoordinates(vertex3)
00602 vertex4 = self.geompyD.PointCoordinates(vertex4)
00603 v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
00604 v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
00605 normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
00606 axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
00607 return axis
00608 elif len(edges) == 1:
00609 vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geompyDC.ShapeType["VERTEX"] )
00610 p1 = self.geompyD.PointCoordinates( vertex1 )
00611 p2 = self.geompyD.PointCoordinates( vertex2 )
00612 axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
00613 return axis
00614 return None
00615
00616
00617
00618
00619
00620
00621
00622
00623 def SetName(self, obj, name):
00624 if isinstance( obj, Mesh ):
00625 obj = obj.GetMesh()
00626 elif isinstance( obj, Mesh_Algorithm ):
00627 obj = obj.GetAlgorithm()
00628 ior = salome.orb.object_to_string(obj)
00629 SMESH._objref_SMESH_Gen.SetName(self, ior, name)
00630
00631
00632
00633 def SetEmbeddedMode( self,theMode ):
00634
00635 SMESH._objref_SMESH_Gen.SetEmbeddedMode(self,theMode)
00636
00637
00638
00639 def IsEmbeddedMode(self):
00640
00641 return SMESH._objref_SMESH_Gen.IsEmbeddedMode(self)
00642
00643
00644
00645 def SetCurrentStudy( self, theStudy, geompyD = None ):
00646
00647 if not geompyD:
00648 import geompy
00649 geompyD = geompy.geom
00650 pass
00651 self.geompyD=geompyD
00652 self.SetGeomEngine(geompyD)
00653 SMESH._objref_SMESH_Gen.SetCurrentStudy(self,theStudy)
00654
00655
00656
00657 def GetCurrentStudy(self):
00658
00659 return SMESH._objref_SMESH_Gen.GetCurrentStudy(self)
00660
00661
00662
00663
00664 def CreateMeshesFromUNV( self,theFileName ):
00665 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromUNV(self,theFileName)
00666 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00667 return aMesh
00668
00669
00670
00671
00672 def CreateMeshesFromMED( self,theFileName ):
00673 aSmeshMeshes, aStatus = SMESH._objref_SMESH_Gen.CreateMeshesFromMED(self,theFileName)
00674 aMeshes = []
00675 for iMesh in range(len(aSmeshMeshes)) :
00676 aMesh = Mesh(self, self.geompyD, aSmeshMeshes[iMesh])
00677 aMeshes.append(aMesh)
00678 return aMeshes, aStatus
00679
00680
00681
00682
00683 def CreateMeshesFromSTL( self, theFileName ):
00684 aSmeshMesh = SMESH._objref_SMESH_Gen.CreateMeshesFromSTL(self,theFileName)
00685 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00686 return aMesh
00687
00688
00689
00690
00691
00692
00693
00694
00695 def Concatenate( self, meshes, uniteIdenticalGroups,
00696 mergeNodesAndElements = False, mergeTolerance = 1e-5, allGroups = False):
00697 mergeTolerance,Parameters = geompyDC.ParseParameters(mergeTolerance)
00698 for i,m in enumerate(meshes):
00699 if isinstance(m, Mesh):
00700 meshes[i] = m.GetMesh()
00701 if allGroups:
00702 aSmeshMesh = SMESH._objref_SMESH_Gen.ConcatenateWithGroups(
00703 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00704 else:
00705 aSmeshMesh = SMESH._objref_SMESH_Gen.Concatenate(
00706 self,meshes,uniteIdenticalGroups,mergeNodesAndElements,mergeTolerance)
00707 aSmeshMesh.SetParameters(Parameters)
00708 aMesh = Mesh(self, self.geompyD, aSmeshMesh)
00709 return aMesh
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719 def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False):
00720 if (isinstance( meshPart, Mesh )):
00721 meshPart = meshPart.GetMesh()
00722 mesh = SMESH._objref_SMESH_Gen.CopyMesh( self,meshPart,meshName,toCopyGroups,toKeepIDs )
00723 return Mesh(self, self.geompyD, mesh)
00724
00725
00726
00727
00728 def GetSubShapesId( self, theMainObject, theListOfSubObjects ):
00729 return SMESH._objref_SMESH_Gen.GetSubShapesId(self,theMainObject, theListOfSubObjects)
00730
00731
00732
00733
00734
00735
00736 def GetPattern(self):
00737 return SMESH._objref_SMESH_Gen.GetPattern(self)
00738
00739
00740
00741
00742
00743 def SetBoundaryBoxSegmentation(self, nbSegments):
00744 SMESH._objref_SMESH_Gen.SetBoundaryBoxSegmentation(self,nbSegments)
00745
00746
00747
00748
00749
00750
00751
00752 def GetEmptyCriterion(self):
00753 Type = self.EnumToLong(FT_Undefined)
00754 Compare = self.EnumToLong(FT_Undefined)
00755 Threshold = 0
00756 ThresholdStr = ""
00757 ThresholdID = ""
00758 UnaryOp = self.EnumToLong(FT_Undefined)
00759 BinaryOp = self.EnumToLong(FT_Undefined)
00760 Tolerance = 1e-07
00761 TypeOfElement = ALL
00762 Precision = -1
00763 return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
00764 UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 def GetCriterion(self,elementType,
00782 CritType,
00783 Compare = FT_EqualTo,
00784 Treshold="",
00785 UnaryOp=FT_Undefined,
00786 BinaryOp=FT_Undefined,
00787 Tolerance=1e-07):
00788 aCriterion = self.GetEmptyCriterion()
00789 aCriterion.TypeOfElement = elementType
00790 aCriterion.Type = self.EnumToLong(CritType)
00791 aCriterion.Tolerance = Tolerance
00792
00793 aTreshold = Treshold
00794
00795 if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
00796 aCriterion.Compare = self.EnumToLong(Compare)
00797 elif Compare == "=" or Compare == "==":
00798 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00799 elif Compare == "<":
00800 aCriterion.Compare = self.EnumToLong(FT_LessThan)
00801 elif Compare == ">":
00802 aCriterion.Compare = self.EnumToLong(FT_MoreThan)
00803 else:
00804 aCriterion.Compare = self.EnumToLong(FT_EqualTo)
00805 aTreshold = Compare
00806
00807 if CritType in [FT_BelongToGeom, FT_BelongToPlane, FT_BelongToGenSurface,
00808 FT_BelongToCylinder, FT_LyingOnGeom]:
00809
00810 if isinstance(aTreshold, geompyDC.GEOM._objref_GEOM_Object):
00811 aCriterion.ThresholdStr = GetName(aTreshold)
00812 aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
00813 else:
00814 print "Error: The treshold should be a shape."
00815 return None
00816 if isinstance(UnaryOp,float):
00817 aCriterion.Tolerance = UnaryOp
00818 UnaryOp = FT_Undefined
00819 pass
00820 elif CritType == FT_RangeOfIds:
00821
00822 if isinstance(aTreshold, str):
00823 aCriterion.ThresholdStr = aTreshold
00824 else:
00825 print "Error: The treshold should be a string."
00826 return None
00827 elif CritType == FT_CoplanarFaces:
00828
00829 if isinstance(aTreshold, int):
00830 aCriterion.ThresholdID = "%s"%aTreshold
00831 elif isinstance(aTreshold, str):
00832 ID = int(aTreshold)
00833 if ID < 1:
00834 raise ValueError, "Invalid ID of mesh face: '%s'"%aTreshold
00835 aCriterion.ThresholdID = aTreshold
00836 else:
00837 raise ValueError,\
00838 "The treshold should be an ID of mesh face and not '%s'"%aTreshold
00839 elif CritType == FT_ElemGeomType:
00840
00841 try:
00842 aCriterion.Threshold = self.EnumToLong(aTreshold)
00843 except:
00844 if isinstance(aTreshold, int):
00845 aCriterion.Threshold = aTreshold
00846 else:
00847 print "Error: The treshold should be an integer or SMESH.GeometryType."
00848 return None
00849 pass
00850 pass
00851 elif CritType == FT_GroupColor:
00852
00853 try:
00854 aCriterion.ThresholdStr = self.ColorToString(aTreshold)
00855 except:
00856 print "Error: The threshold value should be of SALOMEDS.Color type"
00857 return None
00858 pass
00859 elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume, FT_FreeNodes,
00860 FT_FreeFaces, FT_LinearOrQuadratic,
00861 FT_BareBorderFace, FT_BareBorderVolume,
00862 FT_OverConstrainedFace, FT_OverConstrainedVolume]:
00863
00864 if aTreshold == FT_LogicalNOT:
00865 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00866 elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
00867 aCriterion.BinaryOp = aTreshold
00868 else:
00869
00870 try:
00871 aTreshold = float(aTreshold)
00872 aCriterion.Threshold = aTreshold
00873 except:
00874 print "Error: The treshold should be a number."
00875 return None
00876
00877 if Treshold == FT_LogicalNOT or UnaryOp == FT_LogicalNOT:
00878 aCriterion.UnaryOp = self.EnumToLong(FT_LogicalNOT)
00879
00880 if Treshold in [FT_LogicalAND, FT_LogicalOR]:
00881 aCriterion.BinaryOp = self.EnumToLong(Treshold)
00882
00883 if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
00884 aCriterion.BinaryOp = self.EnumToLong(UnaryOp)
00885
00886 if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
00887 aCriterion.BinaryOp = self.EnumToLong(BinaryOp)
00888
00889 return aCriterion
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903 def GetFilter(self,elementType,
00904 CritType=FT_Undefined,
00905 Compare=FT_EqualTo,
00906 Treshold="",
00907 UnaryOp=FT_Undefined,
00908 Tolerance=1e-07):
00909 aCriterion = self.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
00910 aFilterMgr = self.CreateFilterManager()
00911 aFilter = aFilterMgr.CreateFilter()
00912 aCriteria = []
00913 aCriteria.append(aCriterion)
00914 aFilter.SetCriteria(aCriteria)
00915 aFilterMgr.UnRegister()
00916 return aFilter
00917
00918
00919
00920
00921
00922 def GetFunctor(self,theCriterion):
00923 aFilterMgr = self.CreateFilterManager()
00924 if theCriterion == FT_AspectRatio:
00925 return aFilterMgr.CreateAspectRatio()
00926 elif theCriterion == FT_AspectRatio3D:
00927 return aFilterMgr.CreateAspectRatio3D()
00928 elif theCriterion == FT_Warping:
00929 return aFilterMgr.CreateWarping()
00930 elif theCriterion == FT_MinimumAngle:
00931 return aFilterMgr.CreateMinimumAngle()
00932 elif theCriterion == FT_Taper:
00933 return aFilterMgr.CreateTaper()
00934 elif theCriterion == FT_Skew:
00935 return aFilterMgr.CreateSkew()
00936 elif theCriterion == FT_Area:
00937 return aFilterMgr.CreateArea()
00938 elif theCriterion == FT_Volume3D:
00939 return aFilterMgr.CreateVolume3D()
00940 elif theCriterion == FT_MaxElementLength2D:
00941 return aFilterMgr.CreateMaxElementLength2D()
00942 elif theCriterion == FT_MaxElementLength3D:
00943 return aFilterMgr.CreateMaxElementLength3D()
00944 elif theCriterion == FT_MultiConnection:
00945 return aFilterMgr.CreateMultiConnection()
00946 elif theCriterion == FT_MultiConnection2D:
00947 return aFilterMgr.CreateMultiConnection2D()
00948 elif theCriterion == FT_Length:
00949 return aFilterMgr.CreateLength()
00950 elif theCriterion == FT_Length2D:
00951 return aFilterMgr.CreateLength2D()
00952 else:
00953 print "Error: given parameter is not numerucal functor type."
00954
00955
00956
00957
00958
00959 def CreateHypothesis(self, theHType, theLibName="libStdMeshersEngine.so"):
00960 return SMESH._objref_SMESH_Gen.CreateHypothesis(self, theHType, theLibName )
00961
00962
00963
00964
00965 def GetMeshInfo(self, obj):
00966 if isinstance( obj, Mesh ):
00967 obj = obj.GetMesh()
00968 d = {}
00969 if hasattr(obj, "_narrow") and obj._narrow(SMESH.SMESH_IDSource):
00970 values = obj.GetMeshInfo()
00971 for i in range(SMESH.Entity_Last._v):
00972 if i < len(values): d[SMESH.EntityType._item(i)]=values[i]
00973 pass
00974 return d
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990 def MinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
00991 result = self.GetMinDistance(src1, src2, id1, id2, isElem1, isElem2)
00992 if result is None:
00993 result = 0.0
00994 else:
00995 result = result.value
00996 return result
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012 def GetMinDistance(self, src1, src2=None, id1=0, id2=0, isElem1=False, isElem2=False):
01013 if isinstance(src1, Mesh): src1 = src1.mesh
01014 if isinstance(src2, Mesh): src2 = src2.mesh
01015 if src2 is None and id2 != 0: src2 = src1
01016 if not hasattr(src1, "_narrow"): return None
01017 src1 = src1._narrow(SMESH.SMESH_IDSource)
01018 if not src1: return None
01019 if id1 != 0:
01020 m = src1.GetMesh()
01021 e = m.GetMeshEditor()
01022 if isElem1:
01023 src1 = e.MakeIDSource([id1], SMESH.FACE)
01024 else:
01025 src1 = e.MakeIDSource([id1], SMESH.NODE)
01026 pass
01027 if hasattr(src2, "_narrow"):
01028 src2 = src2._narrow(SMESH.SMESH_IDSource)
01029 if src2 and id2 != 0:
01030 m = src2.GetMesh()
01031 e = m.GetMeshEditor()
01032 if isElem2:
01033 src2 = e.MakeIDSource([id2], SMESH.FACE)
01034 else:
01035 src2 = e.MakeIDSource([id2], SMESH.NODE)
01036 pass
01037 pass
01038 aMeasurements = self.CreateMeasurements()
01039 result = aMeasurements.MinDistance(src1, src2)
01040 aMeasurements.UnRegister()
01041 return result
01042
01043
01044
01045
01046
01047
01048 def BoundingBox(self, objects):
01049 result = self.GetBoundingBox(objects)
01050 if result is None:
01051 result = (0.0,)*6
01052 else:
01053 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
01054 return result
01055
01056
01057
01058
01059
01060
01061 def GetBoundingBox(self, objects):
01062 if isinstance(objects, tuple):
01063 objects = list(objects)
01064 if not isinstance(objects, list):
01065 objects = [objects]
01066 srclist = []
01067 for o in objects:
01068 if isinstance(o, Mesh):
01069 srclist.append(o.mesh)
01070 elif hasattr(o, "_narrow"):
01071 src = o._narrow(SMESH.SMESH_IDSource)
01072 if src: srclist.append(src)
01073 pass
01074 pass
01075 aMeasurements = self.CreateMeasurements()
01076 result = aMeasurements.BoundingBox(srclist)
01077 aMeasurements.UnRegister()
01078 return result
01079
01080 import omniORB
01081
01082 omniORB.registerObjref(SMESH._objref_SMESH_Gen._NP_RepositoryId, smeshDC)
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093 class Mesh:
01094
01095 geom = 0
01096 mesh = 0
01097 editor = 0
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108 def __init__(self, smeshpyD, geompyD, obj=0, name=0):
01109 self.smeshpyD=smeshpyD
01110 self.geompyD=geompyD
01111 if obj is None:
01112 obj = 0
01113 if obj != 0:
01114 if isinstance(obj, geompyDC.GEOM._objref_GEOM_Object):
01115 self.geom = obj
01116
01117 if not self.geom.GetStudyEntry():
01118 studyID = smeshpyD.GetCurrentStudy()._get_StudyId()
01119 if studyID != geompyD.myStudyId:
01120 geompyD.init_geom( smeshpyD.GetCurrentStudy())
01121 pass
01122 geo_name = "%s_%s"%(self.geom.GetShapeType(), id(self.geom)%100)
01123 geompyD.addToStudy( self.geom, geo_name )
01124 self.mesh = self.smeshpyD.CreateMesh(self.geom)
01125
01126 elif isinstance(obj, SMESH._objref_SMESH_Mesh):
01127 self.SetMesh(obj)
01128 else:
01129 self.mesh = self.smeshpyD.CreateEmptyMesh()
01130 if name != 0:
01131 self.smeshpyD.SetName(self.mesh, name)
01132 elif obj != 0:
01133 self.smeshpyD.SetName(self.mesh, GetName(obj))
01134
01135 if not self.geom:
01136 self.geom = self.mesh.GetShapeToMesh()
01137
01138 self.editor = self.mesh.GetMeshEditor()
01139
01140
01141
01142
01143 def SetMesh(self, theMesh):
01144 self.mesh = theMesh
01145 self.geom = self.mesh.GetShapeToMesh()
01146
01147
01148
01149
01150 def GetMesh(self):
01151 return self.mesh
01152
01153
01154
01155
01156 def GetName(self):
01157 name = GetName(self.GetMesh())
01158 return name
01159
01160
01161
01162
01163 def SetName(self, name):
01164 self.smeshpyD.SetName(self.GetMesh(), name)
01165
01166
01167
01168
01169
01170
01171
01172 def GetSubMesh(self, geom, name):
01173 AssureGeomPublished( self, geom, name )
01174 submesh = self.mesh.GetSubMesh( geom, name )
01175 return submesh
01176
01177
01178
01179
01180 def GetShape(self):
01181 return self.geom
01182
01183
01184
01185
01186 def SetShape(self, geom):
01187 self.mesh = self.smeshpyD.CreateMesh(geom)
01188
01189
01190
01191
01192
01193 def IsReadyToCompute(self, theSubObject):
01194 return self.smeshpyD.IsReadyToCompute(self.mesh, theSubObject)
01195
01196
01197
01198
01199
01200
01201 def GetAlgoState(self, theSubObject):
01202 return self.smeshpyD.GetAlgoState(self.mesh, theSubObject)
01203
01204
01205
01206
01207
01208
01209
01210
01211 def GetGeometryByMeshElement(self, theElementID, theGeomName):
01212 return self.smeshpyD.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
01213
01214
01215
01216
01217 def MeshDimension(self):
01218 shells = self.geompyD.SubShapeAllIDs( self.geom, geompyDC.ShapeType["SHELL"] )
01219 if len( shells ) > 0 :
01220 return 3
01221 elif self.geompyD.NumberOfFaces( self.geom ) > 0 :
01222 return 2
01223 elif self.geompyD.NumberOfEdges( self.geom ) > 0 :
01224 return 1
01225 else:
01226 return 0;
01227 pass
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240 def Segment(self, algo=REGULAR, geom=0):
01241
01242 if isinstance( algo, geompyDC.GEOM._objref_GEOM_Object):
01243 algo, geom = geom, algo
01244 if not algo: algo = REGULAR
01245 pass
01246 if algo == REGULAR:
01247 return Mesh_Segment(self, geom)
01248 elif algo == PYTHON:
01249 return Mesh_Segment_Python(self, geom)
01250 elif algo == COMPOSITE:
01251 return Mesh_CompositeSegment(self, geom)
01252 else:
01253 return Mesh_Segment(self, geom)
01254
01255
01256
01257
01258
01259
01260
01261 def UseExisting1DElements(self, geom=0):
01262 return Mesh_UseExistingElements(1,self, geom)
01263
01264
01265
01266
01267
01268
01269
01270 def UseExisting2DElements(self, geom=0):
01271 return Mesh_UseExistingElements(2,self, geom)
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281 def UseExistingSegments(self, geom=0):
01282 algo = Mesh_UseExisting(1,self,geom)
01283 return algo.GetAlgorithm()
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293 def UseExistingFaces(self, geom=0):
01294 algo = Mesh_UseExisting(2,self,geom)
01295 return algo.GetAlgorithm()
01296
01297
01298
01299
01300
01301
01302
01303
01304 def Triangle(self, algo=MEFISTO, geom=0):
01305
01306 if (isinstance(algo, geompyDC.GEOM._objref_GEOM_Object)):
01307 geom = algo
01308 algo = MEFISTO
01309 return Mesh_Triangle(self, algo, geom)
01310
01311
01312
01313
01314
01315
01316
01317
01318 def Quadrangle(self, geom=0, algo=QUADRANGLE):
01319 if algo==RADIAL_QUAD:
01320 return Mesh_RadialQuadrangle1D2D(self,geom)
01321 else:
01322 return Mesh_Quadrangle(self, geom)
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332 def Tetrahedron(self, algo=NETGEN, geom=0):
01333
01334 if ( isinstance( algo, geompyDC.GEOM._objref_GEOM_Object)):
01335 algo, geom = geom, algo
01336 if not algo: algo = NETGEN
01337 pass
01338 return Mesh_Tetrahedron(self, algo, geom)
01339
01340
01341
01342
01343
01344
01345
01346
01347 def Hexahedron(self, algo=Hexa, geom=0):
01348
01349 if ( isinstance(algo, geompyDC.GEOM._objref_GEOM_Object) ):
01350 if geom in [Hexa, Hexotic]: algo, geom = geom, algo
01351 elif geom == 0: algo, geom = Hexa, algo
01352 return Mesh_Hexahedron(self, algo, geom)
01353
01354
01355
01356
01357 def Netgen(self, is3D, geom=0):
01358 return Mesh_Netgen(self, is3D, geom)
01359
01360
01361
01362
01363
01364
01365
01366 def Projection1D(self, geom=0):
01367 return Mesh_Projection1D(self, geom)
01368
01369
01370
01371
01372
01373
01374
01375 def Projection2D(self, geom=0):
01376 return Mesh_Projection2D(self, geom)
01377
01378
01379
01380
01381
01382
01383
01384 def Projection3D(self, geom=0):
01385 return Mesh_Projection3D(self, geom)
01386
01387
01388
01389
01390
01391
01392
01393 def Prism(self, geom=0):
01394 shape = geom
01395 if shape==0:
01396 shape = self.geom
01397 nbSolids = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SOLID"] ))
01398 nbShells = len( self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHELL"] ))
01399 if nbSolids == 0 or nbSolids == nbShells:
01400 return Mesh_Prism3D(self, geom)
01401 return Mesh_RadialPrism3D(self, geom)
01402
01403
01404
01405
01406
01407 def Evaluate(self, geom=0):
01408 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01409 if self.geom == 0:
01410 geom = self.mesh.GetShapeToMesh()
01411 else:
01412 geom = self.geom
01413 return self.smeshpyD.Evaluate(self.mesh, geom)
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423 def Compute(self, geom=0, discardModifs=False):
01424 if geom == 0 or not isinstance(geom, geompyDC.GEOM._objref_GEOM_Object):
01425 if self.geom == 0:
01426 geom = self.mesh.GetShapeToMesh()
01427 else:
01428 geom = self.geom
01429 ok = False
01430 try:
01431 if discardModifs and self.mesh.HasModificationsToDiscard():
01432 self.mesh.Clear()
01433 ok = self.smeshpyD.Compute(self.mesh, geom)
01434 except SALOME.SALOME_Exception, ex:
01435 print "Mesh computation failed, exception caught:"
01436 print " ", ex.details.text
01437 except:
01438 import traceback
01439 print "Mesh computation failed, exception caught:"
01440 traceback.print_exc()
01441 if True:
01442 allReasons = ""
01443
01444
01445 computeErrors = self.smeshpyD.GetComputeErrors( self.mesh, geom )
01446 for err in computeErrors:
01447 shapeText = ""
01448 if self.mesh.HasShapeToMesh():
01449 try:
01450 mainIOR = salome.orb.object_to_string(geom)
01451 for sname in salome.myStudyManager.GetOpenStudies():
01452 s = salome.myStudyManager.GetStudyByName(sname)
01453 if not s: continue
01454 mainSO = s.FindObjectIOR(mainIOR)
01455 if not mainSO: continue
01456 if err.subShapeID == 1:
01457 shapeText = ' on "%s"' % mainSO.GetName()
01458 subIt = s.NewChildIterator(mainSO)
01459 while subIt.More():
01460 subSO = subIt.Value()
01461 subIt.Next()
01462 obj = subSO.GetObject()
01463 if not obj: continue
01464 go = obj._narrow( geompyDC.GEOM._objref_GEOM_Object )
01465 if not go: continue
01466 ids = go.GetSubShapeIndices()
01467 if len(ids) == 1 and ids[0] == err.subShapeID:
01468 shapeText = ' on "%s"' % subSO.GetName()
01469 break
01470 if not shapeText:
01471 shape = self.geompyD.GetSubShape( geom, [err.subShapeID])
01472 if shape:
01473 shapeText = " on %s #%s" % (shape.GetShapeType(), err.subShapeID)
01474 else:
01475 shapeText = " on subshape #%s" % (err.subShapeID)
01476 except:
01477 shapeText = " on subshape #%s" % (err.subShapeID)
01478 errText = ""
01479 stdErrors = ["OK",
01480 "Invalid input mesh",
01481 "std::exception",
01482 "OCC exception",
01483 "SALOME exception",
01484 "Unknown exception",
01485 "Memory allocation problem",
01486 "Algorithm failed",
01487 "Unexpected geometry"]
01488 if err.code > 0:
01489 if err.code < len(stdErrors): errText = stdErrors[err.code]
01490 else:
01491 errText = "code %s" % -err.code
01492 if errText: errText += ". "
01493 errText += err.comment
01494 if allReasons != "":allReasons += "\n"
01495 allReasons += '"%s" failed%s. Error: %s' %(err.algoName, shapeText, errText)
01496 pass
01497
01498
01499 errors = self.smeshpyD.GetAlgoState( self.mesh, geom )
01500 for err in errors:
01501 if err.isGlobalAlgo:
01502 glob = "global"
01503 else:
01504 glob = "local"
01505 pass
01506 dim = err.algoDim
01507 name = err.algoName
01508 if len(name) == 0:
01509 reason = '%s %sD algorithm is missing' % (glob, dim)
01510 elif err.state == HYP_MISSING:
01511 reason = ('%s %sD algorithm "%s" misses %sD hypothesis'
01512 % (glob, dim, name, dim))
01513 elif err.state == HYP_NOTCONFORM:
01514 reason = 'Global "Not Conform mesh allowed" hypothesis is missing'
01515 elif err.state == HYP_BAD_PARAMETER:
01516 reason = ('Hypothesis of %s %sD algorithm "%s" has a bad parameter value'
01517 % ( glob, dim, name ))
01518 elif err.state == HYP_BAD_GEOMETRY:
01519 reason = ('%s %sD algorithm "%s" is assigned to mismatching'
01520 'geometry' % ( glob, dim, name ))
01521 else:
01522 reason = "For unknown reason."+\
01523 " Revise Mesh.Compute() implementation in smeshDC.py!"
01524 pass
01525 if allReasons != "":allReasons += "\n"
01526 allReasons += reason
01527 pass
01528 if allReasons != "":
01529 print '"' + GetName(self.mesh) + '"',"has not been computed:"
01530 print allReasons
01531 ok = False
01532 elif not ok:
01533 print '"' + GetName(self.mesh) + '"',"has not been computed."
01534 pass
01535 pass
01536 if salome.sg.hasDesktop():
01537 smeshgui = salome.ImportComponentGUI("SMESH")
01538 smeshgui.Init(self.mesh.GetStudyId())
01539 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), ok, (self.NbNodes()==0) )
01540 salome.sg.updateObjBrowser(1)
01541 pass
01542 return ok
01543
01544
01545
01546
01547 def GetMeshOrder(self):
01548 return self.mesh.GetMeshOrder()
01549
01550
01551
01552
01553 def SetMeshOrder(self, submeshes):
01554 return self.mesh.SetMeshOrder(submeshes)
01555
01556
01557
01558 def Clear(self):
01559 self.mesh.Clear()
01560 if salome.sg.hasDesktop():
01561 smeshgui = salome.ImportComponentGUI("SMESH")
01562 smeshgui.Init(self.mesh.GetStudyId())
01563 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01564 salome.sg.updateObjBrowser(1)
01565
01566
01567
01568 def ClearSubMesh(self, geomId):
01569 self.mesh.ClearSubMesh(geomId)
01570 if salome.sg.hasDesktop():
01571 smeshgui = salome.ImportComponentGUI("SMESH")
01572 smeshgui.Init(self.mesh.GetStudyId())
01573 smeshgui.SetMeshIcon( salome.ObjectToID( self.mesh ), False, True )
01574 salome.sg.updateObjBrowser(1)
01575
01576
01577
01578
01579
01580 def AutomaticTetrahedralization(self, fineness=0):
01581 dim = self.MeshDimension()
01582
01583 self.RemoveGlobalHypotheses()
01584 self.Segment().AutomaticLength(fineness)
01585 if dim > 1 :
01586 self.Triangle().LengthFromEdges()
01587 pass
01588 if dim > 2 :
01589 self.Tetrahedron(NETGEN)
01590 pass
01591 return self.Compute()
01592
01593
01594
01595
01596
01597 def AutomaticHexahedralization(self, fineness=0):
01598 dim = self.MeshDimension()
01599
01600 self.RemoveGlobalHypotheses()
01601 self.Segment().AutomaticLength(fineness)
01602 if dim > 1 :
01603 self.Quadrangle()
01604 pass
01605 if dim > 2 :
01606 self.Hexahedron()
01607 pass
01608 return self.Compute()
01609
01610
01611
01612
01613
01614
01615 def AddHypothesis(self, hyp, geom=0):
01616 if isinstance( hyp, Mesh_Algorithm ):
01617 hyp = hyp.GetAlgorithm()
01618 pass
01619 if not geom:
01620 geom = self.geom
01621 if not geom:
01622 geom = self.mesh.GetShapeToMesh()
01623 pass
01624 status = self.mesh.AddHypothesis(geom, hyp)
01625 isAlgo = hyp._narrow( SMESH_Algo )
01626 hyp_name = GetName( hyp )
01627 geom_name = ""
01628 if geom:
01629 geom_name = GetName( geom )
01630 TreatHypoStatus( status, hyp_name, geom_name, isAlgo )
01631 return status
01632
01633
01634
01635
01636
01637
01638 def RemoveHypothesis(self, hyp, geom=0):
01639 if isinstance( hyp, Mesh_Algorithm ):
01640 hyp = hyp.GetAlgorithm()
01641 pass
01642 if not geom:
01643 geom = self.geom
01644 pass
01645 status = self.mesh.RemoveHypothesis(geom, hyp)
01646 return status
01647
01648
01649
01650
01651
01652 def GetHypothesisList(self, geom):
01653 return self.mesh.GetHypothesisList( geom )
01654
01655
01656
01657 def RemoveGlobalHypotheses(self):
01658 current_hyps = self.mesh.GetHypothesisList( self.geom )
01659 for hyp in current_hyps:
01660 self.mesh.RemoveHypothesis( self.geom, hyp )
01661 pass
01662 pass
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673 def ExportToMED(self, f, version, opt=0, overwrite=1):
01674 self.mesh.ExportToMEDX(f, opt, version, overwrite)
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685 def ExportMED(self, f, auto_groups=0, version=MED_V2_2, overwrite=1):
01686 self.mesh.ExportToMEDX(f, auto_groups, version, overwrite)
01687
01688
01689
01690
01691 def ExportDAT(self, f):
01692 self.mesh.ExportDAT(f)
01693
01694
01695
01696
01697 def ExportUNV(self, f):
01698 self.mesh.ExportUNV(f)
01699
01700
01701
01702
01703
01704 def ExportSTL(self, f, ascii=1):
01705 self.mesh.ExportSTL(f, ascii)
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716 def CreateEmptyGroup(self, elementType, name):
01717 return self.mesh.CreateGroup(elementType, name)
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727 def Group(self, grp, name=""):
01728 return self.GroupOnGeom(grp, name)
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739 def GroupOnGeom(self, grp, name="", typ=None):
01740 AssureGeomPublished( self, grp, name )
01741 if name == "":
01742 name = grp.GetName()
01743 if not typ:
01744 typ = self._groupTypeFromShape( grp )
01745 return self.mesh.CreateGroupFromGEOM(typ, name, grp)
01746
01747
01748 def _groupTypeFromShape( self, shape ):
01749 tgeo = str(shape.GetShapeType())
01750 if tgeo == "VERTEX":
01751 typ = NODE
01752 elif tgeo == "EDGE":
01753 typ = EDGE
01754 elif tgeo == "FACE" or tgeo == "SHELL":
01755 typ = FACE
01756 elif tgeo == "SOLID" or tgeo == "COMPSOLID":
01757 typ = VOLUME
01758 elif tgeo == "COMPOUND":
01759 sub = self.geompyD.SubShapeAll( shape, geompyDC.ShapeType["SHAPE"])
01760 if not sub:
01761 raise ValueError,"_groupTypeFromShape(): empty geometric group or compound '%s'" % GetName(shape)
01762 return self._groupTypeFromShape( sub[0] )
01763 else:
01764 raise ValueError, \
01765 "_groupTypeFromShape(): invalid geometry '%s'" % GetName(shape)
01766 return typ
01767
01768
01769
01770
01771
01772
01773
01774 def MakeGroupByIds(self, groupName, elementType, elemIDs):
01775 group = self.mesh.CreateGroup(elementType, groupName)
01776 group.Add(elemIDs)
01777 return group
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790 def MakeGroup(self,
01791 groupName,
01792 elementType,
01793 CritType=FT_Undefined,
01794 Compare=FT_EqualTo,
01795 Treshold="",
01796 UnaryOp=FT_Undefined,
01797 Tolerance=1e-07):
01798 aCriterion = self.smeshpyD.GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined,Tolerance)
01799 group = self.MakeGroupByCriterion(groupName, aCriterion)
01800 return group
01801
01802
01803
01804
01805
01806
01807 def MakeGroupByCriterion(self, groupName, Criterion):
01808 aFilterMgr = self.smeshpyD.CreateFilterManager()
01809 aFilter = aFilterMgr.CreateFilter()
01810 aCriteria = []
01811 aCriteria.append(Criterion)
01812 aFilter.SetCriteria(aCriteria)
01813 group = self.MakeGroupByFilter(groupName, aFilter)
01814 aFilterMgr.UnRegister()
01815 return group
01816
01817
01818
01819
01820
01821
01822 def MakeGroupByCriteria(self, groupName, theCriteria):
01823 aFilterMgr = self.smeshpyD.CreateFilterManager()
01824 aFilter = aFilterMgr.CreateFilter()
01825 aFilter.SetCriteria(theCriteria)
01826 group = self.MakeGroupByFilter(groupName, aFilter)
01827 aFilterMgr.UnRegister()
01828 return group
01829
01830
01831
01832
01833
01834
01835 def MakeGroupByFilter(self, groupName, theFilter):
01836 group = self.CreateEmptyGroup(theFilter.GetElementType(), groupName)
01837 theFilter.SetMesh( self.mesh )
01838 group.AddFrom( theFilter )
01839 return group
01840
01841
01842
01843
01844
01845 def GetIdsFromFilter(self, theFilter):
01846 theFilter.SetMesh( self.mesh )
01847 return theFilter.GetIDs()
01848
01849
01850
01851
01852
01853 def GetFreeBorders(self):
01854 aFilterMgr = self.smeshpyD.CreateFilterManager()
01855 aPredicate = aFilterMgr.CreateFreeEdges()
01856 aPredicate.SetMesh(self.mesh)
01857 aBorders = aPredicate.GetBorders()
01858 aFilterMgr.UnRegister()
01859 return aBorders
01860
01861
01862
01863 def RemoveGroup(self, group):
01864 self.mesh.RemoveGroup(group)
01865
01866
01867
01868 def RemoveGroupWithContents(self, group):
01869 self.mesh.RemoveGroupWithContents(group)
01870
01871
01872
01873
01874 def GetGroups(self):
01875 return self.mesh.GetGroups()
01876
01877
01878
01879
01880 def NbGroups(self):
01881 return self.mesh.NbGroups()
01882
01883
01884
01885
01886 def GetGroupNames(self):
01887 groups = self.GetGroups()
01888 names = []
01889 for group in groups:
01890 names.append(group.GetName())
01891 return names
01892
01893
01894
01895
01896
01897
01898 def UnionGroups(self, group1, group2, name):
01899 return self.mesh.UnionGroups(group1, group2, name)
01900
01901
01902
01903
01904
01905
01906 def UnionListOfGroups(self, groups, name):
01907 return self.mesh.UnionListOfGroups(groups, name)
01908
01909
01910
01911
01912
01913
01914 def IntersectGroups(self, group1, group2, name):
01915 return self.mesh.IntersectGroups(group1, group2, name)
01916
01917
01918
01919
01920
01921
01922 def IntersectListOfGroups(self, groups, name):
01923 return self.mesh.IntersectListOfGroups(groups, name)
01924
01925
01926
01927
01928
01929
01930 def CutGroups(self, main_group, tool_group, name):
01931 return self.mesh.CutGroups(main_group, tool_group, name)
01932
01933
01934
01935
01936
01937
01938 def CutListOfGroups(self, main_groups, tool_groups, name):
01939 return self.mesh.CutListOfGroups(main_groups, tool_groups, name)
01940
01941
01942
01943
01944
01945
01946
01947 def CreateDimGroup(self, groups, elem_type, name):
01948 return self.mesh.CreateDimGroup(groups, elem_type, name)
01949
01950
01951
01952
01953 def ConvertToStandalone(self, group):
01954 return self.mesh.ConvertToStandalone(group)
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968 def GetLog(self, clearAfterGet):
01969 return self.mesh.GetLog(clearAfterGet)
01970
01971
01972
01973
01974 def ClearLog(self):
01975 self.mesh.ClearLog()
01976
01977
01978
01979
01980 def SetAutoColor(self, theAutoColor):
01981 self.mesh.SetAutoColor(theAutoColor)
01982
01983
01984
01985
01986 def GetAutoColor(self):
01987 return self.mesh.GetAutoColor()
01988
01989
01990
01991
01992 def GetId(self):
01993 return self.mesh.GetId()
01994
01995
01996
01997
01998 def GetStudyId(self):
01999 return self.mesh.GetStudyId()
02000
02001
02002
02003
02004
02005 def HasDuplicatedGroupNamesMED(self):
02006 return self.mesh.HasDuplicatedGroupNamesMED()
02007
02008
02009
02010
02011 def GetMeshEditor(self):
02012 return self.mesh.GetMeshEditor()
02013
02014
02015
02016
02017
02018 def GetIDSource(self, ids, elemType):
02019 return self.GetMeshEditor().MakeIDSource(ids, elemType)
02020
02021
02022
02023
02024 def GetMEDMesh(self):
02025 return self.mesh.GetMEDMesh()
02026
02027
02028
02029
02030
02031
02032
02033
02034 def GetMeshInfo(self, obj = None):
02035 if not obj: obj = self.mesh
02036 return self.smeshpyD.GetMeshInfo(obj)
02037
02038
02039
02040
02041 def NbNodes(self):
02042 return self.mesh.NbNodes()
02043
02044
02045
02046
02047 def NbElements(self):
02048 return self.mesh.NbElements()
02049
02050
02051
02052
02053 def Nb0DElements(self):
02054 return self.mesh.Nb0DElements()
02055
02056
02057
02058
02059 def NbEdges(self):
02060 return self.mesh.NbEdges()
02061
02062
02063
02064
02065
02066
02067 def NbEdgesOfOrder(self, elementOrder):
02068 return self.mesh.NbEdgesOfOrder(elementOrder)
02069
02070
02071
02072
02073 def NbFaces(self):
02074 return self.mesh.NbFaces()
02075
02076
02077
02078
02079
02080
02081 def NbFacesOfOrder(self, elementOrder):
02082 return self.mesh.NbFacesOfOrder(elementOrder)
02083
02084
02085
02086
02087 def NbTriangles(self):
02088 return self.mesh.NbTriangles()
02089
02090
02091
02092
02093
02094
02095 def NbTrianglesOfOrder(self, elementOrder):
02096 return self.mesh.NbTrianglesOfOrder(elementOrder)
02097
02098
02099
02100
02101 def NbQuadrangles(self):
02102 return self.mesh.NbQuadrangles()
02103
02104
02105
02106
02107
02108
02109 def NbQuadranglesOfOrder(self, elementOrder):
02110 return self.mesh.NbQuadranglesOfOrder(elementOrder)
02111
02112
02113
02114
02115 def NbPolygons(self):
02116 return self.mesh.NbPolygons()
02117
02118
02119
02120
02121 def NbVolumes(self):
02122 return self.mesh.NbVolumes()
02123
02124
02125
02126
02127
02128
02129 def NbVolumesOfOrder(self, elementOrder):
02130 return self.mesh.NbVolumesOfOrder(elementOrder)
02131
02132
02133
02134
02135 def NbTetras(self):
02136 return self.mesh.NbTetras()
02137
02138
02139
02140
02141
02142
02143 def NbTetrasOfOrder(self, elementOrder):
02144 return self.mesh.NbTetrasOfOrder(elementOrder)
02145
02146
02147
02148
02149 def NbHexas(self):
02150 return self.mesh.NbHexas()
02151
02152
02153
02154
02155
02156
02157 def NbHexasOfOrder(self, elementOrder):
02158 return self.mesh.NbHexasOfOrder(elementOrder)
02159
02160
02161
02162
02163 def NbPyramids(self):
02164 return self.mesh.NbPyramids()
02165
02166
02167
02168
02169
02170
02171 def NbPyramidsOfOrder(self, elementOrder):
02172 return self.mesh.NbPyramidsOfOrder(elementOrder)
02173
02174
02175
02176
02177 def NbPrisms(self):
02178 return self.mesh.NbPrisms()
02179
02180
02181
02182
02183
02184
02185 def NbPrismsOfOrder(self, elementOrder):
02186 return self.mesh.NbPrismsOfOrder(elementOrder)
02187
02188
02189
02190
02191 def NbPolyhedrons(self):
02192 return self.mesh.NbPolyhedrons()
02193
02194
02195
02196
02197 def NbSubMesh(self):
02198 return self.mesh.NbSubMesh()
02199
02200
02201
02202
02203 def GetElementsId(self):
02204 return self.mesh.GetElementsId()
02205
02206
02207
02208
02209
02210 def GetElementsByType(self, elementType):
02211 return self.mesh.GetElementsByType(elementType)
02212
02213
02214
02215
02216 def GetNodesId(self):
02217 return self.mesh.GetNodesId()
02218
02219
02220
02221
02222
02223
02224
02225 def GetElementType(self, id, iselem):
02226 return self.mesh.GetElementType(id, iselem)
02227
02228
02229
02230
02231 def GetElementGeomType(self, id):
02232 return self.mesh.GetElementGeomType(id)
02233
02234
02235
02236
02237
02238
02239 def GetSubMeshElementsId(self, Shape):
02240 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02241 ShapeID = Shape.GetSubShapeIndices()[0]
02242 else:
02243 ShapeID = Shape
02244 return self.mesh.GetSubMeshElementsId(ShapeID)
02245
02246
02247
02248
02249
02250
02251
02252 def GetSubMeshNodesId(self, Shape, all):
02253 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02254 ShapeID = Shape.GetSubShapeIndices()[0]
02255 else:
02256 ShapeID = Shape
02257 return self.mesh.GetSubMeshNodesId(ShapeID, all)
02258
02259
02260
02261
02262
02263
02264 def GetSubMeshElementType(self, Shape):
02265 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02266 ShapeID = Shape.GetSubShapeIndices()[0]
02267 else:
02268 ShapeID = Shape
02269 return self.mesh.GetSubMeshElementType(ShapeID)
02270
02271
02272
02273
02274 def Dump(self):
02275 return self.mesh.Dump()
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285 def GetNodeXYZ(self, id):
02286 return self.mesh.GetNodeXYZ(id)
02287
02288
02289
02290
02291
02292 def GetNodeInverseElements(self, id):
02293 return self.mesh.GetNodeInverseElements(id)
02294
02295
02296
02297
02298 def GetNodePosition(self,NodeID):
02299 return self.mesh.GetNodePosition(NodeID)
02300
02301
02302
02303
02304
02305 def GetShapeID(self, id):
02306 return self.mesh.GetShapeID(id)
02307
02308
02309
02310
02311
02312
02313 def GetShapeIDForElem(self,id):
02314 return self.mesh.GetShapeIDForElem(id)
02315
02316
02317
02318
02319
02320 def GetElemNbNodes(self, id):
02321 return self.mesh.GetElemNbNodes(id)
02322
02323
02324
02325
02326
02327
02328 def GetElemNode(self, id, index):
02329 return self.mesh.GetElemNode(id, index)
02330
02331
02332
02333
02334 def GetElemNodes(self, id):
02335 return self.mesh.GetElemNodes(id)
02336
02337
02338
02339 def IsMediumNode(self, elementID, nodeID):
02340 return self.mesh.IsMediumNode(elementID, nodeID)
02341
02342
02343
02344 def IsMediumNodeOfAnyElem(self, nodeID, elementType):
02345 return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
02346
02347
02348
02349 def ElemNbEdges(self, id):
02350 return self.mesh.ElemNbEdges(id)
02351
02352
02353
02354 def ElemNbFaces(self, id):
02355 return self.mesh.ElemNbFaces(id)
02356
02357
02358
02359 def GetElemFaceNodes(self,elemId, faceIndex):
02360 return self.mesh.GetElemFaceNodes(elemId, faceIndex)
02361
02362
02363
02364 def FindElementByNodes(self,nodes):
02365 return self.mesh.FindElementByNodes(nodes)
02366
02367
02368
02369 def IsPoly(self, id):
02370 return self.mesh.IsPoly(id)
02371
02372
02373
02374 def IsQuadratic(self, id):
02375 return self.mesh.IsQuadratic(id)
02376
02377
02378
02379
02380
02381 def BaryCenter(self, id):
02382 return self.mesh.BaryCenter(id)
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395 def MinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02396 aMeasure = self.GetMinDistance(id1, id2, isElem1, isElem2)
02397 return aMeasure.value
02398
02399
02400
02401
02402
02403
02404
02405
02406 def GetMinDistance(self, id1, id2=0, isElem1=False, isElem2=False):
02407 if isElem1:
02408 id1 = self.editor.MakeIDSource([id1], SMESH.FACE)
02409 else:
02410 id1 = self.editor.MakeIDSource([id1], SMESH.NODE)
02411 if id2 != 0:
02412 if isElem2:
02413 id2 = self.editor.MakeIDSource([id2], SMESH.FACE)
02414 else:
02415 id2 = self.editor.MakeIDSource([id2], SMESH.NODE)
02416 pass
02417 else:
02418 id2 = None
02419
02420 aMeasurements = self.smeshpyD.CreateMeasurements()
02421 aMeasure = aMeasurements.MinDistance(id1, id2)
02422 aMeasurements.UnRegister()
02423 return aMeasure
02424
02425
02426
02427
02428
02429
02430
02431 def BoundingBox(self, objects=None, isElem=False):
02432 result = self.GetBoundingBox(objects, isElem)
02433 if result is None:
02434 result = (0.0,)*6
02435 else:
02436 result = (result.minX, result.minY, result.minZ, result.maxX, result.maxY, result.maxZ)
02437 return result
02438
02439
02440
02441
02442
02443
02444
02445 def GetBoundingBox(self, IDs=None, isElem=False):
02446 if IDs is None:
02447 IDs = [self.mesh]
02448 elif isinstance(IDs, tuple):
02449 IDs = list(IDs)
02450 if not isinstance(IDs, list):
02451 IDs = [IDs]
02452 if len(IDs) > 0 and isinstance(IDs[0], int):
02453 IDs = [IDs]
02454 srclist = []
02455 for o in IDs:
02456 if isinstance(o, Mesh):
02457 srclist.append(o.mesh)
02458 elif hasattr(o, "_narrow"):
02459 src = o._narrow(SMESH.SMESH_IDSource)
02460 if src: srclist.append(src)
02461 pass
02462 elif isinstance(o, list):
02463 if isElem:
02464 srclist.append(self.editor.MakeIDSource(o, SMESH.FACE))
02465 else:
02466 srclist.append(self.editor.MakeIDSource(o, SMESH.NODE))
02467 pass
02468 pass
02469 aMeasurements = self.smeshpyD.CreateMeasurements()
02470 aMeasure = aMeasurements.BoundingBox(srclist)
02471 aMeasurements.UnRegister()
02472 return aMeasure
02473
02474
02475
02476
02477
02478
02479
02480
02481 def RemoveElements(self, IDsOfElements):
02482 return self.editor.RemoveElements(IDsOfElements)
02483
02484
02485
02486
02487
02488 def RemoveNodes(self, IDsOfNodes):
02489 return self.editor.RemoveNodes(IDsOfNodes)
02490
02491
02492
02493
02494 def RemoveOrphanNodes(self):
02495 return self.editor.RemoveOrphanNodes()
02496
02497
02498
02499
02500 def AddNode(self, x, y, z):
02501 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02502 self.mesh.SetParameters(Parameters)
02503 return self.editor.AddNode( x, y, z)
02504
02505
02506
02507
02508
02509 def Add0DElement(self, IDOfNode):
02510 return self.editor.Add0DElement(IDOfNode)
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520 def AddEdge(self, IDsOfNodes):
02521 return self.editor.AddEdge(IDsOfNodes)
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531 def AddFace(self, IDsOfNodes):
02532 return self.editor.AddFace(IDsOfNodes)
02533
02534
02535
02536
02537
02538 def AddPolygonalFace(self, IdsOfNodes):
02539 return self.editor.AddPolygonalFace(IdsOfNodes)
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549 def AddVolume(self, IDsOfNodes):
02550 return self.editor.AddVolume(IDsOfNodes)
02551
02552
02553
02554
02555
02556
02557
02558 def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
02559 return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
02560
02561
02562
02563
02564
02565
02566
02567
02568 def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
02569 return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
02570
02571
02572
02573
02574
02575
02576
02577 def SetNodeOnVertex(self, NodeID, Vertex):
02578 if ( isinstance( Vertex, geompyDC.GEOM._objref_GEOM_Object)):
02579 VertexID = Vertex.GetSubShapeIndices()[0]
02580 else:
02581 VertexID = Vertex
02582 try:
02583 self.editor.SetNodeOnVertex(NodeID, VertexID)
02584 except SALOME.SALOME_Exception, inst:
02585 raise ValueError, inst.details.text
02586 return True
02587
02588
02589
02590
02591
02592
02593
02594
02595 def SetNodeOnEdge(self, NodeID, Edge, paramOnEdge):
02596 if ( isinstance( Edge, geompyDC.GEOM._objref_GEOM_Object)):
02597 EdgeID = Edge.GetSubShapeIndices()[0]
02598 else:
02599 EdgeID = Edge
02600 try:
02601 self.editor.SetNodeOnEdge(NodeID, EdgeID, paramOnEdge)
02602 except SALOME.SALOME_Exception, inst:
02603 raise ValueError, inst.details.text
02604 return True
02605
02606
02607
02608
02609
02610
02611
02612
02613 def SetNodeOnFace(self, NodeID, Face, u, v):
02614 if ( isinstance( Face, geompyDC.GEOM._objref_GEOM_Object)):
02615 FaceID = Face.GetSubShapeIndices()[0]
02616 else:
02617 FaceID = Face
02618 try:
02619 self.editor.SetNodeOnFace(NodeID, FaceID, u, v)
02620 except SALOME.SALOME_Exception, inst:
02621 raise ValueError, inst.details.text
02622 return True
02623
02624
02625
02626
02627
02628
02629 def SetNodeInVolume(self, NodeID, Solid):
02630 if ( isinstance( Solid, geompyDC.GEOM._objref_GEOM_Object)):
02631 SolidID = Solid.GetSubShapeIndices()[0]
02632 else:
02633 SolidID = Solid
02634 try:
02635 self.editor.SetNodeInVolume(NodeID, SolidID)
02636 except SALOME.SALOME_Exception, inst:
02637 raise ValueError, inst.details.text
02638 return True
02639
02640
02641
02642
02643
02644
02645 def SetMeshElementOnShape(self, ElementID, Shape):
02646 if ( isinstance( Shape, geompyDC.GEOM._objref_GEOM_Object)):
02647 ShapeID = Shape.GetSubShapeIndices()[0]
02648 else:
02649 ShapeID = Shape
02650 try:
02651 self.editor.SetMeshElementOnShape(ElementID, ShapeID)
02652 except SALOME.SALOME_Exception, inst:
02653 raise ValueError, inst.details.text
02654 return True
02655
02656
02657
02658
02659
02660
02661
02662
02663
02664 def MoveNode(self, NodeID, x, y, z):
02665 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02666 self.mesh.SetParameters(Parameters)
02667 return self.editor.MoveNode(NodeID, x, y, z)
02668
02669
02670
02671
02672
02673
02674
02675
02676
02677 def MoveClosestNodeToPoint(self, x, y, z, NodeID):
02678 x,y,z,Parameters = geompyDC.ParseParameters(x,y,z)
02679 self.mesh.SetParameters(Parameters)
02680 return self.editor.MoveClosestNodeToPoint(x, y, z, NodeID)
02681
02682
02683
02684
02685
02686
02687
02688 def FindNodeClosestTo(self, x, y, z):
02689
02690
02691 return self.editor.FindNodeClosestTo(x, y, z)
02692
02693
02694
02695
02696
02697
02698
02699
02700
02701 def FindElementsByPoint(self, x, y, z, elementType = SMESH.ALL):
02702 return self.editor.FindElementsByPoint(x, y, z, elementType)
02703
02704
02705
02706
02707 def GetPointState(self, x, y, z):
02708 return self.editor.GetPointState(x, y, z)
02709
02710
02711
02712
02713
02714
02715
02716 def MeshToPassThroughAPoint(self, x, y, z):
02717 return self.editor.MoveClosestNodeToPoint(x, y, z, -1)
02718
02719
02720
02721
02722
02723
02724
02725 def InverseDiag(self, NodeID1, NodeID2):
02726 return self.editor.InverseDiag(NodeID1, NodeID2)
02727
02728
02729
02730
02731
02732
02733
02734 def DeleteDiag(self, NodeID1, NodeID2):
02735 return self.editor.DeleteDiag(NodeID1, NodeID2)
02736
02737
02738
02739
02740
02741 def Reorient(self, IDsOfElements=None):
02742 if IDsOfElements == None:
02743 IDsOfElements = self.GetElementsId()
02744 return self.editor.Reorient(IDsOfElements)
02745
02746
02747
02748
02749
02750 def ReorientObject(self, theObject):
02751 if ( isinstance( theObject, Mesh )):
02752 theObject = theObject.GetMesh()
02753 return self.editor.ReorientObject(theObject)
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763 def TriToQuad(self, IDsOfElements, theCriterion, MaxAngle):
02764 flag = False
02765 if isinstance(MaxAngle,str):
02766 flag = True
02767 MaxAngle,Parameters = geompyDC.ParseParameters(MaxAngle)
02768 if flag:
02769 MaxAngle = DegreesToRadians(MaxAngle)
02770 if IDsOfElements == []:
02771 IDsOfElements = self.GetElementsId()
02772 self.mesh.SetParameters(Parameters)
02773 Functor = 0
02774 if ( isinstance( theCriterion, SMESH._objref_NumericalFunctor ) ):
02775 Functor = theCriterion
02776 else:
02777 Functor = self.smeshpyD.GetFunctor(theCriterion)
02778 return self.editor.TriToQuad(IDsOfElements, Functor, MaxAngle)
02779
02780
02781
02782
02783
02784
02785
02786
02787 def TriToQuadObject (self, theObject, theCriterion, MaxAngle):
02788 if ( isinstance( theObject, Mesh )):
02789 theObject = theObject.GetMesh()
02790 return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
02791
02792
02793
02794
02795
02796
02797 def QuadToTri (self, IDsOfElements, theCriterion):
02798 if IDsOfElements == []:
02799 IDsOfElements = self.GetElementsId()
02800 return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
02801
02802
02803
02804
02805
02806
02807 def QuadToTriObject (self, theObject, theCriterion):
02808 if ( isinstance( theObject, Mesh )):
02809 theObject = theObject.GetMesh()
02810 return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
02811
02812
02813
02814
02815
02816
02817 def SplitQuad (self, IDsOfElements, Diag13):
02818 if IDsOfElements == []:
02819 IDsOfElements = self.GetElementsId()
02820 return self.editor.SplitQuad(IDsOfElements, Diag13)
02821
02822
02823
02824
02825
02826
02827 def SplitQuadObject (self, theObject, Diag13):
02828 if ( isinstance( theObject, Mesh )):
02829 theObject = theObject.GetMesh()
02830 return self.editor.SplitQuadObject(theObject, Diag13)
02831
02832
02833
02834
02835
02836
02837
02838 def BestSplit (self, IDOfQuad, theCriterion):
02839 return self.editor.BestSplit(IDOfQuad, self.smeshpyD.GetFunctor(theCriterion))
02840
02841
02842
02843
02844
02845
02846 def SplitVolumesIntoTetra(self, elemIDs, method=Hex_5Tet ):
02847 if isinstance( elemIDs, Mesh ):
02848 elemIDs = elemIDs.GetMesh()
02849 if ( isinstance( elemIDs, list )):
02850 elemIDs = self.editor.MakeIDSource(elemIDs, SMESH.VOLUME)
02851 self.editor.SplitVolumesIntoTetra(elemIDs, method)
02852
02853
02854
02855
02856 def SplitQuadsNearTriangularFacets(self):
02857 faces_array = self.GetElementsByType(SMESH.FACE)
02858 for face_id in faces_array:
02859 if self.GetElemNbNodes(face_id) == 4:
02860 quad_nodes = self.mesh.GetElemNodes(face_id)
02861 node1_elems = self.GetNodeInverseElements(quad_nodes[1 -1])
02862 isVolumeFound = False
02863 for node1_elem in node1_elems:
02864 if not isVolumeFound:
02865 if self.GetElementType(node1_elem, True) == SMESH.VOLUME:
02866 nb_nodes = self.GetElemNbNodes(node1_elem)
02867 if 3 < nb_nodes and nb_nodes < 7:
02868 volume_elem = node1_elem
02869 volume_nodes = self.mesh.GetElemNodes(volume_elem)
02870 if volume_nodes.count(quad_nodes[2 -1]) > 0:
02871 if volume_nodes.count(quad_nodes[4 -1]) > 0:
02872 isVolumeFound = True
02873 if volume_nodes.count(quad_nodes[3 -1]) == 0:
02874 self.SplitQuad([face_id], False)
02875 elif volume_nodes.count(quad_nodes[3 -1]) > 0:
02876 isVolumeFound = True
02877 self.SplitQuad([face_id], True)
02878 elif volume_nodes.count(quad_nodes[4 -1]) > 0:
02879 if volume_nodes.count(quad_nodes[3 -1]) > 0:
02880 isVolumeFound = True
02881 self.SplitQuad([face_id], True)
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894 def SplitHexaToTetras (self, theObject, theNode000, theNode001):
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908 pattern_tetra = "!!! Nb of points: \n 8 \n\
02909 !!! Points: \n\
02910 0 0 0 !- 0 \n\
02911 0 1 0 !- 1 \n\
02912 1 1 0 !- 2 \n\
02913 1 0 0 !- 3 \n\
02914 0 0 1 !- 4 \n\
02915 0 1 1 !- 5 \n\
02916 1 1 1 !- 6 \n\
02917 1 0 1 !- 7 \n\
02918 !!! Indices of points of 6 tetras: \n\
02919 0 3 4 1 \n\
02920 7 4 3 1 \n\
02921 4 7 5 1 \n\
02922 6 2 5 7 \n\
02923 1 5 2 7 \n\
02924 2 3 1 7 \n"
02925
02926 pattern = self.smeshpyD.GetPattern()
02927 isDone = pattern.LoadFromFile(pattern_tetra)
02928 if not isDone:
02929 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02930 return isDone
02931
02932 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02933 isDone = pattern.MakeMesh(self.mesh, False, False)
02934 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02935
02936
02937 self.SplitQuadsNearTriangularFacets()
02938
02939 return isDone
02940
02941
02942
02943
02944
02945
02946
02947
02948
02949
02950
02951
02952 def SplitHexaToPrisms (self, theObject, theNode000, theNode001):
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966 pattern_prism = "!!! Nb of points: \n 8 \n\
02967 !!! Points: \n\
02968 0 0 0 !- 0 \n\
02969 0 1 0 !- 1 \n\
02970 1 1 0 !- 2 \n\
02971 1 0 0 !- 3 \n\
02972 0 0 1 !- 4 \n\
02973 0 1 1 !- 5 \n\
02974 1 1 1 !- 6 \n\
02975 1 0 1 !- 7 \n\
02976 !!! Indices of points of 2 prisms: \n\
02977 0 1 3 4 5 7 \n\
02978 2 3 1 6 7 5 \n"
02979
02980 pattern = self.smeshpyD.GetPattern()
02981 isDone = pattern.LoadFromFile(pattern_prism)
02982 if not isDone:
02983 print 'Pattern.LoadFromFile :', pattern.GetErrorCode()
02984 return isDone
02985
02986 pattern.ApplyToHexahedrons(self.mesh, theObject.GetIDs(), theNode000, theNode001)
02987 isDone = pattern.MakeMesh(self.mesh, False, False)
02988 if not isDone: print 'Pattern.MakeMesh :', pattern.GetErrorCode()
02989
02990
02991 self.SplitQuadsNearTriangularFacets()
02992
02993 return isDone
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004 def Smooth(self, IDsOfElements, IDsOfFixedNodes,
03005 MaxNbOfIterations, MaxAspectRatio, Method):
03006 if IDsOfElements == []:
03007 IDsOfElements = self.GetElementsId()
03008 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
03009 self.mesh.SetParameters(Parameters)
03010 return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
03011 MaxNbOfIterations, MaxAspectRatio, Method)
03012
03013
03014
03015
03016
03017
03018
03019
03020
03021
03022 def SmoothObject(self, theObject, IDsOfFixedNodes,
03023 MaxNbOfIterations, MaxAspectRatio, Method):
03024 if ( isinstance( theObject, Mesh )):
03025 theObject = theObject.GetMesh()
03026 return self.editor.SmoothObject(theObject, IDsOfFixedNodes,
03027 MaxNbOfIterations, MaxAspectRatio, Method)
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038 def SmoothParametric(self, IDsOfElements, IDsOfFixedNodes,
03039 MaxNbOfIterations, MaxAspectRatio, Method):
03040 if IDsOfElements == []:
03041 IDsOfElements = self.GetElementsId()
03042 MaxNbOfIterations,MaxAspectRatio,Parameters = geompyDC.ParseParameters(MaxNbOfIterations,MaxAspectRatio)
03043 self.mesh.SetParameters(Parameters)
03044 return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
03045 MaxNbOfIterations, MaxAspectRatio, Method)
03046
03047
03048
03049
03050
03051
03052
03053
03054
03055
03056 def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
03057 MaxNbOfIterations, MaxAspectRatio, Method):
03058 if ( isinstance( theObject, Mesh )):
03059 theObject = theObject.GetMesh()
03060 return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
03061 MaxNbOfIterations, MaxAspectRatio, Method)
03062
03063
03064
03065
03066
03067
03068
03069
03070 def ConvertToQuadratic(self, theForce3d, theSubMesh=None):
03071 if theSubMesh:
03072 self.editor.ConvertToQuadraticObject(theForce3d,theSubMesh)
03073 else:
03074 self.editor.ConvertToQuadratic(theForce3d)
03075
03076
03077
03078
03079
03080
03081 def ConvertFromQuadratic(self, theSubMesh=None):
03082 if theSubMesh:
03083 self.editor.ConvertFromQuadraticObject(theSubMesh)
03084 else:
03085 return self.editor.ConvertFromQuadratic()
03086
03087
03088
03089
03090 def Make2DMeshFrom3D(self):
03091 return self.editor. Make2DMeshFrom3D()
03092
03093
03094
03095
03096
03097
03098
03099
03100
03101
03102
03103
03104
03105
03106
03107
03108
03109
03110 def MakeBoundaryMesh(self, elements, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
03111 toCopyElements=False, toCopyExistingBondary=False):
03112 if isinstance( elements, Mesh ):
03113 elements = elements.GetMesh()
03114 if ( isinstance( elements, list )):
03115 elemType = SMESH.ALL
03116 if elements: elemType = self.GetElementType( elements[0], iselem=True)
03117 elements = self.editor.MakeIDSource(elements, elemType)
03118 mesh, group = self.editor.MakeBoundaryMesh(elements,dimension,groupName,meshName,
03119 toCopyElements,toCopyExistingBondary)
03120 if mesh: mesh = self.smeshpyD.Mesh(mesh)
03121 return mesh, group
03122
03123
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139 def MakeBoundaryElements(self, dimension=SMESH.BND_2DFROM3D, groupName="", meshName="",
03140 toCopyAll=False, groups=[]):
03141 nb, mesh, group = self.editor.MakeBoundaryElements(dimension,groupName,meshName,
03142 toCopyAll,groups)
03143 if mesh: mesh = self.smeshpyD.Mesh(mesh)
03144 return nb, mesh, group
03145
03146
03147
03148 def RenumberNodes(self):
03149 self.editor.RenumberNodes()
03150
03151
03152
03153 def RenumberElements(self):
03154 self.editor.RenumberElements()
03155
03156
03157
03158
03159
03160
03161
03162
03163
03164
03165
03166
03167 def RotationSweep(self, IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance,
03168 MakeGroups=False, TotalAngle=False):
03169 flag = False
03170 if isinstance(AngleInRadians,str):
03171 flag = True
03172 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03173 if flag:
03174 AngleInRadians = DegreesToRadians(AngleInRadians)
03175 if IDsOfElements == []:
03176 IDsOfElements = self.GetElementsId()
03177 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03178 Axis = self.smeshpyD.GetAxisStruct(Axis)
03179 Axis,AxisParameters = ParseAxisStruct(Axis)
03180 if TotalAngle and NbOfSteps:
03181 AngleInRadians /= NbOfSteps
03182 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03183 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03184 self.mesh.SetParameters(Parameters)
03185 if MakeGroups:
03186 return self.editor.RotationSweepMakeGroups(IDsOfElements, Axis,
03187 AngleInRadians, NbOfSteps, Tolerance)
03188 self.editor.RotationSweep(IDsOfElements, Axis, AngleInRadians, NbOfSteps, Tolerance)
03189 return []
03190
03191
03192
03193
03194
03195
03196
03197
03198
03199
03200
03201
03202
03203 def RotationSweepObject(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03204 MakeGroups=False, TotalAngle=False):
03205 flag = False
03206 if isinstance(AngleInRadians,str):
03207 flag = True
03208 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03209 if flag:
03210 AngleInRadians = DegreesToRadians(AngleInRadians)
03211 if ( isinstance( theObject, Mesh )):
03212 theObject = theObject.GetMesh()
03213 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03214 Axis = self.smeshpyD.GetAxisStruct(Axis)
03215 Axis,AxisParameters = ParseAxisStruct(Axis)
03216 if TotalAngle and NbOfSteps:
03217 AngleInRadians /= NbOfSteps
03218 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03219 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03220 self.mesh.SetParameters(Parameters)
03221 if MakeGroups:
03222 return self.editor.RotationSweepObjectMakeGroups(theObject, Axis, AngleInRadians,
03223 NbOfSteps, Tolerance)
03224 self.editor.RotationSweepObject(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03225 return []
03226
03227
03228
03229
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239 def RotationSweepObject1D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03240 MakeGroups=False, TotalAngle=False):
03241 flag = False
03242 if isinstance(AngleInRadians,str):
03243 flag = True
03244 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03245 if flag:
03246 AngleInRadians = DegreesToRadians(AngleInRadians)
03247 if ( isinstance( theObject, Mesh )):
03248 theObject = theObject.GetMesh()
03249 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03250 Axis = self.smeshpyD.GetAxisStruct(Axis)
03251 Axis,AxisParameters = ParseAxisStruct(Axis)
03252 if TotalAngle and NbOfSteps:
03253 AngleInRadians /= NbOfSteps
03254 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03255 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03256 self.mesh.SetParameters(Parameters)
03257 if MakeGroups:
03258 return self.editor.RotationSweepObject1DMakeGroups(theObject, Axis, AngleInRadians,
03259 NbOfSteps, Tolerance)
03260 self.editor.RotationSweepObject1D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03261 return []
03262
03263
03264
03265
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275 def RotationSweepObject2D(self, theObject, Axis, AngleInRadians, NbOfSteps, Tolerance,
03276 MakeGroups=False, TotalAngle=False):
03277 flag = False
03278 if isinstance(AngleInRadians,str):
03279 flag = True
03280 AngleInRadians,AngleParameters = geompyDC.ParseParameters(AngleInRadians)
03281 if flag:
03282 AngleInRadians = DegreesToRadians(AngleInRadians)
03283 if ( isinstance( theObject, Mesh )):
03284 theObject = theObject.GetMesh()
03285 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03286 Axis = self.smeshpyD.GetAxisStruct(Axis)
03287 Axis,AxisParameters = ParseAxisStruct(Axis)
03288 if TotalAngle and NbOfSteps:
03289 AngleInRadians /= NbOfSteps
03290 NbOfSteps,Tolerance,Parameters = geompyDC.ParseParameters(NbOfSteps,Tolerance)
03291 Parameters = AxisParameters + var_separator + AngleParameters + var_separator + Parameters
03292 self.mesh.SetParameters(Parameters)
03293 if MakeGroups:
03294 return self.editor.RotationSweepObject2DMakeGroups(theObject, Axis, AngleInRadians,
03295 NbOfSteps, Tolerance)
03296 self.editor.RotationSweepObject2D(theObject, Axis, AngleInRadians, NbOfSteps, Tolerance)
03297 return []
03298
03299
03300
03301
03302
03303
03304
03305
03306 def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps, MakeGroups=False):
03307 if IDsOfElements == []:
03308 IDsOfElements = self.GetElementsId()
03309 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03310 StepVector = self.smeshpyD.GetDirStruct(StepVector)
03311 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03312 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03313 Parameters = StepVectorParameters + var_separator + Parameters
03314 self.mesh.SetParameters(Parameters)
03315 if MakeGroups:
03316 return self.editor.ExtrusionSweepMakeGroups(IDsOfElements, StepVector, NbOfSteps)
03317 self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
03318 return []
03319
03320
03321
03322
03323
03324
03325
03326
03327
03328
03329
03330 def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps,
03331 ExtrFlags, SewTolerance, MakeGroups=False):
03332 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03333 StepVector = self.smeshpyD.GetDirStruct(StepVector)
03334 if MakeGroups:
03335 return self.editor.AdvancedExtrusionMakeGroups(IDsOfElements, StepVector, NbOfSteps,
03336 ExtrFlags, SewTolerance)
03337 self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps,
03338 ExtrFlags, SewTolerance)
03339 return []
03340
03341
03342
03343
03344
03345
03346
03347
03348
03349 def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03350 if ( isinstance( theObject, Mesh )):
03351 theObject = theObject.GetMesh()
03352 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03353 StepVector = self.smeshpyD.GetDirStruct(StepVector)
03354 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03355 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03356 Parameters = StepVectorParameters + var_separator + Parameters
03357 self.mesh.SetParameters(Parameters)
03358 if MakeGroups:
03359 return self.editor.ExtrusionSweepObjectMakeGroups(theObject, StepVector, NbOfSteps)
03360 self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
03361 return []
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371 def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03372 if ( isinstance( theObject, Mesh )):
03373 theObject = theObject.GetMesh()
03374 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03375 StepVector = self.smeshpyD.GetDirStruct(StepVector)
03376 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03377 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03378 Parameters = StepVectorParameters + var_separator + Parameters
03379 self.mesh.SetParameters(Parameters)
03380 if MakeGroups:
03381 return self.editor.ExtrusionSweepObject1DMakeGroups(theObject, StepVector, NbOfSteps)
03382 self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
03383 return []
03384
03385
03386
03387
03388
03389
03390
03391
03392
03393 def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps, MakeGroups=False):
03394 if ( isinstance( theObject, Mesh )):
03395 theObject = theObject.GetMesh()
03396 if ( isinstance( StepVector, geompyDC.GEOM._objref_GEOM_Object)):
03397 StepVector = self.smeshpyD.GetDirStruct(StepVector)
03398 StepVector,StepVectorParameters = ParseDirStruct(StepVector)
03399 NbOfSteps,Parameters = geompyDC.ParseParameters(NbOfSteps)
03400 Parameters = StepVectorParameters + var_separator + Parameters
03401 self.mesh.SetParameters(Parameters)
03402 if MakeGroups:
03403 return self.editor.ExtrusionSweepObject2DMakeGroups(theObject, StepVector, NbOfSteps)
03404 self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
03405 return []
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427 def ExtrusionAlongPathX(self, Base, Path, NodeStart,
03428 HasAngles, Angles, LinearVariation,
03429 HasRefPoint, RefPoint, MakeGroups, ElemType):
03430 Angles,AnglesParameters = ParseAngles(Angles)
03431 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03432 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03433 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03434 pass
03435 Parameters = AnglesParameters + var_separator + RefPointParameters
03436 self.mesh.SetParameters(Parameters)
03437
03438 if (isinstance(Path, Mesh)): Path = Path.GetMesh()
03439
03440 if isinstance(Base, list):
03441 IDsOfElements = []
03442 if Base == []: IDsOfElements = self.GetElementsId()
03443 else: IDsOfElements = Base
03444 return self.editor.ExtrusionAlongPathX(IDsOfElements, Path, NodeStart,
03445 HasAngles, Angles, LinearVariation,
03446 HasRefPoint, RefPoint, MakeGroups, ElemType)
03447 else:
03448 if isinstance(Base, Mesh): Base = Base.GetMesh()
03449 if isinstance(Base, SMESH._objref_SMESH_Mesh) or isinstance(Base, SMESH._objref_SMESH_Group) or isinstance(Base, SMESH._objref_SMESH_subMesh):
03450 return self.editor.ExtrusionAlongPathObjX(Base, Path, NodeStart,
03451 HasAngles, Angles, LinearVariation,
03452 HasRefPoint, RefPoint, MakeGroups, ElemType)
03453 else:
03454 raise RuntimeError, "Invalid Base for ExtrusionAlongPathX"
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475 def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
03476 HasAngles, Angles, HasRefPoint, RefPoint,
03477 MakeGroups=False, LinearVariation=False):
03478 Angles,AnglesParameters = ParseAngles(Angles)
03479 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03480 if IDsOfElements == []:
03481 IDsOfElements = self.GetElementsId()
03482 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03483 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03484 pass
03485 if ( isinstance( PathMesh, Mesh )):
03486 PathMesh = PathMesh.GetMesh()
03487 if HasAngles and Angles and LinearVariation:
03488 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03489 pass
03490 Parameters = AnglesParameters + var_separator + RefPointParameters
03491 self.mesh.SetParameters(Parameters)
03492 if MakeGroups:
03493 return self.editor.ExtrusionAlongPathMakeGroups(IDsOfElements, PathMesh,
03494 PathShape, NodeStart, HasAngles,
03495 Angles, HasRefPoint, RefPoint)
03496 return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape,
03497 NodeStart, HasAngles, Angles, HasRefPoint, RefPoint)
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518 def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
03519 HasAngles, Angles, HasRefPoint, RefPoint,
03520 MakeGroups=False, LinearVariation=False):
03521 Angles,AnglesParameters = ParseAngles(Angles)
03522 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03523 if ( isinstance( theObject, Mesh )):
03524 theObject = theObject.GetMesh()
03525 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03526 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03527 if ( isinstance( PathMesh, Mesh )):
03528 PathMesh = PathMesh.GetMesh()
03529 if HasAngles and Angles and LinearVariation:
03530 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03531 pass
03532 Parameters = AnglesParameters + var_separator + RefPointParameters
03533 self.mesh.SetParameters(Parameters)
03534 if MakeGroups:
03535 return self.editor.ExtrusionAlongPathObjectMakeGroups(theObject, PathMesh,
03536 PathShape, NodeStart, HasAngles,
03537 Angles, HasRefPoint, RefPoint)
03538 return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape,
03539 NodeStart, HasAngles, Angles, HasRefPoint,
03540 RefPoint)
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561 def ExtrusionAlongPathObject1D(self, theObject, PathMesh, PathShape, NodeStart,
03562 HasAngles, Angles, HasRefPoint, RefPoint,
03563 MakeGroups=False, LinearVariation=False):
03564 Angles,AnglesParameters = ParseAngles(Angles)
03565 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03566 if ( isinstance( theObject, Mesh )):
03567 theObject = theObject.GetMesh()
03568 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03569 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03570 if ( isinstance( PathMesh, Mesh )):
03571 PathMesh = PathMesh.GetMesh()
03572 if HasAngles and Angles and LinearVariation:
03573 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03574 pass
03575 Parameters = AnglesParameters + var_separator + RefPointParameters
03576 self.mesh.SetParameters(Parameters)
03577 if MakeGroups:
03578 return self.editor.ExtrusionAlongPathObject1DMakeGroups(theObject, PathMesh,
03579 PathShape, NodeStart, HasAngles,
03580 Angles, HasRefPoint, RefPoint)
03581 return self.editor.ExtrusionAlongPathObject1D(theObject, PathMesh, PathShape,
03582 NodeStart, HasAngles, Angles, HasRefPoint,
03583 RefPoint)
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601
03602
03603
03604 def ExtrusionAlongPathObject2D(self, theObject, PathMesh, PathShape, NodeStart,
03605 HasAngles, Angles, HasRefPoint, RefPoint,
03606 MakeGroups=False, LinearVariation=False):
03607 Angles,AnglesParameters = ParseAngles(Angles)
03608 RefPoint,RefPointParameters = ParsePointStruct(RefPoint)
03609 if ( isinstance( theObject, Mesh )):
03610 theObject = theObject.GetMesh()
03611 if ( isinstance( RefPoint, geompyDC.GEOM._objref_GEOM_Object)):
03612 RefPoint = self.smeshpyD.GetPointStruct(RefPoint)
03613 if ( isinstance( PathMesh, Mesh )):
03614 PathMesh = PathMesh.GetMesh()
03615 if HasAngles and Angles and LinearVariation:
03616 Angles = self.editor.LinearAnglesVariation( PathMesh, PathShape, Angles )
03617 pass
03618 Parameters = AnglesParameters + var_separator + RefPointParameters
03619 self.mesh.SetParameters(Parameters)
03620 if MakeGroups:
03621 return self.editor.ExtrusionAlongPathObject2DMakeGroups(theObject, PathMesh,
03622 PathShape, NodeStart, HasAngles,
03623 Angles, HasRefPoint, RefPoint)
03624 return self.editor.ExtrusionAlongPathObject2D(theObject, PathMesh, PathShape,
03625 NodeStart, HasAngles, Angles, HasRefPoint,
03626 RefPoint)
03627
03628
03629
03630
03631
03632
03633
03634
03635
03636
03637 def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03638 if IDsOfElements == []:
03639 IDsOfElements = self.GetElementsId()
03640 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03641 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03642 Mirror,Parameters = ParseAxisStruct(Mirror)
03643 self.mesh.SetParameters(Parameters)
03644 if Copy and MakeGroups:
03645 return self.editor.MirrorMakeGroups(IDsOfElements, Mirror, theMirrorType)
03646 self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
03647 return []
03648
03649
03650
03651
03652
03653
03654
03655
03656
03657
03658 def MirrorMakeMesh(self, IDsOfElements, Mirror, theMirrorType, MakeGroups=0, NewMeshName=""):
03659 if IDsOfElements == []:
03660 IDsOfElements = self.GetElementsId()
03661 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03662 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03663 Mirror,Parameters = ParseAxisStruct(Mirror)
03664 mesh = self.editor.MirrorMakeMesh(IDsOfElements, Mirror, theMirrorType,
03665 MakeGroups, NewMeshName)
03666 mesh.SetParameters(Parameters)
03667 return Mesh(self.smeshpyD,self.geompyD,mesh)
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677
03678 def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0, MakeGroups=False):
03679 if ( isinstance( theObject, Mesh )):
03680 theObject = theObject.GetMesh()
03681 if ( isinstance( Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03682 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03683 Mirror,Parameters = ParseAxisStruct(Mirror)
03684 self.mesh.SetParameters(Parameters)
03685 if Copy and MakeGroups:
03686 return self.editor.MirrorObjectMakeGroups(theObject, Mirror, theMirrorType)
03687 self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
03688 return []
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699 def MirrorObjectMakeMesh (self, theObject, Mirror, theMirrorType,MakeGroups=0, NewMeshName=""):
03700 if ( isinstance( theObject, Mesh )):
03701 theObject = theObject.GetMesh()
03702 if (isinstance(Mirror, geompyDC.GEOM._objref_GEOM_Object)):
03703 Mirror = self.smeshpyD.GetAxisStruct(Mirror)
03704 Mirror,Parameters = ParseAxisStruct(Mirror)
03705 mesh = self.editor.MirrorObjectMakeMesh(theObject, Mirror, theMirrorType,
03706 MakeGroups, NewMeshName)
03707 mesh.SetParameters(Parameters)
03708 return Mesh( self.smeshpyD,self.geompyD,mesh )
03709
03710
03711
03712
03713
03714
03715
03716
03717 def Translate(self, IDsOfElements, Vector, Copy, MakeGroups=False):
03718 if IDsOfElements == []:
03719 IDsOfElements = self.GetElementsId()
03720 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03721 Vector = self.smeshpyD.GetDirStruct(Vector)
03722 Vector,Parameters = ParseDirStruct(Vector)
03723 self.mesh.SetParameters(Parameters)
03724 if Copy and MakeGroups:
03725 return self.editor.TranslateMakeGroups(IDsOfElements, Vector)
03726 self.editor.Translate(IDsOfElements, Vector, Copy)
03727 return []
03728
03729
03730
03731
03732
03733
03734
03735
03736 def TranslateMakeMesh(self, IDsOfElements, Vector, MakeGroups=False, NewMeshName=""):
03737 if IDsOfElements == []:
03738 IDsOfElements = self.GetElementsId()
03739 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03740 Vector = self.smeshpyD.GetDirStruct(Vector)
03741 Vector,Parameters = ParseDirStruct(Vector)
03742 mesh = self.editor.TranslateMakeMesh(IDsOfElements, Vector, MakeGroups, NewMeshName)
03743 mesh.SetParameters(Parameters)
03744 return Mesh ( self.smeshpyD, self.geompyD, mesh )
03745
03746
03747
03748
03749
03750
03751
03752
03753 def TranslateObject(self, theObject, Vector, Copy, MakeGroups=False):
03754 if ( isinstance( theObject, Mesh )):
03755 theObject = theObject.GetMesh()
03756 if ( isinstance( Vector, geompyDC.GEOM._objref_GEOM_Object)):
03757 Vector = self.smeshpyD.GetDirStruct(Vector)
03758 Vector,Parameters = ParseDirStruct(Vector)
03759 self.mesh.SetParameters(Parameters)
03760 if Copy and MakeGroups:
03761 return self.editor.TranslateObjectMakeGroups(theObject, Vector)
03762 self.editor.TranslateObject(theObject, Vector, Copy)
03763 return []
03764
03765
03766
03767
03768
03769
03770
03771
03772 def TranslateObjectMakeMesh(self, theObject, Vector, MakeGroups=False, NewMeshName=""):
03773 if (isinstance(theObject, Mesh)):
03774 theObject = theObject.GetMesh()
03775 if (isinstance(Vector, geompyDC.GEOM._objref_GEOM_Object)):
03776 Vector = self.smeshpyD.GetDirStruct(Vector)
03777 Vector,Parameters = ParseDirStruct(Vector)
03778 mesh = self.editor.TranslateObjectMakeMesh(theObject, Vector, MakeGroups, NewMeshName)
03779 mesh.SetParameters(Parameters)
03780 return Mesh( self.smeshpyD, self.geompyD, mesh )
03781
03782
03783
03784
03785
03786
03787
03788
03789
03790
03791
03792
03793 def Scale(self, theObject, thePoint, theScaleFact, Copy, MakeGroups=False):
03794 if ( isinstance( theObject, Mesh )):
03795 theObject = theObject.GetMesh()
03796 if ( isinstance( theObject, list )):
03797 theObject = self.GetIDSource(theObject, SMESH.ALL)
03798
03799 thePoint, Parameters = ParsePointStruct(thePoint)
03800 self.mesh.SetParameters(Parameters)
03801
03802 if Copy and MakeGroups:
03803 return self.editor.ScaleMakeGroups(theObject, thePoint, theScaleFact)
03804 self.editor.Scale(theObject, thePoint, theScaleFact, Copy)
03805 return []
03806
03807
03808
03809
03810
03811
03812
03813
03814 def ScaleMakeMesh(self, theObject, thePoint, theScaleFact, MakeGroups=False, NewMeshName=""):
03815 if (isinstance(theObject, Mesh)):
03816 theObject = theObject.GetMesh()
03817 if ( isinstance( theObject, list )):
03818 theObject = self.GetIDSource(theObject,SMESH.ALL)
03819
03820 mesh = self.editor.ScaleMakeMesh(theObject, thePoint, theScaleFact,
03821 MakeGroups, NewMeshName)
03822
03823 return Mesh( self.smeshpyD, self.geompyD, mesh )
03824
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835 def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy, MakeGroups=False):
03836 flag = False
03837 if isinstance(AngleInRadians,str):
03838 flag = True
03839 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03840 if flag:
03841 AngleInRadians = DegreesToRadians(AngleInRadians)
03842 if IDsOfElements == []:
03843 IDsOfElements = self.GetElementsId()
03844 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03845 Axis = self.smeshpyD.GetAxisStruct(Axis)
03846 Axis,AxisParameters = ParseAxisStruct(Axis)
03847 Parameters = AxisParameters + var_separator + Parameters
03848 self.mesh.SetParameters(Parameters)
03849 if Copy and MakeGroups:
03850 return self.editor.RotateMakeGroups(IDsOfElements, Axis, AngleInRadians)
03851 self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
03852 return []
03853
03854
03855
03856
03857
03858
03859
03860
03861
03862 def RotateMakeMesh (self, IDsOfElements, Axis, AngleInRadians, MakeGroups=0, NewMeshName=""):
03863 flag = False
03864 if isinstance(AngleInRadians,str):
03865 flag = True
03866 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03867 if flag:
03868 AngleInRadians = DegreesToRadians(AngleInRadians)
03869 if IDsOfElements == []:
03870 IDsOfElements = self.GetElementsId()
03871 if ( isinstance( Axis, geompyDC.GEOM._objref_GEOM_Object)):
03872 Axis = self.smeshpyD.GetAxisStruct(Axis)
03873 Axis,AxisParameters = ParseAxisStruct(Axis)
03874 Parameters = AxisParameters + var_separator + Parameters
03875 mesh = self.editor.RotateMakeMesh(IDsOfElements, Axis, AngleInRadians,
03876 MakeGroups, NewMeshName)
03877 mesh.SetParameters(Parameters)
03878 return Mesh( self.smeshpyD, self.geompyD, mesh )
03879
03880
03881
03882
03883
03884
03885
03886
03887
03888 def RotateObject (self, theObject, Axis, AngleInRadians, Copy, MakeGroups=False):
03889 flag = False
03890 if isinstance(AngleInRadians,str):
03891 flag = True
03892 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03893 if flag:
03894 AngleInRadians = DegreesToRadians(AngleInRadians)
03895 if (isinstance(theObject, Mesh)):
03896 theObject = theObject.GetMesh()
03897 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03898 Axis = self.smeshpyD.GetAxisStruct(Axis)
03899 Axis,AxisParameters = ParseAxisStruct(Axis)
03900 Parameters = AxisParameters + ":" + Parameters
03901 self.mesh.SetParameters(Parameters)
03902 if Copy and MakeGroups:
03903 return self.editor.RotateObjectMakeGroups(theObject, Axis, AngleInRadians)
03904 self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
03905 return []
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915 def RotateObjectMakeMesh(self, theObject, Axis, AngleInRadians, MakeGroups=0,NewMeshName=""):
03916 flag = False
03917 if isinstance(AngleInRadians,str):
03918 flag = True
03919 AngleInRadians,Parameters = geompyDC.ParseParameters(AngleInRadians)
03920 if flag:
03921 AngleInRadians = DegreesToRadians(AngleInRadians)
03922 if (isinstance( theObject, Mesh )):
03923 theObject = theObject.GetMesh()
03924 if (isinstance(Axis, geompyDC.GEOM._objref_GEOM_Object)):
03925 Axis = self.smeshpyD.GetAxisStruct(Axis)
03926 Axis,AxisParameters = ParseAxisStruct(Axis)
03927 Parameters = AxisParameters + ":" + Parameters
03928 mesh = self.editor.RotateObjectMakeMesh(theObject, Axis, AngleInRadians,
03929 MakeGroups, NewMeshName)
03930 mesh.SetParameters(Parameters)
03931 return Mesh( self.smeshpyD, self.geompyD, mesh )
03932
03933
03934
03935
03936
03937 def FindCoincidentNodes (self, Tolerance):
03938 return self.editor.FindCoincidentNodes(Tolerance)
03939
03940
03941
03942
03943
03944
03945
03946 def FindCoincidentNodesOnPart (self, SubMeshOrGroup, Tolerance, exceptNodes=[]):
03947 if (isinstance( SubMeshOrGroup, Mesh )):
03948 SubMeshOrGroup = SubMeshOrGroup.GetMesh()
03949 if not isinstance( exceptNodes, list):
03950 exceptNodes = [ exceptNodes ]
03951 if exceptNodes and isinstance( exceptNodes[0], int):
03952 exceptNodes = [ self.GetIDSource( exceptNodes, SMESH.NODE)]
03953 return self.editor.FindCoincidentNodesOnPartBut(SubMeshOrGroup, Tolerance,exceptNodes)
03954
03955
03956
03957
03958 def MergeNodes (self, GroupsOfNodes):
03959 self.editor.MergeNodes(GroupsOfNodes)
03960
03961
03962
03963
03964
03965 def FindEqualElements (self, MeshOrSubMeshOrGroup):
03966 if ( isinstance( MeshOrSubMeshOrGroup, Mesh )):
03967 MeshOrSubMeshOrGroup = MeshOrSubMeshOrGroup.GetMesh()
03968 return self.editor.FindEqualElements(MeshOrSubMeshOrGroup)
03969
03970
03971
03972
03973 def MergeElements(self, GroupsOfElementsID):
03974 self.editor.MergeElements(GroupsOfElementsID)
03975
03976
03977
03978 def MergeEqualElements(self):
03979 self.editor.MergeEqualElements()
03980
03981
03982
03983
03984 def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03985 FirstNodeID2, SecondNodeID2, LastNodeID2,
03986 CreatePolygons, CreatePolyedrs):
03987 return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03988 FirstNodeID2, SecondNodeID2, LastNodeID2,
03989 CreatePolygons, CreatePolyedrs)
03990
03991
03992
03993
03994 def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
03995 FirstNodeID2, SecondNodeID2):
03996 return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
03997 FirstNodeID2, SecondNodeID2)
03998
03999
04000
04001
04002 def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
04003 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
04004 return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
04005 FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015 def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
04016 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
04017 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
04018 return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
04019 NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
04020 NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
04021
04022
04023
04024
04025
04026
04027 def ChangeElemNodes(self, ide, newIDs):
04028 return self.editor.ChangeElemNodes(ide, newIDs)
04029
04030
04031
04032
04033
04034
04035 def GetLastCreatedNodes(self):
04036 return self.editor.GetLastCreatedNodes()
04037
04038
04039
04040
04041
04042
04043 def GetLastCreatedElems(self):
04044 return self.editor.GetLastCreatedElems()
04045
04046
04047
04048
04049
04050
04051
04052
04053 def DoubleNodes(self, theNodes, theModifiedElems):
04054 return self.editor.DoubleNodes(theNodes, theModifiedElems)
04055
04056
04057
04058
04059
04060
04061
04062 def DoubleNode(self, theNodeId, theModifiedElems):
04063 return self.editor.DoubleNode(theNodeId, theModifiedElems)
04064
04065
04066
04067
04068
04069
04070
04071
04072
04073 def DoubleNodeGroup(self, theNodes, theModifiedElems, theMakeGroup=False):
04074 if theMakeGroup:
04075 return self.editor.DoubleNodeGroupNew(theNodes, theModifiedElems)
04076 return self.editor.DoubleNodeGroup(theNodes, theModifiedElems)
04077
04078
04079
04080
04081
04082
04083
04084 def DoubleNodeGroups(self, theNodes, theModifiedElems, theMakeGroup=False):
04085 if theMakeGroup:
04086 return self.editor.DoubleNodeGroupsNew(theNodes, theModifiedElems)
04087 return self.editor.DoubleNodeGroups(theNodes, theModifiedElems)
04088
04089
04090
04091
04092
04093
04094
04095
04096
04097 def DoubleNodeElem(self, theElems, theNodesNot, theAffectedElems):
04098 return self.editor.DoubleNodeElem(theElems, theNodesNot, theAffectedElems)
04099
04100
04101
04102
04103
04104
04105
04106
04107
04108
04109 def DoubleNodeElemInRegion(self, theElems, theNodesNot, theShape):
04110 return self.editor.DoubleNodeElemInRegion(theElems, theNodesNot, theShape)
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122 def DoubleNodeElemGroup(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
04123 if theMakeGroup:
04124 return self.editor.DoubleNodeElemGroupNew(theElems, theNodesNot, theAffectedElems)
04125 return self.editor.DoubleNodeElemGroup(theElems, theNodesNot, theAffectedElems)
04126
04127
04128
04129
04130
04131
04132
04133
04134
04135 def DoubleNodeElemGroupInRegion(self, theElems, theNodesNot, theShape):
04136 return self.editor.DoubleNodeElemGroupInRegion(theElems, theNodesNot, theShape)
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148 def DoubleNodeElemGroups(self, theElems, theNodesNot, theAffectedElems, theMakeGroup=False):
04149 if theMakeGroup:
04150 return self.editor.DoubleNodeElemGroupsNew(theElems, theNodesNot, theAffectedElems)
04151 return self.editor.DoubleNodeElemGroups(theElems, theNodesNot, theAffectedElems)
04152
04153
04154
04155
04156
04157
04158
04159
04160
04161
04162 def DoubleNodeElemGroupsInRegion(self, theElems, theNodesNot, theShape):
04163 return self.editor.DoubleNodeElemGroupsInRegion(theElems, theNodesNot, theShape)
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173 def DoubleNodesOnGroupBoundaries(self, theDomains, createJointElems ):
04174 return self.editor.DoubleNodesOnGroupBoundaries( theDomains, createJointElems )
04175
04176
04177
04178
04179
04180
04181
04182
04183 def CreateFlatElementsOnFacesGroups(self, theGroupsOfFaces ):
04184 return self.editor.CreateFlatElementsOnFacesGroups( theGroupsOfFaces )
04185
04186 def _valueFromFunctor(self, funcType, elemId):
04187 fn = self.smeshpyD.GetFunctor(funcType)
04188 fn.SetMesh(self.mesh)
04189 if fn.GetElementType() == self.GetElementType(elemId, True):
04190 val = fn.GetValue(elemId)
04191 else:
04192 val = 0
04193 return val
04194
04195
04196
04197
04198
04199 def GetLength(self, elemId):
04200 return self._valueFromFunctor(SMESH.FT_Length, elemId)
04201
04202
04203
04204
04205
04206 def GetArea(self, elemId):
04207 return self._valueFromFunctor(SMESH.FT_Area, elemId)
04208
04209
04210
04211
04212
04213 def GetVolume(self, elemId):
04214 return self._valueFromFunctor(SMESH.FT_Volume3D, elemId)
04215
04216
04217
04218
04219
04220 def GetMaxElementLength(self, elemId):
04221 if self.GetElementType(elemId, True) == SMESH.VOLUME:
04222 ftype = SMESH.FT_MaxElementLength3D
04223 else:
04224 ftype = SMESH.FT_MaxElementLength2D
04225 return self._valueFromFunctor(ftype, elemId)
04226
04227
04228
04229
04230
04231 def GetAspectRatio(self, elemId):
04232 if self.GetElementType(elemId, True) == SMESH.VOLUME:
04233 ftype = SMESH.FT_AspectRatio3D
04234 else:
04235 ftype = SMESH.FT_AspectRatio
04236 return self._valueFromFunctor(ftype, elemId)
04237
04238
04239
04240
04241
04242 def GetWarping(self, elemId):
04243 return self._valueFromFunctor(SMESH.FT_Warping, elemId)
04244
04245
04246
04247
04248
04249 def GetMinimumAngle(self, elemId):
04250 return self._valueFromFunctor(SMESH.FT_MinimumAngle, elemId)
04251
04252
04253
04254
04255
04256 def GetTaper(self, elemId):
04257 return self._valueFromFunctor(SMESH.FT_Taper, elemId)
04258
04259
04260
04261
04262
04263 def GetSkew(self, elemId):
04264 return self._valueFromFunctor(SMESH.FT_Skew, elemId)
04265
04266
04267
04268
04269
04270 class Mesh_Algorithm:
04271
04272
04273
04274
04275
04276 def __init__(self):
04277 self.mesh = None
04278 self.geom = None
04279 self.subm = None
04280 self.algo = None
04281
04282
04283
04284
04285 def FindHypothesis (self, hypname, args, CompareMethod, smeshpyD):
04286 study = smeshpyD.GetCurrentStudy()
04287
04288 scomp = study.FindComponent(smeshpyD.ComponentDataType())
04289 if scomp is not None:
04290 res,hypRoot = scomp.FindSubObject(SMESH.Tag_HypothesisRoot)
04291
04292 if res and hypRoot is not None:
04293 iter = study.NewChildIterator(hypRoot)
04294
04295 while iter.More():
04296 hypo_so_i = iter.Value()
04297 attr = hypo_so_i.FindAttribute("AttributeIOR")[1]
04298 if attr is not None:
04299 anIOR = attr.Value()
04300 hypo_o_i = salome.orb.string_to_object(anIOR)
04301 if hypo_o_i is not None:
04302
04303 hypo_i = hypo_o_i._narrow(SMESH.SMESH_Hypothesis)
04304 if hypo_i is not None:
04305
04306 if smeshpyD.GetObjectId(hypo_i) > 0:
04307
04308 if hypo_i.GetName() == hypname:
04309
04310 if CompareMethod(hypo_i, args):
04311
04312 return hypo_i
04313 pass
04314 pass
04315 pass
04316 pass
04317 pass
04318 iter.Next()
04319 pass
04320 pass
04321 pass
04322 return None
04323
04324
04325
04326
04327 def FindAlgorithm (self, algoname, smeshpyD):
04328 study = smeshpyD.GetCurrentStudy()
04329
04330 scomp = study.FindComponent(smeshpyD.ComponentDataType())
04331 if scomp is not None:
04332 res,hypRoot = scomp.FindSubObject(SMESH.Tag_AlgorithmsRoot)
04333
04334 if res and hypRoot is not None:
04335 iter = study.NewChildIterator(hypRoot)
04336
04337 while iter.More():
04338 algo_so_i = iter.Value()
04339 attr = algo_so_i.FindAttribute("AttributeIOR")[1]
04340 if attr is not None:
04341 anIOR = attr.Value()
04342 algo_o_i = salome.orb.string_to_object(anIOR)
04343 if algo_o_i is not None:
04344
04345 algo_i = algo_o_i._narrow(SMESH.SMESH_Algo)
04346 if algo_i is not None:
04347
04348 if smeshpyD.GetObjectId(algo_i) > 0:
04349
04350 if algo_i.GetName() == algoname:
04351
04352 return algo_i
04353 pass
04354 pass
04355 pass
04356 pass
04357 iter.Next()
04358 pass
04359 pass
04360 pass
04361 return None
04362
04363
04364
04365 def GetSubMesh(self):
04366 return self.subm
04367
04368
04369 def GetAlgorithm(self):
04370 return self.algo
04371
04372
04373 def GetCompatibleHypothesis(self):
04374 mylist = []
04375 if self.algo:
04376 mylist = self.algo.GetCompatibleHypothesis()
04377 return mylist
04378
04379
04380 def GetName(self):
04381 GetName(self.algo)
04382
04383
04384 def SetName(self, name):
04385 self.mesh.smeshpyD.SetName(self.algo, name)
04386
04387
04388 def GetId(self):
04389 return self.algo.GetId()
04390
04391
04392 def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
04393 if geom is None:
04394 raise RuntimeError, "Attemp to create " + hypo + " algoritm on None shape"
04395 algo = self.FindAlgorithm(hypo, mesh.smeshpyD)
04396 if algo is None:
04397 algo = mesh.smeshpyD.CreateHypothesis(hypo, so)
04398 pass
04399 self.Assign(algo, mesh, geom)
04400 return self.algo
04401
04402
04403 def Assign(self, algo, mesh, geom):
04404 if geom is None:
04405 raise RuntimeError, "Attemp to create " + algo + " algoritm on None shape"
04406 self.mesh = mesh
04407 name = ""
04408 if not geom:
04409 self.geom = mesh.geom
04410 else:
04411 self.geom = geom
04412 AssureGeomPublished( mesh, geom )
04413 try:
04414 name = GetName(geom)
04415 pass
04416 except:
04417 pass
04418 self.subm = mesh.mesh.GetSubMesh(geom, algo.GetName())
04419 self.algo = algo
04420 status = mesh.mesh.AddHypothesis(self.geom, self.algo)
04421 TreatHypoStatus( status, algo.GetName(), name, True )
04422 return
04423
04424 def CompareHyp (self, hyp, args):
04425 print "CompareHyp is not implemented for ", self.__class__.__name__, ":", hyp.GetName()
04426 return False
04427
04428 def CompareEqualHyp (self, hyp, args):
04429 return True
04430
04431
04432 def Hypothesis (self, hyp, args=[], so="libStdMeshersEngine.so",
04433 UseExisting=0, CompareMethod=""):
04434 hypo = None
04435 if UseExisting:
04436 if CompareMethod == "": CompareMethod = self.CompareHyp
04437 hypo = self.FindHypothesis(hyp, args, CompareMethod, self.mesh.smeshpyD)
04438 pass
04439 if hypo is None:
04440 hypo = self.mesh.smeshpyD.CreateHypothesis(hyp, so)
04441 a = ""
04442 s = "="
04443 i = 0
04444 n = len(args)
04445 while i<n:
04446 a = a + s + str(args[i])
04447 s = ","
04448 i = i + 1
04449 pass
04450 self.mesh.smeshpyD.SetName(hypo, hyp + a)
04451 pass
04452 geomName=""
04453 if self.geom:
04454 geomName = GetName(self.geom)
04455 status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
04456 TreatHypoStatus( status, GetName(hypo), geomName, 0 )
04457 return hypo
04458
04459
04460 def MainShapeEntry(self):
04461 entry = ""
04462 if not self.mesh or not self.mesh.GetMesh(): return entry
04463 if not self.mesh.GetMesh().HasShapeToMesh(): return entry
04464 study = self.mesh.smeshpyD.GetCurrentStudy()
04465 ior = salome.orb.object_to_string( self.mesh.GetShape() )
04466 sobj = study.FindObjectIOR(ior)
04467 if sobj: entry = sobj.GetID()
04468 if not entry: return ""
04469 return entry
04470
04471
04472
04473
04474
04475
04476
04477
04478
04479 def ViscousLayers(self, thickness, numberOfLayers, stretchFactor, ignoreFaces=[]):
04480 if not isinstance(self.algo, SMESH._objref_SMESH_3D_Algo):
04481 raise TypeError, "ViscousLayers are supported by 3D algorithms only"
04482 if not "ViscousLayers" in self.GetCompatibleHypothesis():
04483 raise TypeError, "ViscousLayers are not supported by %s"%self.algo.GetName()
04484 if ignoreFaces and isinstance( ignoreFaces[0], geompyDC.GEOM._objref_GEOM_Object ):
04485 ignoreFaces = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, f) for f in ignoreFaces ]
04486 hyp = self.Hypothesis("ViscousLayers",
04487 [thickness, numberOfLayers, stretchFactor, ignoreFaces])
04488 hyp.SetTotalThickness(thickness)
04489 hyp.SetNumberLayers(numberOfLayers)
04490 hyp.SetStretchFactor(stretchFactor)
04491 hyp.SetIgnoreFaces(ignoreFaces)
04492 return hyp
04493
04494
04495
04496
04497
04498
04499
04500
04501 class Mesh_Segment(Mesh_Algorithm):
04502
04503
04504 def __init__(self, mesh, geom=0):
04505 Mesh_Algorithm.__init__(self)
04506 self.Create(mesh, geom, "Regular_1D")
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523 def LocalLength(self, l, UseExisting=0, p=1e-07):
04524 hyp = self.Hypothesis("LocalLength", [l,p], UseExisting=UseExisting,
04525 CompareMethod=self.CompareLocalLength)
04526 hyp.SetLength(l)
04527 hyp.SetPrecision(p)
04528 return hyp
04529
04530
04531
04532 def CompareLocalLength(self, hyp, args):
04533 if IsEqual(hyp.GetLength(), args[0]):
04534 return IsEqual(hyp.GetPrecision(), args[1])
04535 return False
04536
04537
04538
04539
04540
04541
04542
04543
04544 def MaxSize(self, length=0.0, UseExisting=0):
04545 hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting)
04546 if length > 0.0:
04547
04548 hyp.SetLength(length)
04549 if not UseExisting:
04550
04551 gen = self.mesh.smeshpyD
04552 initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so",
04553 self.mesh.GetMesh(), self.mesh.GetShape(),
04554 False)
04555 preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength)
04556 if preHyp:
04557 hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() )
04558 pass
04559 pass
04560 hyp.SetUsePreestimatedLength( length == 0.0 )
04561 return hyp
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571 def NumberOfSegments(self, n, s=[], reversedEdges=[], UseExisting=0):
04572 if not isinstance(reversedEdges,list):
04573 reversedEdges, UseExisting = [], reversedEdges
04574 entry = self.MainShapeEntry()
04575 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04576 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04577 if s == []:
04578 hyp = self.Hypothesis("NumberOfSegments", [n, reversedEdges, entry],
04579 UseExisting=UseExisting,
04580 CompareMethod=self.CompareNumberOfSegments)
04581 else:
04582 hyp = self.Hypothesis("NumberOfSegments", [n,s, reversedEdges, entry],
04583 UseExisting=UseExisting,
04584 CompareMethod=self.CompareNumberOfSegments)
04585 hyp.SetDistrType( 1 )
04586 hyp.SetScaleFactor(s)
04587 hyp.SetNumberOfSegments(n)
04588 hyp.SetReversedEdges( reversedEdges )
04589 hyp.SetObjectEntry( entry )
04590 return hyp
04591
04592
04593
04594 def CompareNumberOfSegments(self, hyp, args):
04595 if hyp.GetNumberOfSegments() == args[0]:
04596 if len(args) == 3:
04597 if hyp.GetReversedEdges() == args[1]:
04598 if not args[1] or hyp.GetObjectEntry() == args[2]:
04599 return True
04600 else:
04601 if hyp.GetReversedEdges() == args[2]:
04602 if not args[2] or hyp.GetObjectEntry() == args[3]:
04603 if hyp.GetDistrType() == 1:
04604 if IsEqual(hyp.GetScaleFactor(), args[1]):
04605 return True
04606 return False
04607
04608
04609
04610
04611
04612
04613
04614
04615
04616 def Arithmetic1D(self, start, end, reversedEdges=[], UseExisting=0):
04617 if not isinstance(reversedEdges,list):
04618 reversedEdges, UseExisting = [], reversedEdges
04619 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04620 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04621 entry = self.MainShapeEntry()
04622 hyp = self.Hypothesis("Arithmetic1D", [start, end, reversedEdges, entry],
04623 UseExisting=UseExisting,
04624 CompareMethod=self.CompareArithmetic1D)
04625 hyp.SetStartLength(start)
04626 hyp.SetEndLength(end)
04627 hyp.SetReversedEdges( reversedEdges )
04628 hyp.SetObjectEntry( entry )
04629 return hyp
04630
04631
04632
04633 def CompareArithmetic1D(self, hyp, args):
04634 if IsEqual(hyp.GetLength(1), args[0]):
04635 if IsEqual(hyp.GetLength(0), args[1]):
04636 if hyp.GetReversedEdges() == args[2]:
04637 if not args[2] or hyp.GetObjectEntry() == args[3]:
04638 return True
04639 return False
04640
04641
04642
04643
04644
04645
04646
04647
04648
04649
04650
04651
04652
04653
04654 def FixedPoints1D(self, points, nbSegs=[1], reversedEdges=[], UseExisting=0):
04655 if not isinstance(reversedEdges,list):
04656 reversedEdges, UseExisting = [], reversedEdges
04657 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04658 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04659 entry = self.MainShapeEntry()
04660 hyp = self.Hypothesis("FixedPoints1D", [points, nbSegs, reversedEdges, entry],
04661 UseExisting=UseExisting,
04662 CompareMethod=self.CompareFixedPoints1D)
04663 hyp.SetPoints(points)
04664 hyp.SetNbSegments(nbSegs)
04665 hyp.SetReversedEdges(reversedEdges)
04666 hyp.SetObjectEntry(entry)
04667 return hyp
04668
04669
04670
04671
04672 def CompareFixedPoints1D(self, hyp, args):
04673 if hyp.GetPoints() == args[0]:
04674 if hyp.GetNbSegments() == args[1]:
04675 if hyp.GetReversedEdges() == args[2]:
04676 if not args[2] or hyp.GetObjectEntry() == args[3]:
04677 return True
04678 return False
04679
04680
04681
04682
04683
04684
04685
04686
04687
04688
04689
04690 def StartEndLength(self, start, end, reversedEdges=[], UseExisting=0):
04691 if not isinstance(reversedEdges,list):
04692 reversedEdges, UseExisting = [], reversedEdges
04693 if reversedEdges and isinstance(reversedEdges[0],geompyDC.GEOM._objref_GEOM_Object):
04694 reversedEdges = [ self.mesh.geompyD.GetSubShapeID(self.mesh.geom, e) for e in reversedEdges ]
04695 entry = self.MainShapeEntry()
04696 hyp = self.Hypothesis("StartEndLength", [start, end, reversedEdges, entry],
04697 UseExisting=UseExisting,
04698 CompareMethod=self.CompareStartEndLength)
04699 hyp.SetStartLength(start)
04700 hyp.SetEndLength(end)
04701 hyp.SetReversedEdges( reversedEdges )
04702 hyp.SetObjectEntry( entry )
04703 return hyp
04704
04705
04706 def CompareStartEndLength(self, hyp, args):
04707 if IsEqual(hyp.GetLength(1), args[0]):
04708 if IsEqual(hyp.GetLength(0), args[1]):
04709 if hyp.GetReversedEdges() == args[2]:
04710 if not args[2] or hyp.GetObjectEntry() == args[3]:
04711 return True
04712 return False
04713
04714
04715
04716
04717
04718
04719 def Deflection1D(self, d, UseExisting=0):
04720 hyp = self.Hypothesis("Deflection1D", [d], UseExisting=UseExisting,
04721 CompareMethod=self.CompareDeflection1D)
04722 hyp.SetDeflection(d)
04723 return hyp
04724
04725
04726 def CompareDeflection1D(self, hyp, args):
04727 return IsEqual(hyp.GetDeflection(), args[0])
04728
04729
04730
04731
04732 def Propagation(self):
04733 return self.Hypothesis("Propagation", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04734
04735
04736
04737
04738
04739
04740 def AutomaticLength(self, fineness=0, UseExisting=0):
04741 hyp = self.Hypothesis("AutomaticLength",[fineness],UseExisting=UseExisting,
04742 CompareMethod=self.CompareAutomaticLength)
04743 hyp.SetFineness( fineness )
04744 return hyp
04745
04746
04747 def CompareAutomaticLength(self, hyp, args):
04748 return IsEqual(hyp.GetFineness(), args[0])
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758 def LengthNearVertex(self, length, vertex=0, UseExisting=0):
04759 import types
04760 store_geom = self.geom
04761 if type(vertex) is types.IntType:
04762 if vertex == 0 or vertex == 1:
04763 vertex = self.mesh.geompyD.ExtractShapes(self.geom, geompyDC.ShapeType["VERTEX"],True)[vertex]
04764 self.geom = vertex
04765 pass
04766 pass
04767 else:
04768 self.geom = vertex
04769 pass
04770
04771 if self.geom is None:
04772 raise RuntimeError, "Attemp to create SegmentAroundVertex_0D algoritm on None shape"
04773 AssureGeomPublished( self.mesh, self.geom )
04774 name = GetName(self.geom)
04775
04776 algo = self.FindAlgorithm("SegmentAroundVertex_0D", self.mesh.smeshpyD)
04777 if algo is None:
04778 algo = self.mesh.smeshpyD.CreateHypothesis("SegmentAroundVertex_0D", "libStdMeshersEngine.so")
04779 pass
04780 status = self.mesh.mesh.AddHypothesis(self.geom, algo)
04781 TreatHypoStatus(status, "SegmentAroundVertex_0D", name, True)
04782
04783 hyp = self.Hypothesis("SegmentLengthAroundVertex", [length], UseExisting=UseExisting,
04784 CompareMethod=self.CompareLengthNearVertex)
04785 self.geom = store_geom
04786 hyp.SetLength( length )
04787 return hyp
04788
04789
04790
04791 def CompareLengthNearVertex(self, hyp, args):
04792 return IsEqual(hyp.GetLength(), args[0])
04793
04794
04795
04796
04797
04798
04799
04800
04801
04802 def QuadraticMesh(self):
04803 hyp = self.Hypothesis("QuadraticMesh", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04804 return hyp
04805
04806
04807
04808
04809
04810
04811
04812 class Mesh_CompositeSegment(Mesh_Segment):
04813
04814
04815 def __init__(self, mesh, geom=0):
04816 self.Create(mesh, geom, "CompositeSegment_1D")
04817
04818
04819
04820
04821
04822
04823
04824
04825 class Mesh_Segment_Python(Mesh_Segment):
04826
04827
04828 def __init__(self, mesh, geom=0):
04829 import Python1dPlugin
04830 self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
04831
04832
04833
04834
04835
04836
04837
04838 def PythonSplit1D(self, n, func, UseExisting=0):
04839 hyp = self.Hypothesis("PythonSplit1D", [n], "libPython1dEngine.so",
04840 UseExisting=UseExisting, CompareMethod=self.ComparePythonSplit1D)
04841 hyp.SetNumberOfSegments(n)
04842 hyp.SetPythonLog10RatioFunction(func)
04843 return hyp
04844
04845
04846 def ComparePythonSplit1D(self, hyp, args):
04847
04848
04849
04850 return False
04851
04852
04853
04854
04855
04856
04857
04858 class Mesh_Triangle(Mesh_Algorithm):
04859
04860
04861 algoType = 0
04862 params = 0
04863
04864 _angleMeshS = 8
04865 _gradation = 1.1
04866
04867
04868 def __init__(self, mesh, algoType, geom=0):
04869 Mesh_Algorithm.__init__(self)
04870
04871 self.algoType = algoType
04872 if algoType == MEFISTO:
04873 self.Create(mesh, geom, "MEFISTO_2D")
04874 pass
04875 elif algoType == BLSURF:
04876 CheckPlugin(BLSURF)
04877 self.Create(mesh, geom, "BLSURF", "libBLSURFEngine.so")
04878
04879 elif algoType == NETGEN:
04880 CheckPlugin(NETGEN)
04881 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
04882 pass
04883 elif algoType == NETGEN_2D:
04884 CheckPlugin(NETGEN)
04885 self.Create(mesh, geom, "NETGEN_2D_ONLY", "libNETGENEngine.so")
04886 pass
04887
04888
04889
04890
04891
04892
04893
04894
04895 def MaxElementArea(self, area, UseExisting=0):
04896 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
04897 hyp = self.Hypothesis("MaxElementArea", [area], UseExisting=UseExisting,
04898 CompareMethod=self.CompareMaxElementArea)
04899 elif self.algoType == NETGEN:
04900 hyp = self.Parameters(SIMPLE)
04901 hyp.SetMaxElementArea(area)
04902 return hyp
04903
04904
04905 def CompareMaxElementArea(self, hyp, args):
04906 return IsEqual(hyp.GetMaxElementArea(), args[0])
04907
04908
04909
04910
04911
04912
04913 def LengthFromEdges(self):
04914 if self.algoType == MEFISTO or self.algoType == NETGEN_2D:
04915 hyp = self.Hypothesis("LengthFromEdges", UseExisting=1, CompareMethod=self.CompareEqualHyp)
04916 return hyp
04917 elif self.algoType == NETGEN:
04918 hyp = self.Parameters(SIMPLE)
04919 hyp.LengthFromEdges()
04920 return hyp
04921
04922
04923
04924
04925 def SetPhysicalMesh(self, thePhysicalMesh=DefaultSize):
04926
04927 self.Parameters().SetPhysicalMesh(thePhysicalMesh)
04928
04929
04930
04931 def SetPhySize(self, theVal):
04932
04933 self.SetPhysicalMesh(1)
04934 self.Parameters().SetPhySize(theVal)
04935
04936
04937
04938 def SetPhyMin(self, theVal=-1):
04939
04940 self.Parameters().SetPhyMin(theVal)
04941
04942
04943
04944 def SetPhyMax(self, theVal=-1):
04945
04946 self.Parameters().SetPhyMax(theVal)
04947
04948
04949
04950
04951 def SetGeometricMesh(self, theGeometricMesh=0):
04952
04953 if self.Parameters().GetPhysicalMesh() == 0: theGeometricMesh = 1
04954 self.params.SetGeometricMesh(theGeometricMesh)
04955
04956
04957
04958 def SetAngleMeshS(self, theVal=_angleMeshS):
04959
04960 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
04961 self.params.SetAngleMeshS(theVal)
04962
04963
04964
04965 def SetAngleMeshC(self, theVal=_angleMeshS):
04966
04967 if self.Parameters().GetGeometricMesh() == 0: theVal = self._angleMeshS
04968 self.params.SetAngleMeshC(theVal)
04969
04970
04971
04972 def SetGeoMin(self, theVal=-1):
04973
04974 self.Parameters().SetGeoMin(theVal)
04975
04976
04977
04978 def SetGeoMax(self, theVal=-1):
04979
04980 self.Parameters().SetGeoMax(theVal)
04981
04982
04983
04984 def SetGradation(self, theVal=_gradation):
04985
04986 if self.Parameters().GetGeometricMesh() == 0: theVal = self._gradation
04987 self.params.SetGradation(theVal)
04988
04989
04990
04991
04992
04993
04994 def SetTopology(self, way):
04995
04996 self.Parameters().SetTopology(way)
04997
04998
04999
05000 def SetDecimesh(self, toIgnoreEdges=False):
05001
05002 self.Parameters().SetDecimesh(toIgnoreEdges)
05003
05004
05005
05006 def SetVerbosity(self, level):
05007
05008 self.Parameters().SetVerbosity(level)
05009
05010
05011
05012 def SetOptionValue(self, optionName, level):
05013
05014 self.Parameters().SetOptionValue(optionName,level)
05015
05016
05017
05018
05019
05020
05021
05022
05023
05024 def SetAttractorGeom(self, theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance):
05025 AssureGeomPublished( self.mesh, theFace )
05026 AssureGeomPublished( self.mesh, theAttractor )
05027
05028 self.Parameters().SetAttractorGeom(theFace, theAttractor, theStartSize, theEndSize, theInfluenceDistance, theConstantSizeDistance)
05029
05030
05031
05032
05033 def UnsetAttractorGeom(self, theFace):
05034 AssureGeomPublished( self.mesh, theFace )
05035
05036 self.Parameters().SetAttractorGeom(theFace)
05037
05038
05039
05040
05041 def SetQuadAllowed(self, toAllow=True):
05042 if self.algoType == NETGEN_2D:
05043 if not self.params:
05044
05045 hasSimpleHyps = False
05046 simpleHyps = ["QuadranglePreference","LengthFromEdges","MaxElementArea"]
05047 for hyp in self.mesh.GetHypothesisList( self.geom ):
05048 if hyp.GetName() in simpleHyps:
05049 hasSimpleHyps = True
05050 if hyp.GetName() == "QuadranglePreference":
05051 if not toAllow:
05052 self.mesh.RemoveHypothesis( self.geom, hyp )
05053 pass
05054 return
05055 pass
05056 pass
05057 if hasSimpleHyps:
05058 if toAllow:
05059 self.Hypothesis("QuadranglePreference", UseExisting=1, CompareMethod=self.CompareEqualHyp)
05060 pass
05061 return
05062 pass
05063 pass
05064 if self.Parameters():
05065 self.params.SetQuadAllowed(toAllow)
05066 return
05067
05068
05069
05070
05071 def Parameters(self, which=SOLE):
05072 if not self.params:
05073 if self.algoType == NETGEN:
05074 if which == SIMPLE:
05075 self.params = self.Hypothesis("NETGEN_SimpleParameters_2D", [],
05076 "libNETGENEngine.so", UseExisting=0)
05077 else:
05078 self.params = self.Hypothesis("NETGEN_Parameters_2D", [],
05079 "libNETGENEngine.so", UseExisting=0)
05080 elif self.algoType == MEFISTO:
05081 print "Mefisto algo support no multi-parameter hypothesis"
05082 elif self.algoType == NETGEN_2D:
05083 self.params = self.Hypothesis("NETGEN_Parameters_2D_ONLY", [],
05084 "libNETGENEngine.so", UseExisting=0)
05085 elif self.algoType == BLSURF:
05086 self.params = self.Hypothesis("BLSURF_Parameters", [],
05087 "libBLSURFEngine.so", UseExisting=0)
05088 else:
05089 print "Mesh_Triangle with algo type %s does not have such a parameter, check algo type"%self.algoType
05090 return self.params
05091
05092
05093
05094
05095
05096 def SetMaxSize(self, theSize):
05097 if self.Parameters():
05098 self.params.SetMaxSize(theSize)
05099
05100
05101
05102
05103
05104 def SetSecondOrder(self, theVal):
05105 if self.Parameters():
05106 self.params.SetSecondOrder(theVal)
05107
05108
05109
05110
05111
05112 def SetOptimize(self, theVal):
05113 if self.Parameters():
05114 self.params.SetOptimize(theVal)
05115
05116
05117
05118
05119
05120
05121
05122 def SetFineness(self, theFineness):
05123 if self.Parameters():
05124 self.params.SetFineness(theFineness)
05125
05126
05127
05128
05129
05130 def SetGrowthRate(self, theRate):
05131 if self.Parameters():
05132 self.params.SetGrowthRate(theRate)
05133
05134
05135
05136
05137
05138 def SetNbSegPerEdge(self, theVal):
05139 if self.Parameters():
05140 self.params.SetNbSegPerEdge(theVal)
05141
05142
05143
05144
05145
05146 def SetNbSegPerRadius(self, theVal):
05147 if self.Parameters():
05148 self.params.SetNbSegPerRadius(theVal)
05149
05150
05151
05152
05153
05154 def SetNumberOfSegments(self, theVal):
05155 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
05156
05157
05158
05159
05160
05161 def SetLocalLength(self, theVal):
05162 self.Parameters(SIMPLE).SetLocalLength(theVal)
05163
05164 pass
05165
05166
05167
05168
05169
05170
05171
05172
05173 class Mesh_Quadrangle(Mesh_Algorithm):
05174
05175 params=0
05176
05177
05178 def __init__(self, mesh, geom=0):
05179 Mesh_Algorithm.__init__(self)
05180 self.Create(mesh, geom, "Quadrangle_2D")
05181 return
05182
05183
05184
05185
05186
05187
05188
05189
05190
05191
05192
05193
05194
05195
05196
05197
05198
05199
05200
05201
05202
05203
05204
05205
05206
05207 def QuadrangleParameters(self, quadType=StdMeshers.QUAD_STANDARD, triangleVertex=0, UseExisting=0):
05208 vertexID = triangleVertex
05209 if isinstance( triangleVertex, geompyDC.GEOM._objref_GEOM_Object ):
05210 vertexID = self.mesh.geompyD.GetSubShapeID( self.mesh.geom, triangleVertex )
05211 if not self.params:
05212 compFun = lambda hyp,args: \
05213 hyp.GetQuadType() == args[0] and \
05214 ( hyp.GetTriaVertex()==args[1] or ( hyp.GetTriaVertex()<1 and args[1]<1))
05215 self.params = self.Hypothesis("QuadrangleParams", [quadType,vertexID],
05216 UseExisting = UseExisting, CompareMethod=compFun)
05217 pass
05218 if self.params.GetQuadType() != quadType:
05219 self.params.SetQuadType(quadType)
05220 if vertexID > 0:
05221 self.params.SetTriaVertex( vertexID )
05222 return self.params
05223
05224
05225
05226
05227
05228
05229
05230
05231 def QuadranglePreference(self, reversed=False, UseExisting=0):
05232 if reversed:
05233 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF_REVERSED,UseExisting=UseExisting)
05234 return self.QuadrangleParameters(QUAD_QUADRANGLE_PREF,UseExisting=UseExisting)
05235
05236
05237
05238
05239
05240
05241 def TrianglePreference(self, UseExisting=0):
05242 return self.QuadrangleParameters(QUAD_TRIANGLE_PREF,UseExisting=UseExisting)
05243
05244
05245
05246
05247
05248
05249
05250
05251
05252 def Reduced(self, UseExisting=0):
05253 return self.QuadrangleParameters(QUAD_REDUCED,UseExisting=UseExisting)
05254
05255
05256
05257
05258
05259
05260
05261
05262
05263 def TriangleVertex(self, vertex, UseExisting=0):
05264 return self.QuadrangleParameters(QUAD_STANDARD,vertex,UseExisting)
05265
05266
05267
05268
05269
05270
05271
05272
05273 class Mesh_Tetrahedron(Mesh_Algorithm):
05274
05275 params = 0
05276 algoType = 0
05277
05278
05279 def __init__(self, mesh, algoType, geom=0):
05280 Mesh_Algorithm.__init__(self)
05281
05282 if algoType == NETGEN:
05283 CheckPlugin(NETGEN)
05284 self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
05285 pass
05286
05287 elif algoType == FULL_NETGEN:
05288 CheckPlugin(NETGEN)
05289 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
05290 pass
05291
05292 elif algoType == GHS3D:
05293 CheckPlugin(GHS3D)
05294 self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
05295 pass
05296
05297 elif algoType == GHS3DPRL:
05298 CheckPlugin(GHS3DPRL)
05299 self.Create(mesh, geom, "GHS3DPRL_3D" , "libGHS3DPRLEngine.so")
05300 pass
05301
05302 self.algoType = algoType
05303
05304
05305
05306
05307
05308
05309 def MaxElementVolume(self, vol, UseExisting=0):
05310 if self.algoType == NETGEN:
05311 hyp = self.Hypothesis("MaxElementVolume", [vol], UseExisting=UseExisting,
05312 CompareMethod=self.CompareMaxElementVolume)
05313 hyp.SetMaxElementVolume(vol)
05314 return hyp
05315 elif self.algoType == FULL_NETGEN:
05316 self.Parameters(SIMPLE).SetMaxElementVolume(vol)
05317 return None
05318
05319
05320 def CompareMaxElementVolume(self, hyp, args):
05321 return IsEqual(hyp.GetMaxElementVolume(), args[0])
05322
05323
05324
05325
05326 def Parameters(self, which=SOLE):
05327 if not self.params:
05328
05329 if self.algoType == FULL_NETGEN:
05330 if which == SIMPLE:
05331 self.params = self.Hypothesis("NETGEN_SimpleParameters_3D", [],
05332 "libNETGENEngine.so", UseExisting=0)
05333 else:
05334 self.params = self.Hypothesis("NETGEN_Parameters", [],
05335 "libNETGENEngine.so", UseExisting=0)
05336
05337 elif self.algoType == NETGEN:
05338 self.params = self.Hypothesis("NETGEN_Parameters_3D", [],
05339 "libNETGENEngine.so", UseExisting=0)
05340
05341 elif self.algoType == GHS3D:
05342 self.params = self.Hypothesis("GHS3D_Parameters", [],
05343 "libGHS3DEngine.so", UseExisting=0)
05344
05345 elif self.algoType == GHS3DPRL:
05346 self.params = self.Hypothesis("GHS3DPRL_Parameters", [],
05347 "libGHS3DPRLEngine.so", UseExisting=0)
05348 else:
05349 print "Warning: %s supports no multi-parameter hypothesis"%self.algo.GetName()
05350
05351 return self.params
05352
05353
05354
05355
05356 def SetMaxSize(self, theSize):
05357 self.Parameters().SetMaxSize(theSize)
05358
05359
05360
05361
05362 def SetSecondOrder(self, theVal):
05363 self.Parameters().SetSecondOrder(theVal)
05364
05365
05366
05367
05368 def SetOptimize(self, theVal):
05369 self.Parameters().SetOptimize(theVal)
05370
05371
05372
05373
05374
05375
05376 def SetFineness(self, theFineness):
05377 self.Parameters().SetFineness(theFineness)
05378
05379
05380
05381
05382 def SetGrowthRate(self, theRate):
05383 self.Parameters().SetGrowthRate(theRate)
05384
05385
05386
05387
05388 def SetNbSegPerEdge(self, theVal):
05389 self.Parameters().SetNbSegPerEdge(theVal)
05390
05391
05392
05393
05394 def SetNbSegPerRadius(self, theVal):
05395 self.Parameters().SetNbSegPerRadius(theVal)
05396
05397
05398
05399
05400 def SetNumberOfSegments(self, theVal):
05401 self.Parameters(SIMPLE).SetNumberOfSegments(theVal)
05402
05403
05404
05405
05406 def SetLocalLength(self, theVal):
05407 self.Parameters(SIMPLE).SetLocalLength(theVal)
05408
05409
05410
05411
05412
05413 def MaxElementArea(self, area):
05414 self.Parameters(SIMPLE).SetMaxElementArea(area)
05415
05416
05417
05418
05419
05420 def LengthFromEdges(self):
05421 self.Parameters(SIMPLE).LengthFromEdges()
05422
05423
05424
05425
05426
05427 def LengthFromFaces(self):
05428 self.Parameters(SIMPLE).LengthFromFaces()
05429
05430
05431
05432 def SetToMeshHoles(self, toMesh):
05433
05434 self.Parameters().SetToMeshHoles(toMesh)
05435
05436
05437
05438
05439
05440
05441 def SetOptimizationLevel(self, level):
05442
05443 self.Parameters().SetOptimizationLevel(level)
05444
05445
05446
05447 def SetMaximumMemory(self, MB):
05448
05449 self.Parameters().SetMaximumMemory(MB)
05450
05451
05452
05453
05454 def SetInitialMemory(self, MB):
05455
05456 self.Parameters().SetInitialMemory(MB)
05457
05458
05459
05460 def SetWorkingDirectory(self, path):
05461
05462 self.Parameters().SetWorkingDirectory(path)
05463
05464
05465
05466 def SetKeepFiles(self, toKeep):
05467
05468 self.Parameters().SetKeepFiles(toKeep)
05469
05470
05471
05472
05473
05474
05475
05476
05477
05478
05479 def SetVerboseLevel(self, level):
05480
05481 self.Parameters().SetVerboseLevel(level)
05482
05483
05484
05485 def SetToCreateNewNodes(self, toCreate):
05486
05487 self.Parameters().SetToCreateNewNodes(toCreate)
05488
05489
05490
05491
05492 def SetToUseBoundaryRecoveryVersion(self, toUse):
05493
05494 self.Parameters().SetToUseBoundaryRecoveryVersion(toUse)
05495
05496
05497
05498
05499
05500
05501 def SetFEMCorrection(self, toUseFem):
05502
05503 self.Parameters().SetFEMCorrection(toUseFem)
05504
05505
05506
05507 def SetToRemoveCentralPoint(self, toRemove):
05508
05509 self.Parameters().SetToRemoveCentralPoint(toRemove)
05510
05511
05512
05513 def SetEnforcedVertex(self, x, y, z, size):
05514
05515 return self.Parameters().SetEnforcedVertex(x, y, z, size)
05516
05517
05518
05519
05520 def SetEnforcedVertexWithGroup(self, x, y, z, size, groupName):
05521
05522 return self.Parameters().SetEnforcedVertex(x, y, z, size,groupName)
05523
05524
05525
05526 def RemoveEnforcedVertex(self, x, y, z):
05527
05528 return self.Parameters().RemoveEnforcedVertex(x, y, z)
05529
05530
05531
05532 def SetEnforcedVertexGeom(self, theVertex, size):
05533 AssureGeomPublished( self.mesh, theVertex )
05534
05535 return self.Parameters().SetEnforcedVertexGeom(theVertex, size)
05536
05537
05538
05539
05540
05541 def SetEnforcedVertexGeomWithGroup(self, theVertex, size, groupName):
05542 AssureGeomPublished( self.mesh, theVertex )
05543
05544 return self.Parameters().SetEnforcedVertexGeomWithGroup(theVertex, size,groupName)
05545
05546
05547
05548 def RemoveEnforcedVertexGeom(self, theVertex):
05549 AssureGeomPublished( self.mesh, theVertex )
05550
05551 return self.Parameters().RemoveEnforcedVertexGeom(theVertex)
05552
05553
05554
05555 def SetEnforcedMesh(self, theSource, elementType):
05556
05557 return self.Parameters().SetEnforcedMesh(theSource, elementType)
05558
05559
05560
05561 def SetEnforcedMeshWithGroup(self, theSource, elementType, groupName):
05562
05563 return self.Parameters().SetEnforcedMeshWithGroup(theSource, elementType, groupName)
05564
05565
05566
05567 def SetEnforcedMeshSize(self, theSource, elementType, size):
05568
05569 return self.Parameters().SetEnforcedMeshSize(theSource, elementType, size)
05570
05571
05572
05573 def SetEnforcedMeshSizeWithGroup(self, theSource, elementType, size, groupName):
05574
05575 return self.Parameters().SetEnforcedMeshSizeWithGroup(theSource, elementType, size, groupName)
05576
05577
05578
05579 def SetTextOption(self, option):
05580
05581 self.Parameters().SetTextOption(option)
05582
05583
05584 def SetMEDName(self, value):
05585 self.Parameters().SetMEDName(value)
05586
05587
05588 def SetNbPart(self, value):
05589 self.Parameters().SetNbPart(value)
05590
05591
05592 def SetBackground(self, value):
05593 self.Parameters().SetBackground(value)
05594
05595
05596
05597
05598
05599
05600
05601 class Mesh_Hexahedron(Mesh_Algorithm):
05602
05603 params = 0
05604 algoType = 0
05605
05606
05607 def __init__(self, mesh, algoType=Hexa, geom=0):
05608 Mesh_Algorithm.__init__(self)
05609
05610 self.algoType = algoType
05611
05612 if algoType == Hexa:
05613 self.Create(mesh, geom, "Hexa_3D")
05614 pass
05615
05616 elif algoType == Hexotic:
05617 CheckPlugin(Hexotic)
05618 self.Create(mesh, geom, "Hexotic_3D", "libHexoticEngine.so")
05619 pass
05620
05621
05622
05623 def MinMaxQuad(self, min=3, max=8, quad=True):
05624 self.params = self.Hypothesis("Hexotic_Parameters", [], "libHexoticEngine.so",
05625 UseExisting=0)
05626 self.params.SetHexesMinLevel(min)
05627 self.params.SetHexesMaxLevel(max)
05628 self.params.SetHexoticQuadrangles(quad)
05629 return self.params
05630
05631
05632
05633
05634
05635
05636
05637
05638
05639
05640
05641
05642 class Mesh_Netgen(Mesh_Algorithm):
05643
05644 is3D = 0
05645
05646
05647 def __init__(self, mesh, is3D, geom=0):
05648 Mesh_Algorithm.__init__(self)
05649
05650 CheckPlugin(NETGEN)
05651
05652 self.is3D = is3D
05653 if is3D:
05654 self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
05655 pass
05656
05657 else:
05658 self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
05659 pass
05660
05661
05662 def Parameters(self):
05663 if self.is3D:
05664 hyp = self.Hypothesis("NETGEN_Parameters", [],
05665 "libNETGENEngine.so", UseExisting=0)
05666 else:
05667 hyp = self.Hypothesis("NETGEN_Parameters_2D", [],
05668 "libNETGENEngine.so", UseExisting=0)
05669 return hyp
05670
05671
05672
05673
05674
05675
05676
05677 class Mesh_Projection1D(Mesh_Algorithm):
05678
05679
05680 def __init__(self, mesh, geom=0):
05681 Mesh_Algorithm.__init__(self)
05682 self.Create(mesh, geom, "Projection_1D")
05683
05684
05685
05686
05687
05688
05689
05690
05691
05692
05693
05694 def SourceEdge(self, edge, mesh=None, srcV=None, tgtV=None, UseExisting=0):
05695 AssureGeomPublished( self.mesh, edge )
05696 AssureGeomPublished( self.mesh, srcV )
05697 AssureGeomPublished( self.mesh, tgtV )
05698 hyp = self.Hypothesis("ProjectionSource1D", [edge,mesh,srcV,tgtV],
05699 UseExisting=0)
05700
05701 hyp.SetSourceEdge( edge )
05702 if not mesh is None and isinstance(mesh, Mesh):
05703 mesh = mesh.GetMesh()
05704 hyp.SetSourceMesh( mesh )
05705 hyp.SetVertexAssociation( srcV, tgtV )
05706 return hyp
05707
05708
05709
05710
05711
05712
05713
05714
05715
05716
05717
05718
05719
05720 class Mesh_Projection2D(Mesh_Algorithm):
05721
05722
05723 def __init__(self, mesh, geom=0):
05724 Mesh_Algorithm.__init__(self)
05725 self.Create(mesh, geom, "Projection_2D")
05726
05727
05728
05729
05730
05731
05732
05733
05734
05735
05736
05737
05738
05739
05740
05741
05742 def SourceFace(self, face, mesh=None, srcV1=None, tgtV1=None,
05743 srcV2=None, tgtV2=None, UseExisting=0):
05744 for geom in [ face, srcV1, tgtV1, srcV2, tgtV2 ]:
05745 AssureGeomPublished( self.mesh, geom )
05746 hyp = self.Hypothesis("ProjectionSource2D", [face,mesh,srcV1,tgtV1,srcV2,tgtV2],
05747 UseExisting=0)
05748
05749 hyp.SetSourceFace( face )
05750 if isinstance(mesh, Mesh):
05751 mesh = mesh.GetMesh()
05752 hyp.SetSourceMesh( mesh )
05753 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
05754 return hyp
05755
05756
05757
05758
05759
05760
05761
05762
05763
05764
05765
05766
05767 class Mesh_Projection3D(Mesh_Algorithm):
05768
05769
05770 def __init__(self, mesh, geom=0):
05771 Mesh_Algorithm.__init__(self)
05772 self.Create(mesh, geom, "Projection_3D")
05773
05774
05775
05776
05777
05778
05779
05780
05781
05782
05783
05784
05785
05786
05787
05788
05789 def SourceShape3D(self, solid, mesh=0, srcV1=0, tgtV1=0,
05790 srcV2=0, tgtV2=0, UseExisting=0):
05791 for geom in [ solid, srcV1, tgtV1, srcV2, tgtV2 ]:
05792 AssureGeomPublished( self.mesh, geom )
05793 hyp = self.Hypothesis("ProjectionSource3D",
05794 [solid,mesh,srcV1,tgtV1,srcV2,tgtV2],
05795 UseExisting=0)
05796
05797 hyp.SetSource3DShape( solid )
05798 if not mesh is None and isinstance(mesh, Mesh):
05799 mesh = mesh.GetMesh()
05800 hyp.SetSourceMesh( mesh )
05801 if srcV1 and srcV2 and tgtV1 and tgtV2:
05802 hyp.SetVertexAssociation( srcV1, srcV2, tgtV1, tgtV2 )
05803
05804 return hyp
05805
05806
05807
05808
05809
05810
05811
05812
05813
05814
05815
05816
05817
05818 class Mesh_Prism3D(Mesh_Algorithm):
05819
05820
05821 def __init__(self, mesh, geom=0):
05822 Mesh_Algorithm.__init__(self)
05823 self.Create(mesh, geom, "Prism_3D")
05824
05825
05826
05827
05828
05829
05830
05831 class Mesh_RadialPrism3D(Mesh_Algorithm):
05832
05833
05834 def __init__(self, mesh, geom=0):
05835 Mesh_Algorithm.__init__(self)
05836 self.Create(mesh, geom, "RadialPrism_3D")
05837
05838 self.distribHyp = self.Hypothesis("LayerDistribution", UseExisting=0)
05839 self.nbLayers = None
05840
05841
05842 def Get3DHypothesis(self):
05843 return self.distribHyp
05844
05845
05846
05847 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
05848
05849 if not self.nbLayers is None:
05850 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
05851 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
05852 study = self.mesh.smeshpyD.GetCurrentStudy()
05853 self.mesh.smeshpyD.SetCurrentStudy( None )
05854 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
05855 self.mesh.smeshpyD.SetCurrentStudy( study )
05856 self.distribHyp.SetLayerDistribution( hyp )
05857 return hyp
05858
05859
05860
05861
05862
05863
05864 def NumberOfLayers(self, n, UseExisting=0):
05865 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
05866 self.nbLayers = self.Hypothesis("NumberOfLayers", [n], UseExisting=UseExisting,
05867 CompareMethod=self.CompareNumberOfLayers)
05868 self.nbLayers.SetNumberOfLayers( n )
05869 return self.nbLayers
05870
05871
05872 def CompareNumberOfLayers(self, hyp, args):
05873 return IsEqual(hyp.GetNumberOfLayers(), args[0])
05874
05875
05876
05877
05878
05879 def LocalLength(self, l, p=1e-07):
05880 hyp = self.OwnHypothesis("LocalLength", [l,p])
05881 hyp.SetLength(l)
05882 hyp.SetPrecision(p)
05883 return hyp
05884
05885
05886
05887
05888
05889 def NumberOfSegments(self, n, s=[]):
05890 if s == []:
05891 hyp = self.OwnHypothesis("NumberOfSegments", [n])
05892 else:
05893 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
05894 hyp.SetDistrType( 1 )
05895 hyp.SetScaleFactor(s)
05896 hyp.SetNumberOfSegments(n)
05897 return hyp
05898
05899
05900
05901
05902
05903 def Arithmetic1D(self, start, end ):
05904 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
05905 hyp.SetLength(start, 1)
05906 hyp.SetLength(end , 0)
05907 return hyp
05908
05909
05910
05911
05912
05913 def StartEndLength(self, start, end):
05914 hyp = self.OwnHypothesis("StartEndLength", [start, end])
05915 hyp.SetLength(start, 1)
05916 hyp.SetLength(end , 0)
05917 return hyp
05918
05919
05920
05921
05922 def AutomaticLength(self, fineness=0):
05923 hyp = self.OwnHypothesis("AutomaticLength")
05924 hyp.SetFineness( fineness )
05925 return hyp
05926
05927
05928
05929
05930
05931
05932
05933 class Mesh_RadialQuadrangle1D2D(Mesh_Algorithm):
05934
05935
05936 def __init__(self, mesh, geom=0):
05937 Mesh_Algorithm.__init__(self)
05938 self.Create(mesh, geom, "RadialQuadrangle_1D2D")
05939
05940 self.distribHyp = None
05941 self.nbLayers = None
05942
05943
05944 def Get2DHypothesis(self):
05945 return self.distribHyp
05946
05947
05948
05949 def OwnHypothesis(self, hypType, args=[], so="libStdMeshersEngine.so"):
05950
05951 if self.nbLayers:
05952 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.nbLayers )
05953 if self.distribHyp is None:
05954 self.distribHyp = self.Hypothesis("LayerDistribution2D", UseExisting=0)
05955 else:
05956 self.mesh.GetMesh().AddHypothesis( self.geom, self.distribHyp )
05957 study = self.mesh.smeshpyD.GetCurrentStudy()
05958 self.mesh.smeshpyD.SetCurrentStudy( None )
05959 hyp = self.mesh.smeshpyD.CreateHypothesis(hypType, so)
05960 self.mesh.smeshpyD.SetCurrentStudy( study )
05961 self.distribHyp.SetLayerDistribution( hyp )
05962 return hyp
05963
05964
05965
05966
05967
05968 def NumberOfLayers(self, n, UseExisting=0):
05969 if self.distribHyp:
05970 self.mesh.GetMesh().RemoveHypothesis( self.geom, self.distribHyp )
05971 self.nbLayers = self.Hypothesis("NumberOfLayers2D", [n], UseExisting=UseExisting,
05972 CompareMethod=self.CompareNumberOfLayers)
05973 self.nbLayers.SetNumberOfLayers( n )
05974 return self.nbLayers
05975
05976
05977 def CompareNumberOfLayers(self, hyp, args):
05978 return IsEqual(hyp.GetNumberOfLayers(), args[0])
05979
05980
05981
05982
05983 def LocalLength(self, l, p=1e-07):
05984 hyp = self.OwnHypothesis("LocalLength", [l,p])
05985 hyp.SetLength(l)
05986 hyp.SetPrecision(p)
05987 return hyp
05988
05989
05990
05991
05992 def NumberOfSegments(self, n, s=[]):
05993 if s == []:
05994 hyp = self.OwnHypothesis("NumberOfSegments", [n])
05995 else:
05996 hyp = self.OwnHypothesis("NumberOfSegments", [n,s])
05997 hyp.SetDistrType( 1 )
05998 hyp.SetScaleFactor(s)
05999 hyp.SetNumberOfSegments(n)
06000 return hyp
06001
06002
06003
06004
06005
06006 def Arithmetic1D(self, start, end ):
06007 hyp = self.OwnHypothesis("Arithmetic1D", [start, end])
06008 hyp.SetLength(start, 1)
06009 hyp.SetLength(end , 0)
06010 return hyp
06011
06012
06013
06014
06015
06016 def StartEndLength(self, start, end):
06017 hyp = self.OwnHypothesis("StartEndLength", [start, end])
06018 hyp.SetLength(start, 1)
06019 hyp.SetLength(end , 0)
06020 return hyp
06021
06022
06023
06024 def AutomaticLength(self, fineness=0):
06025 hyp = self.OwnHypothesis("AutomaticLength")
06026 hyp.SetFineness( fineness )
06027 return hyp
06028
06029
06030
06031
06032
06033
06034
06035 class Mesh_UseExistingElements(Mesh_Algorithm):
06036
06037 def __init__(self, dim, mesh, geom=0):
06038 if dim == 1:
06039 self.Create(mesh, geom, "Import_1D")
06040 else:
06041 self.Create(mesh, geom, "Import_1D2D")
06042 return
06043
06044
06045
06046
06047
06048
06049
06050 def SourceEdges(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
06051 if self.algo.GetName() == "Import_2D":
06052 raise ValueError, "algoritm dimension mismatch"
06053 for group in groups:
06054 AssureGeomPublished( self.mesh, group )
06055 hyp = self.Hypothesis("ImportSource1D", [groups, toCopyMesh, toCopyGroups],
06056 UseExisting=UseExisting, CompareMethod=self._compareHyp)
06057 hyp.SetSourceEdges(groups)
06058 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
06059 return hyp
06060
06061
06062
06063
06064
06065
06066
06067 def SourceFaces(self, groups, toCopyMesh=False, toCopyGroups=False, UseExisting=False):
06068 if self.algo.GetName() == "Import_1D":
06069 raise ValueError, "algoritm dimension mismatch"
06070 for group in groups:
06071 AssureGeomPublished( self.mesh, group )
06072 hyp = self.Hypothesis("ImportSource2D", [groups, toCopyMesh, toCopyGroups],
06073 UseExisting=UseExisting, CompareMethod=self._compareHyp)
06074 hyp.SetSourceFaces(groups)
06075 hyp.SetCopySourceMesh(toCopyMesh, toCopyGroups)
06076 return hyp
06077
06078 def _compareHyp(self,hyp,args):
06079 if hasattr( hyp, "GetSourceEdges"):
06080 entries = hyp.GetSourceEdges()
06081 else:
06082 entries = hyp.GetSourceFaces()
06083 groups = args[0]
06084 toCopyMesh,toCopyGroups = hyp.GetCopySourceMesh()
06085 if len(entries)==len(groups) and toCopyMesh==args[1] and toCopyGroups==args[2]:
06086 entries2 = []
06087 study = self.mesh.smeshpyD.GetCurrentStudy()
06088 if study:
06089 for g in groups:
06090 ior = salome.orb.object_to_string(g)
06091 sobj = study.FindObjectIOR(ior)
06092 if sobj: entries2.append( sobj.GetID() )
06093 pass
06094 pass
06095 entries.sort()
06096 entries2.sort()
06097 return entries == entries2
06098 return False
06099
06100
06101
06102
06103 class Mesh_UseExisting(Mesh_Algorithm):
06104
06105 def __init__(self, dim, mesh, geom=0):
06106 if dim == 1:
06107 self.Create(mesh, geom, "UseExisting_1D")
06108 else:
06109 self.Create(mesh, geom, "UseExisting_2D")
06110
06111
06112 import salome_notebook
06113 notebook = salome_notebook.notebook
06114
06115
06116 def ParseParameters(last, nbParams,nbParam, value):
06117 result = None
06118 strResult = ""
06119 counter = 0
06120 listSize = len(last)
06121 for n in range(0,nbParams):
06122 if n+1 != nbParam:
06123 if counter < listSize:
06124 strResult = strResult + last[counter]
06125 else:
06126 strResult = strResult + ""
06127 else:
06128 if isinstance(value, str):
06129 if notebook.isVariable(value):
06130 result = notebook.get(value)
06131 strResult=strResult+value
06132 else:
06133 raise RuntimeError, "Variable with name '" + value + "' doesn't exist!!!"
06134 else:
06135 strResult=strResult+str(value)
06136 result = value
06137 if nbParams - 1 != counter:
06138 strResult=strResult+var_separator
06139 counter = counter+1
06140 return result, strResult
06141
06142
06143 class LocalLength(StdMeshers._objref_StdMeshers_LocalLength):
06144
06145
06146
06147 def SetLength(self, length):
06148 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,1,length)
06149 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
06150 StdMeshers._objref_StdMeshers_LocalLength.SetLength(self,length)
06151
06152
06153
06154 def SetPrecision(self, precision):
06155 precision,parameters = ParseParameters(StdMeshers._objref_StdMeshers_LocalLength.GetLastParameters(self),2,2,precision)
06156 StdMeshers._objref_StdMeshers_LocalLength.SetParameters(self,parameters)
06157 StdMeshers._objref_StdMeshers_LocalLength.SetPrecision(self, precision)
06158
06159
06160 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LocalLength._NP_RepositoryId, LocalLength)
06161
06162
06163
06164 class LayerDistribution(StdMeshers._objref_StdMeshers_LayerDistribution):
06165
06166 def SetLayerDistribution(self, hypo):
06167 StdMeshers._objref_StdMeshers_LayerDistribution.SetParameters(self,hypo.GetParameters())
06168 hypo.ClearParameters();
06169 StdMeshers._objref_StdMeshers_LayerDistribution.SetLayerDistribution(self,hypo)
06170
06171
06172 omniORB.registerObjref(StdMeshers._objref_StdMeshers_LayerDistribution._NP_RepositoryId, LayerDistribution)
06173
06174
06175 class SegmentLengthAroundVertex(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex):
06176
06177
06178
06179 def SetLength(self, length):
06180 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.GetLastParameters(self),1,1,length)
06181 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetParameters(self,parameters)
06182 StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex.SetLength(self,length)
06183
06184
06185 omniORB.registerObjref(StdMeshers._objref_StdMeshers_SegmentLengthAroundVertex._NP_RepositoryId, SegmentLengthAroundVertex)
06186
06187
06188
06189 class Arithmetic1D(StdMeshers._objref_StdMeshers_Arithmetic1D):
06190
06191
06192
06193
06194 def SetLength(self, length, isStart):
06195 nb = 2
06196 if isStart:
06197 nb = 1
06198 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Arithmetic1D.GetLastParameters(self),2,nb,length)
06199 StdMeshers._objref_StdMeshers_Arithmetic1D.SetParameters(self,parameters)
06200 StdMeshers._objref_StdMeshers_Arithmetic1D.SetLength(self,length,isStart)
06201
06202
06203 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Arithmetic1D._NP_RepositoryId, Arithmetic1D)
06204
06205
06206 class Deflection1D(StdMeshers._objref_StdMeshers_Deflection1D):
06207
06208
06209
06210 def SetDeflection(self, deflection):
06211 deflection,parameters = ParseParameters(StdMeshers._objref_StdMeshers_Deflection1D.GetLastParameters(self),1,1,deflection)
06212 StdMeshers._objref_StdMeshers_Deflection1D.SetParameters(self,parameters)
06213 StdMeshers._objref_StdMeshers_Deflection1D.SetDeflection(self,deflection)
06214
06215
06216 omniORB.registerObjref(StdMeshers._objref_StdMeshers_Deflection1D._NP_RepositoryId, Deflection1D)
06217
06218
06219 class StartEndLength(StdMeshers._objref_StdMeshers_StartEndLength):
06220
06221
06222
06223
06224 def SetLength(self, length, isStart):
06225 nb = 2
06226 if isStart:
06227 nb = 1
06228 length,parameters = ParseParameters(StdMeshers._objref_StdMeshers_StartEndLength.GetLastParameters(self),2,nb,length)
06229 StdMeshers._objref_StdMeshers_StartEndLength.SetParameters(self,parameters)
06230 StdMeshers._objref_StdMeshers_StartEndLength.SetLength(self,length,isStart)
06231
06232
06233 omniORB.registerObjref(StdMeshers._objref_StdMeshers_StartEndLength._NP_RepositoryId, StartEndLength)
06234
06235
06236 class MaxElementArea(StdMeshers._objref_StdMeshers_MaxElementArea):
06237
06238
06239
06240 def SetMaxElementArea(self, area):
06241 area ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementArea.GetLastParameters(self),1,1,area)
06242 StdMeshers._objref_StdMeshers_MaxElementArea.SetParameters(self,parameters)
06243 StdMeshers._objref_StdMeshers_MaxElementArea.SetMaxElementArea(self,area)
06244
06245
06246 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementArea._NP_RepositoryId, MaxElementArea)
06247
06248
06249
06250 class MaxElementVolume(StdMeshers._objref_StdMeshers_MaxElementVolume):
06251
06252
06253
06254 def SetMaxElementVolume(self, volume):
06255 volume ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_MaxElementVolume.GetLastParameters(self),1,1,volume)
06256 StdMeshers._objref_StdMeshers_MaxElementVolume.SetParameters(self,parameters)
06257 StdMeshers._objref_StdMeshers_MaxElementVolume.SetMaxElementVolume(self,volume)
06258
06259
06260 omniORB.registerObjref(StdMeshers._objref_StdMeshers_MaxElementVolume._NP_RepositoryId, MaxElementVolume)
06261
06262
06263
06264 class NumberOfLayers(StdMeshers._objref_StdMeshers_NumberOfLayers):
06265
06266
06267
06268 def SetNumberOfLayers(self, nbLayers):
06269 nbLayers ,parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfLayers.GetLastParameters(self),1,1,nbLayers)
06270 StdMeshers._objref_StdMeshers_NumberOfLayers.SetParameters(self,parameters)
06271 StdMeshers._objref_StdMeshers_NumberOfLayers.SetNumberOfLayers(self,nbLayers)
06272
06273
06274 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfLayers._NP_RepositoryId, NumberOfLayers)
06275
06276
06277 class NumberOfSegments(StdMeshers._objref_StdMeshers_NumberOfSegments):
06278
06279
06280
06281 def SetNumberOfSegments(self, nbSeg):
06282 lastParameters = StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self)
06283 nbSeg , parameters = ParseParameters(lastParameters,1,1,nbSeg)
06284 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
06285 StdMeshers._objref_StdMeshers_NumberOfSegments.SetNumberOfSegments(self,nbSeg)
06286
06287
06288
06289 def SetScaleFactor(self, factor):
06290 factor, parameters = ParseParameters(StdMeshers._objref_StdMeshers_NumberOfSegments.GetLastParameters(self),2,2,factor)
06291 StdMeshers._objref_StdMeshers_NumberOfSegments.SetParameters(self,parameters)
06292 StdMeshers._objref_StdMeshers_NumberOfSegments.SetScaleFactor(self,factor)
06293
06294
06295 omniORB.registerObjref(StdMeshers._objref_StdMeshers_NumberOfSegments._NP_RepositoryId, NumberOfSegments)
06296
06297 if not noNETGENPlugin:
06298
06299 class NETGENPlugin_Hypothesis(NETGENPlugin._objref_NETGENPlugin_Hypothesis):
06300
06301
06302
06303 def SetMaxSize(self, maxsize):
06304 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06305 maxsize, parameters = ParseParameters(lastParameters,4,1,maxsize)
06306 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06307 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetMaxSize(self,maxsize)
06308
06309
06310
06311 def SetGrowthRate(self, value):
06312 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06313 value, parameters = ParseParameters(lastParameters,4,2,value)
06314 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06315 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetGrowthRate(self,value)
06316
06317
06318
06319 def SetNbSegPerEdge(self, value):
06320 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06321 value, parameters = ParseParameters(lastParameters,4,3,value)
06322 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06323 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerEdge(self,value)
06324
06325
06326
06327 def SetNbSegPerRadius(self, value):
06328 lastParameters = NETGENPlugin._objref_NETGENPlugin_Hypothesis.GetLastParameters(self)
06329 value, parameters = ParseParameters(lastParameters,4,4,value)
06330 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetParameters(self,parameters)
06331 NETGENPlugin._objref_NETGENPlugin_Hypothesis.SetNbSegPerRadius(self,value)
06332
06333
06334 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis._NP_RepositoryId, NETGENPlugin_Hypothesis)
06335
06336
06337
06338 class NETGENPlugin_Hypothesis_2D(NETGENPlugin_Hypothesis,NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D):
06339 pass
06340
06341
06342 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_Hypothesis_2D._NP_RepositoryId, NETGENPlugin_Hypothesis_2D)
06343
06344
06345 class NETGEN_SimpleParameters_2D(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D):
06346
06347
06348
06349 def SetNumberOfSegments(self, nbSeg):
06350 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06351 nbSeg, parameters = ParseParameters(lastParameters,2,1,nbSeg)
06352 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06353 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetNumberOfSegments(self, nbSeg)
06354
06355
06356
06357 def SetLocalLength(self, length):
06358 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06359 length, parameters = ParseParameters(lastParameters,2,1,length)
06360 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06361 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetLocalLength(self, length)
06362
06363
06364
06365 def SetMaxElementArea(self, area):
06366 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06367 area, parameters = ParseParameters(lastParameters,2,2,area)
06368 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06369 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetMaxElementArea(self, area)
06370
06371 def LengthFromEdges(self):
06372 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.GetLastParameters(self)
06373 value = 0;
06374 value, parameters = ParseParameters(lastParameters,2,2,value)
06375 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.SetParameters(self,parameters)
06376 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D.LengthFromEdges(self)
06377
06378
06379 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_2D._NP_RepositoryId, NETGEN_SimpleParameters_2D)
06380
06381
06382
06383 class NETGEN_SimpleParameters_3D(NETGEN_SimpleParameters_2D,NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D):
06384
06385
06386 def SetMaxElementVolume(self, volume):
06387 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
06388 volume, parameters = ParseParameters(lastParameters,3,3,volume)
06389 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
06390 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetMaxElementVolume(self, volume)
06391
06392 def LengthFromFaces(self):
06393 lastParameters = NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.GetLastParameters(self)
06394 value = 0;
06395 value, parameters = ParseParameters(lastParameters,3,3,value)
06396 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.SetParameters(self,parameters)
06397 NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D.LengthFromFaces(self)
06398
06399
06400 omniORB.registerObjref(NETGENPlugin._objref_NETGENPlugin_SimpleHypothesis_3D._NP_RepositoryId, NETGEN_SimpleParameters_3D)
06401
06402 pass
06403
06404 class Pattern(SMESH._objref_SMESH_Pattern):
06405
06406 def ApplyToMeshFaces(self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse):
06407 flag = False
06408 if isinstance(theNodeIndexOnKeyPoint1,str):
06409 flag = True
06410 theNodeIndexOnKeyPoint1,Parameters = geompyDC.ParseParameters(theNodeIndexOnKeyPoint1)
06411 if flag:
06412 theNodeIndexOnKeyPoint1 -= 1
06413 theMesh.SetParameters(Parameters)
06414 return SMESH._objref_SMESH_Pattern.ApplyToMeshFaces( self, theMesh, theFacesIDs, theNodeIndexOnKeyPoint1, theReverse )
06415
06416 def ApplyToHexahedrons(self, theMesh, theVolumesIDs, theNode000Index, theNode001Index):
06417 flag0 = False
06418 flag1 = False
06419 if isinstance(theNode000Index,str):
06420 flag0 = True
06421 if isinstance(theNode001Index,str):
06422 flag1 = True
06423 theNode000Index,theNode001Index,Parameters = geompyDC.ParseParameters(theNode000Index,theNode001Index)
06424 if flag0:
06425 theNode000Index -= 1
06426 if flag1:
06427 theNode001Index -= 1
06428 theMesh.SetParameters(Parameters)
06429 return SMESH._objref_SMESH_Pattern.ApplyToHexahedrons( self, theMesh, theVolumesIDs, theNode000Index, theNode001Index )
06430
06431
06432 omniORB.registerObjref(SMESH._objref_SMESH_Pattern._NP_RepositoryId, Pattern)