⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itkquadedgemesheuleroperatorstest.cxx

📁 DTMK软件开发包,此为开源软件,是一款很好的医学图像开发资源.
💻 CXX
📖 第 1 页 / 共 5 页
字号:

  CreateCenterVertex::Pointer createCenterVertex = CreateCenterVertex::New( );
  std::cout << "     " << "Test No Mesh Input";
  if( createCenterVertex->Evaluate( (QEType*)1 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << "OK" << std::endl;
  
  (void)createCenterVertex->GetNameOfClass(); 

  createCenterVertex->SetInput( mesh );
  std::cout << "     " << "Test QE Input with no left face";
  dummy = new QEType;
  if( createCenterVertex->Evaluate( dummy ) ) 
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  delete dummy;
  std::cout << "OK" << std::endl;

  std::cout << "     " << "Test No QE Input";
  if( createCenterVertex->Evaluate( (QEType*)0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << "OK" << std::endl;

  std::cout << "     ";
  std::cout << "Create a center vertex of a triangle (possible).";
  if( !createCenterVertex->Evaluate( mesh->FindEdge( 8, 2 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 26, 59, 34, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  if ( mesh->GetPoint( createCenterVertex->GetNewPointID( ) ).GetValence( ) != 3 )
    {
    std::cout << "FAILED, wrong valence of "
       << mesh->GetPoint( createCenterVertex->GetNewPointID( ) ).GetValence( )
       << " for vertex "
       << createCenterVertex->GetNewPointID( )
       << "." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  // test with a bigger polygon
  //
  //   20 --------- 21 --------- 22 --------- 23 --------- 24
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //   15 --------- 16 --------- 17 --------- 18 --------- 19
  //    |        __/ | \__        |        __/ |        __/ |
  //    |     __/    |    \__     |     __/    |     __/    |
  //    |  __/       |       \__  |  __/       |  __/       |
  //    | /          |          \ | /          | /          |
  //   10 --------- 11---------- xx --------- 13 --------- 14
  //    |        __/ |        __/ | \__        |        __/ |
  //    |     __/    |     __/    |    \__     |     __/    |
  //    |  __/       |  __/       |       \__  |  __/       |
  //    | /          | /          |          \ | /          |
  //    5 ---------- 6 ---------- 7 ---------- 8 ---------  9
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //    0 ---------- 1 ---------- 2  --------- 3 ---------  4
  
  PopulateMesh<MeshType>( mesh );
  
  std::cout << "     ";
  std::cout << "Create a center vertex of a Polygon (possible).";
  
  // this create the 16-17-18-13-8-7-6-11 polygon.
  mesh->LightWeightDeleteEdge( mesh->FindEdge( 11, 12 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge(  6, 12 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge(  7, 12 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge(  7, 13 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge( 12, 13 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge( 12, 18 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge( 12, 17 ) );
  mesh->LightWeightDeleteEdge( mesh->FindEdge( 11, 17 ) );
  mesh->DeletePoint( 12 );
  mesh->AddFace( mesh->FindEdge( 6, 7 ) );
  if( !createCenterVertex->Evaluate( mesh->FindEdge( 6,  7 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }   
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 25, 56, 32, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  if ( mesh->GetPoint( createCenterVertex->GetNewPointID( ) ).GetValence( ) != 8 )
    {
    std::cout << "FAILED, wrong valence of "
       << mesh->GetPoint( createCenterVertex->GetNewPointID( ) ).GetValence( )
       << " for vertex "
       << createCenterVertex->GetNewPointID( )
       << "." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  std::cout << "Checking CreateCenterVertex." << "OK" << std::endl << std::endl;
  /////////////////////////////////////////
  //
  //          Delete Center Vertex
  //
  /////////////////////////////////////////
  // first test with the center vertex.
  // we take 6-->12 as incoming parameter.
  //
  //    Vertices: 24 , Edges: 50, Faces: 27, Boundary = 1, Chi = 1
  //
  //   20 --------- 21 --------- 22 --------- 23 --------- 24
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //   15 --------- 16 --------- 17 --------- 18 --------- 19
  //    |        __/ |        __/              |        __/ |
  //    |     __/    |     __/                 |     __/    |
  //    |  __/       |  __/                    |  __/       |
  //    | /          | /                       | /          |
  //   10 --------- 11                        13 --------- 14
  //    |        __/ |                     __/ |        __/ |
  //    |     __/    |                  __/    |     __/    |
  //    |  __/       |               __/       |  __/       |
  //    | /          |              /          | /          |
  //    5 ---------- 6 ---------- 7 ---------- 8 ---------  9
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //    0 ---------- 1 ---------- 2  --------- 3 ---------  4
  std::cout << "Checking DeleteCenterVertex." << std::endl;
  PopulateMesh<MeshType>( mesh );

  DeleteCenterVertex::Pointer deleteCenterVertex = DeleteCenterVertex::New( );
  std::cout << "     " << "Test No Mesh Input";
  if( deleteCenterVertex->Evaluate( (QEType*)1 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << "OK" << std::endl;
  
  (void)deleteCenterVertex->GetNameOfClass(); 

  deleteCenterVertex->SetInput( mesh );
  std::cout << "     " << "Test No QE Input";
  if( deleteCenterVertex->Evaluate( (QEType*)0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << "OK" << std::endl;

  deleteCenterVertex->SetInput( mesh );
  std::cout << "     " << "Test one-ring not full (impossible)";
  if( deleteCenterVertex->Evaluate( mesh->FindEdge( 15, 21 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << "OK" << std::endl;

    {
    MeshPointer  specialmesh = MeshType::New();
    PointType pts3[4];
    pts3[ 0][0] = 0.0;  pts3[ 0][1] = 0.0;  pts3[ 0][2] = 0.0;
    pts3[ 1][0] = 1.0;  pts3[ 1][1] = 0.0;  pts3[ 1][2] = 0.0;
    pts3[ 2][0] = 0.0;  pts3[ 2][1] = 1.0;  pts3[ 2][2] = 0.0;
    pts3[ 3][0] = 0.0;  pts3[ 3][1] = 0.0;  pts3[ 3][2] = 1.0;
    for(int i=0; i<4; i++)
      {
      specialmesh->SetPoint( i, pts3[i] );
      }
    int specialCells[12] =
    {  0,  1,  2,
       0,  2,  3,
       3,  1,  0,
       1,  3,  2 };

    CellType::CellAutoPointer cellpointer;
    typedef itk::QuadEdgeMeshPolygonCell< CellType > QEPolygonCellType;
    QEPolygonCellType *poly;
    for(int i=0; i<4; i++)
      {
      poly = new QEPolygonCellType( 3 );
      cellpointer.TakeOwnership( poly );
      cellpointer->SetPointId( 0, specialCells[3*i] );
      cellpointer->SetPointId( 1, specialCells[3*i+1] );
      cellpointer->SetPointId( 2, specialCells[3*i+2] );
      specialmesh->SetCell( i, cellpointer );
      }
    deleteCenterVertex->SetInput( specialmesh );
    std::cout << "     ";
    std::cout << "Delete a vertex of a non-collapsable mesh (impossible).";
    if( deleteCenterVertex->Evaluate( specialmesh->FindEdge( 0, 1 ) ) )
      {
      std::cout << "FAILED." << std::endl;
      return 1;
      }
    }

  deleteCenterVertex->SetInput( mesh );
  std::cout << "     ";
  std::cout << "Delete center vertex with internal 1-ring (possible).";
  if( !deleteCenterVertex->Evaluate( mesh->FindEdge( 6, 12 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  mesh->DeletePoint( deleteCenterVertex->GetOldPointID( ) );
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 24, 50, 27, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  // The initial configuration and numbering of simpleSquare.vtk:
  //    Vertices: 25 , Edges: 56, Faces: 32, Boundary = 1, Chi = 1
  //
  //   20 --------- 21 --------- 22 --------- 23 --------- 24
  //    |        __/ |        __/ |        __/              |
  //    |     __/    |     __/    |     __/                 |
  //    |  __/       |  __/       |  __/                    |
  //    | /          | /          | /                       |
  //   15 --------- 16 --------- 17                        19
  //    |        __/ |        __/ |                     __/ |
  //    |     __/    |     __/    |                  __/    |
  //    |  __/       |  __/       |               __/       |
  //    | /          | /          |              /          |
  //   10 --------- 11 --------- 12 --------- 13 --------- 14
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //    5 ---------- 6 ---------- 7 ---------- 8 ---------  9
  //    |        __/ |        __/ |        __/ |        __/ |
  //    |     __/    |     __/    |     __/    |     __/    |
  //    |  __/       |  __/       |  __/       |  __/       |
  //    | /          | /          | /          | /          |
  //    0 ---------- 1 ---------- 2  --------- 3 ---------  4
  //
  PopulateMesh<MeshType>( mesh );
  std::cout << "     ";
  std::cout << "Delete center vertex with border 1-ring (possible).";
  deleteCenterVertex->SetInput( mesh );
  if( !deleteCenterVertex->Evaluate( mesh->FindEdge( 17, 18 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  mesh->DeletePoint( deleteCenterVertex->GetOldPointID( ) );
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 24, 50, 27, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  // test that border points can not be deleted.
  PopulateMesh<MeshType>( mesh );
  std::cout << "     ";
  std::cout << "Check deleting a border vertex (impossible).";

  deleteCenterVertex->SetInput( mesh );
  if( deleteCenterVertex->Evaluate( mesh->FindEdge( 23, 24 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 25, 56, 32, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  
  // test that points including an hole in the 1-ring
  // can not be deleted.
  PopulateMesh<MeshType>( mesh );
  std::cout << "     ";
  std::cout << "Check deleting a vertex around an hole (impossible).";
  mesh->LightWeightDeleteEdge( mesh->FindEdge(  6, 12 ) );
  deleteCenterVertex->SetInput( mesh );
  if( deleteCenterVertex->Evaluate( mesh->FindEdge(  6,  7 ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  if( !AssertTopologicalInvariants< MeshType >
          ( mesh, 25, 55, 30, 2, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;

  std::cout << "Checking DeleteCenterVertex." << "OK" << std::endl << std::endl;

  std::cout << "Checking DeleteCenterVertex( CreateCenterVertex()) Invariance.";
   
  PopulateMesh<MeshType>( mesh );   
  if( !deleteCenterVertex->Evaluate( createCenterVertex->Evaluate( mesh->FindEdge( 0, 1 ) ) ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  mesh->DeletePoint( deleteCenterVertex->GetOldPointID( ) );
  if( ! AssertTopologicalInvariants< MeshType >
          ( mesh, 25, 56, 32, 1, 0 ) )
    {
    std::cout << "FAILED." << std::endl;
    return 1;
    }
  std::cout << ".OK" << std::endl;
  return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -