📄 itkquadedgemesheuleroperatorstest.cxx
字号:
// | __/ | / | | __/ |
// | / | / | | / |
// 10 --------- 11 _/ | 13 --------- 14
// | __/ | / | | __/ |
// | __/ | / | | __/ |
// | __/ | / | | __/ |
// | / | / | | / |
// 5 ---------- 6 ---------- 7 ---------- 8 --------- 9
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 0 ---------- 1 ---------- 2 --------- 3 --------- 4
//
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 24, 50, 27, 1, 0 ) )
{
std::cout << "FAILED (for [ 12, 13 ] )." << std::endl;
return 1;
}
// Push it one step further: we should obtain
//
// 20 --------- 21 --------- 22 --------- 23 --------- 24
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 15 --------- 16 --------- 17 --------- 18 --------- 19
// | __/ | //| \ | __/ |
// | __/ | // | \ | __/ |
// | __/ | / | | \ | __/ |
// | / | / / | \ | / |
// 10 --------- 11 _/ | | \_ 13 --------- 14
// | __/ | / / | \ | __/ |
// | __/ | / | | \ | __/ |
// | __/ | / | | \ | __/ |
// | / | / | | \ | / |
// 5 ---------- 6 / | 8 --------- 9
// | __/ | | | __/ | __/ |
// | __/ | / | __/ | __/ |
// | __/ | | | __/ | __/ |
// | / | / | / | / |
// 0 ---------- 1 ---------- 2 --------- 3 --------- 4
//
mesh->LightWeightDeleteEdge( mesh->FindEdge( 6, 17 ) );
mesh->AddFace( mesh->FindEdge( 7, 17 ) );
if( !joinVertex->Evaluate( mesh->FindEdge( 7, 17 ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
mesh->DeletePoint( joinVertex->GetOldPointID( ) );
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 23, 48, 26, 1, 0 ) )
{
std::cout << "FAILED (for [ 12, 13 ] )." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl;
// Consider a last pathological test of an edge with an isolated
// end potientaly immersed in a face. Here is the initial situation:
//
// 20 --------- 21 --------- 22 --------- 23 --------- 24
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 15 --------- 16 --------- 17 --------- 18 --------- 19
// | __/ | __/ | | __/ |
// | __/ | __/ | | __/ |
// | __/ | __/ | | __/ |
// | / | / | | / |
// 10 --------- 11 12 13 --------- 14
// | __/ | | __/ |
// | __/ | | __/ |
// | __/ | | __/ |
// | / | | / |
// 5 ---------- 6 ---------- 7 ---------- 8 --------- 9
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 0 ---------- 1 ---------- 2 --------- 3 --------- 4
//
// Vertices: 25 , Edges: 56, Faces: 32, Boundary = 1, Chi = 1
PopulateMesh<MeshType>( mesh );
std::cout << " ";
std::cout << "Join v of antenna - version 1 (possible).";
joinVertex->SetInput( mesh );
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->AddFace( mesh->FindEdge( 7, 8 ) );
if( !joinVertex->Evaluate( mesh->FindEdge( 12, 17 ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
mesh->DeletePoint( joinVertex->GetOldPointID( ) );
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 24, 49, 26, 1, 0 ) )
{
std::cout << "FAILED (for antenna - version 1)." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
PopulateMesh<MeshType>( mesh );
std::cout << " ";
std::cout << "Join v of antenna - version 2 (possible).";
joinVertex->SetInput( mesh );
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->AddFace( mesh->FindEdge( 7, 8 ) );
if( !joinVertex->Evaluate( mesh->FindEdge( 12, 17 )->GetSym( ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
mesh->DeletePoint( joinVertex->GetOldPointID( ) );
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 24, 49, 26, 1, 0 ) )
{
std::cout << "FAILED (for antenna - version 2)." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
std::cout << "Checking JoinVertex." << "OK" << std::endl << std::endl;
/////////////////////////////////////////
//
// Split Vertex
//
/////////////////////////////////////////
std::cout << "Checking SplitVertex." << std::endl;
PopulateMesh<MeshType>( mesh );
SplitVertex::Pointer splitVertex = SplitVertex::New( );
std::cout << " " << "Test No Mesh Input";
if( splitVertex->Evaluate( (QEType*)1, (QEType*)1 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
(void)splitVertex->GetNameOfClass();
splitVertex->SetInput( mesh );
std::cout << " " << "Test No QE Input";
if( splitVertex->Evaluate( (QEType*)0, (QEType*)0 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
std::cout << " ";
std::cout << "Split Vertex (Possible).";
if( !splitVertex->Evaluate( mesh->FindEdge( 5, 11 ),
mesh->FindEdge( 17, 11 ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
// move the new point, for example along z axis for special effect :-D
PointType PtTmp = mesh->GetPoint( splitVertex->GetNewPointID( ) );
PtTmp[2] = 1;
mesh->SetPoint( splitVertex->GetNewPointID( ), PtTmp );
// Test
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 26, 57, 32, 1, 0 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
if ( mesh->GetPoint( splitVertex->GetNewPointID( ) ).GetValence( ) != 4 )
{
std::cout << "FAILED, wrong valence of "
<< mesh->GetPoint( splitVertex->GetNewPointID( ) ).GetValence( )
<< " for vertex " << splitVertex->GetNewPointID( ) << "." << std::endl;
return 1;
}
if ( mesh->GetPoint( 11 ).GetValence( ) != 4 )
{
std::cout << "FAILED (for, wrong valence of "
<< mesh->GetPoint( 11 ).GetValence( )
<< " for vertex 11 )." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl;
//test antenna
PopulateMesh<MeshType>( mesh );
std::cout << " ";
std::cout << "Try to split antenna (impossible).";
splitVertex->SetInput( mesh );
if( splitVertex->Evaluate( mesh->FindEdge( 12, 17 ),
mesh->FindEdge( 12, 17 ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl;
//test different dest( )
PopulateMesh<MeshType>( mesh );
std::cout << " ";
std::cout << "Test with args with different Dest( ) (Impossible).";
splitVertex->SetInput( mesh );
if( splitVertex->Evaluate( mesh->FindEdge( 5, 11 ),
mesh->FindEdge( 5, 6 ) ) )
{
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( 5 ).GetValence( ) != 4 )
{
std::cout << "FAILED, wrong valence of "
<< mesh->GetPoint( 5 ).GetValence( )
<< " for vertex 5." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl;
std::cout << "Checking SplitVertex." << std::endl << std::endl;
std::cout << "Checking JoinVertex( SplitVertex()) Invariance.";
PopulateMesh<MeshType>( mesh );
splitVertex->SetInput( mesh );
joinVertex->SetInput( mesh );
if( !joinVertex->Evaluate( splitVertex->Evaluate( mesh->FindEdge( 5, 11 ),
mesh->FindEdge( 17, 11 ) )) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
mesh->DeletePoint( joinVertex->GetOldPointID( ) );
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 25, 56, 32, 1, 0 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl << std::endl;
/////////////////////////////////////////
//
// Split Edge
//
/////////////////////////////////////////
std::cout << "Checking SplitEdge." << std::endl;
PopulateMesh<MeshType>( mesh );
SplitEdge::Pointer splitEdge = SplitEdge::New( );
std::cout << " " << "Test No Mesh Input";
if( splitEdge->Evaluate( (QEType*)1 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
(void)splitEdge->GetNameOfClass();
splitEdge->SetInput( mesh );
std::cout << " " << "Test No QE Input";
if( splitEdge->Evaluate( (QEType*)0 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << "OK" << std::endl;
std::cout << " ";
std::cout << "Split an internal edge (possible).";
if( !splitEdge->Evaluate( mesh->FindEdge( 6, 12 ) ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
if( ! AssertTopologicalInvariants< MeshType >
( mesh, 26, 57, 32, 1, 0 ) )
{
std::cout << "FAILED." << std::endl;
return 1;
}
std::cout << ".OK" << std::endl;
std::cout << "Checking SplitEdge." << "OK" << std::endl << std::endl;
/////////////////////////////////////////
//
// Create Center Vertex
//
/////////////////////////////////////////
//
// 20 --------- 21 --------- 22 --------- 23 --------- 24
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 15 --------- 16 --------- 17 --------- 18 --------- 19
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 10 --------- 11 --------- 12 --------- 13 --------- 14
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | __/ | __/ | __/ | __/ |
// | / | / | / | / |
// 5 ---------- 6 ---------- 7 ---------- 8 --------- 9
// | __/ | __/ | __//| __/ |
// | __/ | __/ | __/ / | __/ |
// | __/ | __/ | __/ __x/ | __/ |
// | / | / | /___/ \_ | / |
// 0 ---------- 1 ---------- 2 --------- 3 --------- 4
std::cout << "Checking CreateCenterVertex." << std::endl;
PopulateMesh<MeshType>( mesh );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -