[vtkusers] [Collision detection ] How to prevent overlapping actors ?
agatte
agatakrason at gmail.com
Thu Jan 23 03:17:13 EST 2014
Hi Cory,
No, I don't receive an error message.
But when I move actors, they are overlapping. It doesn't prevent
overlapping actors .
I don't know, maybe I made a mistake in the code.
Could You look at this part of code ?
Here, my code :
int main(int, char *[])
{
// Lower - first model
vtkSmartPointer<vtkSTLReader> readerLower =
vtkSmartPointer<vtkSTLReader>::New();
readerLower->SetFileName("lower.stl");
readerLower->Update();
// Upper - second model
vtkSmartPointer<vtkSTLReader> readerUpper =
vtkSmartPointer<vtkSTLReader>::New();
readerUpper->SetFileName("upper.stl");
readerUpper->Update();
// Create polydata
vtkSmartPointer<vtkPolyData> lowerPolyData = readerLower->GetOutput();
vtkSmartPointer<vtkPolyData> upperPolyData = readerUpper->GetOutput();
// Set input transform to avoid overlap actors (models)
vtkSmartPointer<vtkTransform> transform =
vtkSmartPointer<vtkTransform>::New();
transform->PostMultiply();
transform->RotateZ(180.0);
transform->RotateX(180.0);
transform->Translate(0,0,35);
// Set polydata filter
vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter =
vtkSmartPointer<vtkTransformPolyDataFilter>::New();
transformFilter->SetInput(upperPolyData);
transformFilter->SetTransform(transform);
transformFilter->Update();
vtkSmartPointer<vtkPolyDataMapper> lowerMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
lowerMapper->SetInput(lowerPolyData);
vtkSmartPointer<vtkPolyDataMapper> upperMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
upperMapper->SetInput(upperPolyData);
vtkSmartPointer<vtkActor> upperActor = vtkSmartPointer<vtkActor>::New();
upperActor->SetMapper(upperMapper);
vtkSmartPointer<vtkActor> lowerActor = vtkSmartPointer<vtkActor>::New();
lowerActor->SetMapper(lowerMapper);
lowerActor->SetUserTransform(transform);
* vtkSmartPointer<vtkIntersectionPolyDataFilter>
intersectionPolyDataFilter =
vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();*
* intersectionPolyDataFilter->SetInput( 0, lowerPolyData );*
* intersectionPolyDataFilter->SetInput( 1, upperPolyData );*
* intersectionPolyDataFilter->Update();*
* vtkSmartPointer<vtkPolyDataMapper> intersectionMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();*
* intersectionMapper->SetInputConnection(
intersectionPolyDataFilter->GetOutputPort() );*
* intersectionMapper->ScalarVisibilityOff();*
* vtkSmartPointer<vtkActor> intersectionActor =
vtkSmartPointer<vtkActor>::New();*
* intersectionActor->SetMapper( intersectionMapper );*
* intersectionActor->VisibilityOff();*
// Visualization
// Create a renderer, render window, and interactor
* vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();*
* renderer->AddActor(lowerActor);*
* renderer->AddActor(upperActor);*
* renderer->AddActor(intersectionActor);*
// Render Window
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
// Interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);
// Move actors
vtkSmartPointer<vtkInteractorStyleTrackballActor> styleActor =
vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();
renderWindowInteractor->SetInteractorStyle( styleActor );
renderWindowInteractor->SetRenderWindow(renderWindow);
// Render and interact
renderer->SetBackground(.2, .3, .4);
renderWindow->Render();
renderWindowInteractor->Start();
return EXIT_SUCCESS;
}
I would appreciate for any help please.
agatte
2014/1/23 Cory Quammen-2 [via VTK] <
ml-node+s1045678n5725553h92 at n5.nabble.com>
> How do you know vtkIntersectionPolyDataFilter doesn't work?
>
> Is the intersection empty? Do you get an error message?
>
> Thanks,
> Cory
>
> On Wed, Jan 22, 2014 at 4:57 PM, agatte <[hidden email]<http://user/SendEmail.jtp?type=node&node=5725553&i=0>>
> wrote:
>
> > Hi,
> >
> > I want to prevent overlapping/collision of two actors in the render
> scene.
> > I have already tried vtkIntersectionFilter, bu tit doesn't work in my
> case.
> >
> > Could You advice me something different ?
> >
> > int main(int, char *[])
> > {
> > // Lower - first model
> > vtkSmartPointer<vtkSTLReader> readerLower =
> > vtkSmartPointer<vtkSTLReader>::New();
> > readerLower->SetFileName("lower.stl");
> > readerLower->Update();
> >
> > // Upper - second model
> > vtkSmartPointer<vtkSTLReader> readerUpper =
> > vtkSmartPointer<vtkSTLReader>::New();
> > readerUpper->SetFileName("upper.stl");
> > readerUpper->Update();
> >
> > // Create polydata
> > vtkSmartPointer<vtkPolyData> lowerPolyData = readerLower->GetOutput();
> > vtkSmartPointer<vtkPolyData> pointsUpperPolyData =
> > readerUpper->GetOutput();
> > pointsUpperPolyData->GetPoints();
> >
> >
> > // Set input transform to avoid overlap actors (models)
> > vtkSmartPointer<vtkTransform> transform =
> > vtkSmartPointer<vtkTransform>::New();
> > transform->PostMultiply();
> > transform->RotateZ(180.0);
> > transform->RotateX(180.0);
> > transform->Translate(0,0,35);
> >
> > // Set polydata filter
> > vtkSmartPointer<vtkTransformPolyDataFilter> transformFilter =
> > vtkSmartPointer<vtkTransformPolyDataFilter>::New();
> > transformFilter->SetInput(pointsUpperPolyData); // upperPolyData
> > transformFilter->SetTransform(transform);
> > transformFilter->Update();
> >
> > vtkSmartPointer<vtkPolyDataMapper> lowerMapper =
> > vtkSmartPointer<vtkPolyDataMapper>::New();
> > lowerMapper->SetInput(lowerPolyData);
> > vtkSmartPointer<vtkPolyDataMapper> upperMapper =
> > vtkSmartPointer<vtkPolyDataMapper>::New();
> > upperMapper->SetInput(pointsUpperPolyData);
> >
> > vtkSmartPointer<vtkActor> upperActor =
> vtkSmartPointer<vtkActor>::New();
> > upperActor->SetMapper(upperMapper);
> > vtkSmartPointer<vtkActor> lowerActor =
> vtkSmartPointer<vtkActor>::New();
> > lowerActor->SetMapper(lowerMapper);
> > lowerActor->SetUserTransform(transform);
> >
> >
> > vtkSmartPointer<vtkIntersectionPolyDataFilter>
> intersectionPolyDataFilter
> > =
> > vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();
> > intersectionPolyDataFilter->SetInput( 0, lowerPolyData );
> > intersectionPolyDataFilter->SetInput( 1, pointsUpperPolyData );
> > intersectionPolyDataFilter->Update();
> >
> > vtkSmartPointer<vtkPolyDataMapper> intersectionMapper =
> > vtkSmartPointer<vtkPolyDataMapper>::New();
> > intersectionMapper->SetInputConnection(
> > intersectionPolyDataFilter->GetOutputPort() );
> > intersectionMapper->ScalarVisibilityOff();
> >
> > vtkSmartPointer<vtkActor> intersectionActor =
> > vtkSmartPointer<vtkActor>::New();
> > intersectionActor->SetMapper( intersectionMapper );
> >
> > //vtkSmartPointer<vtkRenderer> renderer =
> > vtkSmartPointer<vtkRenderer>::New();
> > //renderer->AddViewProp(sphere1Actor);
> > //renderer->AddViewProp(sphere2Actor);
> > //renderer->AddViewProp(intersectionActor);
> >
> >
> > // Visualization
> >
> > // Create a renderer, render window, and interactor
> > vtkSmartPointer<vtkRenderer> renderer =
> > vtkSmartPointer<vtkRenderer>::New();
> > renderer->AddActor(lowerActor);
> > renderer->AddActor(upperActor);
> > //renderer->AddActor(booleanOperationActor);
> > renderer->AddActor(intersectionActor);
> >
> > // Render Window
> > vtkSmartPointer<vtkRenderWindow> renderWindow =
> > vtkSmartPointer<vtkRenderWindow>::New();
> > renderWindow->AddRenderer(renderer);
> >
> > // Interactor
> > vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
> > vtkSmartPointer<vtkRenderWindowInteractor>::New();
> > renderWindowInteractor->SetRenderWindow(renderWindow);
> >
> > // Move actors
> > vtkSmartPointer<vtkInteractorStyleTrackballActor> styleActor =
> > vtkSmartPointer<vtkInteractorStyleTrackballActor>::New();
> > renderWindowInteractor->SetInteractorStyle( styleActor );
> > renderWindowInteractor->SetRenderWindow(renderWindow);
> >
> > // Render and interact
> > renderer->SetBackground(.2, .3, .4);
> > renderWindow->Render();
> > renderWindowInteractor->Start();
> >
> > return EXIT_SUCCESS;
> > }
> >
> >
> > I would appreciate for any help please.
> >
> >
> >
> >
> >
> > --
> > View this message in context:
> http://vtk.1045678.n5.nabble.com/Collision-detection-How-to-prevent-overlapping-actors-tp5725551.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/Collision-detection-How-to-prevent-overlapping-actors-tp5725551p5725553.html
> To unsubscribe from [Collision detection ] How to prevent overlapping
> actors ?, click here<http://vtk.1045678.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5725551&code=YWdhdGFrcmFzb25AZ21haWwuY29tfDU3MjU1NTF8LTIxODgyMDQwNQ==>
> .
> 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>
>
screenOverlapping.png (214K) <http://vtk.1045678.n5.nabble.com/attachment/5725554/0/screenOverlapping.png>
--
View this message in context: http://vtk.1045678.n5.nabble.com/Collision-detection-How-to-prevent-overlapping-actors-tp5725551p5725554.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/20140123/93f1a564/attachment.html>
More information about the vtkusers
mailing list