1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 CEA/DEN, EDF R&D
12 from time import sleep
14 # NRI : temporary added because interface is declared into Engines module.
23 from omniORB import CORBA
25 from time import sleep
28 myNamingService = None
29 myLifeCycleCORBA = None
30 myNamingService = None
31 myLocalStudyManager = None
37 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
38 global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
39 global mySession, myLocalVisu, myDelay
42 myNamingService = theNamingService
43 myLifeCycleCORBA = theLifeCycleCORBA
44 myLocalStudyManager = theStudyManager
45 mySession = myNamingService.Resolve("/Kernel/Session")
46 mySession.GetInterface()
49 myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "VISU")
50 myLocalStudy = theStudy
51 myLocalVisu.SetCurrentStudy(myLocalStudy)
54 def StrToMap(theString) :
55 aPairList = split(theString,";")
58 for i in range(iEnd) :
59 aPair = split(aPairList[i],"=")
60 aMap[aPair[0]] = aPair[1]
63 def IntToEntity(theInt) :
74 def HasValue(theList, theValue) :
76 return theList.index(theValue) + 1
77 except StandardError, e :
80 def CreateStudyForMed(theVisu, theFileName) :
81 print "CreateStudyForMed ", theFileName,
82 if os.path.isfile(theFileName) :
83 if os.path.splitext(theFileName)[1] == '.med' :
85 aStudyName = os.path.basename(theFileName)
86 aStudyName = os.path.splitext(aStudyName)[0]
87 aStudyName = generateName(aStudyName)
88 print "myLocalStudyManager.NewStudy -", aStudyName, "...",
89 aStudy = myLocalStudyManager.NewStudy(aStudyName)
90 if aStudy is None : raise RuntimeError, "Error"
93 print "CreateStudyForMed - Creating a 3D viewer...",
94 theVisu.SetCurrentStudy(aStudy)
95 myViewManager = theVisu.GetViewManager()
96 if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager"
97 myView = myViewManager.Create3DView()
98 if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView"
102 return [aStudy, myViewManager, myView]
103 raise RuntimeError, "Error: There is no shuch file."
105 def getMedObjectFromStudy(theStudy = myLocalStudy):
107 theStudy = myLocalStudy
108 mySO = theStudy.FindObject("Objet MED")
109 anAttr = mySO.FindAttribute("AttributeIOR")[1]
110 obj = myORB.string_to_object(anAttr.Value())
111 myObj = obj._narrow(SALOME_MED.MED)
114 def getMedSObject(theStudy = myLocalStudy ):
115 return theStudy.FindObject("Objet MED")
117 def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
119 theStudy = myLocalStudy
120 mySO = theStudy.FindObject("MEDFIELD")
122 raise Runtime, "getFieldObjectFromStudy mySO is None"
123 mysub = mySO.FindSubObject(number)[1]
125 mysubsub = mysub.FindSubObject(subnumber)[1]
127 Builder = theStudy.NewBuilder()
128 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
129 obj = myORB.string_to_object(anAttr.Value())
130 myObj = obj._narrow(SALOME_MED.FIELDINT)
132 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
135 print "ERROR: No Field Object stored in this Study"
138 def SObjectToObject(theSObject) :
140 if theSObject is None :
141 print "SObjectToObject : argument is None"
143 res,Attr = theSObject.FindAttribute("AttributeIOR")
144 if (res != 0) and (Attr is not None) :
145 anIOR = Attr._narrow(SALOMEDS.AttributeIOR);
146 aValue = anIOR.Value();
147 if(len(aValue) != 0) :
148 anObj = myORB.string_to_object(aValue);
150 print "SObjectToObject - IOR = ''"
153 def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
155 global myLifeCycleCORBA
156 print "lcc.FindOrLoadComponent...",
157 aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "MED")
158 if aMedComp is None : print "Error"
161 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
163 print "aMedComp.readStructFileWithFieldType...",
164 aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
165 aMedSObj = getMedSObject(myLocalStudy)
166 if aMedSObj is None : raise RuntimeError, "Error"
169 print "theVisu.ImportMed...",
170 aResult = theVisu.ImportMed(aMedSObj)
171 if aResult is None : raise RuntimeError, "Error"
173 aVISUObjList.append(aResult)
174 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
176 aFolderIter = myLocalStudy.NewChildIterator(aMedSObj);
177 while aFolderIter.More() :
178 aFolderSObj = aFolderIter.Value()
180 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
181 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
182 aFolderName = anAttr.Value()
183 print " ", aFolderName
185 if aFolderName == 'MEDMESH' :
186 aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj);
187 while aMeshIter.More() :
188 aMeshSObj = aMeshIter.Value()
190 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
191 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
192 aMeshName = anAttr.Value()
195 aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj);
196 while aSupportIter.More() :
197 aSupportSObj = aSupportIter.Value()
199 anAttr = aSupportSObj.FindAttribute("AttributeName")[1]
200 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
201 aSupportName = anAttr.Value()
202 print " ", aSupportName
204 if aFolderName == 'MEDFIELD' :
205 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
206 while aFieldIter.More() :
207 aFieldSObj = aFieldIter.Value()
209 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
210 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
211 aFieldName = anAttr.Value()
212 print " ", aFieldName
214 print "theVisu.ImportMed...",
215 aResult = theVisu.ImportMed(aFieldSObj)
216 if aResult is None : raise RuntimeError, "Error"
218 aVISUObjList.append(aResult)
219 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
221 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
222 if aTimeStampIter.More() :
223 aTimeStampIter.Next()
224 while aTimeStampIter.More() :
225 aTimeStampSObj = aTimeStampIter.Value()
226 aTimeStampIter.Next()
227 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
228 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
229 aTimeStampName = anAttr.Value()
230 print " ", aTimeStampName
232 print "theVisu.ImportMed...",
233 aMedField = SObjectToObject(aTimeStampSObj)
234 aResult = theVisu.ImportMedFiled(aMedField)
235 if aResult is None : raise RuntimeError, "Error"
237 aVISUObjList.append(aResult)
238 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
242 # except Exception, e:
245 def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
247 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
249 print "theVisu.ImportMed..."
250 aResult = theVisu.ImportFile(theFileName)
251 if aResult is None : raise RuntimeError, "Error"
254 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
258 # except Exception, e:
261 def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) :
263 print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
264 myLocalStudy = theVisu.GetCurrentStudy()
265 aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
266 if aSObj is None : raise RuntimeError, "Error"
268 aMeshIter = myLocalStudy.NewChildIterator(aSObj);
269 while aMeshIter.More() :
270 aMeshSObj = aMeshIter.Value()
272 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
274 aMeshSObj = aMeshIter.Value()
276 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
277 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
278 aMeshName = anAttr.Value()
279 aMeshNamePic = re.sub(".","_",aMeshName)
282 aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj);
283 while aFolderIter.More() :
284 aFolderSObj = aFolderIter.Value()
286 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
287 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
288 aFolderName = anAttr.Value()
289 print " ", aFolderName
291 if aFolderName == 'Families' :
292 anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj);
293 while anEntityIter.More() :
294 anEntitySObj = anEntityIter.Value()
296 anAttr = anEntitySObj.FindAttribute("AttributeName")[1]
297 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
298 anEntityName = anAttr.Value()
301 if anEntityName == 'onNodes' :
304 if anEntityName == 'onEdges' :
307 if anEntityName == 'onFaces' :
310 if anEntityName == 'onCells' :
314 if HasValue(thePrsTypeList,VISU.TMESH) :
315 print " ", anEntityName, aMeshName,
316 aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
317 if aMesh is None : print "Error"
319 theView.DisplayOnly(aMesh)
321 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
322 aPictureName = re.sub("\s+","_", aPictureName);
323 theView.SavePicture(aPictureName)
324 aVISUObjList.append(aMesh)
326 anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
327 while anFamilyIter.More() :
328 aFamilySObj = anFamilyIter.Value()
330 anAttr = aFamilySObj.FindAttribute("AttributeName")[1]
331 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
332 anFamilyName = anAttr.Value()
333 if HasValue(thePrsTypeList,VISU.TMESH) :
334 print " ", anFamilyName,
335 aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
336 if aMesh is None : print "Error"
338 theView.DisplayOnly(aMesh)
340 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
341 aPictureName = re.sub("\s+","_", aPictureName);
342 theView.SavePicture(aPictureName)
343 aVISUObjList.append(aMesh)
345 if aFolderName == 'Groups' :
346 aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
347 while aGroupIter.More() :
348 aGroupSObj = aGroupIter.Value()
350 anAttr = aGroupSObj.FindAttribute("AttributeName")[1]
351 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
352 aGroupName = anAttr.Value()
353 if HasValue(thePrsTypeList,VISU.TMESH) :
354 print " ", aGroupName,
355 aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
356 if aMesh is None : print "Error"
358 theView.DisplayOnly(aMesh)
360 aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
361 aPictureName = re.sub("\s+","_", aPictureName);
362 theView.SavePicture(aPictureName)
363 aVISUObjList.append(aMesh)
365 if aFolderName == 'Fields' :
366 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
367 while aFieldIter.More() :
368 aFieldSObj = aFieldIter.Value()
370 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
371 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
372 aFieldName = anAttr.Value()
373 print " ", aFieldName
375 anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]
376 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
377 aFieldComment = anAttr.Value()
378 aMap = StrToMap(aFieldComment)
380 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
381 if aTimeStampIter.More() :
382 aTimeStampIter.Next()
383 while aTimeStampIter.More() :
384 aTimeStampSObj = aTimeStampIter.Value()
385 aTimeStampIter.Next()
386 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
387 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
388 aTimeStampName = anAttr.Value()
389 print " ", aTimeStampName
391 anAttr = aTimeStampSObj.FindAttribute("AttributeComment")[1]
392 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
393 aTimeStampComment = anAttr.Value()
394 aMap = StrToMap(aTimeStampComment)
395 aMeshName = aMap["myMeshName"]
396 aFieldName = aMap["myFieldName"]
397 aTimeStampId = atoi(aMap["myTimeStampId"])
398 anEntity = IntToEntity(aMap["myEntityId"])
399 anEntityId = str(aMap["myEntityId"]);
400 #print aMeshName, aFieldName, anEntity, aTimeStampId
401 if HasValue(thePrsTypeList,VISU.TSCALARMAP) :
402 print " Creating ScalarMapOnField",
403 aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
404 if aPrsObj is None : print "Error"
406 theView.DisplayOnly(aPrsObj)
408 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
409 aPictureName = re.sub("\s+","_", aPictureName);
410 theView.SavePicture(aPictureName)
411 aVISUObjList.append(aPrsObj)
413 if HasValue(thePrsTypeList,VISU.TISOSURFACE) :
414 print " Creating IsoSurfacesOnField",
415 aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
416 if aPrsObj is None : print "Error"
418 theView.DisplayOnly(aPrsObj)
420 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
421 aPictureName = re.sub("\s+","_", aPictureName);
422 theView.SavePicture(aPictureName)
423 aVISUObjList.append(aPrsObj)
425 if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
426 print " Creating CutPlanesOnField",
427 aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
428 if aPrsObj is None : print "Error"
430 aPrsObj.SetOrientationType(VISU.CutPlanes.ZX)
431 theView.DisplayOnly(aPrsObj)
433 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
434 aPictureName = re.sub("\s+","_", aPictureName)
435 theView.SavePicture(aPictureName)
436 aVISUObjList.append(aPrsObj)
438 if HasValue(thePrsTypeList,VISU.TCUTLINES) :
439 print " Creating CutLinesOnField",
440 aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
441 if aPrsObj is None : print "Error"
443 aPrsObj.SetOrientationType(VISU.CutPlanes.XY)
444 aPrsObj.SetOrientationType2(VISU.CutPlanes.ZX)
445 theView.DisplayOnly(aPrsObj)
447 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
448 aPictureName = re.sub("\s+","_", aPictureName)
449 theView.SavePicture(aPictureName)
450 aVISUObjList.append(aPrsObj)
452 aNumComponent = atoi(aMap["myNumComponent"])
453 if aNumComponent > 1 :
454 if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) :
455 print " Creating DeformedShapeOnField",
456 aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
457 if aPrsObj is None : print "Error"
459 theView.DisplayOnly(aPrsObj)
461 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
462 aPictureName = re.sub("\s+","_", aPictureName)
463 theView.SavePicture(aPictureName)
464 aVISUObjList.append(aPrsObj)
466 if HasValue(thePrsTypeList,VISU.TVECTORS) :
467 print " Creating VectorsOnField",
468 aPrsObj = theVisu.VectorsOnField(theResult,aMeshNamePic,anEntity,aFieldName,aTimeStampId)
469 if aPrsObj is None : print "Error"
471 theView.DisplayOnly(aPrsObj)
473 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
474 aPictureName = re.sub("\s+","_", aPictureName)
475 theView.SavePicture(aPictureName)
476 aVISUObjList.append(aPrsObj)
478 if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
479 print " Creating StreamLinesOnField",
480 aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
481 if aPrsObj is None : print "Error"
483 theView.DisplayOnly(aPrsObj)
485 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
486 aPictureName = re.sub("\s+","_", aPictureName)
487 theView.SavePicture(aPictureName)
488 aVISUObjList.append(aPrsObj)
493 def generateName(prefix = None):
495 int = whrandom.randint(1,1000);
497 return "Study" + str(int)
499 return prefix + str(int)
503 # ----------------------
505 # ----------------------
506 def try_mesh_parameters(theMeshPattern):
508 if theMeshPattern is None : return aResult ;
509 theMeshPattern = theMeshPattern._narrow(VISU.Mesh)
510 if theMeshPattern is None : return aResult ;
512 aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
513 import copy; import os;
515 aNewMesh = copy.deepcopy(theMeshPattern);
516 aNewMesh.SetPresentationType(ind)
517 aResult.append(aNewMesh)
522 # ----------------------------
524 # ----------------------------
526 def try_scalarmap_parameters(thePattern, dump = 0):
528 if thePattern is None : return None
530 SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
534 anObj = thePattern#copy.deepcopy(thePattern);
535 #ind = random.randint(1,2)
537 #try incorrect value deliberately (but allowed by idl description)
538 #try SetScalarMode(long)
539 mode = random.randint(-100000,100000); #incorrect value deliberately
541 #correct value of ScalarMode
542 mode = random.randint(0, 3)
544 if dump : print "\tSetScalarMode(" + str(mode) +")"
545 anObj.SetScalarMode(mode)
548 scal = random.randint(0,1)
549 if dump : print "\tSetScaling(" + str(SCALING[scal]) +")"
550 anObj.SetScaling(SCALING[scal])
554 alfa = random.random()*random.randint(-100000,100000)
555 betta = random.random()*random.randint(-100000,100000)
556 aMin = alfa; aMax = betta
559 aPMin = thePattern.GetMin()
560 aPMax = thePattern.GetMax()
562 alfa = random.random()%0.5
563 betta = random.random()%0.5
564 aMin = alfa*aLen*random.randint(-1,1) + aPMin
565 aMax = betta*aLen*random.randint(-1,1) + aPMax
566 if dump : print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
567 anObj.SetRange(aMin, aMax)
571 X=random.random()*random.randint(-100000,100000)
572 Y=random.random()*random.randint(-100000,100000)
576 if dump : print "SetPosition("+ str(X) + ", " + str(Y) + " )"
577 anObj.SetPosition(X, Y)
579 # --- SCALAR BAR SIZE ---
581 aWidth=random.random()*random.randint(-100000,100000)
582 aHeight=random.random()*random.randint(-100000,100000)
584 aWidth=random.random()
585 aHeight=random.random()
586 if dump : print " SCALAR BAR Width = " + str(aWidth) + " Height = ", str(aHeight)
587 anObj.SetSize(aWidth, aHeight)
592 def dump_scalarmap_parameters(anObj):
594 print "\tGetScalarMode() = " + str(anObj.GetScalarMode())
595 print "\tGetScaling() = " + str(anObj.GetScaling())
596 print "\tGetMin() = " + str(anObj.GetMin()) + " GetMax() = " + str (anObj.GetMax())
597 print "\tGetOrientation() = " + str(anObj.GetOrientation())
598 print "\tGetPosX() = ", str(anObj.GetPosX()) + " GetPosY() = ", str(anObj.GetPosY())
599 print "\tGetWidth() = ", str ( anObj.GetWidth()) + " GetHeight() = " + str(anObj.GetHeight())
601 # ----------------------
603 # ----------------------
604 def try_deformedshape_parameters(thePattern) :
606 if thePattern is None : return None
610 anObj = try_scalarmap_parameters(thePattern)
614 anObj.SetScale( random.random()*random.randint(-100000, 100000))
616 anObj.SetScale( anObj.GetScale()*random.random())
621 def dump_deformedshape_parameters(theObject):
622 dump_scalarmap_parameters(theObject)
623 print "GetScale() = ", theObject.GetScale()
625 # ----------------------
627 # ----------------------
628 def try_cutplanes_parameters(thePattern) :
630 if thePattern is None : return aList
634 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
636 ind = random.randint(1,2)
637 anObj = try_scalarmap_parameters(thePattern)
639 # --- ORIENTATION ---
640 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
642 # --- NUMBER OF PLANES ---
643 if ind%2 : anObj.SetNbPlanes(random.randint(-40,40))
644 else : anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
646 # --- DISPLACEMENT ---
647 anObj.SetDisplacement(random.randint(-100000,100000))
649 # --- PLANE POSITION ---
651 PlaneNb = random.randint(-100000,100000) #incorrect value is possible
652 else : PlaneNb = random.randint(0, anObj.GetNbPlanes())
654 anObj.SetPlanePosition(PlaneNb, random.random()*random.randint(-100000,100000))
656 # --- SET DEFAULT ---
657 anObj.SetDefault(PlaneNb)
659 # --- SET X,Y,Z ROTATION ---
661 angle1 = random.random()*random.randint(-100000,100000)
662 angle2 = random.random()*random.randint(-100000,100000)
664 angle1 = random.random()*3.14
665 angle2 = random.random()*3.14
667 anObj.SetRotateX(angle1)
668 anObj.SetRotateY(angle2)
672 def dump_cutplanes_parameters(theObject):
673 dump_saclarmap_parameters(theObject)
675 print "GetOrientationType = " + str(theObject.GetOrientationType())
676 PlanesNb = theObject.GetNbPlanes()
677 print "GetNbPlanes() = ", str(PlanesNb)
678 for i in range(0,PlanesNb+1):
679 if theObject.IsDefault(i) :
680 print "Default plane : "+str(i); break
681 print "GetPlanePosition(" + str(i) + ") = ", theObject.GetPlanePosition(i)
682 print "GetDisplacement() = ", str(theObject.GetDisplacement())
683 print "GetRotateX() = ", str(theObject.GetRotateX())
684 print "GetRotateY() = ", str(theObject.GetRotateY())
685 print "GetRotateZ() = ", str(theObject.GetRotateZ())
687 # ----------------------
689 # ----------------------
690 def try_cutlines_parameters(thePattern):
692 if thePattern is None : return None
696 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
697 ind = random.randint(1,2)
698 anObj = try_scalarmap_parameters(thePattern)
700 # --- ORIENTATION ---
701 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
702 anObj.SetOrientationType2(ORIENT[random.randint(0,2)])
704 # --- Base Plane Position ---
705 anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
707 # --- NUMBER OF LINES ---
709 anObj.SetNbLines(random.randint(-5, 50))
712 anObj.SetRotateX(random.randint(-100,100)*random.random())
713 anObj.SetRotateX2(random.randint(-100,100)*random.random())
714 anObj.SetRotateY(random.randint(-100,100)*random.random())
715 anObj.SetRotateY2(random.randint(-100,100)*random.random())
719 def dump_cutlines_parameters(theObject):
720 dump_scalarmap_parameters(theObject)
722 print "GetOrientationType() = " + str(theObject.GetOrientationType())
723 print "GetOrientationType2() = " + str(theObject.GetOrientationType2())
724 print "GetBasePlanePosition() = "+ str(theObject.GetBasePlanePosition())
725 print "GetNbLines() = " + str(theObject.GetNbLines())
726 print "GetRotateX() = ", str(theObject.GetRotateX())
727 print "GetRotateX2() = ", str(theObject.GetRotateX2())
728 print "GetRotateY() = ", str(theObject.GetRotateY())
729 print "GetRotateY2() = ", str(theObject.GetRotateY2())
731 # ----------------------
733 # ----------------------
734 def try_streamlines_parameters(thePattern):
736 if thePattern is None : return None
740 DIRECTION = [VISU.StreamLines.FORWARD, VISU.StreamLines.BACKWARD, VISU.StreamLines.BOTH]
742 ind = random.randint(1,2)
743 anObj = (try_deformedshape_parameters(thePattern))[0]
746 anObj.SetDirection(DIRECTION[random.randint(0,2)])
748 # --- STEP LENGTH ---
749 if ind%2 : anObj.SetStepLength(random.random()*random.randint(-1000,1000))
751 aLen = anObj.GetMax() - anObj.GetMin()
752 anObj.SetStepLength(aLen/random.randint(1,100))
754 # --- PROPAGATION TIME ---
755 anObj.SetPropagationTime(random.random()*random.randint(1,100))
757 # --- INTEGRATION STEP ---
759 anObj.SetIntegrationStep(random.random()*random.randint(-1000,1000))
761 anObj.SetIntegrationStep(random.random())
764 anObj.SetUsedPoints(random.random()*random.randint(-10000,10000))
768 def dump_streamlines_parameters(theObject):
770 dump_deformedshape_parameters(theObject)
772 print "GetDirection() = " + str(theObject.GetDirection())
773 print "GetStepLength() = " + str(theObject.GetStepLength())
774 print "GetPropagationTime() =" + str(theObject.GetPropagationTime())
775 print "GetIntegrationStep() =" + str(theObject.GetIntegrationStep())
776 print "GetUsedPoints() =" + str(theObject.GetUsedPoints())
778 # ----------------------
780 # ----------------------
781 def try_vectors_parameters(thePattern, theNum):
783 if thePattern is None : return None
786 GLIPH_TYPE = [VISU.Vectors.ARROW, VISU.Vectors.CONE2, VISU.Vectors.CONE6, VISU.Vectors.NONE]
787 GLIPH_POS = [VISU.Vectors.CENTER, VISU.Vectors.TAIL, VISU.Vectors.HEAD]
788 ind = random.randint(1,2)
789 anObj = (try_deformedshape_parameters(thePattern))[0]
793 anObj.SetLineWidth(random.random()*random.randint(-10000,10000))
795 anObj.SetLineWidth(random.randint(1, 10))
798 anObj.SetGlyphType(GLIPH_TYPE[random.randint(0, len(GLIPH_TYPE)-1)])
801 anObj.SetGlyphPos(GLIPH_POS[random.randint(0, len(GLIPH_POS)-1)])
805 def dump_vetctors_parameters(theObject):
807 dump_deformedshape_parameters(theObject)
809 print "GetLineWidth() = " +str(theObject.GetLineWidth())
810 print "GetGlyphType() = " +str(theObject.GetGlyphType())
811 print "GetGlyphPos() = " +str(theObject.GetGlyphPos())
814 # ----------------------
816 # ----------------------
818 def try_isosurfaces_parameters(thePattern) :
819 if thePattern is None : return None
823 anObj = try_scalarmap_parameters(thePattern)
824 ind = random.randint(1,2)
825 # --- SURFACES NUMBER ---
827 anObj.SetNbSurfaces(random.randint(-100000,100000))
829 anObj.SetNbSurfaces(random.randint(1, 50))
833 def dump_isosurfaces_parameters(theObject):
835 dump_scalarmap_parameters(theObject)
836 print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())