2 \page medcouplingcppexamples MEDCoupling C++ examples
5 \anchor cpp_mcpointset_
8 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_
9 \snippet MEDCouplingExamplesTest.py PySnippet_MEDCouplingPointSet_
10 \snippet MEDCouplingExamplesTest.py Snippet_MEDCouplingPointSet_
13 \anchor cpp_mcpointset_scale
14 <br><h2> Scaling the mesh </h2>
16 First, we create a 2D mesh with 4 nodes and no cells.
17 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_1
18 Then we scale it by a factor of 2 with a center (0.,0.).
19 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_2
20 Finally we check that all node coordinates have changed by more than 0.9.
21 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_3
26 \anchor cpp_mcpointset_translate
27 <br><h2> Translating the mesh </h2>
29 First, we create a 2D mesh with 4 nodes and no cells.
30 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_1
31 Then we translate it by a vector (1.,1.).
32 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_2
33 Finally we check that all node coordinates have changed by more than 0.9.
34 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_3
38 \anchor cpp_mcpointset_rotate
39 <br><h2> Rotating the mesh </h2>
41 First, we create a 2D mesh with 4 nodes and no cells.
42 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_1
43 Then we rotate it around a point (0.,0.) by 90 degrees clockwise.
44 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_2
45 Next, we make a 3D mesh from the 2D one and rotate it around the Z axis by 90 degrees
47 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_3
48 Finally we transform the mesh back to 2D space and check that all nodes get back to the
50 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_4
52 \anchor cpp_mcpointset_getBoundingBox
53 <br><h2> Getting a minimum box bounding nodes </h2>
55 First, we create a 3D mesh with 2 nodes, so that the first one has minimal coordinates and
56 the second one has maximal coordinates.
57 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_1
58 Now we get a bounding box enclosing these nodes. This bounding box should contain
59 coordinates of our two nodes (but in "no interlace" mode), as the nodes coincide with
60 points returned by the bounding box.
61 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_2
64 \anchor cpp_mcpointset_getnodeidsnearpoint
65 <br><h2> Getting nodes close to a point </h2>
67 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
68 "MEDCouplingUMesh" with 5 nodes and no cells.
69 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_1
70 Now we define an array of coordinates of a point close to nodes #0, #2 and #4.
73 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoint "getNodeIdsNearPoint()" that
75 if called with \b eps = 0.003, would return ids of nodes #0, #2 and #4.
76 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_2
79 \anchor cpp_mcpointset_getnodeidsnearpoints
80 <br><h2> Getting nodes close to some points </h2>
82 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
83 "MEDCouplingUMesh" with 7 nodes and no cells.
84 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_1
85 Now we define an array of coordinates of 3 points near which we want to find nodes of the mesh.
86 - Point #0 is at distance 0.001 from the node #1.
87 - Point #1 is rather far from all nodes.
88 - Point #2 is close to nodes #3, #4 and #5.
91 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoints "getNodeIdsNearPoints()" that
93 if called with \b eps = 0.003, would return ids of close nodes #1, #3, #4 and #5.
94 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_2
95 \b idsIndex returns [0, 1, 1, 4] which means that:
96 - Point #0 is close to 1 (== \b idsIndex[1] - \b idsIndex[0]) node whose id is
97 \b ids[ \b idsIndex[ 0 ]].
98 - Point #1 is close to 0 (== \b idsIndex[2] - \b idsIndex[1]) nodes.
99 - Point #2 is close to 3 (== \b idsIndex[3] - \b idsIndex[2]) nodes whose ids are
100 \b ids[ \b idsIndex[ 2 ]], \b ids[ \b idsIndex[ 2 ] + 1 ] and \b ids[ \b idsIndex[ 2 ] + 2 ].
103 \anchor cpp_mcpointset_findcommonnodes
104 <br><h2> Finding coincident nodes </h2>
106 First, we create a mesh with 6 nodes, of which two nodes (#3 and #4) are fully coincident
107 and 3 nodes (#0, #2 and #5) have distance less than 0.004 between them.
108 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_1
109 Then, we use \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" to find
110 coincident nodes, and check that (1) calling
111 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" with \b prec
112 == 1e-13 finds the two fully coincident nodes only and (2)
113 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes"(0.004) finds 5
115 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_2
117 \anchor cpp_mcpointset_getcoordinatesofnode
118 <br><h2> Getting coordinates of a node </h2>
120 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
121 "MEDCouplingUMesh" with 3 nodes and no cells.
122 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_1
123 Here we get coordinates of the second node and check its two coordinates.
124 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_2
126 \anchor cpp_mcdataarrayint_getTuple
127 <br><h2> Getting a tuple of DataArrayInt </h2>
129 In this simple example we create an array of integers arranged into 3
130 tuples per 2 components, and finally print the second tuple.
131 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_1
134 Note that we can traverse all tuples in the array by simply iterating
135 over it as the code below does.
136 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_2
144 \anchor cpp_mcdataarrayint_buildpermutationarr
145 <br><h2> Building a permutation array </h2>
147 Here we create two arrays containing same values but in different order and then we use
148 \ref ParaMEDMEM::DataArrayInt::buildPermutationArr "DataArrayInt::buildPermutationArr()" to get
149 an array showing in what places the values of \b b array are located in \b a array.
150 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_buildPermutationArr_1
151 The result array \b c contains [1,0,4,2,3].
153 <br><h2> Inverting renumbering maps </h2>
154 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
155 <h3> invertArrayO2N2N2O() </h3>
157 In this example we create a DataArrayInt containing a renumbering map in
158 "Old to New" mode, convert it into the renumbering map in "New to Old" mode and check the
160 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
162 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
163 <br><h3> invertArrayN2O2O2N() </h3>
165 In this example we create a DataArrayInt containing a renumbering map in
166 "New to Old" mode, convert it into the renumbering map in "Old to New" mode and check the
168 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
172 \anchor cpp_mcdataarraydouble_getidsinrange
173 <br><h2> Finding values in range in DataArrayDouble</h2>
175 In this example we create an array \b da containing same values as ones returned by
176 \c range( \c 10 ). Then we get an array of indices of values of \b da being in
178 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
179 As result contents of the array \b da2 are as follows.
188 \anchor cpp_mcdataarraydouble_setselectedcomponents
189 <br><h2> Set part of values of DataArrayDouble </h2>
190 <h3> setSelectedComponents() </h3>
191 First, we create a 'source' array.
192 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents1
193 Now we create a larger zero array and assign the array \b da into it.
194 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents2
195 As result contents of the array \b dv are as follows.
197 Info of components : "a2" "a1" "v3" "v4"
203 The same result can be achieved other way (except that component info
205 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
207 \anchor cpp_mcdataarraydouble_setpartofvalues1
208 <br><h3> setPartOfValues1() </h3>
209 We create two arrays:
210 - a "large" (4x4) zero array \b da to assign to and
211 - a smaller (2x2) array \b dv filled with values [7.,8.,9.,10].
213 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_1
214 Now we copy \b dv to the middle of \b da.
215 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_2
216 As result contents of the array \b da are as follows.
218 Info of components :"v1" "v2" "v3" "v4"
225 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
227 Note that the last parameter \a strictCompoCompare should be \a False
228 in this case, else \ref ParaMEDMEM::DataArrayDouble::setPartOfValues1()
229 throws an exception because \b da has 2 components but only one target
230 component is specified.
231 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_3
238 Below more two variants of location of target values are shown.
239 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
247 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
254 The same result can be achieved other way:
255 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
259 \anchor cpp_mcdataarraydouble_setpartofvaluessimple1
260 <br><h3> setPartOfValuesSimple1() </h3>
261 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
262 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_1
263 Now we assign \b dv to the middle of \b da.
264 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_2
265 As result contents of the array \b da are as follows.
273 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
274 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_3
281 Below more two variants of location of target values are shown.
282 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
290 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
297 The same result can be achieved other way:
298 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
301 \anchor cpp_mcdataarraydouble_setpartofvaluessimple2
302 <br><h3> setPartOfValuesSimple2() </h3>
303 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
304 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_1
305 Now we assign \b dv to the middle of \b da.
306 We explicitly specify tuples and component to assign to by a list [1,2].
307 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_2
308 As result contents of the array \b da are as follows.
316 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
317 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_3
324 Below more two variants of location of target values are shown.
325 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
333 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
340 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
341 be explicitly called in Python.
344 \anchor cpp_mcdataarraydouble_setpartofvaluessimple3
345 <br><h3> setPartOfValuesSimple3() </h3>
346 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
347 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_1
348 Now we assign \b dv to the middle of \b da.
349 We explicitly specify tuples to assign to by a list [1,2]. And we specify
350 components to assign to using slicing: 1:3.
351 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_2
352 As result contents of the array \b da are as follows.
360 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
361 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_3
368 Below more two variants of location of target values are shown.
369 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
377 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
384 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
385 be explicitly called in Python.
388 \anchor cpp_mcdataarraydouble_setpartofvalues2
389 <br><h3> setPartOfValues2() </h3>
390 We create two arrays:
391 - a "large" (4x7) zero array \b da to assign to,
392 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
394 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_1
395 Now we assign the two components of \b dv to the components of \b da
396 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
397 indices [0,1,2]. This is the first mode of usage.
398 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_2
399 As result contents of the array \b da are as follows.
401 Tuple #0 : 0 7 0 8 0 0 0
402 Tuple #1 : 0 9 0 10 0 0 0
403 Tuple #2 : 0 11 0 12 0 0 0
404 Tuple #3 : 0 0 0 0 0 0 0
406 Every value of \b dv has been assigned to its own location within \b da.
408 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
409 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
410 This is the second mode of usage.
411 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_3
412 The contents of \b dv have been assigned to each of specified tuples of \b da.
413 Every value of \b dv is repeated in the 3 specified tuples within \b da.
415 Tuple #0 : 7 0 8 9 10 11 12
416 Tuple #1 : 0 0 0 0 0 0 0
417 Tuple #2 : 7 0 8 9 10 11 12
418 Tuple #3 : 7 0 8 9 10 11 12
420 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
421 be explicitly called in Python.
424 \anchor cpp_mcdataarraydouble_setpartofvalues3
425 <br><h3> setPartOfValues3() </h3>
426 We create two arrays:
427 - a "large" (4x7) zero array \b da to assign to,
428 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
430 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_1
431 Now we assign the two components of \b dv to the components of \b da
432 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
433 indices [0,1,2] which are specified using slicing: "0:3".
434 This is the first mode of usage.
435 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_2
436 As result contents of the array \b da are as follows.
438 Tuple #0 : 0 7 0 8 0 0 0
439 Tuple #1 : 0 9 0 10 0 0 0
440 Tuple #2 : 0 11 0 12 0 0 0
441 Tuple #3 : 0 0 0 0 0 0 0
443 Every value of \b dv has been assigned to its own location within \b da.
445 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
446 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
447 slice notation "0:4:2". This is the second mode of usage.
448 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_3
449 The contents of \b dv have been assigned to each of specified tuples of \b da.
450 Every value of \b dv is repeated in the 3 specified tuples within \b da.
452 Tuple #0 : 7 0 8 9 10 11 12
453 Tuple #1 : 0 0 0 0 0 0 0
454 Tuple #2 : 7 0 8 9 10 11 12
455 Tuple #3 : 0 0 0 0 0 0 0
457 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
458 be explicitly called in Python.
461 \anchor cpp_mcdataarrayint_setselectedcomponents
462 <br><h2> Set part of values of DataArrayInt </h2>
463 <h3> setSelectedComponents() </h3>
464 First, we create a 'source' array.
465 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents1
466 Now we create a larger zero array and assign the array \b da to it.
467 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents2
468 As result contents of the array \b dv are as follows.
470 Info of components : "a2" "a1" "v3" "v4"
476 The same result can be achieved other way (except that component info
478 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
480 \anchor cpp_mcdataarrayint_setpartofvalues1
481 <br><h3> setPartOfValues1() </h3>
482 We create two arrays:
483 - a "large" (4x4) zero array \b da to assign to and
484 - a smaller (2x2) array \b dv filled with values [7,8,9,10].
486 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_1
487 Now we copy \b dv to the middle of \b da.
488 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_2
489 As result contents of the array \b da are as follows.
491 Info of components :"v1" "v2" "v3" "v4"
498 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
500 Note that the last parameter \a strictCompoCompare should be \a False
501 in this case, else \ref ParaMEDMEM::DataArrayInt::setPartOfValues1()
502 throws an exception because \b da has 2 components but only one target
503 component is specified.
504 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_3
511 Below more two variants of location of target values are shown.
512 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
520 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
527 The same result can be achieved other way:
528 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
532 \anchor cpp_mcdataarrayint_setpartofvaluessimple1
533 <br><h3> setPartOfValuesSimple1() </h3>
534 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
535 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_1
536 Now we assign \b dv to the middle of \b da.
537 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_2
538 As result contents of the array \b da are as follows.
546 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
547 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_3
554 Below more two variants of location of target values are shown.
555 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
563 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
570 The same result can be achieved other way:
571 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
574 \anchor cpp_mcdataarrayint_setpartofvaluessimple2
575 <br><h3> setPartOfValuesSimple2() </h3>
576 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
577 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_1
578 Now we assign \b dv to the middle of \b da.
579 We explicitly specify tuples and component to assign to by a list [1,2].
580 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_2
581 As result contents of the array \b da are as follows.
589 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
590 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_3
597 Below more two variants of location of target values are shown.
598 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
606 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
613 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
614 be explicitly called in Python.
617 \anchor cpp_mcdataarrayint_setpartofvaluessimple3
618 <br><h3> setPartOfValuesSimple3() </h3>
619 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
620 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_1
621 Now we assign \b dv to the middle of \b da.
622 We explicitly specify tuples to assign to by a list [1,2]. And we specify
623 components to assign to using slicing: 1:3.
624 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_2
625 As result contents of the array \b da are as follows.
633 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
634 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_3
641 Below more two variants of location of target values are shown.
642 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
650 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
657 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
658 be explicitly called in Python.
661 \anchor cpp_mcdataarrayint_setpartofvalues2
662 <br><h3> setPartOfValues2() </h3>
663 We create two arrays:
664 - a "large" (4x7) zero array \b da to assign to,
665 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
667 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_1
668 Now we assign the two components of \b dv to the components of \b da
669 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
670 indices [0,1,2]. This is the first mode of usage.
671 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_2
672 As result contents of the array \b da are as follows.
674 Tuple #0 : 0 7 0 8 0 0 0
675 Tuple #1 : 0 9 0 10 0 0 0
676 Tuple #2 : 0 11 0 12 0 0 0
677 Tuple #3 : 0 0 0 0 0 0 0
679 Every value of \b dv has been assigned to its own location within \b da.
681 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
682 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
683 This is the second mode of usage.
684 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_3
685 The contents of \b dv have been assigned to each of specified tuples of \b da.
686 Every value of \b dv is repeated in the 3 specified tuples within \b da.
688 Tuple #0 : 7 0 8 9 10 11 12
689 Tuple #1 : 0 0 0 0 0 0 0
690 Tuple #2 : 7 0 8 9 10 11 12
691 Tuple #3 : 7 0 8 9 10 11 12
693 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
694 be explicitly called in Python.
697 \anchor cpp_mcdataarrayint_setpartofvalues3
698 <br><h3> setPartOfValues3() </h3>
699 We create two arrays:
700 - a "large" (4x7) zero array \b da to assign to,
701 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
703 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_1
704 Now we assign the two components of \b dv to the components of \b da
705 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
706 indices [0,1,2] which are specified using slicing: "0:3".
707 This is the first mode of usage.
708 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_2
709 As result contents of the array \b da are as follows.
711 Tuple #0 : 0 7 0 8 0 0 0
712 Tuple #1 : 0 9 0 10 0 0 0
713 Tuple #2 : 0 11 0 12 0 0 0
714 Tuple #3 : 0 0 0 0 0 0 0
716 Every value of \b dv has been assigned to its own location within \b da.
718 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
719 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
720 slice notation "0:4:2". This is the second mode of usage.
721 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_3
722 The contents of \b dv have been assigned to each of specified tuples of \b da.
723 Every value of \b dv is repeated in the 3 specified tuples within \b da.
725 Tuple #0 : 7 0 8 9 10 11 12
726 Tuple #1 : 0 0 0 0 0 0 0
727 Tuple #2 : 7 0 8 9 10 11 12
728 Tuple #3 : 0 0 0 0 0 0 0
730 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
731 be explicitly called in Python.
734 \anchor cpp_mcdataarraydouble_getdifferentvalues
735 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
737 The code below creates an array of real values and than an array of
738 unique values, not closer one to another than 0.2, is retrieved from it.
739 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_getDifferentValues1
742 \anchor cpp_mcdataarraydouble_findcommontuples
743 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
745 Let's create an array of 6 tuples and 2 components that can be
746 considered as coordinates of 6 points in 2D space.
747 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples1
748 Now we find points that are not far each from other than 1e-1.
749 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples2
750 As we can realize from the above code, a hardcoded array \b expected3 is equal
751 to the raw data of a DataArrayInt \b c and a hardcoded array \b expected4 is equal
752 to the raw data of the DataArrayInt \b cI.
754 The array \b c contains indices of 5 coincident points. The array \b
755 cI shows us boundaries of (cI->getNumberOfTuples()-1) = 2 groups of coincident points:
756 - The first group starts at index 0 and includes (3 - 0) = 3 points: 0,3,4.
757 - The second group starts at index 3 and includes (5 - 3) = 2 points: 1,2.
759 \anchor cpp_mcdataarraydouble_meldwith
760 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
762 In this example we create two data arrays including \b same number of
763 tuples and then we concatenate them using \ref
764 ParaMEDMEM::DataArrayDouble::meldWith "meldWith()".
765 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_Meld1_1
766 Now the array \b da1 includes 7 tuples (as before) of 3 components
767 each. Its components are: "c0da1","c1da1","c0da2".
770 \anchor cpp_mcdataarrayint_meldwith
771 <br><h2> Concatenating DataArrayInt's by appending components </h2>
773 In this example we create two data arrays including \b same number of
774 tuples and then we concatenate them using \ref
775 ParaMEDMEM::DataArrayInt::meldWith "meldWith()".
776 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_Meld1_1
777 Now the array \b da1 includes 7 tuples (as before) of 3 components
778 each. Its components are: "c0da1","c1da1","c0da2".
781 \anchor cpp_mcdataarraydouble_KeepSelectedComponents
783 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
785 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_1
786 We created an array \b a1 containing 5 tuples of 4 components each (20
787 values). Now we are going to create an array \b a2 containing some
789 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_2
790 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
791 the result array \b a2 includes 30 elements (5 tuples per 6 components).
793 \anchor cpp_mcfielddouble_subpart1
795 \anchor cpp_mcdataarrayint_keepselectedcomponents
797 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
799 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_1
800 We created an array \b a1 containing 5 tuples of 4 components each (20
801 values). Now we are going to create an array \b a2 containing some
803 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_2
804 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
805 the result array \b a2 includes 30 elements (5 tuples per 6 components).
808 \ref ParaMEDMEM::DataArrayInt::keepSelectedComponents() "DataArrayInt::keepSelectedComponents()"
809 is called, providing the same result, by the following python code:
810 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_3
812 \anchor cpp_mcfielddouble_subpart1
815 <br><h2>Creation of a sub part of a field</h2>
816 <br><h3>Creation of a sub part of a field on cells</h3>
817 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
818 The field on cells \b f1 lies on a mesh containing 5 cells and 9 nodes.
819 So this field \b f1 contains 5 tuples of 2 components each (10 values).
820 Now let's create a subfield on cells \b f2 from \b f1.
821 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
823 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
825 So the array \b part1 lists ids on cells.
827 - cell #0 of \b f2 is the same cell of cell #2 of \b f1
828 - cell #1 of \b f2 is the same cell of cell #1 of \b f1
829 - cell #2 of \b f2 is the same cell of cell #4 of \b f1
831 So \b f2 contains 3 tuples with 2 components.
833 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).
834 \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).
835 \nOnly fields on cells have this particular behaviour.
837 <br><h3>Creation of a sub part of a field on nodes</h3>
838 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
839 The field on nodes \b f1 lies on a mesh containing 5 cells and 9 nodes.
840 So this field \b f1 contains 9 tuples of 2 components each (18 values).
841 Now let's create a subfield on nodes \b f2 from \b f1.
842 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
844 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
846 After the call of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" on node field \b f1, \b f1 will be reduced on a
847 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.
848 \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"
849 method does not match the size of the input array (here \b part2).
854 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
856 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
857 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
859 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
861 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
863 Gives an upper bound of the number of cells to be inserted into the unstructured mesh.
864 \n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method.
865 \n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance.
867 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
869 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.
871 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
873 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
875 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
880 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
882 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).
883 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1
885 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
887 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
889 Then enter nodal connectivity at once.
891 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
893 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.
895 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
897 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
899 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
904 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
906 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
908 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
910 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
912 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
914 There are 2 techniques to get it.
918 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
922 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
924 \c mesh is now available for use :
926 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
928 When this mesh is no more needed simply call decrRef to decrement its reference counter.
930 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
935 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached </h1>
937 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
942 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
944 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
949 \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>
951 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
956 \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>
958 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
963 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
965 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
967 The decrementation of ref counter should be carried out in CPlusPlus only ...
969 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3