vtkTransform::Identity() where it gets wrong?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

vtkTransform::Identity() where it gets wrong?

Anka Kochanowska
void vtkTransform::Identity()
{
  this->Concatenation->Identity();
  this->Modified();

  // support for the legacy hack in InternalUpdate
  if (this->Matrix->GetMTime() > this->MatrixUpdateMTime)
  {
    this->Matrix->Identity();
  }
}
Modified() is called before the matrix is reset to Identity.
Should it be called at the end?

My code reacts to Modified event and promptly uses matrix that was not yet changed.
I patch it by calling transform->Modified() after transform->Identity();

Anka

            




_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkTransform::Identity() where it gets wrong?

David Gobbi
Thanks for the report.  That vtkTransform code was actually written before ModifiedEvent even existed.


Be careful with how you use ModifiedEvent. The events in vtkCommand.h are handled synchronously, so if you have a callback bound to the ModifiedEvent for an object, then any code that modifies that object has to sit and wait until your callback finished running.

The Modified() method was initially designed to do only one thing: change the object's timestamp.  VTK was designed from the ground up to be a pull pipeline: the pipeline is meant to be driven by either user interaction (mouse, keyboard, I/O) or by timer events (e.g. for animation); the pipeline checks timestamps to see what has changed since the last time it executed.  Driving actions from ModifiedEvent goes against this and will lead to less efficient code, and can cause instability depending on how your ModifiedEvent callback changes the pipeline state.

I recommend using ModifiedEvent only for logging, debugging, or simple bookkeeping.  I'll stop ranting now :)

Thanks again for the bug report,

 - David


On Tue, Sep 18, 2018 at 9:12 AM Anka Kochanowska <[hidden email]> wrote:
void vtkTransform::Identity()
{
  this->Concatenation->Identity();
  this->Modified();

  // support for the legacy hack in InternalUpdate
  if (this->Matrix->GetMTime() > this->MatrixUpdateMTime)
  {
    this->Matrix->Identity();
  }
}
Modified() is called before the matrix is reset to Identity.
Should it be called at the end?

My code reacts to Modified event and promptly uses matrix that was not yet changed.
I patch it by calling transform->Modified() after transform->Identity();

Anka

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkTransform::Identity() where it gets wrong?

Anka Kochanowska
Thanks!
Anka


On Tue, Sep 18, 2018 at 12:12 PM David Gobbi <[hidden email]> wrote:
Thanks for the report.  That vtkTransform code was actually written before ModifiedEvent even existed.


Be careful with how you use ModifiedEvent. The events in vtkCommand.h are handled synchronously, so if you have a callback bound to the ModifiedEvent for an object, then any code that modifies that object has to sit and wait until your callback finished running.

The Modified() method was initially designed to do only one thing: change the object's timestamp.  VTK was designed from the ground up to be a pull pipeline: the pipeline is meant to be driven by either user interaction (mouse, keyboard, I/O) or by timer events (e.g. for animation); the pipeline checks timestamps to see what has changed since the last time it executed.  Driving actions from ModifiedEvent goes against this and will lead to less efficient code, and can cause instability depending on how your ModifiedEvent callback changes the pipeline state.

I recommend using ModifiedEvent only for logging, debugging, or simple bookkeeping.  I'll stop ranting now :)

Thanks again for the bug report,

 - David


On Tue, Sep 18, 2018 at 9:12 AM Anka Kochanowska <[hidden email]> wrote:
void vtkTransform::Identity()
{
  this->Concatenation->Identity();
  this->Modified();

  // support for the legacy hack in InternalUpdate
  if (this->Matrix->GetMTime() > this->MatrixUpdateMTime)
  {
    this->Matrix->Identity();
  }
}
Modified() is called before the matrix is reset to Identity.
Should it be called at the end?

My code reacts to Modified event and promptly uses matrix that was not yet changed.
I patch it by calling transform->Modified() after transform->Identity();

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

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtkTransform::Identity() where it gets wrong?

Anka Kochanowska
In reply to this post by David Gobbi
Hi!
I still see the same code in vtk 8, your patch has not been applied. 
I am trying to follow ypur advice.
Anka


On Tue, Sep 18, 2018 at 12:12 PM David Gobbi <[hidden email]> wrote:
Thanks for the report.  That vtkTransform code was actually written before ModifiedEvent even existed.


Be careful with how you use ModifiedEvent. The events in vtkCommand.h are handled synchronously, so if you have a callback bound to the ModifiedEvent for an object, then any code that modifies that object has to sit and wait until your callback finished running.

The Modified() method was initially designed to do only one thing: change the object's timestamp.  VTK was designed from the ground up to be a pull pipeline: the pipeline is meant to be driven by either user interaction (mouse, keyboard, I/O) or by timer events (e.g. for animation); the pipeline checks timestamps to see what has changed since the last time it executed.  Driving actions from ModifiedEvent goes against this and will lead to less efficient code, and can cause instability depending on how your ModifiedEvent callback changes the pipeline state.

I recommend using ModifiedEvent only for logging, debugging, or simple bookkeeping.  I'll stop ranting now :)

Thanks again for the bug report,

 - David


On Tue, Sep 18, 2018 at 9:12 AM Anka Kochanowska <[hidden email]> wrote:
void vtkTransform::Identity()
{
  this->Concatenation->Identity();
  this->Modified();

  // support for the legacy hack in InternalUpdate
  if (this->Matrix->GetMTime() > this->MatrixUpdateMTime)
  {
    this->Matrix->Identity();
  }
}
Modified() is called before the matrix is reset to Identity.
Should it be called at the end?

My code reacts to Modified event and promptly uses matrix that was not yet changed.
I patch it by calling transform->Modified() after transform->Identity();

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

_______________________________________________
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://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkTransform::Identity() where it gets wrong?

David Gobbi
The change was merged into master on Sept 18, 2018 and is in the VTK 8.2 release.  It is not in 8.0 or 8.1.

  David

On Mon, Feb 4, 2019 at 10:50 AM Anka Kochanowska <[hidden email]> wrote:
Hi!
I still see the same code in vtk 8, your patch has not been applied. 
I am trying to follow ypur advice.
Anka

_______________________________________________
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://vtk.org/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: vtkTransform::Identity() where it gets wrong?

Anka Kochanowska
Sorry, I am using 8.1.2. 
Anka


On Mon, Feb 4, 2019 at 1:03 PM David Gobbi <[hidden email]> wrote:
The change was merged into master on Sept 18, 2018 and is in the VTK 8.2 release.  It is not in 8.0 or 8.1.

  David

On Mon, Feb 4, 2019 at 10:50 AM Anka Kochanowska <[hidden email]> wrote:
Hi!
I still see the same code in vtk 8, your patch has not been applied. 
I am trying to follow ypur advice.
Anka
_______________________________________________
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://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

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

Follow this link to subscribe/unsubscribe:
https://vtk.org/mailman/listinfo/vtkusers