Salome HOME
Boost of expression evaluator DataArrayDouble::applyFunc* + DataArrayDouble::applyFun...
[modules/med.git] / src / MEDCoupling / Test / MEDCouplingExamplesTest.cxx
index 365d6dd58b3349800e3a53dbaf10cb16097088ab..9bf0c7f4a87c1cec0aa9e342b1a70c3a543db297 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -104,7 +104,7 @@ void CppExample_MEDCouplingFieldDouble_MergeFields()
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field2 =
     field1->cloneWithMesh( true );
   double vec[1] = { 5. };
-  ((ParaMEDMEM::MEDCouplingMesh *)field2->getMesh())->translate(vec); // translate mesh2
+  (const_cast<ParaMEDMEM::MEDCouplingMesh *>(field2->getMesh()))->translate(vec); // translate mesh2
   field2->applyFunc("x + 5"); // "translate" field2
 
   // concatenate field1 and field2
@@ -189,8 +189,8 @@ void CppExample_MEDCouplingFieldDouble_applyFunc_same_nb_comp()
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field =
     MEDCouplingFieldDouble::New( ParaMEDMEM::ON_CELLS );
   field->setArray( array );
-  const char func[] = "IVec * v + JVec * v*v + 10";
-  field->applyFunc( func );
+  const char func[] = "IVec * v + JVec * w*w + 10";
+  field->applyFunc( 2, func );
   CPPUNIT_ASSERT( field->getNumberOfComponents() == 2 ); // 2 components remains
   //! [CppSnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_1]
   //! [CppSnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_2]
@@ -596,7 +596,7 @@ void CppExample_MEDCouplingFieldDouble_renumberNodes()
   field->renumberNodes(renumber,false);
   const MEDCouplingMesh* mesh2 = field->getMesh(); // field now refers to another mesh
   values = field->getArray();
-  nodeCoords = ((MEDCouplingUMesh*)mesh2)->getCoords();
+  nodeCoords = (static_cast<const MEDCouplingUMesh*>(mesh2))->getCoords();
   CPPUNIT_ASSERT( values->isEqualWithoutConsideringStr( *nodeCoords, 1e-13 ));
   //! [CppSnippet_MEDCouplingFieldDouble_renumberNodes_3]
 }
@@ -945,12 +945,12 @@ void CppExample_MEDCouplingUMesh_getCellsContainingPoints()
                             0.3, 0.3,              // point located somewhere inside the mesh
                             coords[2], coords[3]}; // point at the node #1
   const double eps = 1e-4; // ball radius
-  std::vector<int> cells, cellsIndex;
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cells, cellsIndex;
   mesh->getCellsContainingPoints( pos, 3, eps, cells, cellsIndex );
   const int cellsExpected[3]={4, 0, 1};
   const int cellsIndexExpected[4]={0, 0, 1, 3};
-  CPPUNIT_ASSERT(std::equal( cellsExpected,      cellsExpected+3,      &cells[0]));
-  CPPUNIT_ASSERT(std::equal( cellsIndexExpected, cellsIndexExpected+4, &cellsIndex[0]));
+  CPPUNIT_ASSERT(std::equal( cellsExpected,      cellsExpected+3,      cells->begin()));
+  CPPUNIT_ASSERT(std::equal( cellsIndexExpected, cellsIndexExpected+4, cellsIndex->begin()));
   //! [CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_2]
 }