[vtkusers] vtkOBJReader example for C++

Todd Martin nztoddler at yahoo.com
Mon Jul 2 08:09:02 EDT 2018


You probably need to do something like
 reader->GetOutput()->GetBounds() or reader->GetOutput()->GetCenter()


Todd Martin, PhD.
Freelance Engineer/Software Architect.
 

    On Monday, July 2, 2018, 11:30:42 PM GMT+12, shayan moradkhani <shayan.moradkhani at gmail.com> wrote:  
 
 int main(int, char *[])
{
    std::string filename = "Part3.obj";
    vtkSmartPointer<vtkOBJReader> reader =
vtkSmartPointer<vtkOBJReader>::New();
    reader->SetFileName(filename.c_str());
    reader->Update();
    // Visualize
    vtkSmartPointer<vtkPolyDataMapper> mapper =
        vtkSmartPointer<vtkPolyDataMapper>::New();
    mapper->SetInputConnection(reader->GetOutputPort());
    
    vtkSmartPointer<vtkActor> actor =
        vtkSmartPointer<vtkActor>::New();
    actor->SetMapper(mapper);
    actor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
    

    vtkSmartPointer<vtkRenderer> renderer =
        vtkSmartPointer<vtkRenderer>::New();
    renderer->AddActor(actor);
    renderer->SetBackground(.1, .3, .3); // Background color green    
    // Zoom in a little by accessing the camera and invoking its "Zoom" method.
    renderer->ResetCamera();
    //renderer->GetActiveCamera()->Zoom(1.5);

    vtkSmartPointer<vtkRenderWindow> renderWindow =
        vtkSmartPointer<vtkRenderWindow>::New();
    renderWindow->SetSize(800, 600);
    renderWindow->AddRenderer(renderer);

    vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
        vtkSmartPointer<vtkRenderWindowInteractor>::New();
    renderWindowInteractor->SetRenderWindow(renderWindow);



    renderWindowInteractor->Start();

    return EXIT_SUCCESS;
}

this is what i have. however, when i load in vtk, i have no idead where the
model is loaded (with respect to the global coordinate system). if i could
get its center, it would be easier i guess to apply transformation on the
object



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180702/82fce0bb/attachment.html>


More information about the vtkusers mailing list