1 # VISU VISU_SWIG : binding of C++ implementation and Python
3 # Copyright (C) 2003 CEA/DEN, EDF R&D
12 from time import sleep
19 from omniORB import CORBA
21 from time import sleep
24 myNamingService = None
25 myLifeCycleCORBA = None
26 myNamingService = None
27 myLocalStudyManager = None
33 def Initialize(theORB, theNamingService, theLifeCycleCORBA, theStudyManager, theStudy, theDelay) :
34 global myORB, myNamingService, myLifeCycleCORBA, myLocalStudyManager, myLocalStudy
35 global mySession, myLocalVisu, myDelay
38 myNamingService = theNamingService
39 myLifeCycleCORBA = theLifeCycleCORBA
40 myLocalStudyManager = theStudyManager
41 mySession = myNamingService.Resolve("/Kernel/Session")
42 mySession.GetInterface()
45 myLocalVisu = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "VISU")
46 myLocalStudy = theStudy
47 myLocalVisu.SetCurrentStudy(myLocalStudy)
50 def StrToMap(theString) :
51 aPairList = split(theString,";")
54 for i in range(iEnd) :
55 aPair = split(aPairList[i],"=")
56 aMap[aPair[0]] = aPair[1]
59 def IntToEntity(theInt) :
70 def HasValue(theList, theValue) :
72 return theList.index(theValue) + 1
73 except StandardError, e :
76 def CreateStudyForMed(theVisu, theFileName) :
77 print "CreateStudyForMed ", theFileName,
78 if os.path.isfile(theFileName) :
79 if os.path.splitext(theFileName)[1] == '.med' :
81 aStudyName = os.path.basename(theFileName)
82 aStudyName = os.path.splitext(aStudyName)[0]
83 aStudyName = generateName(aStudyName)
84 print "myLocalStudyManager.NewStudy -", aStudyName, "...",
85 aStudy = myLocalStudyManager.NewStudy(aStudyName)
86 if aStudy is None : raise RuntimeError, "Error"
89 print "CreateStudyForMed - Creating a 3D viewer...",
90 theVisu.SetCurrentStudy(aStudy)
91 myViewManager = theVisu.GetViewManager()
92 if myViewManager is None : raise RuntimeError, "Error - theVisu.GetViewManager"
93 myView = myViewManager.Create3DView()
94 if myView is None : raise RuntimeError, "Error - myViewManager.Create3DView"
98 return [aStudy, myViewManager, myView]
99 raise RuntimeError, "Error: There is no shuch file."
101 def getMedObjectFromStudy(theStudy = myLocalStudy):
103 theStudy = myLocalStudy
104 mySO = theStudy.FindObject("Objet MED")
105 anAttr = mySO.FindAttribute("AttributeIOR")[1]
106 obj = myORB.string_to_object(anAttr.Value())
107 myObj = obj._narrow(SALOME_MED.MED)
110 def getMedSObject(theStudy = myLocalStudy ):
111 return theStudy.FindObject("Objet MED")
113 def getFieldObjectFromStudy(number, subnumber, theStudy = myLocalStudy):
115 theStudy = myLocalStudy
116 mySO = theStudy.FindObject("MEDFIELD")
118 raise Runtime, "getFieldObjectFromStudy mySO is None"
119 mysub = mySO.FindSubObject(number)[1]
121 mysubsub = mysub.FindSubObject(subnumber)[1]
123 Builder = theStudy.NewBuilder()
124 anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR")
125 obj = myORB.string_to_object(anAttr.Value())
126 myObj = obj._narrow(SALOME_MED.FIELDINT)
128 myObj = obj._narrow(SALOME_MED.FIELDDOUBLE)
131 print "ERROR: No Field Object stored in this Study"
134 def SObjectToObject(theSObject) :
136 if theSObject is None :
137 print "SObjectToObject : argument is None"
139 res,Attr = theSObject.FindAttribute("AttributeIOR")
140 if (res != 0) and (Attr is not None) :
141 anIOR = Attr._narrow(SALOMEDS.AttributeIOR);
142 aValue = anIOR.Value();
143 if(len(aValue) != 0) :
144 anObj = myORB.string_to_object(aValue);
146 print "SObjectToObject - IOR = ''"
149 def CreatePrsForMed(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
151 global myLifeCycleCORBA
152 print "lcc.FindOrLoadComponent...",
153 aMedComp = myLifeCycleCORBA.FindOrLoadComponent("FactoryServer", "MED")
154 if aMedComp is None : print "Error"
157 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
159 print "aMedComp.readStructFileWithFieldType...",
160 aMedComp.readStructFileWithFieldType(theFileName,myLocalStudy._get_Name())
161 aMedSObj = getMedSObject(myLocalStudy)
162 if aMedSObj is None : raise RuntimeError, "Error"
165 print "theVisu.ImportMed...",
166 aResult = theVisu.ImportMed(aMedSObj)
167 if aResult is None : raise RuntimeError, "Error"
169 aVISUObjList.append(aResult)
170 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
172 aFolderIter = myLocalStudy.NewChildIterator(aMedSObj);
173 while aFolderIter.More() :
174 aFolderSObj = aFolderIter.Value()
176 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
177 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
178 aFolderName = anAttr.Value()
179 print " ", aFolderName
181 if aFolderName == 'MEDMESH' :
182 aMeshIter = myLocalStudy.NewChildIterator(aFolderSObj);
183 while aMeshIter.More() :
184 aMeshSObj = aMeshIter.Value()
186 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
187 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
188 aMeshName = anAttr.Value()
191 aSupportIter = myLocalStudy.NewChildIterator(aMeshSObj);
192 while aSupportIter.More() :
193 aSupportSObj = aSupportIter.Value()
195 anAttr = aSupportSObj.FindAttribute("AttributeName")[1]
196 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
197 aSupportName = anAttr.Value()
198 print " ", aSupportName
200 if aFolderName == 'MEDFIELD' :
201 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
202 while aFieldIter.More() :
203 aFieldSObj = aFieldIter.Value()
205 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
206 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
207 aFieldName = anAttr.Value()
208 print " ", aFieldName
210 print "theVisu.ImportMed...",
211 aResult = theVisu.ImportMed(aFieldSObj)
212 if aResult is None : raise RuntimeError, "Error"
214 aVISUObjList.append(aResult)
215 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
217 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
218 if aTimeStampIter.More() :
219 aTimeStampIter.Next()
220 while aTimeStampIter.More() :
221 aTimeStampSObj = aTimeStampIter.Value()
222 aTimeStampIter.Next()
223 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
224 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
225 aTimeStampName = anAttr.Value()
226 print " ", aTimeStampName
228 print "theVisu.ImportMed...",
229 aMedField = SObjectToObject(aTimeStampSObj)
230 aResult = theVisu.ImportMedFiled(aMedField)
231 if aResult is None : raise RuntimeError, "Error"
233 aVISUObjList.append(aResult)
234 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
238 # except Exception, e:
241 def CreatePrsForFile(theVisu, theFileName, thePrsTypeList, thePictureDir, thePictureExt) :
243 aVISUObjList = [myLocalStudy, myViewManager, myView] = CreateStudyForMed(theVisu, theFileName)
245 print "theVisu.ImportMed..."
246 aResult = theVisu.ImportFile(theFileName)
247 if aResult is None : raise RuntimeError, "Error"
250 aVISUObjList.extend(CreatePrsForResult(theVisu, aResult, myView, thePrsTypeList, thePictureDir, thePictureExt))
254 # except Exception, e:
257 def CreatePrsForResult(theVisu, theResult, theView, thePrsTypeList, thePictureDir, thePictureExt) :
259 print "CreatePrsForResult - myLocalStudy.FindObjectIOR...",
260 myLocalStudy = theVisu.GetCurrentStudy()
261 aSObj = myLocalStudy.FindObjectIOR(theResult.GetID())
262 if aSObj is None : raise RuntimeError, "Error"
264 aMeshIter = myLocalStudy.NewChildIterator(aSObj);
265 while aMeshIter.More() :
266 aMeshSObj = aMeshIter.Value()
268 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
270 aMeshSObj = aMeshIter.Value()
272 anAttr = aMeshSObj.FindAttribute("AttributeName")[1]
273 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
274 aMeshName = anAttr.Value()
275 aMeshNamePic = re.sub(".","_",aMeshName)
278 aFolderIter = myLocalStudy.NewChildIterator(aMeshSObj);
279 while aFolderIter.More() :
280 aFolderSObj = aFolderIter.Value()
282 anAttr = aFolderSObj.FindAttribute("AttributeName")[1]
283 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
284 aFolderName = anAttr.Value()
285 print " ", aFolderName
287 if aFolderName == 'Families' :
288 anEntityIter = myLocalStudy.NewChildIterator(aFolderSObj);
289 while anEntityIter.More() :
290 anEntitySObj = anEntityIter.Value()
292 anAttr = anEntitySObj.FindAttribute("AttributeName")[1]
293 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
294 anEntityName = anAttr.Value()
297 if anEntityName == 'onNodes' :
300 if anEntityName == 'onEdges' :
303 if anEntityName == 'onFaces' :
306 if anEntityName == 'onCells' :
310 if HasValue(thePrsTypeList,VISU.TMESH) :
311 print " ", anEntityName, aMeshName,
312 aMesh = theVisu.MeshOnEntity(theResult,aMeshName,anEntity)
313 if aMesh is None : print "Error"
315 theView.DisplayOnly(aMesh)
317 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "." + thePictureExt
318 aPictureName = re.sub("\s+","_", aPictureName);
319 theView.SavePicture(aPictureName)
320 aVISUObjList.append(aMesh)
322 anFamilyIter = myLocalStudy.NewChildIterator(anEntitySObj);
323 while anFamilyIter.More() :
324 aFamilySObj = anFamilyIter.Value()
326 anAttr = aFamilySObj.FindAttribute("AttributeName")[1]
327 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
328 anFamilyName = anAttr.Value()
329 if HasValue(thePrsTypeList,VISU.TMESH) :
330 print " ", anFamilyName,
331 aMesh = theVisu.FamilyMeshOnEntity(theResult,aMeshName,anEntity,anFamilyName)
332 if aMesh is None : print "Error"
334 theView.DisplayOnly(aMesh)
336 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + anFamilyName + "." + thePictureExt
337 aPictureName = re.sub("\s+","_", aPictureName);
338 theView.SavePicture(aPictureName)
339 aVISUObjList.append(aMesh)
341 if aFolderName == 'Groups' :
342 aGroupIter = myLocalStudy.NewChildIterator(aFolderSObj);
343 while aGroupIter.More() :
344 aGroupSObj = aGroupIter.Value()
346 anAttr = aGroupSObj.FindAttribute("AttributeName")[1]
347 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
348 aGroupName = anAttr.Value()
349 if HasValue(thePrsTypeList,VISU.TMESH) :
350 print " ", aGroupName,
351 aMesh = theVisu.GroupMesh(theResult,aMeshName,aGroupName)
352 if aMesh is None : print "Error"
354 theView.DisplayOnly(aMesh)
356 aPictureName = thePictureDir + aMeshNamePic + "_" + aGroupName + "." + thePictureExt
357 aPictureName = re.sub("\s+","_", aPictureName);
358 theView.SavePicture(aPictureName)
359 aVISUObjList.append(aMesh)
361 if aFolderName == 'Fields' :
362 aFieldIter = myLocalStudy.NewChildIterator(aFolderSObj);
363 while aFieldIter.More() :
364 aFieldSObj = aFieldIter.Value()
366 anAttr = aFieldSObj.FindAttribute("AttributeName")[1]
367 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
368 aFieldName = anAttr.Value()
369 print " ", aFieldName
371 anAttr = aFieldSObj.FindAttribute("AttributeComment")[1]
372 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
373 aFieldComment = anAttr.Value()
374 aMap = StrToMap(aFieldComment)
376 aTimeStampIter = myLocalStudy.NewChildIterator(aFieldSObj);
377 if aTimeStampIter.More() :
378 aTimeStampIter.Next()
379 while aTimeStampIter.More() :
380 aTimeStampSObj = aTimeStampIter.Value()
381 aTimeStampIter.Next()
382 anAttr = aTimeStampSObj.FindAttribute("AttributeName")[1]
383 anAttr = anAttr._narrow(SALOMEDS.AttributeName);
384 aTimeStampName = anAttr.Value()
385 print " ", aTimeStampName
387 anAttr = aTimeStampSObj.FindAttribute("AttributeComment")[1]
388 anAttr = anAttr._narrow(SALOMEDS.AttributeComment);
389 aTimeStampComment = anAttr.Value()
390 aMap = StrToMap(aTimeStampComment)
391 aMeshName = aMap["myMeshName"]
392 aFieldName = aMap["myFieldName"]
393 aTimeStampId = atoi(aMap["myTimeStampId"])
394 anEntity = IntToEntity(aMap["myEntityId"])
395 anEntityId = str(aMap["myEntityId"]);
396 #print aMeshName, aFieldName, anEntity, aTimeStampId
397 if HasValue(thePrsTypeList,VISU.TSCALARMAP) :
398 print " Creating ScalarMapOnField",
399 aPrsObj = theVisu.ScalarMapOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
400 if aPrsObj is None : print "Error"
402 theView.DisplayOnly(aPrsObj)
404 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSCALARMAP." + thePictureExt
405 aPictureName = re.sub("\s+","_", aPictureName);
406 theView.SavePicture(aPictureName)
407 aVISUObjList.append(aPrsObj)
409 if HasValue(thePrsTypeList,VISU.TISOSURFACE) :
410 print " Creating IsoSurfacesOnField",
411 aPrsObj = theVisu.IsoSurfacesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
412 if aPrsObj is None : print "Error"
414 theView.DisplayOnly(aPrsObj)
416 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TISOSURFACE." + thePictureExt
417 aPictureName = re.sub("\s+","_", aPictureName);
418 theView.SavePicture(aPictureName)
419 aVISUObjList.append(aPrsObj)
421 if HasValue(thePrsTypeList,VISU.TCUTPLANES) :
422 print " Creating CutPlanesOnField",
423 aPrsObj = theVisu.CutPlanesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
424 if aPrsObj is None : print "Error"
426 aPrsObj.SetOrientationType(VISU.CutPlanes.ZX)
427 theView.DisplayOnly(aPrsObj)
429 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTPLANES." + thePictureExt
430 aPictureName = re.sub("\s+","_", aPictureName)
431 theView.SavePicture(aPictureName)
432 aVISUObjList.append(aPrsObj)
434 if HasValue(thePrsTypeList,VISU.TCUTLINES) :
435 print " Creating CutLinesOnField",
436 aPrsObj = theVisu.CutLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
437 if aPrsObj is None : print "Error"
439 aPrsObj.SetOrientationType(VISU.CutPlanes.XY)
440 aPrsObj.SetOrientationType2(VISU.CutPlanes.ZX)
441 theView.DisplayOnly(aPrsObj)
443 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TCUTLINES." + thePictureExt
444 aPictureName = re.sub("\s+","_", aPictureName)
445 theView.SavePicture(aPictureName)
446 aVISUObjList.append(aPrsObj)
448 aNumComponent = atoi(aMap["myNumComponent"])
449 if aNumComponent > 1 :
450 if HasValue(thePrsTypeList,VISU.TDEFORMEDSHAPE) :
451 print " Creating DeformedShapeOnField",
452 aPrsObj = theVisu.DeformedShapeOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
453 if aPrsObj is None : print "Error"
455 theView.DisplayOnly(aPrsObj)
457 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TDEFORMEDSHAPE." + thePictureExt
458 aPictureName = re.sub("\s+","_", aPictureName)
459 theView.SavePicture(aPictureName)
460 aVISUObjList.append(aPrsObj)
462 if HasValue(thePrsTypeList,VISU.TVECTORS) :
463 print " Creating VectorsOnField",
464 aPrsObj = theVisu.VectorsOnField(theResult,aMeshNamePic,anEntity,aFieldName,aTimeStampId)
465 if aPrsObj is None : print "Error"
467 theView.DisplayOnly(aPrsObj)
469 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TVECTORS." + thePictureExt
470 aPictureName = re.sub("\s+","_", aPictureName)
471 theView.SavePicture(aPictureName)
472 aVISUObjList.append(aPrsObj)
474 if HasValue(thePrsTypeList,VISU.TSTREAMLINES) :
475 print " Creating StreamLinesOnField",
476 aPrsObj = theVisu.StreamLinesOnField(theResult,aMeshName,anEntity,aFieldName,aTimeStampId)
477 if aPrsObj is None : print "Error"
479 theView.DisplayOnly(aPrsObj)
481 aPictureName = thePictureDir + aMeshNamePic + "_" + anEntityId + "_" + aFieldName + "_" + str(aTimeStampId) + "_TSTREAMLINES." + thePictureExt
482 aPictureName = re.sub("\s+","_", aPictureName)
483 theView.SavePicture(aPictureName)
484 aVISUObjList.append(aPrsObj)
489 def generateName(prefix = None):
491 int = whrandom.randint(1,1000);
493 return "Study" + str(int)
495 return prefix + str(int)
499 # ----------------------
501 # ----------------------
502 def try_mesh_parameters(theMeshPattern):
504 if theMeshPattern is None : return aResult ;
505 theMeshPattern = theMeshPattern._narrow(VISU.Mesh)
506 if theMeshPattern is None : return aResult ;
508 aTYPES = [VISU.POINT, VISU.WIREFRAME, VISU.SHADED, VISU.INSIDEFRAME, VISU.SHRINK]
509 import copy; import os;
511 aNewMesh = copy.deepcopy(theMeshPattern);
512 aNewMesh.SetPresentationType(ind)
513 aResult.append(aNewMesh)
518 # ----------------------------
520 # ----------------------------
522 def try_scalarmap_parameters(thePattern, dump = 0):
524 if thePattern is None : return None
526 SCALING = [VISU.LINEAR, VISU.LOGARITHMIC]
530 anObj = thePattern#copy.deepcopy(thePattern);
531 #ind = random.randint(1,2)
533 #try incorrect value deliberately (but allowed by idl description)
534 #try SetScalarMode(long)
535 mode = random.randint(-100000,100000); #incorrect value deliberately
537 #correct value of ScalarMode
538 mode = random.randint(0, 3)
540 if dump : print "\tSetScalarMode(" + str(mode) +")"
541 anObj.SetScalarMode(mode)
544 scal = random.randint(0,1)
545 if dump : print "\tSetScaling(" + str(SCALING[scal]) +")"
546 anObj.SetScaling(SCALING[scal])
550 alfa = random.random()*random.randint(-100000,100000)
551 betta = random.random()*random.randint(-100000,100000)
552 aMin = alfa; aMax = betta
555 aPMin = thePattern.GetMin()
556 aPMax = thePattern.GetMax()
558 alfa = random.random()%0.5
559 betta = random.random()%0.5
560 aMin = alfa*aLen*random.randint(-1,1) + aPMin
561 aMax = betta*aLen*random.randint(-1,1) + aPMax
562 if dump : print "\tSetRange(" + str(aMin) + ", " + str(aMax) + ")"
563 anObj.SetRange(aMin, aMax)
567 X=random.random()*random.randint(-100000,100000)
568 Y=random.random()*random.randint(-100000,100000)
572 if dump : print "SetPosition("+ str(X) + ", " + str(Y) + " )"
573 anObj.SetPosition(X, Y)
575 # --- SCALAR BAR SIZE ---
577 aWidth=random.random()*random.randint(-100000,100000)
578 aHeight=random.random()*random.randint(-100000,100000)
580 aWidth=random.random()
581 aHeight=random.random()
582 if dump : print " SCALAR BAR Width = " + str(aWidth) + " Height = ", str(aHeight)
583 anObj.SetSize(aWidth, aHeight)
588 def dump_scalarmap_parameters(anObj):
590 print "\tGetScalarMode() = " + str(anObj.GetScalarMode())
591 print "\tGetScaling() = " + str(anObj.GetScaling())
592 print "\tGetMin() = " + str(anObj.GetMin()) + " GetMax() = " + str (anObj.GetMax())
593 print "\tGetOrientation() = " + str(anObj.GetOrientation())
594 print "\tGetPosX() = ", str(anObj.GetPosX()) + " GetPosY() = ", str(anObj.GetPosY())
595 print "\tGetWidth() = ", str ( anObj.GetWidth()) + " GetHeight() = " + str(anObj.GetHeight())
597 # ----------------------
599 # ----------------------
600 def try_deformedshape_parameters(thePattern) :
602 if thePattern is None : return None
606 anObj = try_scalarmap_parameters(thePattern)
610 anObj.SetScale( random.random()*random.randint(-100000, 100000))
612 anObj.SetScale( anObj.GetScale()*random.random())
617 def dump_deformedshape_parameters(theObject):
618 dump_scalarmap_parameters(theObject)
619 print "GetScale() = ", theObject.GetScale()
621 # ----------------------
623 # ----------------------
624 def try_cutplanes_parameters(thePattern) :
626 if thePattern is None : return aList
630 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
632 ind = random.randint(1,2)
633 anObj = try_scalarmap_parameters(thePattern)
635 # --- ORIENTATION ---
636 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
638 # --- NUMBER OF PLANES ---
639 if ind%2 : anObj.SetNbPlanes(random.randint(-40,40))
640 else : anObj.SetNbPlanes(random.randint(0,10)) #try behaivor if NbPlanes=0
642 # --- DISPLACEMENT ---
643 anObj.SetDisplacement(random.randint(-100000,100000))
645 # --- PLANE POSITION ---
647 PlaneNb = random.randint(-100000,100000) #incorrect value is possible
648 else : PlaneNb = random.randint(0, anObj.GetNbPlanes())
650 anObj.SetPlanePosition(PlaneNb, random.random()*random.randint(-100000,100000))
652 # --- SET DEFAULT ---
653 anObj.SetDefault(PlaneNb)
655 # --- SET X,Y,Z ROTATION ---
657 angle1 = random.random()*random.randint(-100000,100000)
658 angle2 = random.random()*random.randint(-100000,100000)
660 angle1 = random.random()*3.14
661 angle2 = random.random()*3.14
663 anObj.SetRotateX(angle1)
664 anObj.SetRotateY(angle2)
668 def dump_cutplanes_parameters(theObject):
669 dump_saclarmap_parameters(theObject)
671 print "GetOrientationType = " + str(theObject.GetOrientationType())
672 PlanesNb = theObject.GetNbPlanes()
673 print "GetNbPlanes() = ", str(PlanesNb)
674 for i in range(0,PlanesNb+1):
675 if theObject.IsDefault(i) :
676 print "Default plane : "+str(i); break
677 print "GetPlanePosition(" + str(i) + ") = ", theObject.GetPlanePosition(i)
678 print "GetDisplacement() = ", str(theObject.GetDisplacement())
679 print "GetRotateX() = ", str(theObject.GetRotateX())
680 print "GetRotateY() = ", str(theObject.GetRotateY())
681 print "GetRotateZ() = ", str(theObject.GetRotateZ())
683 # ----------------------
685 # ----------------------
686 def try_cutlines_parameters(thePattern):
688 if thePattern is None : return None
692 ORIENT = [VISU.CutPlanes.XY, VISU.CutPlanes.YZ, VISU.CutPlanes.ZX]
693 ind = random.randint(1,2)
694 anObj = try_scalarmap_parameters(thePattern)
696 # --- ORIENTATION ---
697 anObj.SetOrientationType(ORIENT[random.randint(0,2)])
698 anObj.SetOrientationType2(ORIENT[random.randint(0,2)])
700 # --- Base Plane Position ---
701 anObj.SetBasePlanePosition( random.random()*random.randint(-100000,100000))
703 # --- NUMBER OF LINES ---
705 anObj.SetNbLines(random.randint(-5, 50))
708 anObj.SetRotateX(random.randint(-100,100)*random.random())
709 anObj.SetRotateX2(random.randint(-100,100)*random.random())
710 anObj.SetRotateY(random.randint(-100,100)*random.random())
711 anObj.SetRotateY2(random.randint(-100,100)*random.random())
715 def dump_cutlines_parameters(theObject):
716 dump_scalarmap_parameters(theObject)
718 print "GetOrientationType() = " + str(theObject.GetOrientationType())
719 print "GetOrientationType2() = " + str(theObject.GetOrientationType2())
720 print "GetBasePlanePosition() = "+ str(theObject.GetBasePlanePosition())
721 print "GetNbLines() = " + str(theObject.GetNbLines())
722 print "GetRotateX() = ", str(theObject.GetRotateX())
723 print "GetRotateX2() = ", str(theObject.GetRotateX2())
724 print "GetRotateY() = ", str(theObject.GetRotateY())
725 print "GetRotateY2() = ", str(theObject.GetRotateY2())
727 # ----------------------
729 # ----------------------
730 def try_streamlines_parameters(thePattern):
732 if thePattern is None : return None
736 DIRECTION = [VISU.StreamLines.FORWARD, VISU.StreamLines.BACKWARD, VISU.StreamLines.BOTH]
738 ind = random.randint(1,2)
739 anObj = (try_deformedshape_parameters(thePattern))[0]
742 anObj.SetDirection(DIRECTION[random.randint(0,2)])
744 # --- STEP LENGTH ---
745 if ind%2 : anObj.SetStepLength(random.random()*random.randint(-1000,1000))
747 aLen = anObj.GetMax() - anObj.GetMin()
748 anObj.SetStepLength(aLen/random.randint(1,100))
750 # --- PROPAGATION TIME ---
751 anObj.SetPropagationTime(random.random()*random.randint(1,100))
753 # --- INTEGRATION STEP ---
755 anObj.SetIntegrationStep(random.random()*random.randint(-1000,1000))
757 anObj.SetIntegrationStep(random.random())
760 anObj.SetUsedPoints(random.random()*random.randint(-10000,10000))
764 def dump_streamlines_parameters(theObject):
766 dump_deformedshape_parameters(theObject)
768 print "GetDirection() = " + str(theObject.GetDirection())
769 print "GetStepLength() = " + str(theObject.GetStepLength())
770 print "GetPropagationTime() =" + str(theObject.GetPropagationTime())
771 print "GetIntegrationStep() =" + str(theObject.GetIntegrationStep())
772 print "GetUsedPoints() =" + str(theObject.GetUsedPoints())
774 # ----------------------
776 # ----------------------
777 def try_vectors_parameters(thePattern, theNum):
779 if thePattern is None : return None
782 GLIPH_TYPE = [VISU.Vectors.ARROW, VISU.Vectors.CONE2, VISU.Vectors.CONE6, VISU.Vectors.NONE]
783 GLIPH_POS = [VISU.Vectors.CENTER, VISU.Vectors.TAIL, VISU.Vectors.HEAD]
784 ind = random.randint(1,2)
785 anObj = (try_deformedshape_parameters(thePattern))[0]
789 anObj.SetLineWidth(random.random()*random.randint(-10000,10000))
791 anObj.SetLineWidth(random.randint(1, 10))
794 anObj.SetGlyphType(GLIPH_TYPE[random.randint(0, len(GLIPH_TYPE)-1)])
797 anObj.SetGlyphPos(GLIPH_POS[random.randint(0, len(GLIPH_POS)-1)])
801 def dump_vetctors_parameters(theObject):
803 dump_deformedshape_parameters(theObject)
805 print "GetLineWidth() = " +str(theObject.GetLineWidth())
806 print "GetGlyphType() = " +str(theObject.GetGlyphType())
807 print "GetGlyphPos() = " +str(theObject.GetGlyphPos())
810 # ----------------------
812 # ----------------------
814 def try_isosurfaces_parameters(thePattern) :
815 if thePattern is None : return None
819 anObj = try_scalarmap_parameters(thePattern)
820 ind = random.randint(1,2)
821 # --- SURFACES NUMBER ---
823 anObj.SetNbSurfaces(random.randint(-100000,100000))
825 anObj.SetNbSurfaces(random.randint(1, 50))
829 def dump_isosurfaces_parameters(theObject):
831 dump_scalarmap_parameters(theObject)
832 print "GetNbSurfaces() = "+ str(theObject.GetNbSurfaces())