moo
This commit is contained in:
parent
c953cf6f6c
commit
65fd6f4b6a
@ -7,4 +7,17 @@ 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)
|
||||
target_link_libraries(pfe PRIVATE
|
||||
VTK::CommonCore
|
||||
VTK::ViewsCore
|
||||
VTK::RenderingCore
|
||||
VTK::IOCore
|
||||
VTK::FiltersCore
|
||||
VTK::CommonColor
|
||||
VTK::GUISupportQt
|
||||
VTK::RenderingQt
|
||||
VTK::ViewsQt
|
||||
VTK::RenderingVolume
|
||||
VTK::CommonDataModel
|
||||
VTK::IOLegacy
|
||||
VTK::IOXML)
|
||||
|
8
LISEZMOI
8
LISEZMOI
@ -2,18 +2,18 @@ Projet de fin d'étude de M2 Info Géométrie et Informatique Graphique.
|
||||
|
||||
|
||||
Compilation :
|
||||
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build
|
||||
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build
|
||||
|
||||
|
||||
Compilation (pour développeurs) :
|
||||
cmake -Bbuild \
|
||||
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||
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_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
|
||||
|
60
src/main.cc
60
src/main.cc
@ -8,61 +8,55 @@
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkVolumeMapper.h>
|
||||
#include <vtkVolume.h>
|
||||
#include <vtkProjectedTetrahedraMapper.h>
|
||||
#include <vtkDataSetReader.h>
|
||||
#include <vtkPolyDataReader.h>
|
||||
#include <vtkXMLPolyDataReader.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
int main(int, char*[]) {
|
||||
int main(int argc, char **argv) {
|
||||
if (argc != 2) {
|
||||
std::cerr << "Usage: " << argv[0] << " FILE.vtk" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
vtkNew<vtkNamedColors> colors;
|
||||
|
||||
// Set the background color.
|
||||
std::array<unsigned char, 4> 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<vtkCylinderSource> cylinder;
|
||||
cylinder->SetResolution(8);
|
||||
vtkNew<vtkXMLPolyDataReader> reader;
|
||||
reader->SetFileName(argv[1]);
|
||||
|
||||
// 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<vtkPolyDataMapper> cylinderMapper;
|
||||
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
|
||||
// vtkNew<vtkProjectedTetrahedraMapper> volumeMapper;
|
||||
// volumeMapper->SetInputConnection(reader->GetOutputPort());
|
||||
vtkNew<vtkPolyDataMapper> mapper;
|
||||
mapper->SetInputConnection(reader->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<vtkActor> cylinderActor;
|
||||
cylinderActor->SetMapper(cylinderMapper);
|
||||
cylinderActor->GetProperty()->SetColor(
|
||||
// vtkNew<vtkVolume> volume;
|
||||
// volume->SetMapper(volumeMapper);
|
||||
vtkNew<vtkActor> actor;
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
actor->GetProperty()->SetColor(
|
||||
colors->GetColor4d("Tomato").GetData());
|
||||
cylinderActor->RotateX(30.0);
|
||||
cylinderActor->RotateY(-45.0);
|
||||
actor->RotateX(30.0);
|
||||
actor->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<vtkRenderer> renderer;
|
||||
renderer->AddActor(cylinderActor);
|
||||
renderer->AddActor(actor);
|
||||
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<vtkRenderWindow> 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<vtkRenderWindowInteractor> renderWindowInteractor;
|
||||
renderWindowInteractor->SetRenderWindow(renderWindow);
|
||||
|
||||
// This starts the event loop and as a side effect causes an initial render.
|
||||
renderWindow->Render();
|
||||
renderWindowInteractor->Start();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user