Salome HOME
Merge from V6_main 15/03/2013
[tools/medcoupling.git] / doc / doxygen / medcouplingexamples.doxy
1 /*!
2 \page medcouplingcppexamples <br><h1> MEDCoupling C++ examples </h1>
3
4
5 \anchor cpp_mcdataarrayint_
6 <br><h2>  </h2>
7
8 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_
9 \snippet MEDCouplingExamplesTest.py PySnippet_DataArrayInt_
10 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_
11
12
13 \anchor cpp_mcdataarrayint_getTuple
14 <br><h2> Getting a tuple of DataArrayInt </h2>
15
16 In this simple example we create an array of integers arranged into 3
17 tuples per 2 components, and finally print the second tuple.
18 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_1
19 The output is
20 <pre> [9, 10] </pre>
21 Note that we can traverse all tuples in the array by simply iterating
22 over it as the code below does.
23 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_2
24 Its output follows.
25 <pre>
26 (7, 8)
27 (9, 10)
28 (11, 12)
29 </pre>
30
31 \anchor cpp_mcdataarrayint_buildpermutationarr
32 <br><h2> Building a permutation array </h2>
33
34 Here we create two arrays containing same values but in different order and then we use
35 \ref ParaMEDMEM::DataArrayInt::buildPermutationArr "DataArrayInt::buildPermutationArr()" to get
36 an array showing in what places the values of \b b array are located in \b a array.
37 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_buildPermutationArr_1
38 The result array \b c contains [1,0,4,2,3].
39
40 <br><h2> Inverting renumbering maps </h2>
41 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
42 <h3> invertArrayO2N2N2O() </h3>
43
44 In this example we create a DataArrayInt containing a renumbering map in 
45 "Old to New" mode, convert it into the renumbering map in "New to Old" mode and check the
46 result.
47 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
48
49 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
50 <br><h3> invertArrayN2O2O2N() </h3>
51
52 In this example we create a DataArrayInt containing a renumbering map in 
53 "New to Old" mode, convert it into the renumbering map in "Old to New" mode and check the
54 result.
55 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
56
57
58
59 \anchor cpp_mcdataarraydouble_getidsinrange
60 <br><h2> Finding values in range in  DataArrayDouble</h2>
61
62 In this example we create an array \b da containing same values as ones returned by
63 \c range( \c 10 ). Then we get an array of indices of values of \b da being in
64 range [ 2.5, 6 ].
65 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
66 As result contents of the array \b da2 are as follows.
67 <pre>
68     Tuple #0 : 3
69     Tuple #1 : 4
70     Tuple #2 : 5
71     Tuple #3 : 6
72 </pre>
73
74
75 \anchor cpp_mcdataarraydouble_setselectedcomponents
76 <br><h2> Set part of values of DataArrayDouble </h2>
77 <h3> setSelectedComponents() </h3>
78 First, we create a 'source' array.
79 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents1
80 Now we create a larger zero array and assign the array \b da into it.
81 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents2
82 As result contents of the array \b dv are as follows.
83 <pre>
84 Info of components : "a2"   "a1"   "v3"   "v4"   
85     Tuple #0 : 2 1 0 0 
86     Tuple #1 : 4 3 0 0 
87     Tuple #2 : 6 5 0 0 
88     Tuple #3 : 0 0 0 0 
89 </pre>
90 The same result can be achieved other way (except that component info
91 is not copied):
92 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
93
94 \anchor cpp_mcdataarraydouble_setpartofvalues1
95 <br><h3> setPartOfValues1() </h3>
96 We create two arrays: 
97 - a "large" (4x4) zero array \b da to assign to and
98 - a smaller (2x2) array \b dv filled with values [7.,8.,9.,10].
99
100 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_1
101 Now we copy \b dv to the middle of \b da.
102 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_2
103 As result contents of the array \b da are as follows.
104 <pre>
105     Info of components :"v1"   "v2"   "v3"   "v4"
106     Tuple #0 : 0 0 0 0 
107     Tuple #1 : 0 7 8 0 
108     Tuple #2 : 0 9 10 0 
109     Tuple #3 : 0 0 0 0 
110 </pre>
111
112 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
113
114 Note that the last parameter \a strictCompoCompare should be \a False
115 in this case, else \ref ParaMEDMEM::DataArrayDouble::setPartOfValues1() 
116 throws an exception because \b da has 2 components but only one target
117 component is specified.
118 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_3
119 <pre>
120     Tuple #0 : 0 7 0 0 
121     Tuple #1 : 0 8 0 0 
122     Tuple #2 : 0 9 0 0 
123     Tuple #3 : 0 10 0 0 
124 </pre>
125 Below more two variants of location of target values are shown.
126 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
127 <pre>
128     Tuple #0 : 0 0 0 0 
129     Tuple #1 : 7 8 9 10 
130     Tuple #2 : 0 0 0 0 
131     Tuple #3 : 0 0 0 0 
132 </pre>
133
134 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
135 <pre>
136     Tuple #0 : 0 7 0 8 
137     Tuple #1 : 0 0 0 0 
138     Tuple #2 : 0 9 0 10 
139     Tuple #3 : 0 0 0 0 
140 </pre>
141 The same result can be achieved other way:
142 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
143
144
145
146 \anchor cpp_mcdataarraydouble_setpartofvaluessimple1
147 <br><h3> setPartOfValuesSimple1() </h3>
148 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
149 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_1
150 Now we assign \b dv to the middle of \b da.
151 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_2
152 As result contents of the array \b da are as follows.
153 <pre>
154     Tuple #0 : 0 0 0 0 
155     Tuple #1 : 0 7 7 0 
156     Tuple #2 : 0 7 7 0 
157     Tuple #3 : 0 0 0 0 
158 </pre>
159
160 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
161 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_3
162 <pre>
163     Tuple #0 : 0 7 0 0 
164     Tuple #1 : 0 7 0 0 
165     Tuple #2 : 0 7 0 0 
166     Tuple #3 : 0 7 0 0 
167 </pre>
168 Below more two variants of location of target values are shown.
169 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
170 <pre>
171     Tuple #0 : 0 0 0 0 
172     Tuple #1 : 7 7 7 7 
173     Tuple #2 : 0 0 0 0 
174     Tuple #3 : 0 0 0 0 
175 </pre>
176
177 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
178 <pre>
179     Tuple #0 : 0 7 0 7 
180     Tuple #1 : 0 0 0 0 
181     Tuple #2 : 0 7 0 7 
182     Tuple #3 : 0 0 0 0 
183 </pre>
184 The same result can be achieved other way:
185 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
186
187
188 \anchor cpp_mcdataarraydouble_setpartofvaluessimple2
189 <br><h3> setPartOfValuesSimple2() </h3>
190 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
191 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_1
192 Now we assign \b dv to the middle of \b da.
193 We explicitly specify tuples and component to assign to by a list [1,2].
194 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_2
195 As result contents of the array \b da are as follows.
196 <pre>
197     Tuple #0 : 0 0 0 0 
198     Tuple #1 : 0 7 7 0 
199     Tuple #2 : 0 7 7 0 
200     Tuple #3 : 0 0 0 0 
201 </pre>
202
203 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
204 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_3
205 <pre>
206     Tuple #0 : 0 7 0 0 
207     Tuple #1 : 0 7 0 0 
208     Tuple #2 : 0 7 0 0 
209     Tuple #3 : 0 7 0 0 
210 </pre>
211 Below more two variants of location of target values are shown.
212 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
213 <pre>
214     Tuple #0 : 0 0 0 0 
215     Tuple #1 : 7 7 7 7 
216     Tuple #2 : 0 0 0 0 
217     Tuple #3 : 0 0 0 0 
218 </pre>
219
220 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
221 <pre>
222     Tuple #0 : 0 7 0 7 
223     Tuple #1 : 0 0 0 0 
224     Tuple #2 : 0 7 0 7 
225     Tuple #3 : 0 0 0 0 
226 </pre>
227 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
228 be explicitly called in Python.
229
230
231 \anchor cpp_mcdataarraydouble_setpartofvaluessimple3
232 <br><h3> setPartOfValuesSimple3() </h3>
233 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
234 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_1
235 Now we assign \b dv to the middle of \b da.
236 We explicitly specify tuples to assign to by a list [1,2]. And we specify
237 components to assign to using slicing: 1:3.
238 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_2
239 As result contents of the array \b da are as follows.
240 <pre>
241     Tuple #0 : 0 0 0 0 
242     Tuple #1 : 0 7 7 0 
243     Tuple #2 : 0 7 7 0 
244     Tuple #3 : 0 0 0 0 
245 </pre>
246
247 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
248 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_3
249 <pre>
250     Tuple #0 : 0 7 0 0 
251     Tuple #1 : 0 7 0 0 
252     Tuple #2 : 0 7 0 0 
253     Tuple #3 : 0 7 0 0 
254 </pre>
255 Below more two variants of location of target values are shown.
256 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
257 <pre>
258     Tuple #0 : 0 0 0 0 
259     Tuple #1 : 7 7 7 7 
260     Tuple #2 : 0 0 0 0 
261     Tuple #3 : 0 0 0 0 
262 </pre>
263
264 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
265 <pre>
266     Tuple #0 : 0 7 0 7 
267     Tuple #1 : 0 0 0 0 
268     Tuple #2 : 0 7 0 7 
269     Tuple #3 : 0 0 0 0 
270 </pre>
271 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
272 be explicitly called in Python.
273
274
275 \anchor cpp_mcdataarraydouble_setpartofvalues2
276 <br><h3> setPartOfValues2() </h3>
277 We create two arrays: 
278 - a "large" (4x7) zero array \b da to assign to,
279 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
280
281 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_1
282 Now we assign the two components of \b dv to the components of \b da
283 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
284   indices [0,1,2]. This is the first mode of usage.
285 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_2
286 As result contents of the array \b da are as follows.
287 <pre>
288     Tuple #0 : 0  7  0  8  0  0  0  
289     Tuple #1 : 0  9  0 10  0  0  0 
290     Tuple #2 : 0 11  0 12  0  0  0 
291     Tuple #3 : 0  0  0  0  0  0  0
292 </pre>
293 Every value of \b dv has been assigned to its own location within \b da.
294
295 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
296 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
297 This is the second mode of usage.
298 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_3
299 The contents of \b dv have been assigned to each of specified tuples of \b da.
300 Every value of \b dv is repeated in the 3 specified tuples within \b da.
301 <pre>
302     Tuple #0 : 7  0  8  9 10 11 12
303     Tuple #1 : 0  0  0  0  0  0  0   
304     Tuple #2 : 7  0  8  9 10 11 12
305     Tuple #3 : 7  0  8  9 10 11 12
306 </pre>
307 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
308 be explicitly called in Python.
309
310
311 \anchor cpp_mcdataarraydouble_setpartofvalues3
312 <br><h3> setPartOfValues3() </h3>
313 We create two arrays: 
314 - a "large" (4x7) zero array \b da to assign to,
315 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
316
317 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_1
318 Now we assign the two components of \b dv to the components of \b da
319 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
320 indices [0,1,2] which are specified using slicing: "0:3". 
321 This is the first mode of usage.
322 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_2
323 As result contents of the array \b da are as follows.
324 <pre>
325     Tuple #0 : 0  7  0  8  0  0  0  
326     Tuple #1 : 0  9  0 10  0  0  0 
327     Tuple #2 : 0 11  0 12  0  0  0 
328     Tuple #3 : 0  0  0  0  0  0  0
329 </pre>
330 Every value of \b dv has been assigned to its own location within \b da.
331
332 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
333 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
334 slice notation "0:4:2". This is the second mode of usage.
335 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_3
336 The contents of \b dv have been assigned to each of specified tuples of \b da.
337 Every value of \b dv is repeated in the 3 specified tuples within \b da.
338 <pre>
339     Tuple #0 : 7  0  8  9 10 11 12
340     Tuple #1 : 0  0  0  0  0  0  0   
341     Tuple #2 : 7  0  8  9 10 11 12
342     Tuple #3 : 0  0  0  0  0  0  0   
343 </pre>
344 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
345 be explicitly called in Python.
346
347
348 \anchor cpp_mcdataarrayint_setselectedcomponents
349 <br><h2> Set part of values of DataArrayInt </h2>
350 <h3> setSelectedComponents() </h3>
351 First, we create a 'source' array.
352 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents1
353 Now we create a larger zero array and assign the array \b da to it.
354 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents2
355 As result contents of the array \b dv are as follows.
356 <pre>
357 Info of components : "a2"   "a1"   "v3"   "v4"   
358     Tuple #0 : 2 1 0 0 
359     Tuple #1 : 4 3 0 0 
360     Tuple #2 : 6 5 0 0 
361     Tuple #3 : 0 0 0 0 
362 </pre>
363 The same result can be achieved other way (except that component info
364 is not copied):
365 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
366
367 \anchor cpp_mcdataarrayint_setpartofvalues1
368 <br><h3> setPartOfValues1() </h3>
369 We create two arrays: 
370 - a "large" (4x4) zero array \b da to assign to and
371 - a smaller (2x2) array \b dv filled with values [7,8,9,10].
372
373 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_1
374 Now we copy \b dv to the middle of \b da.
375 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_2
376 As result contents of the array \b da are as follows.
377 <pre>
378     Info of components :"v1"   "v2"   "v3"   "v4"
379     Tuple #0 : 0 0 0 0 
380     Tuple #1 : 0 7 8 0 
381     Tuple #2 : 0 9 10 0 
382     Tuple #3 : 0 0 0 0 
383 </pre>
384
385 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
386
387 Note that the last parameter \a strictCompoCompare should be \a False
388 in this case, else \ref ParaMEDMEM::DataArrayInt::setPartOfValues1() 
389 throws an exception because \b da has 2 components but only one target
390 component is specified.
391 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_3
392 <pre>
393     Tuple #0 : 0 7 0 0 
394     Tuple #1 : 0 8 0 0 
395     Tuple #2 : 0 9 0 0 
396     Tuple #3 : 0 10 0 0 
397 </pre>
398 Below more two variants of location of target values are shown.
399 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
400 <pre>
401     Tuple #0 : 0 0 0 0 
402     Tuple #1 : 7 8 9 10 
403     Tuple #2 : 0 0 0 0 
404     Tuple #3 : 0 0 0 0 
405 </pre>
406
407 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
408 <pre>
409     Tuple #0 : 0 7 0 8 
410     Tuple #1 : 0 0 0 0 
411     Tuple #2 : 0 9 0 10 
412     Tuple #3 : 0 0 0 0 
413 </pre>
414 The same result can be achieved other way:
415 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
416
417
418
419 \anchor cpp_mcdataarrayint_setpartofvaluessimple1
420 <br><h3> setPartOfValuesSimple1() </h3>
421 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
422 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_1
423 Now we assign \b dv to the middle of \b da.
424 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_2
425 As result contents of the array \b da are as follows.
426 <pre>
427     Tuple #0 : 0 0 0 0 
428     Tuple #1 : 0 7 7 0 
429     Tuple #2 : 0 7 7 0 
430     Tuple #3 : 0 0 0 0 
431 </pre>
432
433 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
434 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_3
435 <pre>
436     Tuple #0 : 0 7 0 0 
437     Tuple #1 : 0 7 0 0 
438     Tuple #2 : 0 7 0 0 
439     Tuple #3 : 0 7 0 0 
440 </pre>
441 Below more two variants of location of target values are shown.
442 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
443 <pre>
444     Tuple #0 : 0 0 0 0 
445     Tuple #1 : 7 7 7 7 
446     Tuple #2 : 0 0 0 0 
447     Tuple #3 : 0 0 0 0 
448 </pre>
449
450 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
451 <pre>
452     Tuple #0 : 0 7 0 7 
453     Tuple #1 : 0 0 0 0 
454     Tuple #2 : 0 7 0 7 
455     Tuple #3 : 0 0 0 0 
456 </pre>
457 The same result can be achieved other way:
458 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
459
460
461 \anchor cpp_mcdataarrayint_setpartofvaluessimple2
462 <br><h3> setPartOfValuesSimple2() </h3>
463 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
464 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_1
465 Now we assign \b dv to the middle of \b da.
466 We explicitly specify tuples and component to assign to by a list [1,2].
467 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_2
468 As result contents of the array \b da are as follows.
469 <pre>
470     Tuple #0 : 0 0 0 0 
471     Tuple #1 : 0 7 7 0 
472     Tuple #2 : 0 7 7 0 
473     Tuple #3 : 0 0 0 0 
474 </pre>
475
476 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
477 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_3
478 <pre>
479     Tuple #0 : 0 7 0 0 
480     Tuple #1 : 0 7 0 0 
481     Tuple #2 : 0 7 0 0 
482     Tuple #3 : 0 7 0 0 
483 </pre>
484 Below more two variants of location of target values are shown.
485 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
486 <pre>
487     Tuple #0 : 0 0 0 0 
488     Tuple #1 : 7 7 7 7 
489     Tuple #2 : 0 0 0 0 
490     Tuple #3 : 0 0 0 0 
491 </pre>
492
493 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
494 <pre>
495     Tuple #0 : 0 7 0 7 
496     Tuple #1 : 0 0 0 0 
497     Tuple #2 : 0 7 0 7 
498     Tuple #3 : 0 0 0 0 
499 </pre>
500 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
501 be explicitly called in Python.
502
503
504 \anchor cpp_mcdataarrayint_setpartofvaluessimple3
505 <br><h3> setPartOfValuesSimple3() </h3>
506 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
507 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_1
508 Now we assign \b dv to the middle of \b da.
509 We explicitly specify tuples to assign to by a list [1,2]. And we specify
510 components to assign to using slicing: 1:3.
511 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_2
512 As result contents of the array \b da are as follows.
513 <pre>
514     Tuple #0 : 0 0 0 0 
515     Tuple #1 : 0 7 7 0 
516     Tuple #2 : 0 7 7 0 
517     Tuple #3 : 0 0 0 0 
518 </pre>
519
520 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
521 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_3
522 <pre>
523     Tuple #0 : 0 7 0 0 
524     Tuple #1 : 0 7 0 0 
525     Tuple #2 : 0 7 0 0 
526     Tuple #3 : 0 7 0 0 
527 </pre>
528 Below more two variants of location of target values are shown.
529 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
530 <pre>
531     Tuple #0 : 0 0 0 0 
532     Tuple #1 : 7 7 7 7 
533     Tuple #2 : 0 0 0 0 
534     Tuple #3 : 0 0 0 0 
535 </pre>
536
537 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
538 <pre>
539     Tuple #0 : 0 7 0 7 
540     Tuple #1 : 0 0 0 0 
541     Tuple #2 : 0 7 0 7 
542     Tuple #3 : 0 0 0 0 
543 </pre>
544 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
545 be explicitly called in Python.
546
547
548 \anchor cpp_mcdataarrayint_setpartofvalues2
549 <br><h3> setPartOfValues2() </h3>
550 We create two arrays: 
551 - a "large" (4x7) zero array \b da to assign to,
552 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
553
554 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_1
555 Now we assign the two components of \b dv to the components of \b da
556 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
557   indices [0,1,2]. This is the first mode of usage.
558 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_2
559 As result contents of the array \b da are as follows.
560 <pre>
561     Tuple #0 : 0  7  0  8  0  0  0  
562     Tuple #1 : 0  9  0 10  0  0  0 
563     Tuple #2 : 0 11  0 12  0  0  0 
564     Tuple #3 : 0  0  0  0  0  0  0
565 </pre>
566 Every value of \b dv has been assigned to its own location within \b da.
567
568 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
569 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
570 This is the second mode of usage.
571 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_3
572 The contents of \b dv have been assigned to each of specified tuples of \b da.
573 Every value of \b dv is repeated in the 3 specified tuples within \b da.
574 <pre>
575     Tuple #0 : 7  0  8  9 10 11 12
576     Tuple #1 : 0  0  0  0  0  0  0   
577     Tuple #2 : 7  0  8  9 10 11 12
578     Tuple #3 : 7  0  8  9 10 11 12
579 </pre>
580 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
581 be explicitly called in Python.
582
583
584 \anchor cpp_mcdataarrayint_setpartofvalues3
585 <br><h3> setPartOfValues3() </h3>
586 We create two arrays: 
587 - a "large" (4x7) zero array \b da to assign to,
588 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
589
590 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_1
591 Now we assign the two components of \b dv to the components of \b da
592 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
593 indices [0,1,2] which are specified using slicing: "0:3". 
594 This is the first mode of usage.
595 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_2
596 As result contents of the array \b da are as follows.
597 <pre>
598     Tuple #0 : 0  7  0  8  0  0  0  
599     Tuple #1 : 0  9  0 10  0  0  0 
600     Tuple #2 : 0 11  0 12  0  0  0 
601     Tuple #3 : 0  0  0  0  0  0  0
602 </pre>
603 Every value of \b dv has been assigned to its own location within \b da.
604
605 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
606 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
607 slice notation "0:4:2". This is the second mode of usage.
608 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_3
609 The contents of \b dv have been assigned to each of specified tuples of \b da.
610 Every value of \b dv is repeated in the 3 specified tuples within \b da.
611 <pre>
612     Tuple #0 : 7  0  8  9 10 11 12
613     Tuple #1 : 0  0  0  0  0  0  0   
614     Tuple #2 : 7  0  8  9 10 11 12
615     Tuple #3 : 0  0  0  0  0  0  0   
616 </pre>
617 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
618 be explicitly called in Python.
619
620
621 \anchor cpp_mcdataarraydouble_getdifferentvalues
622 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
623
624 The code below creates an array of real values and than an array of
625   unique values, not closer one to another than 0.2, is retrieved from it.
626 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_getDifferentValues1
627
628
629 \anchor cpp_mcdataarraydouble_findcommontuples
630 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
631
632 Let's create an array of 6 tuples and 2 components that can be
633   considered as coordinates of 6 points in 2D space.
634 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples1
635 Now we find points that are not far each from other than 1e-1.
636 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples2
637 As we can realize from the above code, a hardcoded array \b expected3 is equal
638   to the raw data of a DataArrayInt \b c and a hardcoded array \b expected4 is equal
639   to the raw data of the DataArrayInt \b cI.
640
641 The array \b c contains indices of 5 coincident points. The array \b
642   cI shows us boundaries of (cI->getNumberOfTuples()-1) = 2 groups of coincident points: 
643 - The first group starts at index 0 and includes (3 - 0) = 3 points: 0,3,4.
644 - The second group starts at index 3 and includes (5 - 3) = 2 points: 1,2.
645
646 \anchor cpp_mcdataarraydouble_meldwith
647 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
648
649 In this example we create two data arrays including \b same number of
650 tuples and then we concatenate them using \ref
651 ParaMEDMEM::DataArrayDouble::meldWith "meldWith()".
652 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_Meld1_1
653 Now the array \b da1 includes 7 tuples (as before) of 3 components
654 each. Its components are: "c0da1","c1da1","c0da2".
655
656
657 \anchor cpp_mcdataarrayint_meldwith
658 <br><h2> Concatenating DataArrayInt's by appending components </h2>
659
660 In this example we create two data arrays including \b same number of
661 tuples and then we concatenate them using \ref
662 ParaMEDMEM::DataArrayInt::meldWith "meldWith()".
663 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_Meld1_1
664 Now the array \b da1 includes 7 tuples (as before) of 3 components
665 each. Its components are: "c0da1","c1da1","c0da2".
666
667
668 \anchor cpp_mcdataarraydouble_KeepSelectedComponents
669
670 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
671
672 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_1
673 We created an array \b a1 containing 5 tuples of 4 components each (20
674 values). Now we are going to create an array \b a2 containing some
675 components of \b a1.
676 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_2
677 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
678 the result array \b a2 includes 30 elements (5 tuples per 6 components).
679
680 \anchor cpp_mcfielddouble_subpart1
681
682 \anchor cpp_mcdataarrayint_keepselectedcomponents
683
684 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
685
686 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_1
687 We created an array \b a1 containing 5 tuples of 4 components each (20
688 values). Now we are going to create an array \b a2 containing some
689 components of \b a1.
690 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_2
691 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
692 the result array \b a2 includes 30 elements (5 tuples per 6 components).
693
694 Note that
695 \ref ParaMEDMEM::DataArrayInt::keepSelectedComponents() "DataArrayInt::keepSelectedComponents()" 
696 is called, providing the same result, by the following python code:
697 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_3
698
699 \anchor cpp_mcfielddouble_subpart1
700
701
702 <br><h2>Creation of a sub part of a field</h2>
703 <br><h3>Creation of a sub part of a field on cells</h3>
704 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
705 The field on cells \b f1 lies on a mesh containing 5 cells and 9 nodes.         
706 So this field \b f1 contains 5 tuples of 2 components each (10 values).
707 Now let's create a subfield on cells \b f2 from \b f1.
708 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
709
710 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
711
712 So the array \b part1 lists ids on cells.
713
714 - cell #0 of \b f2 is the same cell of cell #2 of \b f1
715 - cell #1 of \b f2 is the same cell of cell #1 of \b f1
716 - cell #2 of \b f2 is the same cell of cell #4 of \b f1
717
718 So \b f2 contains 3 tuples with 2 components.
719
720 The underlying mesh of \b f2 contains a newly created mesh with 3 cells (not as \b mesh1 in \b f1) and 9 nodes (as \b mesh1 in \b f1).
721 \n For fields on cells the number of tuples of the returned field is always equal to the number of ids given in input (here \b part1).
722 \nOnly fields on cells have this particular behaviour.
723
724 <br><h3>Creation of a sub part of a field on nodes</h3>
725 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
726 The field on nodes \b f1 lies on a mesh containing 5 cells and 9 nodes.
727 So this field \b f1 contains 9 tuples of 2 components each (18 values).
728 Now let's create a subfield on nodes \b f2 from \b f1.
729 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
730
731 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
732
733 After the call of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" on node field \b f1, \b f1 will be reduced on a
734 submesh of \b mesh1 containing cells whoses ids are in \b part2. So here the number of cells of \b f2 is 2 and the number of nodes is 4.
735 \nSo contrary to fields on cells, it is normal for fields on nodes that number of tuples of the returned field of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" 
736 method does not match the size of the input array (here \b part2).
737
738 */
739
740 /*!
741 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
742
743 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
744 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
745
746 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
747
748 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
749
750 Gives an upper bound of the number of cells to be inserted into the unstructured mesh.
751 \n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method.
752 \n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance.
753
754 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
755
756 At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above.
757
758 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
759
760 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
761
762 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
763
764 */
765
766 /*!
767 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
768
769 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell, cell type \b included (3 for INTERP_KERNEL::NORM_TRI3 and 4 for INTERP_KERNEL::QUAD4).
770 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1
771
772 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
773
774 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
775
776 Then enter nodal connectivity at once.
777
778 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
779
780 At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above.
781
782 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
783
784 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
785
786 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
787
788 */
789
790 /*!
791 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
792
793 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
794
795 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
796
797 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
798
799 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
800
801 There are 2 techniques to get it.
802
803 Either :
804
805 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
806
807 Or :
808
809 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
810
811 \c mesh is now available for use :
812
813 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
814
815 When this mesh is no more needed simply call decrRef to decrement its reference counter.
816
817 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
818
819 */
820
821 /*!
822 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached  </h1>
823
824 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
825
826 */
827
828 /*!
829 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
830
831 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
832
833 */
834
835 /*!
836 \page medcouplingcppexamplesFieldDoubleBuild3 <br><h1> Examples in C++ of standard build of a vector field on cells with with one time attached and no time interval </h1>
837
838 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
839
840 */
841
842 /*!
843 \page medcouplingcppexamplesFieldDoubleBuild4 <br><h1> Examples in C++ of standard build of a vector field on nodes defined on a time interval with a constant value during this interval </h1>
844
845 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
846
847 */
848
849 /*!
850 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
851
852 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
853
854 The decrementation of ref counter should be carried out in CPlusPlus only ...
855
856 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3
857
858 */