1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 CEA/DEN, EDF R&D
12 from time import sleep
17 from omniORB import CORBA
19 from time import sleep
22 myNamingService = None
23 myLifeCycleCORBA = None
24 myNamingService = None
25 myLocalStudyManager = None
31 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
32 global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
33 global mySession, myLocalVisu, myDelay
36 myNamingService = theNamingService
37 myLifeCycleCORBA = theLifeCycleCORBA
38 myLocalStudyManager = theStudyManager
39 mySession = myNamingService.Resolve("/Kernel/Session")
40 mySession.GetInterface()
43 myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Visu")
44 myLocalStudy = theStudy
45 myLocalVisu.SetCurrentStudy(myLocalStudy)
48 def StrToMap(theString) :
49 aPairList = split(theString,";")
52 for i in range(iEnd) :
53 aPair = split(aPairList[i],"=")
54 aMap[aPair[0]] = aPair[1]
57 def IntToEntity(theInt) :
68 def HasValue(theList, theValue) :
70 return theList.index(theValue) + 1
71 except StandardError, e :
74 def CreateStudyForMed(theVisu, theFileName) :
75 print "CreateStudyForMed ", theFileName,
76 if os.path.isfile(theFileName) :
77 if os.path.splitext(theFileName)[1] == '.med' :
79 aStudyName = os.path.basename(theFileName)
80 aStudyName = os.path.splitext(aStudyName)[0]
81 aStudyName = generateName(aStudyName)
82 print "myLocalStudyManager.NewStudy -", aStudyName, "...",
83 aStudy = myLocalStudyManager.NewStudy(aStudyName)
84 if aStudy is None : raise RuntimeError, "Error"
87 print "CreateStudyForMed - Creating a 3D viewer...",
88 theVisu.SetCurrentStudy(aStudy)
89 myViewManager = theVisu.GetViewManager()
90 if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager"
91 myView = myViewManager.Create3DView()
92 if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView"
96 return [aStudy, myViewManager, myView]
97 raise RuntimeError, "Error: There is no shuch file."
99 def getMedObjectFromStudy(theStudy = myLocalStudy):
101 theStudy = myLocalStudy
102 mySO = theStudy.FindObject("Objet MED")
103 anAttr = mySO.FindAttribute("AttributeIOR")[1]
104 obj = myORB.string_to_object(anAttr.Value())
105 myObj = obj._narrow(SALOME_MED.MED)
108 def getMedSObject(theStudy = myLocalStudy ):
109 return theStudy.FindObject("Objet MED")
111 def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
113 theStudy = myLocalStudy
114 mySO = theStudy.FindObject("MEDFIELD")
116 raise Runtime, "getFieldObjectFromStudy mySO is None"
117 mysub = mySO.FindSubObject(number)[1]
119 mysubsub = mysub.FindSubObject(subnumber)[1]
121 Builder = theStudy.NewBuilder()
122 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
123 obj = myORB.string_to_object(anAttr.Value())
124 myObj = obj._narrow(SALOME_MED.FIELDINT)
126 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
129 print "ERROR: No Field Object stored in this Study"
132 def SObjectToObject(theSObject) :
134 if theSObject is None :
135 print "SObjectToObject : argument is None"
137 res,Attr = theSObject.FindAttribute("AttributeIOR")
138 if (res != 0) and (Attr is not None) :
139 anIOR = Attr._narrow(SALOMEDS.AttributeIOR);
140 aValue = anIOR.Value();
141 if(len(aValue) != 0) :
142 anObj = myORB.string_to_object(aValue);
144 print "SObjectToObject - IOR = ''"
147 def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
149 global myLifeCycleCORBA
150 print "lcc.FindOrLoadComponent...",
151 aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "Med")
152 if aMedComp is None : print "Error"
155 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
157 print "aMedComp.readStructFileWithFieldType...",
158 aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
159 aMedSObj = getMedSObject(myLocalStudy)
160 if aMedSObj is None : raise RuntimeError, "Error"
163 print "theVisu.ImportMed...",
164 aResult = theVisu.ImportMed(aMedSObj)
165 if aResult is None : raise RuntimeError, "Error"
167 aVISUObjList.append(aResult)
168 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
170 aFolderIter = myLocalStudy.NewChildIterator(aMedSObj);
171 while aFolderIter.More() :
172 aFolderSObj = aFolderIter.Value()
174 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
175 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
176 aFolderName = anAttr.Value()
177 print " ", aFolderName
179 if aFolderName == 'MEDMESH' :
180 aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj);
181 while aMeshIter.More() :
182 aMeshSObj = aMeshIter.Value()
184 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
185 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
186 aMeshName = anAttr.Value()
189 aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj);
190 while aSupportIter.More() :
191 aSupportSObj = aSupportIter.Value()
193 anAttr = aSupportSObj.FindAttribute("AttributeName")[1]
194 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
195 aSupportName = anAttr.Value()
196 print " ", aSupportName
198 if aFolderName == 'MEDFIELD' :
199 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
200 while aFieldIter.More() :
201 aFieldSObj = aFieldIter.Value()
203 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
204 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
205 aFieldName = anAttr.Value()
206 print " ", aFieldName
208 print "theVisu.ImportMed...",
209 aResult = theVisu.ImportMed(aFieldSObj)
210 if aResult is None : raise RuntimeError, "Error"
212 aVISUObjList.append(aResult)
213 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
215 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
216 if aTimeStampIter.More() :
217 aTimeStampIter.Next()
218 while aTimeStampIter.More() :
219 aTimeStampSObj = aTimeStampIter.Value()
220 aTimeStampIter.Next()
221 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
222 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
223 aTimeStampName = anAttr.Value()
224 print " ", aTimeStampName
226 print "theVisu.ImportMed...",
227 aMedField = SObjectToObject(aTimeStampSObj)
228 aResult = theVisu.ImportMedFiled(aMedField)
229 if aResult is None : raise RuntimeError, "Error"
231 aVISUObjList.append(aResult)
232 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
236 # except Exception, e:
239 def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
241 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
243 print "theVisu.ImportMed..."
244 aResult = theVisu.ImportFile(theFileName)
245 if aResult is None : raise RuntimeError, "Error"
248 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
252 # except Exception, e:
255 def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) :
257 print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
258 myLocalStudy = theVisu.GetCurrentStudy()
259 aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
260 if aSObj is None : raise RuntimeError, "Error"
262 aMeshIter = myLocalStudy.NewChildIterator(aSObj);
263 while aMeshIter.More() :
264 aMeshSObj = aMeshIter.Value()
266 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
268 aMeshSObj = aMeshIter.Value()
270 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
271 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
272 aMeshName = anAttr.Value()
273 aMeshNamePic = re.sub(".","_",aMeshName)
276 aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj);
277 while aFolderIter.More() :
278 aFolderSObj = aFolderIter.Value()
280 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
281 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
282 aFolderName = anAttr.Value()
283 print " ", aFolderName
285 if aFolderName == 'Families' :
286 anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj);
287 while anEntityIter.More() :
288 anEntitySObj = anEntityIter.Value()
290 anAttr = anEntitySObj.FindAttribute("AttributeName")[1]
291 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
292 anEntityName = anAttr.Value()
295 if anEntityName == 'onNodes' :
298 if anEntityName == 'onEdges' :
301 if anEntityName == 'onFaces' :
304 if anEntityName == 'onCells' :
308 if HasValue(thePrsTypeList,VISU.TMESH) :
309 print " ", anEntityName, aMeshName,
310 aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
311 if aMesh is None : print "Error"
313 theView.DisplayOnly(aMesh)
315 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
316 aPictureName = re.sub("\s+","_", aPictureName);
317 theView.SavePicture(aPictureName)
318 aVISUObjList.append(aMesh)
320 anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
321 while anFamilyIter.More() :
322 aFamilySObj = anFamilyIter.Value()
324 anAttr = aFamilySObj.FindAttribute("AttributeName")[1]
325 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
326 anFamilyName = anAttr.Value()
327 if HasValue(thePrsTypeList,VISU.TMESH) :
328 print " ", anFamilyName,
329 aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
330 if aMesh is None : print "Error"
332 theView.DisplayOnly(aMesh)
334 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
335 aPictureName = re.sub("\s+","_", aPictureName);
336 theView.SavePicture(aPictureName)
337 aVISUObjList.append(aMesh)
339 if aFolderName == 'Groups' :
340 aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
341 while aGroupIter.More() :
342 aGroupSObj = aGroupIter.Value()
344 anAttr = aGroupSObj.FindAttribute("AttributeName")[1]
345 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
346 aGroupName = anAttr.Value()
347 if HasValue(thePrsTypeList,VISU.TMESH) :
348 print " ", aGroupName,
349 aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
350 if aMesh is None : print "Error"
352 theView.DisplayOnly(aMesh)
354 aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
355 aPictureName = re.sub("\s+","_", aPictureName);
356 theView.SavePicture(aPictureName)
357 aVISUObjList.append(aMesh)
359 if aFolderName == 'Fields' :
360 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
361 while aFieldIter.More() :
362 aFieldSObj = aFieldIter.Value()
364 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
365 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
366 aFieldName = anAttr.Value()
367 print " ", aFieldName
369 anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]
370 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
371 aFieldComment = anAttr.Value()
372 aMap = StrToMap(aFieldComment)
374 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
375 if aTimeStampIter.More() :
376 aTimeStampIter.Next()
377 while aTimeStampIter.More() :
378 aTimeStampSObj = aTimeStampIter.Value()
379 aTimeStampIter.Next()
380 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
381 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
382 aTimeStampName = anAttr.Value()
383 print " ", aTimeStampName
385 anAttr = aTimeStampSObj.FindAttribute("AttributeComment")[1]
386 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
387 aTimeStampComment = anAttr.Value()
388 aMap = StrToMap(aTimeStampComment)
389 aMeshName = aMap["myMeshName"]
390 aFieldName = aMap["myFieldName"]
391 aTimeStampId = atoi(aMap["myTimeStampId"])
392 anEntity = IntToEntity(aMap["myEntityId"])
393 anEntityId = str(aMap["myEntityId"]);
394 #print aMeshName, aFieldName, anEntity, aTimeStampId
395 if HasValue(thePrsTypeList,VISU.TSCALARMAP) :
396 print " Creating ScalarMapOnField",
397 aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
398 if aPrsObj is None : print "Error"
400 theView.DisplayOnly(aPrsObj)
402 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
403 aPictureName = re.sub("\s+","_", aPictureName);
404 theView.SavePicture(aPictureName)
405 aVISUObjList.append(aPrsObj)
407 if HasValue(thePrsTypeList,VISU.TISOSURFACE) :
408 print " Creating IsoSurfacesOnField",
409 aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
410 if aPrsObj is None : print "Error"
412 theView.DisplayOnly(aPrsObj)
414 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
415 aPictureName = re.sub("\s+","_", aPictureName);
416 theView.SavePicture(aPictureName)
417 aVISUObjList.append(aPrsObj)
419 if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
420 print " Creating CutPlanesOnField",
421 aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
422 if aPrsObj is None : print "Error"
424 aPrsObj.SetOrientationType(VISU.CutPlanes.ZX)
425 theView.DisplayOnly(aPrsObj)
427 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
428 aPictureName = re.sub("\s+","_", aPictureName)
429 theView.SavePicture(aPictureName)
430 aVISUObjList.append(aPrsObj)
432 if HasValue(thePrsTypeList,VISU.TCUTLINES) :
433 print " Creating CutLinesOnField",
434 aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
435 if aPrsObj is None : print "Error"
437 aPrsObj.SetOrientationType(VISU.CutPlanes.XY)
438 aPrsObj.SetOrientationType2(VISU.CutPlanes.ZX)
439 theView.DisplayOnly(aPrsObj)
441 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
442 aPictureName = re.sub("\s+","_", aPictureName)
443 theView.SavePicture(aPictureName)
444 aVISUObjList.append(aPrsObj)
446 aNumComponent = atoi(aMap["myNumComponent"])
447 if aNumComponent > 1 :
448 if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) :
449 print " Creating DeformedShapeOnField",
450 aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
451 if aPrsObj is None : print "Error"
453 theView.DisplayOnly(aPrsObj)
455 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
456 aPictureName = re.sub("\s+","_", aPictureName)
457 theView.SavePicture(aPictureName)
458 aVISUObjList.append(aPrsObj)
460 if HasValue(thePrsTypeList,VISU.TVECTORS) :
461 print " Creating VectorsOnField",
462 aPrsObj = theVisu.VectorsOnField(theResult,aMeshNamePic,anEntity,aFieldName,aTimeStampId)
463 if aPrsObj is None : print "Error"
465 theView.DisplayOnly(aPrsObj)
467 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
468 aPictureName = re.sub("\s+","_", aPictureName)
469 theView.SavePicture(aPictureName)
470 aVISUObjList.append(aPrsObj)
472 if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
473 print " Creating StreamLinesOnField",
474 aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
475 if aPrsObj is None : print "Error"
477 theView.DisplayOnly(aPrsObj)
479 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
480 aPictureName = re.sub("\s+","_", aPictureName)
481 theView.SavePicture(aPictureName)
482 aVISUObjList.append(aPrsObj)
487 def generateName(prefix = None):
489 int = whrandom.randint(1,1000);
491 return "Study" + str(int)
493 return prefix + str(int)
497 # ----------------------
499 # ----------------------
500 def try_mesh_parameters(theMeshPattern):
502 if theMeshPattern is None : return aResult ;
503 theMeshPattern = theMeshPattern._narrow(VISU.Mesh)
504 if theMeshPattern is None : return aResult ;
506 aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
507 import copy; import os;
509 aNewMesh = copy.deepcopy(theMeshPattern);
510 aNewMesh.SetPresentationType(ind)
511 aResult.append(aNewMesh)
516 # ----------------------------
518 # ----------------------------
520 def try_scalarmap_parameters(thePattern, dump = 0):
522 if thePattern is None : return None
524 SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
528 anObj = thePattern#copy.deepcopy(thePattern);
529 #ind = random.randint(1,2)
531 #try incorrect value deliberately (but allowed by idl description)
532 #try SetScalarMode(long)
533 mode = random.randint(-100000,100000); #incorrect value deliberately
535 #correct value of ScalarMode
536 mode = random.randint(0, 3)
538 if dump : print "\tSetScalarMode(" + str(mode) +")"
539 anObj.SetScalarMode(mode)
542 scal = random.randint(0,1)
543 if dump : print "\tSetScaling(" + str(SCALING[scal]) +")"
544 anObj.SetScaling(SCALING[scal])
548 alfa = random.random()*random.randint(-100000,100000)
549 betta = random.random()*random.randint(-100000,100000)
550 aMin = alfa; aMax = betta
553 aPMin = thePattern.GetMin()
554 aPMax = thePattern.GetMax()
556 alfa = random.random()%0.5
557 betta = random.random()%0.5
558 aMin = alfa*aLen*random.randint(-1,1) + aPMin
559 aMax = betta*aLen*random.randint(-1,1) + aPMax
560 if dump : print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
561 anObj.SetRange(aMin, aMax)
565 X=random.random()*random.randint(-100000,100000)
566 Y=random.random()*random.randint(-100000,100000)
570 if dump : print "SetPosition("+ str(X) + ", " + str(Y) + " )"
571 anObj.SetPosition(X, Y)
573 # --- SCALAR BAR SIZE ---
575 aWidth=random.random()*random.randint(-100000,100000)
576 aHeight=random.random()*random.randint(-100000,100000)
578 aWidth=random.random()
579 aHeight=random.random()
580 if dump : print " SCALAR BAR Width = " + str(aWidth) + " Height = ", str(aHeight)
581 anObj.SetSize(aWidth, aHeight)
586 def dump_scalarmap_parameters(anObj):
588 print "\tGetScalarMode() = " + str(anObj.GetScalarMode())
589 print "\tGetScaling() = " + str(anObj.GetScaling())
590 print "\tGetMin() = " + str(anObj.GetMin()) + " GetMax() = " + str (anObj.GetMax())
591 print "\tGetOrientation() = " + str(anObj.GetOrientation())
592 print "\tGetPosX() = ", str(anObj.GetPosX()) + " GetPosY() = ", str(anObj.GetPosY())
593 print "\tGetWidth() = ", str ( anObj.GetWidth()) + " GetHeight() = " + str(anObj.GetHeight())
595 # ----------------------
597 # ----------------------
598 def try_deformedshape_parameters(thePattern) :
600 if thePattern is None : return None
604 anObj = try_scalarmap_parameters(thePattern)
608 anObj.SetScale( random.random()*random.randint(-100000, 100000))
610 anObj.SetScale( anObj.GetScale()*random.random())
615 def dump_deformedshape_parameters(theObject):
616 dump_scalarmap_parameters(theObject)
617 print "GetScale() = ", theObject.GetScale()
619 # ----------------------
621 # ----------------------
622 def try_cutplanes_parameters(thePattern) :
624 if thePattern is None : return aList
628 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
630 ind = random.randint(1,2)
631 anObj = try_scalarmap_parameters(thePattern)
633 # --- ORIENTATION ---
634 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
636 # --- NUMBER OF PLANES ---
637 if ind%2 : anObj.SetNbPlanes(random.randint(-40,40))
638 else : anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
640 # --- DISPLACEMENT ---
641 anObj.SetDisplacement(random.randint(-100000,100000))
643 # --- PLANE POSITION ---
645 PlaneNb = random.randint(-100000,100000) #incorrect value is possible
646 else : PlaneNb = random.randint(0, anObj.GetNbPlanes())
648 anObj.SetPlanePosition(PlaneNb, random.random()*random.randint(-100000,100000))
650 # --- SET DEFAULT ---
651 anObj.SetDefault(PlaneNb)
653 # --- SET X,Y,Z ROTATION ---
655 angle1 = random.random()*random.randint(-100000,100000)
656 angle2 = random.random()*random.randint(-100000,100000)
658 angle1 = random.random()*3.14
659 angle2 = random.random()*3.14
661 anObj.SetRotateX(angle1)
662 anObj.SetRotateY(angle2)
666 def dump_cutplanes_parameters(theObject):
667 dump_saclarmap_parameters(theObject)
669 print "GetOrientationType = " + str(theObject.GetOrientationType())
670 PlanesNb = theObject.GetNbPlanes()
671 print "GetNbPlanes() = ", str(PlanesNb)
672 for i in range(0,PlanesNb+1):
673 if theObject.IsDefault(i) :
674 print "Default plane : "+str(i); break
675 print "GetPlanePosition(" + str(i) + ") = ", theObject.GetPlanePosition(i)
676 print "GetDisplacement() = ", str(theObject.GetDisplacement())
677 print "GetRotateX() = ", str(theObject.GetRotateX())
678 print "GetRotateY() = ", str(theObject.GetRotateY())
679 print "GetRotateZ() = ", str(theObject.GetRotateZ())
681 # ----------------------
683 # ----------------------
684 def try_cutlines_parameters(thePattern):
686 if thePattern is None : return None
690 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
691 ind = random.randint(1,2)
692 anObj = try_scalarmap_parameters(thePattern)
694 # --- ORIENTATION ---
695 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
696 anObj.SetOrientationType2(ORIENT[random.randint(0,2)])
698 # --- Base Plane Position ---
699 anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
701 # --- NUMBER OF LINES ---
703 anObj.SetNbLines(random.randint(-5, 50))
706 anObj.SetRotateX(random.randint(-100,100)*random.random())
707 anObj.SetRotateX2(random.randint(-100,100)*random.random())
708 anObj.SetRotateY(random.randint(-100,100)*random.random())
709 anObj.SetRotateY2(random.randint(-100,100)*random.random())
713 def dump_cutlines_parameters(theObject):
714 dump_scalarmap_parameters(theObject)
716 print "GetOrientationType() = " + str(theObject.GetOrientationType())
717 print "GetOrientationType2() = " + str(theObject.GetOrientationType2())
718 print "GetBasePlanePosition() = "+ str(theObject.GetBasePlanePosition())
719 print "GetNbLines() = " + str(theObject.GetNbLines())
720 print "GetRotateX() = ", str(theObject.GetRotateX())
721 print "GetRotateX2() = ", str(theObject.GetRotateX2())
722 print "GetRotateY() = ", str(theObject.GetRotateY())
723 print "GetRotateY2() = ", str(theObject.GetRotateY2())
725 # ----------------------
727 # ----------------------
728 def try_streamlines_parameters(thePattern):
730 if thePattern is None : return None
734 DIRECTION = [VISU.StreamLines.FORWARD, VISU.StreamLines.BACKWARD, VISU.StreamLines.BOTH]
736 ind = random.randint(1,2)
737 anObj = (try_deformedshape_parameters(thePattern))[0]
740 anObj.SetDirection(DIRECTION[random.randint(0,2)])
742 # --- STEP LENGTH ---
743 if ind%2 : anObj.SetStepLength(random.random()*random.randint(-1000,1000))
745 aLen = anObj.GetMax() - anObj.GetMin()
746 anObj.SetStepLength(aLen/random.randint(1,100))
748 # --- PROPAGATION TIME ---
749 anObj.SetPropagationTime(random.random()*random.randint(1,100))
751 # --- INTEGRATION STEP ---
753 anObj.SetIntegrationStep(random.random()*random.randint(-1000,1000))
755 anObj.SetIntegrationStep(random.random())
758 anObj.SetUsedPoints(random.random()*random.randint(-10000,10000))
762 def dump_streamlines_parameters(theObject):
764 dump_deformedshape_parameters(theObject)
766 print "GetDirection() = " + str(theObject.GetDirection())
767 print "GetStepLength() = " + str(theObject.GetStepLength())
768 print "GetPropagationTime() =" + str(theObject.GetPropagationTime())
769 print "GetIntegrationStep() =" + str(theObject.GetIntegrationStep())
770 print "GetUsedPoints() =" + str(theObject.GetUsedPoints())
772 # ----------------------
774 # ----------------------
775 def try_vectors_parameters(thePattern, theNum):
777 if thePattern is None : return None
780 GLIPH_TYPE = [VISU.Vectors.ARROW, VISU.Vectors.CONE2, VISU.Vectors.CONE6, VISU.Vectors.NONE]
781 GLIPH_POS = [VISU.Vectors.CENTER, VISU.Vectors.TAIL, VISU.Vectors.HEAD]
782 ind = random.randint(1,2)
783 anObj = (try_deformedshape_parameters(thePattern))[0]
787 anObj.SetLineWidth(random.random()*random.randint(-10000,10000))
789 anObj.SetLineWidth(random.randint(1, 10))
792 anObj.SetGlyphType(GLIPH_TYPE[random.randint(0, len(GLIPH_TYPE)-1)])
795 anObj.SetGlyphPos(GLIPH_POS[random.randint(0, len(GLIPH_POS)-1)])
799 def dump_vetctors_parameters(theObject):
801 dump_deformedshape_parameters(theObject)
803 print "GetLineWidth() = " +str(theObject.GetLineWidth())
804 print "GetGlyphType() = " +str(theObject.GetGlyphType())
805 print "GetGlyphPos() = " +str(theObject.GetGlyphPos())
808 # ----------------------
810 # ----------------------
812 def try_isosurfaces_parameters(thePattern) :
813 if thePattern is None : return None
817 anObj = try_scalarmap_parameters(thePattern)
818 ind = random.randint(1,2)
819 # --- SURFACES NUMBER ---
821 anObj.SetNbSurfaces(random.randint(-100000,100000))
823 anObj.SetNbSurfaces(random.randint(1, 50))
827 def dump_isosurfaces_parameters(theObject):
829 dump_scalarmap_parameters(theObject)
830 print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())