[vtkusers] Scaling planeWidget

agatte agatakrason at gmail.com
Tue Jan 28 06:43:32 EST 2014


Hello,


I want to scale a vtkPlaneWidget.
I followed example from vtk wiki. It works well on the sphere, it looks that
has normal size.
But when I load my  mesh model. Plane is very small.

I am trying to add planeWidget->GetProp3D()->SetScale(10,10,10);
I received errror : Access violation reading location ...

I don' t know what is it wrong in my code ?

int main(int, char *[])
{
  // Load model
  vtkSmartPointer<vtkSTLReader> readerLower =
vtkSmartPointer<vtkSTLReader>::New();
  readerLower->SetFileName("model.stl");
  readerLower->Update();
 
  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(readerLower->GetOutputPort());
  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
 
  // A renderer and render window
  vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
  renderer->AddActor(actor);
 
  // An interactor
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
  renderWindowInteractor->SetRenderWindow(renderWindow);
 
  vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
  renderWindowInteractor->SetInteractorStyle( style );
 
  vtkSmartPointer<vtkImagePlaneWidget> planeWidget =
vtkSmartPointer<vtkImagePlaneWidget>::New();
  planeWidget->SetInteractor(renderWindowInteractor);
 
  double origin[3] = {1, 0,0};
  double p1[3] = {10.0,10.0, 10.0};
  planeWidget->SetOrigin(origin);
  //planeWidget->GetProp3D()->SetScale(p1[0],p1[1], p1[2]); //Scale(p1,
p2,1,1);
  //planeWidget->GetProp3D()->GetScale();
 * planeWidget->GetProp3D()->SetScale(p1);*  // ???? 
 
  planeWidget->GetPlaneProperty();
  planeWidget->UpdatePlacement();
 
  // Render
  renderWindow->Render();
  renderWindowInteractor->Initialize();
  renderWindow->Render();
  planeWidget->On();
 
  // Begin mouse interaction
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
}



--
View this message in context: http://vtk.1045678.n5.nabble.com/Scaling-planeWidget-tp5725661.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list