6 #include <cpm/DataStructures/QuadEdgeMesh.h>
7 #include <cpm/DataStructures/SimplexMesh.h>
8 #include <cpm/Algorithms/QuadEdge/MeshToDualFilter.h>
9 #include <cpm/IO/MeshReader.h>
12 #include <vtkCallbackCommand.h>
13 #include <vtkProperty.h>
14 #include <vtkRenderer.h>
15 #include <vtkRenderWindow.h>
16 #include <vtkRenderWindowInteractor.h>
17 #include <vtkSmartPointer.h>
18 #include <cpm/VTK/MeshMapper.h>
20 // -------------------------------------------------------------------------
21 const unsigned int Dimension = 3;
22 const unsigned int Order = 2;
24 typedef float TScalar;
25 typedef cpm::DataStructures::QuadEdgeMesh< TScalar, Dimension > TMesh;
26 typedef cpm::DataStructures::SimplexMesh< TScalar, Order, Dimension > TSimplex;
27 typedef cpm::VTK::MeshMapper< TMesh > TMeshMapper;
29 // -------------------------------------------------------------------------
30 int main( int argc, char* argv[] )
35 << "Usage: " << argv[ 0 ]
42 typedef cpm::IO::MeshReader< TMesh > TReader;
43 TReader::Pointer reader = TReader::New( );
44 reader->SetFileName( argv[ 1 ] );
47 cpm::Algorithms::QuadEdge::MeshToDualFilter< TMesh, TSimplex >
49 TDualFilter::Pointer dual_filter = TDualFilter::New( );
50 dual_filter->SetInput( reader->GetOutput( ) );
51 dual_filter->Update( );
52 TSimplex::Pointer simplex = dual_filter->GetOutput( );
55 << " --> Read " << simplex->GetNumberOfPoints( )
63 << " --> Delete an edge between a and b (-1 to finish) : "
74 if( simplex->OperatorDeleteEdge( a, b ) )
75 std::cout << "Deleted" << std::endl;
77 std::cout << "Not present" << std::endl;
82 vtkSmartPointer< TMeshMapper > mapper =
83 vtkSmartPointer< TMeshMapper >::New( );
84 mapper->SetInputData( reader->GetOutput( ) );
87 vtkSmartPointer< TMeshMapper > dual_mapper =
88 vtkSmartPointer< TMeshMapper >::New( );
89 dual_mapper->SetInputData( dual_filter->GetOutput( ) );
92 vtkSmartPointer< vtkActor > actor =
93 vtkSmartPointer< vtkActor >::New( );
94 actor->SetMapper( mapper );
95 actor->GetProperty( )->SetColor( 1, 1, 0 );
96 actor->GetProperty( )->SetOpacity( 0.5 );
99 vtkSmartPointer< vtkActor > dual_actor =
100 vtkSmartPointer< vtkActor >::New( );
101 dual_actor->SetMapper( dual_mapper );
102 dual_actor->GetProperty( )->SetColor( 1, 0, 0 );
103 dual_actor->GetProperty( )->SetOpacity( 1 );
104 dual_actor->GetProperty( )->SetLineWidth( 2 );
105 dual_actor->GetProperty( )->SetRepresentationToWireframe( );
107 // Configure visualization objects
108 vtkSmartPointer< vtkRenderer > renderer =
109 vtkSmartPointer< vtkRenderer >::New( );
110 renderer->SetBackground( 0.1, 0.3, 0.5 );
112 vtkSmartPointer< vtkRenderWindow > window =
113 vtkSmartPointer< vtkRenderWindow >::New( );
114 window->AddRenderer( renderer );
115 window->SetSize( 800, 800 );
117 // Set up the interaction
118 vtkSmartPointer< vtkRenderWindowInteractor > interactor =
119 vtkSmartPointer< vtkRenderWindowInteractor >::New( );
120 window->SetInteractor( interactor );
123 //renderer->AddActor( actor );
124 renderer->AddActor( dual_actor );
128 interactor->Start( );