commit c953cf6f6ccbc9e7652a30290ea181fbd0500c20 Author: ccolin Date: Mon Jan 31 16:55:32 2022 +0100 initial commit diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..c0e5b72 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) + +project(pfe) + +add_subdirectory(external/vtk) + +add_executable(pfe) + +target_sources(pfe PRIVATE src/main.cc) +target_link_libraries(pfe PRIVATE VTK::CommonCore VTK::ViewsCore VTK::RenderingCore VTK::IOCore VTK::FiltersCore VTK::CommonColor VTK::GUISupportQt VTK::RenderingQt VTK::ViewsQt) diff --git a/LISEZMOI b/LISEZMOI new file mode 100644 index 0000000..30ca7bb --- /dev/null +++ b/LISEZMOI @@ -0,0 +1,20 @@ +Projet de fin d'étude de M2 Info Géométrie et Informatique Graphique. + + +Compilation : + cmake -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build + + +Compilation (pour développeurs) : + cmake -Bbuild \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_CXX_FLAGS="-Wall -Wextra" \ + && cmake --build build + + +Il peut également être nécessaire de passer + -DVTK_MODULE_ENABLE_VTK_GUISupportQt:STRING=YES + -DVTK_MODULE_ENABLE_VTK_RenderingQt:STRING=YES + -DVTK_MODULE_ENABLE_VTK_ViewsQt:STRING=YES +à cmake sans quoi la fenêtre refuse de s'afficher (nécessite d'avoir +Qt installé). diff --git a/external/vtk/CMakeLists.txt b/external/vtk/CMakeLists.txt new file mode 100644 index 0000000..d54068f --- /dev/null +++ b/external/vtk/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) + +set(VTK_ENABLE_WRAPPING OFF) + +include(FetchContent) + +FetchContent_Declare( + vtk + URL https://www.vtk.org/files/release/9.1/VTK-9.1.0.tar.gz + URL_HASH SHA256=8fed42f4f8f1eb8083107b68eaa9ad71da07110161a3116ad807f43e5ca5ce96) + +FetchContent_MakeAvailable(vtk) diff --git a/src/main.cc b/src/main.cc new file mode 100644 index 0000000..e4cebd5 --- /dev/null +++ b/src/main.cc @@ -0,0 +1,70 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +int main(int, char*[]) { + vtkNew colors; + + // Set the background color. + std::array bkg{{26, 51, 102, 255}}; + colors->SetColor("BkgColor", bkg.data()); + + // This creates a polygonal cylinder model with eight circumferential facets + // (i.e, in practice an octagonal prism). + vtkNew cylinder; + cylinder->SetResolution(8); + + // The mapper is responsible for pushing the geometry into the graphics + // library. It may also do color mapping, if scalars or other attributes are + // defined. + vtkNew cylinderMapper; + cylinderMapper->SetInputConnection(cylinder->GetOutputPort()); + + // The actor is a grouping mechanism: besides the geometry (mapper), it + // also has a property, transformation matrix, and/or texture map. + // Here we set its color and rotate it around the X and Y axes. + vtkNew cylinderActor; + cylinderActor->SetMapper(cylinderMapper); + cylinderActor->GetProperty()->SetColor( + colors->GetColor4d("Tomato").GetData()); + cylinderActor->RotateX(30.0); + cylinderActor->RotateY(-45.0); + + // The renderer generates the image + // which is then displayed on the render window. + // It can be thought of as a scene to which the actor is added + vtkNew renderer; + renderer->AddActor(cylinderActor); + renderer->SetBackground(colors->GetColor3d("BkgColor").GetData()); + // Zoom in a little by accessing the camera and invoking its "Zoom" method. + renderer->ResetCamera(); + renderer->GetActiveCamera()->Zoom(1.5); + + // The render window is the actual GUI window + // that appears on the computer screen + vtkNew renderWindow; + renderWindow->SetSize(300, 300); + renderWindow->AddRenderer(renderer); + renderWindow->SetWindowName("Cylinder"); + + // The render window interactor captures mouse events + // and will perform appropriate camera or actor manipulation + // depending on the nature of the events. + vtkNew renderWindowInteractor; + renderWindowInteractor->SetRenderWindow(renderWindow); + + // This starts the event loop and as a side effect causes an initial render. + renderWindow->Render(); + renderWindowInteractor->Start(); + + return EXIT_SUCCESS; +} diff --git a/sujet.pdf b/sujet.pdf new file mode 100644 index 0000000..c7a903c Binary files /dev/null and b/sujet.pdf differ