2015/05/26

[MFC] VTK Hello World

천천히 VTK 를 공부하고 있다.


지난 번 라이브러리를 빌드 한 후 VTK C++ Tutorial을 하나하나씩 해보기로 하였다. 그 첫번째로 Hello World 이다.
Tutorial에서는 C++ 코드와 CMake를 이용한 빌드를 소개하고 있다. 이를 이전에 빌드한 vtkGUISupportMFC 를 이용하여 대화상자에 출력하도록 해 보았다.



m_pvtkMFCWindow = new vtkMFCWindow(this);
m_pvtkMFCWindow->GetRenderWindow()->AddRenderer(m_pvtkRenderer);
m_pvtkRenderer->SetBackground(0.0, 0.0, 0.5);


// This creates a polygonal cylinder model with eight circumferential facets.
//
m_pCylinder = vtkCylinderSource::New();
m_pCylinder->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.
//
m_pCylinderMapper = vtkPolyDataMapper::New();
m_pCylinderMapper->SetInputConnection(m_pCylinder->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 -22.5 degrees.
m_pCylinderActor = vtkActor::New();
m_pCylinderActor->SetMapper(m_pCylinderMapper);
m_pCylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
m_pCylinderActor->RotateX(30.0);
m_pCylinderActor->RotateY(-45.0);

// Render on MFCWindow
// Add the actors to the renderer, set the background and size
//
m_pvtkRenderer->AddActor(m_pCylinderActor);
m_pvtkRenderer->SetBackground(0.1, 0.2, 0.4);

// We'll zoom in a little by accessing the camera and invoking a "Zoom"
// method on it.
m_pvtkRenderer->ResetCamera();
m_pvtkRenderer->GetActiveCamera()->Zoom(1.5);



Original Post : http://neodreamer-dev.tistory.com/745

No comments :

Post a Comment