Salome HOME
This commit was generated by cvs2git to create tag 'V1_3_0'.
[modules/kernel.git] / doc / html / INPUT / exemple / Example18.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>\r
2 <HEAD>\r
3 <!-- hennerik CVSweb $Revision$ -->\r
4 <TITLE>Example</TITLE></HEAD>\r
5 <BODY BGCOLOR="#eeeeee">\r
6 <HR noshade><PRE>#%AttributeTreeNode interface(creations/saving/restoring)%\r
7 #%SALOMEDS methods : FindOrCreateAttribute, NewObject%\r
8 #%Attribute methods : HasFirst, HasFather, SetPrevious, Next, InsertAfter, GetFather, HasNext, SetValue, Append, NewStudy, Label, IsRoot, Prepend, SetFather, Depth, HasPrevious%\r
9 \r
10 child1 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)\r
11 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child1,&quot;AttributeName&quot;)\r
12 if A == None :\r
13  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
14 A = A._narrow(SALOMEDS.AttributeName)\r
15 A.SetValue(&quot;N1&quot;)\r
16 N1 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child1, &quot;AttributeTreeNode&quot;)\r
17 if N1 == None :\r
18  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
19 \r
20 child2 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)\r
21 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child2,&quot;AttributeName&quot;)\r
22 if A == None :\r
23  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
24 A = A._narrow(SALOMEDS.AttributeName)\r
25 A.SetValue(&quot;N2&quot;)\r
26 N2 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child2, &quot;AttributeTreeNode&quot;)\r
27 if N2 == None :\r
28  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
29 \r
30 child3 = batchmode_geompy.myBuilder.NewObject(batchmode_geompy.father)\r
31 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child3,&quot;AttributeName&quot;)\r
32 if A == None :\r
33  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
34 A = A._narrow(SALOMEDS.AttributeName)\r
35 A.SetValue(&quot;N3&quot;)\r
36 N3 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child3, &quot;AttributeTreeNode&quot;)\r
37 if N3 == None :\r
38  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
39 \r
40 \r
41 child11 = batchmode_geompy.myBuilder.NewObject(child1)\r
42 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child11,&quot;AttributeName&quot;)\r
43 if A == None :\r
44  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
45 A = A._narrow(SALOMEDS.AttributeName)\r
46 A.SetValue(&quot;N11&quot;)\r
47 \r
48 N11 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child11, &quot;AttributeTreeNode&quot;)\r
49 \r
50 if N11 == None :\r
51  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
52 \r
53 child111 = batchmode_geompy.myBuilder.NewObject(child11)\r
54 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child111, &quot;AttributeName&quot;)\r
55 if A == None :\r
56  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
57 A = A._narrow(SALOMEDS.AttributeName)\r
58 A.SetValue(&quot;N111&quot;)\r
59 \r
60 N111 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child111, &quot;AttributeTreeNode&quot;)\r
61 \r
62 if N111 == None :\r
63  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
64  \r
65 \r
66 child31 = batchmode_geompy.myBuilder.NewObject(child3)\r
67 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child31,&quot;AttributeName&quot;)\r
68 if A == None :\r
69  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
70 A = A._narrow(SALOMEDS.AttributeName)\r
71 A.SetValue(&quot;N31&quot;)\r
72 \r
73 N31 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child31, &quot;AttributeTreeNode&quot;)\r
74 if N31 == None :\r
75  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
76 \r
77 child32 = batchmode_geompy.myBuilder.NewObject(child3)\r
78 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child32,&quot;AttributeName&quot;)\r
79 if A == None :\r
80  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
81 A = A._narrow(SALOMEDS.AttributeName)\r
82 A.SetValue(&quot;N32&quot;)\r
83 \r
84 N32 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child32, &quot;AttributeTreeNode&quot;)\r
85 if N32 == None :\r
86  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
87 \r
88 child321 = batchmode_geompy.myBuilder.NewObject(child32)\r
89 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child321,&quot;AttributeName&quot;)\r
90 if A == None :\r
91  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
92 A = A._narrow(SALOMEDS.AttributeName)\r
93 A.SetValue(&quot;N321&quot;)\r
94 \r
95 N321 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child321, &quot;AttributeTreeNode&quot;)\r
96 if N321 == None :\r
97  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
98 \r
99 child33 = batchmode_geompy.myBuilder.NewObject(child3)\r
100 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child33,&quot;AttributeName&quot;)\r
101 if A == None :\r
102  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
103 A = A._narrow(SALOMEDS.AttributeName)\r
104 A.SetValue(&quot;N33&quot;)\r
105 \r
106 N33 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child33, &quot;AttributeTreeNode&quot;)\r
107 if N33 == None :\r
108  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
109 \r
110 child34 = batchmode_geompy.myBuilder.NewObject(child3)\r
111 A = batchmode_geompy.myBuilder.FindOrCreateAttribute(child34,&quot;AttributeName&quot;)\r
112 if A == None :\r
113  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeName attribute&quot;\r
114 A = A._narrow(SALOMEDS.AttributeName)\r
115 A.SetValue(&quot;N34&quot;)\r
116 \r
117 N34 = batchmode_geompy.myBuilder.FindOrCreateAttribute(child34, &quot;AttributeTreeNode&quot;)\r
118 if N34 == None :\r
119  &nbsp; &nbsp; &nbsp; &nbsp;raise &nbsp;RuntimeError, &quot;Can't create AttributeTreeNode attribute&quot;\r
120 \r
121 \r
122 \r
123 #Create links between tree nodes.\r
124 # &nbsp;-| root\r
125 # &nbsp; --N1 __\r
126 # &nbsp; | &nbsp; &nbsp; N11__\r
127 # &nbsp; | &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; N111\r
128 # &nbsp; --N2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \r
129 # &nbsp; | &nbsp; \r
130 # &nbsp; --N3__\r
131 # &nbsp; &nbsp; &nbsp; &nbsp; N31\r
132 # &nbsp; &nbsp; &nbsp; &nbsp; N32__\r
133 # &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;N321\r
134 # &nbsp; &nbsp; &nbsp; &nbsp; N33\r
135 # &nbsp; &nbsp; &nbsp; &nbsp; N34\r
136  &nbsp; &nbsp; &nbsp; &nbsp;\r
137 N11.SetFather(N1)\r
138 N11.Append(N111)\r
139 N3.SetPrevious(N1)\r
140 N3.Prepend(N2)\r
141 \r
142 N32.SetFather(N3)\r
143 N32.Prepend(N31)\r
144 N33.InsertAfter(N32)\r
145 N33.Append(N34)\r
146 print &quot;------------- &nbsp;&quot;, N1, &quot; &nbsp;------------- &nbsp;&quot;\r
147 print &quot;N1.Label() = &quot;, N1.Label() , &quot;IsRoot() = &quot;, N1.IsRoot(), &quot;Depth() = &quot;, N1.Depth()\r
148 print &quot;N11.Label() = &quot;, N11.Label() , &quot;IsRoot() = &quot;, N11.IsRoot(), &quot;Depth() = &quot;, N11.Depth()\r
149 print &quot;N111.Label() = &quot;, N111.Label() , &quot;IsRoot() = &quot;, N111.IsRoot(), &quot;Depth() = &quot;, N111.Depth()\r
150 print &quot;N2.Label() = &quot;, N2.Label() , &quot;IsRoot() = &quot;, &nbsp;N2.IsRoot(), &quot;Depth() = &quot;, N2.Depth()\r
151 print &quot;N3.Label() = &quot;, N3.Label() , &quot;IsRoot() = &quot;, N3.IsRoot(), &quot;Depth() = &quot;, N3.Depth()\r
152 print &quot;N31.Label() = &quot;, N31.Label() , &quot;IsRoot() = &quot;, N31.IsRoot(), &quot;Depth() = &quot;, N31.Depth()\r
153 print &quot;N32.Label() = &quot;, N32.Label() , &quot;IsRoot() = &quot;, N32.IsRoot(), &quot;Depth() = &quot;, N32.Depth()\r
154 print &quot;N321.Label() = &quot;, N321.Label() , &quot;IsRoot() = &quot;, N321.IsRoot(), &quot;Depth() = &quot;, N321.Depth()\r
155 print &quot;N33.Label() = &quot;, N33.Label() , &quot;IsRoot() = &quot;, N33.IsRoot(), &quot;Depth() = &quot;, N33.Depth()\r
156 print &quot;N34.Label() = &quot;, N34.Label() , &quot;IsRoot() = &quot;, N34.IsRoot(), &quot;Depth() = &quot;, N34.Depth()\r
157 print &quot;N1.IsRoot()=&quot;, N1.IsRoot()\r
158 \r
159 print &quot;N1.HasNext() = &quot;,N1.HasNext()\r
160 if &nbsp;N1.HasNext():\r
161  &nbsp; &nbsp; &nbsp; &nbsp;print N1.Next().Label()\r
162 \r
163 print &quot;N32.HasPrevious() = &quot;,N32.HasPrevious()\r
164 if &nbsp;N32.HasPrevious():\r
165  &nbsp; &nbsp; &nbsp; &nbsp;print N32.GetPrevious().Label()\r
166 \r
167 print &quot;N111.HasFirst()=&quot;,N111.HasFirst()\r
168 print &quot;N111.HasFather()=&quot;,N111.HasFather()\r
169 if N111.HasFather() :\r
170  &nbsp; &nbsp; &nbsp; &nbsp;print &quot;N111.GetFather().Label()=&quot;,N111.GetFather().Label()\r
171 </PRE>