2 \page medcouplingcppexamples <br><h1> MEDCoupling C++ examples </h1>
5 \anchor cpp_mcdataarrayint_
8 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_
9 \snippet MEDCouplingExamplesTest.py PySnippet_DataArrayInt_
10 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_
13 \anchor cpp_mcdataarrayint_getTuple
14 <br><h2> Getting a tuple of DataArrayInt </h2>
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
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
31 \anchor cpp_mcdataarrayint_buildpermutationarr
32 <br><h2> Building a permutation array </h2>
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].
40 <br><h2> Inverting renumbering maps </h2>
41 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
42 <h3> invertArrayO2N2N2O() </h3>
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
47 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
49 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
50 <br><h3> invertArrayN2O2O2N() </h3>
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
55 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
59 \anchor cpp_mcdataarraydouble_getidsinrange
60 <br><h2> Finding values in range in DataArrayDouble</h2>
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
65 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
66 As result contents of the array \b da2 are as follows.
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.
84 Info of components : "a2" "a1" "v3" "v4"
90 The same result can be achieved other way (except that component info
92 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
94 \anchor cpp_mcdataarraydouble_setpartofvalues1
95 <br><h3> setPartOfValues1() </h3>
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].
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.
105 Info of components :"v1" "v2" "v3" "v4"
112 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
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
125 Below more two variants of location of target values are shown.
126 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
134 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
141 The same result can be achieved other way:
142 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
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.
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
168 Below more two variants of location of target values are shown.
169 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
177 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
184 The same result can be achieved other way:
185 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
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.
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
211 Below more two variants of location of target values are shown.
212 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
220 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
227 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
228 be explicitly called in Python.
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.
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
255 Below more two variants of location of target values are shown.
256 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
264 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
271 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
272 be explicitly called in Python.
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.].
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.
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
293 Every value of \b dv has been assigned to its own location within \b da.
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.
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
307 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
308 be explicitly called in Python.
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.].
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.
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
330 Every value of \b dv has been assigned to its own location within \b da.
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.
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
344 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
345 be explicitly called in Python.
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.
357 Info of components : "a2" "a1" "v3" "v4"
363 The same result can be achieved other way (except that component info
365 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
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].
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.
378 Info of components :"v1" "v2" "v3" "v4"
385 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
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
398 Below more two variants of location of target values are shown.
399 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
407 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
414 The same result can be achieved other way:
415 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
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.
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
441 Below more two variants of location of target values are shown.
442 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
450 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
457 The same result can be achieved other way:
458 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
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.
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
484 Below more two variants of location of target values are shown.
485 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
493 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
500 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
501 be explicitly called in Python.
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.
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
528 Below more two variants of location of target values are shown.
529 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
537 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
544 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
545 be explicitly called in Python.
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].
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.
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
566 Every value of \b dv has been assigned to its own location within \b da.
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.
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
580 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
581 be explicitly called in Python.
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].
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.
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
603 Every value of \b dv has been assigned to its own location within \b da.
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.
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
617 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
618 be explicitly called in Python.
621 \anchor cpp_mcdataarraydouble_getdifferentvalues
622 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
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
629 \anchor cpp_mcdataarraydouble_findcommontuples
630 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
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.
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.
646 \anchor cpp_mcdataarraydouble_meldwith
647 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
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".
657 \anchor cpp_mcdataarrayint_meldwith
658 <br><h2> Concatenating DataArrayInt's by appending components </h2>
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".
668 \anchor cpp_mcdataarraydouble_KeepSelectedComponents
670 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
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
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).
680 \anchor cpp_mcfielddouble_subpart1
682 \anchor cpp_mcdataarrayint_keepselectedcomponents
684 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
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
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).
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
699 \anchor cpp_mcfielddouble_subpart1
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
710 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
712 So the array \b part1 lists ids on cells.
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
718 So \b f2 contains 3 tuples with 2 components.
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.
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
731 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
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).
741 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
743 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
744 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
746 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
748 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
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.
754 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
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.
758 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
760 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
762 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
767 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
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
772 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
774 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
776 Then enter nodal connectivity at once.
778 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
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.
782 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
784 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
786 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
791 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
793 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
795 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
797 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
799 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
801 There are 2 techniques to get it.
805 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
809 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
811 \c mesh is now available for use :
813 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
815 When this mesh is no more needed simply call decrRef to decrement its reference counter.
817 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
822 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached </h1>
824 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
829 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
831 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
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>
838 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
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>
845 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
850 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
852 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
854 The decrementation of ref counter should be carried out in CPlusPlus only ...
856 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3