[vtkusers] Convert vtkActor to vtkPolyData
agatte
agatakrason at gmail.com
Sun Mar 2 12:01:38 EST 2014
Hi Cory,
Yes, I created independent program and tested it.
It works well. Great ! It was a problem in my app, from my side.
Here I add tested program :
int main ( int argc, char *argv[] )
{
std::string inputFilename1 = "CLIP1.STL";
std::string inputFilename2 = "CLIP2.STL";
vtkSmartPointer<vtkSTLReader> reader1 =
vtkSmartPointer<vtkSTLReader>::New();
reader1->SetFileName(inputFilename1.c_str());
reader1->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper1 =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper1->SetInputConnection(reader1->GetOutputPort());
vtkSmartPointer<vtkActor> actor1 = vtkSmartPointer<vtkActor>::New();
actor1->SetMapper(mapper1);
vtkSmartPointer<vtkSTLReader> reader2 =
vtkSmartPointer<vtkSTLReader>::New();
reader2->SetFileName(inputFilename2.c_str());
reader2->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper2 =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper2->SetInputConnection(reader2->GetOutputPort());
vtkSmartPointer<vtkActor> actor2 = vtkSmartPointer<vtkActor>::New();
actor2->SetMapper(mapper2);
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
* vtkSmartPointer<vtkPolyData> part1 = vtkPolyData::SafeDownCast(
actor1->GetMapper()->GetInputAsDataSet());*
* vtkSmartPointer<vtkPolyData> part2 = vtkPolyData::SafeDownCast(
actor2->GetMapper()->GetInputAsDataSet());*
vtkSmartPointer<vtkAppendPolyData> appendFilter =
vtkSmartPointer<vtkAppendPolyData>::New();
appendFilter->AddInput(part1);
appendFilter->AddInput(part2);
appendFilter->Update();
vtkSmartPointer<vtkSTLWriter> writer =
vtkSmartPointer<vtkSTLWriter>::New();
writer->SetFileName("writer2.stl");
writer->SetInputConnection(appendFilter->GetOutputPort());
writer->Update();
renderer->AddActor(actor1);
renderer->AddActor(actor2);
renderer->SetBackground(0, 0, 0);
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
Thanks a lot for Your help Cory !
2014-03-02 17:39 GMT+01:00 David Gobbi [via VTK] <
ml-node+s1045678n5726156h85 at n5.nabble.com>:
> Hi Agatte,
>
> You cannot get the data from the actor until you have done the following:
> 1) set a mapper for the actor
> 2) set an input for the mapper
>
> The actor has no data unless something gives the actor some data.
>
> David
>
>
> On Sun, Mar 2, 2014 at 8:58 AM, Cory Quammen <[hidden email]<http://user/SendEmail.jtp?type=node&node=5726156&i=0>>
> wrote:
>
> > Would you be able to post a fully compilable program that has your
> > original problem to help debug this? It's a bit of work on your part,
> > but it is the easiest way for people on the list to help you.
> >
> > Thanks,
> > Cory
> >
> > On Sun, Mar 2, 2014 at 10:42 AM, agatte <[hidden email]<http://user/SendEmail.jtp?type=node&node=5726156&i=1>>
> wrote:
> >> 1) refLower = vtkPolyData::SafeDownCast(
> >> actorLower->GetMapper()->GetInputAsDataSet());
> >> I received an exception concering :
> >> Unhandled exception at 0x0f0fb5e1 (vtkFiltering.dll) : 0xC0000005:
> >> Access violation reading location 0x00000034.
> >>
> >>
> >> 2) I tried :
> >> actorLower->GetMapper()->GetInputAsDataSet()->Print(std::cout);
> >> It doesn't compiled.
> >> error C2664: 'vtkPolyData::SafeDownCast' : cannot convert parameter
> 1
> >> from 'void' to 'vtkObjectBase *'
> >>
> >>
> >>
> >>
> >> 2014-03-02 16:01 GMT+01:00 Cory Quammen-2 [via VTK] <[hidden email]>:
> >>>
> >>> What does
> >>>
> >>> actorLower->GetMapper()->GetInputAsDataSet()->Print(std::cout);
> >>>
> >>> report?
> >>>
> >>> On Sun, Mar 2, 2014 at 9:52 AM, agatte <[hidden email]> wrote:
> >>>
> >>> > Thanks for quick reply Cory.
> >>> >
> >>> > I tried it but it doesn't work ...
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> > View this message in context:
> >>> >
> http://vtk.1045678.n5.nabble.com/Convert-vtkActor-to-vtkPolyData-tp5726148p5726152.html
> >>> > Sent from the VTK - Users mailing list archive at Nabble.com.
> >>> > _______________________________________________
> >>> > 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
> >>> >
> >>> > Follow this link to subscribe/unsubscribe:
> >>> > http://www.vtk.org/mailman/listinfo/vtkusers
> >>> _______________________________________________
> >>> 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
> >>>
> >>> Follow this link to subscribe/unsubscribe:
> >>> http://www.vtk.org/mailman/listinfo/vtkusers
> >>>
> >>>
> >>> ________________________________
> >>> If you reply to this email, your message will be added to the
> discussion
> >>> below:
> >>>
> >>>
> http://vtk.1045678.n5.nabble.com/Convert-vtkActor-to-vtkPolyData-tp5726148p5726153.html
> >>> To unsubscribe from Convert vtkActor to vtkPolyData, click here.
> >>> NAML
> >>
> >>
> >>
> >> ________________________________
> >> View this message in context: Re: Convert vtkActor to vtkPolyData
> >>
> >> Sent from the VTK - Users mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> 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
> >>
> >> Follow this link to subscribe/unsubscribe:
> >> http://www.vtk.org/mailman/listinfo/vtkusers
> >>
> > _______________________________________________
> > 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
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://vtk.1045678.n5.nabble.com/Convert-vtkActor-to-vtkPolyData-tp5726148p5726156.html
> To unsubscribe from Convert vtkActor to vtkPolyData, click here<http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5726148&code=YWdhdGFrcmFzb25AZ21haWwuY29tfDU3MjYxNDh8LTIxODgyMDQwNQ==>
> .
> NAML<http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://vtk.1045678.n5.nabble.com/Convert-vtkActor-to-vtkPolyData-tp5726148p5726157.html
Sent from the VTK - Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140302/30d9e1aa/attachment.html>
More information about the vtkusers
mailing list