Salome HOME
This commit was generated by cvs2git to create tag 'V1_4_0b1'.
[modules/kernel.git] / doc / html / INPUT / exemple / Example19.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
2 <HEAD>\r
3 <!-- hennerik CVSweb $Revision$ -->\r
4 <TITLE>Exemple</TITLE></HEAD>\r
5 <BODY BGCOLOR="#eeeeee">\r
6 <HR noshade><PRE>\r
7 #^ SALOMEDS methods : &nbsp;FindOrCreateAttribute, Save, SaveAs, Close, Open, FindComponent, FindAttribute, FindObject, LoadWith^\r
8 #^ Attribute methods : Value, SetValue^\r
9 #======================================================================\r
10 #1. Create Study and add some components to it\r
11 #======================================================================\r
12 \r
13 #=================================\r
14 # &nbsp; &nbsp; &nbsp; create AttributeReal &nbsp; &nbsp; &nbsp;\r
15 #=================================\r
16 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(batchmode_geompy.father, &quot;AttributeReal&quot;)\r
17 if A == None :\r
18  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeReal attribute&quot;\r
19 A = A._narrow(SALOMEDS.AttributeReal)\r
20 A.SetValue(0.0001)\r
21 if A.Value() != 0.0001:\r
22  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error : wrong value of &nbsp;AttributeReal&quot;\r
23 \r
24 # === &nbsp;Geometry &nbsp;==================================================\r
25 \r
26 import batchmode_geompy\r
27  \r
28 #===================================\r
29 # &nbsp; &nbsp; define a box\r
30 #===================================\r
31 \r
32 box = batchmode_geompy.MakeBox(0., 0., 0., 100., 200., 300.)\r
33 idbox = batchmode_geompy.addToStudy(box,&quot;box&quot;)\r
34 \r
35 \r
36 geom = batchmode_geompy.geom\r
37 import SMESH\r
38 import batchmode_smesh\r
39 ShapeType = batchmode_smesh.ShapeType\r
40 \r
41 # ---- add first face of box in study\r
42 \r
43 subShapeList = batchmode_geompy.SubShapeAll(box,ShapeType[&quot;Face&quot;])\r
44 face=subShapeList[0]\r
45 name = &quot;box_face&quot;\r
46 print name\r
47 idface= batchmode_geompy.addToStudyInFather(box,face,name)\r
48 \r
49 # ---- add shell from box &nbsp;in study\r
50 \r
51 subShellList= batchmode_geompy.SubShapeAll(box,ShapeType[&quot;Shell&quot;])\r
52 shell = subShellList[0]\r
53 name = &quot;box_shell&quot;\r
54 print name\r
55 idshell= batchmode_geompy.addToStudyInFather(box,shell,name)\r
56 \r
57 # ---- add first edge of face in study\r
58 \r
59 edgeList = &nbsp;batchmode_geompy.SubShapeAll(face,ShapeType[&quot;Edge&quot;])\r
60 edge=edgeList[0];\r
61 name = &quot;face_edge&quot;\r
62 print name\r
63 idedge= batchmode_geompy.addToStudyInFather(face,edge,name)\r
64 \r
65 # ---- launch SMESH, init a Mesh with the box\r
66 \r
67 smesh = &nbsp;batchmode_smesh.smesh\r
68 # &nbsp;-- &nbsp;Init &nbsp;--\r
69 shape = batchmode_geompy.IDToObject(idbox)\r
70 mesh=smesh.Init(geom, batchmode_geompy.myStudyId, shape)\r
71 \r
72 orb = batchmode_geompy.orb\r
73 \r
74 idmesh = batchmode_smesh.AddNewMesh( orb.object_to_string(mesh) )\r
75 batchmode_smesh.SetName(idmesh, &quot;Meshbox&quot;);\r
76 batchmode_smesh.SetShape(idbox, idmesh);\r
77 \r
78 # ---- create Hypothesis\r
79 \r
80 print &quot;-------------------------- create Hypothesis ----------------------&quot;\r
81 print &quot;-------------------------- LocalLength&quot;\r
82 hyp1 = smesh.CreateHypothesis(&quot;LocalLength&quot;, batchmode_geompy.myStudyId )\r
83 hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength)\r
84 hypLen1.SetLength(100)\r
85 print hypLen1.GetName()\r
86 print hypLen1.GetId()\r
87 print hypLen1.GetLength()\r
88 \r
89 idlength = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypLen1) );\r
90 batchmode_smesh.SetName(idlength, &quot;Local_Length_100&quot;);\r
91 \r
92 print &quot;-------------------------- NumberOfSegments&quot;\r
93 hyp2 = &nbsp;smesh.CreateHypothesis(&quot;NumberOfSegments&quot;, batchmode_geompy.myStudyId )\r
94 hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments)\r
95 hypNbSeg1.SetNumberOfSegments(7)\r
96 print hypNbSeg1.GetName()\r
97 print hypNbSeg1.GetId()\r
98 print hypNbSeg1.GetNumberOfSegments()\r
99 \r
100 idseg = &nbsp;batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypNbSeg1) );\r
101 batchmode_smesh.SetName(idseg, &quot;NumberOfSegments_7&quot;);\r
102 \r
103 print &quot;-------------------------- MaxElementArea&quot;\r
104 hyp3 = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, &nbsp;batchmode_geompy.myStudyId)\r
105 hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea)\r
106 hypArea1.SetMaxElementArea(2500)\r
107 print hypArea1.GetName()\r
108 print hypArea1.GetId()\r
109 print hypArea1.GetMaxElementArea()\r
110 \r
111 idarea1 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea1) );\r
112 batchmode_smesh.SetName(idarea1, &quot;MaxElementArea_2500&quot;);\r
113 \r
114 print &quot;-------------------------- MaxElementArea&quot;\r
115 hyp3 = smesh.CreateHypothesis(&quot;MaxElementArea&quot;, &nbsp;batchmode_geompy.myStudyId)\r
116 hypArea2 = hyp3._narrow(SMESH.SMESH_MaxElementArea)\r
117 hypArea2.SetMaxElementArea(500)\r
118 print hypArea2.GetName()\r
119 print hypArea2.GetId()\r
120 print hypArea2.GetMaxElementArea()\r
121 \r
122 idarea2 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea2) );\r
123 batchmode_smesh.SetName(idarea2, &quot;MaxElementArea_500&quot;);\r
124 \r
125 print &quot;-------------------------- Regular_1D&quot;\r
126 alg1 = smesh.CreateHypothesis(&quot;Regular_1D&quot;, &nbsp;batchmode_geompy.myStudyId)\r
127 algo1 = alg1._narrow(SMESH.SMESH_Algo)\r
128 listHyp = algo1.GetCompatibleHypothesis()\r
129 for hyp in listHyp:\r
130  &nbsp; &nbsp;print hyp\r
131 algoReg=alg1._narrow(SMESH.SMESH_Regular_1D)\r
132 print algoReg.GetName()\r
133 print algoReg.GetId()\r
134 \r
135 idreg = batchmode_smesh.AddNewAlgorithms( orb.object_to_string(algoReg) );\r
136 batchmode_smesh.SetName(idreg, &quot;Regular_1D&quot;);\r
137 \r
138 print &quot;-------------------------- MEFISTO_2D&quot;\r
139 alg2 = smesh.CreateHypothesis(&quot;MEFISTO_2D&quot;, &nbsp;batchmode_geompy.myStudyId)\r
140 algo2 = alg2._narrow(SMESH.SMESH_Algo)\r
141 listHyp=algo2.GetCompatibleHypothesis()\r
142 for hyp in listHyp:\r
143  &nbsp; &nbsp;print hyp\r
144 algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D)\r
145 print algoMef.GetName()\r
146 print algoMef.GetId()\r
147 \r
148 idmef = batchmode_smesh.AddNewAlgorithms( orb.object_to_string(algoMef) );\r
149 batchmode_smesh.SetName(idmef, &quot;MEFISTO_2D&quot;);\r
150 \r
151 \r
152 # ---- add hypothesis to edge\r
153 \r
154 print &quot;-------------------------- add hypothesis to edge&quot;\r
155 edge = batchmode_geompy.IDToObject(idedge)\r
156 submesh = mesh.GetElementsOnShape(edge)\r
157 ret = mesh.AddHypothesis(edge,algoReg)\r
158 print ret\r
159 ret=mesh.AddHypothesis(edge,hypLen1)\r
160 print ret\r
161 \r
162 idsm1 = batchmode_smesh.AddSubMeshOnShape( idmesh,\r
163  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; idedge,\r
164  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; orb.object_to_string(submesh),\r
165  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ShapeType[&quot;Edge&quot;] )\r
166 batchmode_smesh.SetName(idsm1, &quot;SubMeshEdge&quot;)\r
167 batchmode_smesh.SetAlgorithms( idsm1, idreg );\r
168 batchmode_smesh.SetHypothesis( idsm1, idlength );\r
169 \r
170 print &quot;-------------------------- add hypothesis to face&quot;\r
171 face=batchmode_geompy.IDToObject(idface)\r
172 submesh=mesh.GetElementsOnShape(face)\r
173 ret=mesh.AddHypothesis(face,hypArea2)\r
174 print ret\r
175 \r
176 idsm2 = batchmode_smesh.AddSubMeshOnShape( idmesh,\r
177  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;idface,\r
178  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;orb.object_to_string(submesh),\r
179  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ShapeType[&quot;Face&quot;] )\r
180 batchmode_smesh.SetName(idsm2, &quot;SubMeshFace&quot;)\r
181 batchmode_smesh.SetHypothesis( idsm2, idarea2 );\r
182 \r
183 # ---- add hypothesis to box\r
184 \r
185 print &quot;-------------------------- add hypothesis to box&quot;\r
186 box=batchmode_geompy.IDToObject(idbox)\r
187 submesh=mesh.GetElementsOnShape(box)\r
188 ret=mesh.AddHypothesis(box,algoReg)\r
189 print ret\r
190 ret=mesh.AddHypothesis(box,hypNbSeg1)\r
191 print ret\r
192 ret=mesh.AddHypothesis(box,algoMef)\r
193 print ret\r
194 ret=mesh.AddHypothesis(box,hypArea1)\r
195 print ret\r
196 \r
197 batchmode_smesh.SetAlgorithms( idmesh, idreg );\r
198 batchmode_smesh.SetHypothesis( idmesh, idseg );\r
199 batchmode_smesh.SetAlgorithms( idmesh, idmef );\r
200 batchmode_smesh.SetHypothesis( idmesh, idarea1 );\r
201 \r
202 # ---- compute box\r
203 \r
204 print &quot;-------------------------- compute box&quot;\r
205 ret=smesh.Compute(mesh,box)\r
206 print ret\r
207 log=mesh.GetLog(0); # no erase trace\r
208 for linelog in log:\r
209  &nbsp; &nbsp;print linelog\r
210 \r
211 \r
212 #=======================================================\r
213 # &nbsp; &nbsp;add &nbsp;SuperVision component\r
214 #=======================================================\r
215 \r
216 from batchmode_SuperV import *\r
217 import os\r
218 dir= os.getenv(&quot;SALOME_ROOT_DIR&quot;)\r
219 if dir == None:\r
220  &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeError, &quot;SALOME_ROOT_DIR is not defined&quot;\r
221 xmlfile = dir +&quot;/../SALOME_ROOT/SuperVisionTest/resources/GraphEssai.xml&quot;\r
222 print &quot;--------------\n&quot;+xmlfile+&quot;\n--------------\n&quot;\r
223 \r
224 myGraph = Graph ( xmlfile )\r
225 \r
226 # This DataFlow is &quot;valid&quot; : no loop, correct links between Nodes etc...\r
227 print myGraph.IsValid()\r
228 \r
229 # Get Nodes\r
230 myGraph.PrintNodes()\r
231 Add,Sub,Mul,Div = myGraph.Nodes()\r
232 \r
233 # Load Datas\r
234 Addx = Add.Input(&quot;x&quot;,3.)\r
235 Addy = Add.Input(&quot;y&quot;,4.5)\r
236 Subx = Sub.Input(&quot;x&quot;,1.5)\r
237 \r
238 # Get Output Port\r
239 Addz = Add.Port('z')\r
240 Subz = Sub.Port('z')\r
241 Mulz = Mul.Port('z')\r
242 Divz = Div.Port('z')\r
243 \r
244 # This DataFlow is &quot;executable&quot; : all pending Ports are defined with Datas\r
245 print myGraph.IsExecutable()\r
246 \r
247 # Starts only execution of that DataFlow and gets control immediatly\r
248 print myGraph.Run()\r
249 \r
250 # That DataFlow is running ==&gt; 0 (false)\r
251 print myGraph.IsDone()\r
252 \r
253 # Events of execution :\r
254 aStatus,aNode,anEvent,aState = myGraph.Event()\r
255 while aStatus :\r
256  &nbsp; &nbsp;print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState\r
257  &nbsp; &nbsp;aStatus,aNode,anEvent,aState = myGraph.Event()\r
258 print myGraph.IsDone()\r
259 \r
260 # Wait for Completion (but it is already done after event loop ...)\r
261 print &quot;Done : &quot;,myGraph.DoneW()\r
262 \r
263 # Get result\r
264 print &quot;Result : &quot;,Divz.ToString()\r
265 \r
266 # Intermediate results :\r
267 print &quot;Intermediate Result Add\z : &quot;,Addz.ToString()\r
268 print &quot;Intermediate Result Sub\z : &quot;,Subz.ToString()\r
269 print &quot;Intermediate Result Mul\z : &quot;,Mulz.ToString()\r
270 \r
271 print &quot; &quot;\r
272 #print &quot;Type : print myGraph.IsDone()&quot;\r
273 #print &quot; &nbsp; &nbsp; &nbsp; If execution is finished ==&gt; 1 (true)&quot;\r
274 res=myGraph.IsDone()\r
275 if res != 1:\r
276  &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeError, &quot;myGraph.Run() is not done&quot;\r
277 \r
278 print &quot; &quot;\r
279 print &quot;Type : print Divz.ToString()&quot;\r
280 print &quot; &nbsp; &nbsp; &nbsp; You will get the result&quot;\r
281 Divz.ToString()\r
282 \r
283 print &quot; &quot;\r
284 print &quot;Type : myGraph.PrintPorts()&quot;\r
285 print &quot; &nbsp; &nbsp; &nbsp; to see input and output values of the graph&quot;\r
286 myGraph.PrintPorts()\r
287 \r
288 print &quot; &quot;\r
289 print &quot;Type : Add.PrintPorts()&quot;\r
290 Add.PrintPorts()\r
291 \r
292 print &quot;Type : Sub.PrintPorts()&quot;\r
293 Sub.PrintPorts()\r
294 \r
295 print &quot;Type : Mul.PrintPorts()&quot;\r
296 Mul.PrintPorts()\r
297 \r
298 print &quot;Type : Div.PrintPorts()&quot;\r
299 print &quot; &nbsp; &nbsp; &nbsp; to see input and output values of nodes&quot;\r
300 Div.PrintPorts()\r
301 \r
302 # Export will create newsupervisionexample.xml and the corresponding .py file\r
303 tmpdir=os.getenv(&quot;TmpDir&quot;)\r
304 if tmpdir is None:\r
305  &nbsp; &nbsp; &nbsp; &nbsp;tmpdir=&quot;/tmp&quot;\r
306 file = tmpdir + &quot;/newsupervisionexample&quot;\r
307 print &quot;--------------\n&quot;+file+&quot;\n--------------\n&quot;\r
308 myGraph.Export(file)\r
309 \r
310 ior = batchmode_geompy.orb.object_to_string(myGraph.G)\r
311 addStudy(ior)\r
312 \r
313 GraphName = myGraph.Name()\r
314 print &quot;Befor save &quot;,\r
315 nodes = myGraph.Nodes()\r
316 length_bs = len(nodes)\r
317 print &quot;ListOfNodes length = &quot;, length_bs\r
318 names=[]\r
319 for node in nodes:\r
320  &nbsp; &nbsp; &nbsp; &nbsp;names.append(node.Name())\r
321 print names\r
322 \r
323 \r
324 #=================================\r
325 # &nbsp; &nbsp; &nbsp;save / restore study &nbsp; &nbsp; &nbsp;\r
326 #=================================\r
327 str= os.getenv(&quot;TmpDir&quot;)\r
328 if str == None: &nbsp;\r
329  &nbsp; &nbsp; &nbsp; &nbsp;str = &quot;/tmp&quot;\r
330 file = str+&quot;/test.hdf&quot;\r
331 \r
332 \r
333 #==================================================\r
334 #1. SaveAs\r
335 #==================================================\r
336 print &quot; ------- &nbsp;We will save to&quot;, file, &quot;-----------&quot;\r
337 \r
338 batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)\r
339 batchmode_geompy.myStudyManager.Close(batchmode_geompy.myStudy)\r
340 \r
341 #rename the file and try to reread it again\r
342 \r
343 os.mkdir(str + &quot;/test_dir&quot;)\r
344 \r
345 #2.==================================================\r
346 print &quot; ------- We rename the file as &quot; + str + &quot;/test_dir/test_new.hdf&quot;\r
347 os.rename(file, str+&quot;/test_dir/test_new.hdf&quot;)\r
348 \r
349 #==================================================\r
350 #3. Open\r
351 #==================================================\r
352 print &quot; ------- We try to open &quot; + str + &quot;/test_dir/test_new.hdf&quot;\r
353 \r
354 try:\r
355  &nbsp; &nbsp; &nbsp; &nbsp;openedStudy=batchmode_geompy.myStudyManager.Open(str+&quot;/test_dir/test_new.hdf&quot;)\r
356 except Exception:\r
357  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
358 \r
359 if openedStudy == None:\r
360  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
361 \r
362 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
363 if father is None:\r
364  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;GEOM component is not found! &nbsp;Wrong study is opened.&quot; \r
365 \r
366 \r
367 #=================================\r
368 # &nbsp; &nbsp; find AttributeReal\r
369 #=================================\r
370 \r
371 res,A=father.FindAttribute(&quot;AttributeReal&quot;)\r
372 if res == 0 or A == None:\r
373  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeReal&quot;\r
374 \r
375 A = A._narrow(SALOMEDS.AttributeReal)\r
376 if A.Value() != 0.0001:\r
377  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error : wrong value of &nbsp;AttributeReal&quot;\r
378 \r
379 #==================================================\r
380 # &nbsp; &nbsp; find &nbsp;box\r
381 #==================================================\r
382 box = openedStudy.FindObject(&quot;box&quot;)\r
383 if box is None :\r
384  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;box was not found! Wrong study is opened.&quot;\r
385 \r
386 edge=openedStudy.FindObject(&quot;face_edge&quot;)\r
387 if edge is None :\r
388  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;face_edge was not found! Wrong study is opened.&quot;\r
389 \r
390 \r
391 father = openedStudy.FindComponent(&quot;MESH&quot;)\r
392 if father is None:\r
393  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;MESH component is not found! &nbsp;Wrong study is opened.&quot; \r
394 \r
395 hp=openedStudy.FindObject(&quot;Meshbox&quot;)\r
396 if hp is None:\r
397  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Meshbox object was not found! Wrong study is opened.&quot;\r
398 \r
399 hp = openedStudy.FindObject(&quot;Algorithms Definition&quot;)\r
400 if hp is None:\r
401  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Algorithms Definition object was not found! Wrong study is opened.&quot;\r
402 \r
403 hp = openedStudy.FindObject(&quot;MEFISTO_2D&quot;)\r
404 if hp is None:\r
405  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;MEFISTO_2D object was not found! Wrong study is opened.&quot;\r
406 \r
407 hp = openedStudy.FindObject(&quot;Hypothesis Definition&quot;)\r
408 if hp is None:\r
409  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Algoriths Definition was not found! Wrong study is opened.&quot;\r
410 \r
411 #==================================================\r
412 # Find Supervisor\r
413 #==================================================\r
414 father = openedStudy.FindComponent(&quot;SUPERV&quot;)\r
415 if father is None: \r
416  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;SUPERV component is not found! &nbsp;Wrong study is opened.&quot; \r
417 \r
418 SuperV = lcc.FindOrLoadComponent(&quot;SuperVisionContainer&quot;,&quot;Supervision&quot;)\r
419 Builder = openedStudy.NewBuilder()\r
420 Builder.LoadWith(father, SuperV)\r
421 import SALOMEDS\r
422 \r
423 aChildIterator = openedStudy.NewChildIterator(father)\r
424 \r
425 #while aChildIterator.More():\r
426 anSObject = aChildIterator.Value()\r
427 #print &quot;iterate: &quot;, anSObject.GetID()\r
428 res, anAttr=anSObject.FindAttribute(&quot;AttributeIOR&quot;)\r
429 if res :\r
430  &nbsp; &nbsp; &nbsp; &nbsp;anAttr=anAttr._narrow(SALOMEDS.AttributeIOR)\r
431  &nbsp; &nbsp; &nbsp; &nbsp;ior = anAttr.Value()\r
432  &nbsp; &nbsp; &nbsp; &nbsp;Graph=SuperV.getGraph(ior)\r
433  &nbsp; &nbsp; &nbsp; &nbsp;ListOfNodes=Graph.Nodes()\r
434  &nbsp; &nbsp; &nbsp; &nbsp;length_as= len(ListOfNodes)\r
435  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;ListOfNodes length = &quot;, length_as\r
436  &nbsp; &nbsp; &nbsp; &nbsp;if length_as != length_bs:\r
437  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeErrror, &quot;defferent length of nodes after study open&quot;\r
438 #aChildIterator.Next()\r
439 \r
440 Names = []\r
441 for node in ListOfNodes:\r
442  &nbsp; &nbsp; &nbsp; &nbsp;Names.append(node.Name())\r
443 names.sort()\r
444 Names.sort()\r
445 if names != Names :\r
446  &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeError, &quot;List of dataflow nodes after save differs from one befor save operation&quot;\r
447 \r
448 #==================================================\r
449 #4. Save\r
450 #==================================================\r
451 batchmode_geompy.myStudyManager.Save(openedStudy)\r
452 batchmode_geompy.myStudyManager.Close(openedStudy)\r
453 #==================================================\r
454 #5. Open\r
455 #==================================================\r
456 try:\r
457  &nbsp; &nbsp; &nbsp; &nbsp;openedStudy = batchmode_geompy.myStudyManager.Open(str+&quot;/test_dir/test_new.hdf&quot;)\r
458 except Exception:\r
459  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
460 \r
461 \r
462 \r
463 if openedStudy == None:\r
464  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't open saved study!&quot;\r
465 \r
466 father = openedStudy.FindComponent(&quot;GEOM&quot;)\r
467 if father is None:\r
468  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;Geom component is not found! &nbsp;Wrong study is opened.&quot; \r
469 \r
470 \r
471 #find AttributeReal\r
472 res,A=father.FindAttribute(&quot;AttributeReal&quot;)\r
473 if res == 0 or A == None:\r
474  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error: &nbsp;not found AttributeReal&quot;\r
475 \r
476 A = A._narrow(SALOMEDS.AttributeReal)\r
477 if A.Value() != 0.0001:\r
478  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Error : wrong value of &nbsp;AttributeReal&quot;\r
479 #==================================================\r
480 # &nbsp; &nbsp; find &nbsp;box\r
481 #==================================================\r
482 box = openedStudy.FindObject(&quot;box&quot;)\r
483 if box is None :\r
484  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;box was not found! Wrong study is opened.&quot;\r
485 \r
486 edge=openedStudy.FindObject(&quot;face_edge&quot;)\r
487 if edge is None :\r
488  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;face_edge was not found! Wrong study is opened.&quot;\r
489 \r
490 \r
491 father = openedStudy.FindComponent(&quot;MESH&quot;)\r
492 if father is None:\r
493  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;MESH component is not found! &nbsp;Wrong study is opened.&quot; \r
494 \r
495 hp=openedStudy.FindObject(&quot;Meshbox&quot;)\r
496 if hp is None:\r
497  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Meshbox object was not found! Wrong study is opened.&quot;\r
498 \r
499 hp = openedStudy.FindObject(&quot;Algorithms Definition&quot;)\r
500 if hp is None:\r
501  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Algorithms Definition object was not found! Wrong study is opened.&quot;\r
502 \r
503 hp = openedStudy.FindObject(&quot;MEFISTO_2D&quot;)\r
504 if hp is None:\r
505  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;MEFISTO_2D object was not found! Wrong study is opened.&quot;\r
506 \r
507 hp = openedStudy.FindObject(&quot;Hypothesis Definition&quot;)\r
508 if hp is None:\r
509  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Algoriths Definition was not found! Wrong study is opened.&quot;\r
510 \r
511 #==================================================\r
512 # Find Supervisor\r
513 #==================================================\r
514 father = openedStudy.FindComponent(&quot;SUPERV&quot;)\r
515 if father is None:\r
516  &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp;RuntimeError, &quot;SUPERV component is not found! &nbsp;Wrong study is opened.&quot; \r
517 \r
518 SuperV = lcc.FindOrLoadComponent(&quot;SuperVisionContainer&quot;,&quot;Supervision&quot;)\r
519 Builder = openedStudy.NewBuilder()\r
520 Builder.LoadWith(father, SuperV)\r
521 import SALOMEDS\r
522 \r
523 aChildIterator = openedStudy.NewChildIterator(father)\r
524 \r
525 #while aChildIterator.More():\r
526 anSObject = aChildIterator.Value()\r
527 \r
528 res, anAttr=anSObject.FindAttribute(&quot;AttributeIOR&quot;)\r
529 if res :\r
530  &nbsp; &nbsp; &nbsp; &nbsp;anAttr=anAttr._narrow(SALOMEDS.AttributeIOR)\r
531  &nbsp; &nbsp; &nbsp; &nbsp;ior = anAttr.Value()\r
532  &nbsp; &nbsp; &nbsp; &nbsp;Graph=SuperV.getGraph(ior)\r
533  &nbsp; &nbsp; &nbsp; &nbsp;ListOfNodes=Graph.Nodes()\r
534  &nbsp; &nbsp; &nbsp; &nbsp;length_as= len(ListOfNodes)\r
535  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;ListOfNodes length = &quot;, length_as\r
536  &nbsp; &nbsp; &nbsp; &nbsp;if length_as != length_bs:\r
537  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeErrror, &quot;defferent length of nodes after study open&quot;\r
538 #aChildIterator.Next()\r
539 \r
540 Names = []\r
541 for node in ListOfNodes:\r
542  &nbsp; &nbsp; &nbsp; &nbsp;Names.append(node.Name())\r
543 names.sort()\r
544 Names.sort()\r
545 if names != Names :\r
546  &nbsp; &nbsp; &nbsp; &nbsp;raise RuntimeError, &quot;List of dataflow nodes after save differs from one befor save operation&quot;\r
547 </PRE>