Discussion:
[vtkusers] isosurface update issue
newcfd via vtkusers
2018-11-30 05:12:05 UTC
Permalink
I have the following code to draw isosurface. No problem when this func is
called by the first time.
However, two isosurfaces show up when this func is called with a different
value by the second time.
The first isosurface is not replaced by the second one although I am using
the same actor. What is
wrong?

void MyApp::redraw( const double value )
{
vtkStructuredGrid * mesh =...

vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputData( mesh );
filter->SetNumberOfContours( 1 );
filter->Setvalue( 0, value ); // value is passed in

vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapSphere->SetInputConnection( filter->GetOutputPort() );
mapSphere->SetScalarRange(0.0, 1.0);

if ( m_pActor == nullptr )
{
m_pActor = vtkActor::New();
m_pActor->SetMapper( mapper );
}

renderer->AddActor( m_pActor );
renderer->SetBackground(1,1,1); // Background color white

renderWindow->Render();
}



--
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
David E DeMarle via vtkusers
2018-11-30 14:40:31 UTC
Permalink
Can't tell from this code fragment what is going on but these look fishy to
Post by newcfd via vtkusers
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapSphere->SetInputConnection( filter->GetOutputPort() );
You make "mapper" and then work with "mapSphere". Where did mapSphere come
from?

You call renderer->AddActor(m_pActor) everytime in this function. If
"renderer" is persistent or in otherwords not created from scratch in
between calls to redraw, you should only have to do that once.


On Fri, Nov 30, 2018 at 12:12 AM newcfd via vtkusers <
Post by newcfd via vtkusers
I have the following code to draw isosurface. No problem when this func is
called by the first time.
However, two isosurfaces show up when this func is called with a different
value by the second time.
The first isosurface is not replaced by the second one although I am using
the same actor. What is
wrong?
void MyApp::redraw( const double value )
{
vtkStructuredGrid * mesh =...
vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputData( mesh );
filter->SetNumberOfContours( 1 );
filter->Setvalue( 0, value ); // value is passed in
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapSphere->SetInputConnection( filter->GetOutputPort() );
mapSphere->SetScalarRange(0.0, 1.0);
if ( m_pActor == nullptr )
{
m_pActor = vtkActor::New();
m_pActor->SetMapper( mapper );
}
renderer->AddActor( m_pActor );
renderer->SetBackground(1,1,1); // Background color white
renderWindow->Render();
}
--
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
newcfd via vtkusers
2018-12-01 14:27:31 UTC
Permalink
Thanks for your reply. mapSphere was a typing error and should be mapper.
I made the following changes and still have the same problem.

void MyApp::redraw( const double value )
{
if ( m_pActor == nullptr )
{
m_pActor = vtkActor::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetScalarRange(0.0, 1.0);
m_pActor->SetMapper( mapper );

renderer->AddActor( m_pActor );
renderer->SetBackground(1,1,1); // Background color white
}

vtkStructuredGrid * mesh =...

vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputData( mesh );
filter->SetNumberOfContours( 1 );
filter->Setvalue( 0, value ); // value is passed in

m_pActor->GetMapper()->SetInputConnection( filter->GetOutputPort() );
renderWindow->Render();
}

It may not be a good idea to delete the actor and make a new one in every
call.



--
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
David E DeMarle via vtkusers
2018-12-03 15:02:37 UTC
Permalink
Post by newcfd via vtkusers
It may not be a good idea to delete the actor and make a new one in every
call.
It can work, but in addition to deleting the old actor, you have to call
renderer->RemoveActor(oldactor); Otherwise the renderer's reference keeps
the original actor alive.

David E DeMarle
Kitware, Inc.
Principal Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Sat, Dec 1, 2018 at 9:27 AM newcfd via vtkusers <
Post by newcfd via vtkusers
Thanks for your reply. mapSphere was a typing error and should be mapper.
I made the following changes and still have the same problem.
void MyApp::redraw( const double value )
{
if ( m_pActor == nullptr )
{
m_pActor = vtkActor::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetScalarRange(0.0, 1.0);
m_pActor->SetMapper( mapper );
renderer->AddActor( m_pActor );
renderer->SetBackground(1,1,1); // Background color white
}
vtkStructuredGrid * mesh =...
vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputData( mesh );
filter->SetNumberOfContours( 1 );
filter->Setvalue( 0, value ); // value is passed in
m_pActor->GetMapper()->SetInputConnection( filter->GetOutputPort() );
renderWindow->Render();
}
It may not be a good idea to delete the actor and make a new one in every
call.
--
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
http://www.vtk.org/Wiki/VTK_FAQ
Search the list archives at: http://markmail.org/search/?q=vtkusers
https://public.kitware.com/mailman/listinfo/vtkusers
newcfd via vtkusers
2018-12-04 09:13:19 UTC
Permalink
I did it in the way you recommended, David. The old ones are still there.
rederWindow->Render() and QVTKOpenGLWidget->update() are added
as well. No help. VTK version 8.1.

void MyApp::redraw( const double value )
{
if ( m_pActor != nullptr )
{
renderer->RemoveActor(m_pActor );
m_pActor->Delete();
m_pActor = nullptr;
}

m_pActor = vtkActor::New();
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetScalarRange(0.0, 1.0);
m_pActor->SetMapper( mapper );

renderer->AddActor( m_pActor );
renderer->SetBackground(1,1,1); // Background color white

vtkStructuredGrid * mesh =...

vtkSmartPointer<vtkContourFilter> filter =
vtkSmartPointer<vtkContourFilter>::New();
filter->SetInputData( mesh );
filter->SetNumberOfContours( 1 );
filter->Setvalue( 0, value ); // value is passed in

m_pActor->GetMapper()->SetInputConnection( filter->GetOutputPort() );
renderer->Render();
}



--
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

Loading...