Salome HOME
Addition of new reference coords including degenerated cells.
[modules/med.git] / src / MEDCoupling / Test / MEDCouplingExamplesTest.cxx
index a98c000a02b11ee79d281d712623cb0cd54d54ee..86a9f7e6f19f789de0e9b3f99e9dd16807d14d0e 100644 (file)
@@ -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
@@ -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]
 }
@@ -928,11 +928,11 @@ void CppExample_MEDCouplingUMesh_getCellsContainingPoints()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);
@@ -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]
 }
 
@@ -1141,11 +1141,11 @@ void CppExample_MEDCouplingUMesh_findBoundaryNodes()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);
@@ -1167,11 +1167,11 @@ void CppExample_MEDCouplingUMesh_buildBoundaryMesh()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);
@@ -1294,11 +1294,11 @@ void CppExample_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);
@@ -1440,11 +1440,11 @@ void CppExample_MEDCouplingUMesh_zipCoordsTraducer()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);
@@ -1473,11 +1473,11 @@ void CppExample_MEDCouplingUMesh_getNodeIdsInUse()
   mesh->setMeshDimension(2);
   mesh->allocateCells(5);
   const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);    // 0
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4);  // 1
-  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7);  // 2
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
-  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn);   
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+4); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+7); 
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10);
+  mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14);
   mesh->finishInsertingCells();
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
   coordsArr->alloc(9,2);