Salome HOME
Bug fix: CellModel - POLYL cell model was buggy (missing 'break' in a switch())
[tools/medcoupling.git] / src / MEDCoupling / Test / MEDCouplingBasicsTest1.cxx
index 9808e0205d113042f28bc8745a07d098741c4fc9..fc06ef5a3b80687316bed8a358b63bb8b4ea60c7 100644 (file)
@@ -2162,25 +2162,24 @@ void MEDCouplingBasicsTest1::testGetCellsContainingPoint()
 {
   MEDCouplingUMesh *targetMesh=build2DTargetMesh_1();
   double pos[12]={0.,0.,0.4,0.4,0.,0.4,0.1,0.1,0.25,0.,0.65,0.};
-  std::vector<int> t1,t2;
+  MEDCouplingAutoRefCountObjectPtr<DataArrayInt> t1,t2;
   //2D basic
   targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
-  CPPUNIT_ASSERT_EQUAL(6,(int)t1.size());
-  CPPUNIT_ASSERT_EQUAL(7,(int)t2.size());
+  CPPUNIT_ASSERT_EQUAL(6,(int)t1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(7,(int)t2->getNbOfElems());
   const int expectedValues1[6]={0,4,3,0,1,2};
   const int expectedValues2[7]={0,1,2,3,4,5,6};
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1));
-  CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
+  CPPUNIT_ASSERT(std::equal(t1->begin(),t1->end(),expectedValues1));
+  CPPUNIT_ASSERT(std::equal(t2->begin(),t2->end(),expectedValues2));
   //2D with no help of bounding box.
   double center[2]={0.2,0.2};
   MEDCouplingPointSet::Rotate2DAlg(center,0.78539816339744830962,6,pos);
   targetMesh->rotate(center,0,0.78539816339744830962);
-  t1.clear(); t2.clear();
   targetMesh->getCellsContainingPoints(pos,6,1e-12,t1,t2);
-  CPPUNIT_ASSERT_EQUAL(6,(int)t1.size());
-  CPPUNIT_ASSERT_EQUAL(7,(int)t2.size());
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues1));
-  CPPUNIT_ASSERT(std::equal(t2.begin(),t2.end(),expectedValues2));
+  CPPUNIT_ASSERT_EQUAL(6,(int)t1->getNbOfElems());
+  CPPUNIT_ASSERT_EQUAL(7,(int)t2->getNbOfElems());
+  CPPUNIT_ASSERT(std::equal(t1->begin(),t1->end(),expectedValues1));
+  CPPUNIT_ASSERT(std::equal(t2->begin(),t2->end(),expectedValues2));
   //2D outside
   const double pos1bis[2]={-0.3303300858899107,-0.11819805153394641};
   CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos1bis,1e-12));
@@ -2188,17 +2187,18 @@ void MEDCouplingBasicsTest1::testGetCellsContainingPoint()
   //test limits 2D
   targetMesh=build2DTargetMesh_1();
   const double pos2[2]={0.2,-0.05};
-  t1.clear();
-  targetMesh->getCellsContainingPoint(pos2,1e-12,t1);
-  CPPUNIT_ASSERT_EQUAL(2,(int)t1.size());
+  std::vector<int> t11;
+  t11.clear();
+  targetMesh->getCellsContainingPoint(pos2,1e-12,t11);
+  CPPUNIT_ASSERT_EQUAL(2,(int)t11.size());
   const int expectedValues3[2]={0,1};
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues3));
+  CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues3));
   const double pos3[2]={0.2,0.2};
-  t1.clear();
-  targetMesh->getCellsContainingPoint(pos3,1e-12,t1);
-  CPPUNIT_ASSERT_EQUAL(5,(int)t1.size());
+  t11.clear();
+  targetMesh->getCellsContainingPoint(pos3,1e-12,t11);
+  CPPUNIT_ASSERT_EQUAL(5,(int)t11.size());
   const int expectedValues4[5]={0,1,2,3,4};
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues4));
+  CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues4));
   CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos3,1e-12));
   targetMesh->decrRef();
   //3D
@@ -2206,17 +2206,17 @@ void MEDCouplingBasicsTest1::testGetCellsContainingPoint()
   const double pos4[3]={25.,25.,25.};
   CPPUNIT_ASSERT_EQUAL(0,targetMesh->getCellContainingPoint(pos4,1e-12));
   const double pos5[3]={50.,50.,50.};
-  t1.clear();
-  targetMesh->getCellsContainingPoint(pos5,1e-12,t1);
-  CPPUNIT_ASSERT_EQUAL(8,(int)t1.size());
+  t11.clear();
+  targetMesh->getCellsContainingPoint(pos5,1e-12,t11);
+  CPPUNIT_ASSERT_EQUAL(8,(int)t11.size());
   const int expectedValues5[8]={0,1,2,3,4,5,6,7};
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues5));
+  CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues5));
   const double pos6[3]={0., 50., 0.};
-  t1.clear();
-  targetMesh->getCellsContainingPoint(pos6,1e-12,t1);
-  CPPUNIT_ASSERT_EQUAL(2,(int)t1.size());
+  t11.clear();
+  targetMesh->getCellsContainingPoint(pos6,1e-12,t11);
+  CPPUNIT_ASSERT_EQUAL(2,(int)t11.size());
   const int expectedValues6[2]={0,2};
-  CPPUNIT_ASSERT(std::equal(t1.begin(),t1.end(),expectedValues6));
+  CPPUNIT_ASSERT(std::equal(t11.begin(),t11.end(),expectedValues6));
   //3D outside
   const double pos7[3]={-1.0,-1.0,0.};
   CPPUNIT_ASSERT_EQUAL(-1,targetMesh->getCellContainingPoint(pos7,1e-12));