[vtkusers] Transforming Data but not... THE ATTACHMENT !

Sebastien Auclair sxa at fluent.com
Fri Jan 24 10:31:17 EST 2003


Some of you were not able to get the attachment... here it is :
This is an e-mail of "tpan" which contains valuable information that 
could be usefull to many !
#################################################


I think I understand now what you are trying to do.  You want to modify
the data IN PLACE in the middle of a pipeline.  Unfortunately, except
for the 1 subclass of vtkImageInPlaceFilter, nothing in VTK allows you
to modify data in a pipeline in place.  

I don't know if this is the source of confusion, but data in VTK is not
a unit of work moving through a pipeline, where filters operate on it
and then pass it along.  Data in VTK are integral parts of the pipeline.
Filters read in data, and then generate new ones for the next filter to
read.

Please see explanation below, and suggestions on how to do what you
want.

> The pipeline we have don't contain any vtkTransform_stuff... It just
as :
> A) Grid
> B) PolyData
> C) Mapper
> D) Actor
> 

If B is a pointer to the output of A, then you would still have a
pipeline.  B carries information about the source filter, A. C and D
will use that information to generate Update calls, which will propagate
all the way back to A.

> Our view is that if they are linked in the form of a pipeline, it
means
> that
> modifying "not the pipeline" but the values contained in PolyData, the
> output of the pipeline would change.

Fundamentally, the pipeline doesn't work the way you described.  Nothing
would happen if you just modify the values inside the polydata, because

1. When a scene is rendered, C calls update on its input, which is B.  B
makes sure its update extents are current, and then calls its source's
Update(), in this case, A.  If there were no source, then nothing
happens.  Even if modifications were made to the internal data
structures (such as the array holding the points) of B directly, the
modify timestamps of B would not be changed because B doesn't actually
check its own data for changes.  To C, B would appear unchanged.

2. When a filter updates, it checks its own modify timestamp against the
pipeline's modify timestamp, which comes from its inputs.  If the inputs
show no change, then update would not be propagated up the pipeline.

However, if a filter upstream to B is changed and therefore the pipeline
is updated, then whatever changes are made to B would be lost.


***
Bottomline is direct changes to B will not generate automatic updates in
the pipeline, and would not be persistent either.
***

> 
> It's really that simple !
> 
> We don't want to create a new PolyData from vtkTransform stuff... we
just
> want to transform the one we already have.
> 

The vtkTransformPolyDataFilter WILL generate a new polydata as output,
and it won't modify the input.  This is by design.


> If A,B, C and D are creating a cube, we would create a C++ "CUBE
class"
> holding those 4 instances as member variables.
> 

sure.


> Then, if we want to translate the cube, our idea is to modify the
PolyData
> (B) which is the second (or first since we may not need to keep grid)
> member
> variable of the class CUBE.
> 

This will not work, for the 2 reasons I mentioned above.

BTW, don't get rid of A, not that you can, anyway, because of VTK uses
reference counting.  If you try to get rid of A by setting the instance
variable to NULL, A would still exist in memory because B references it.
If you get rid of A by calling Delete() on it, A would still exist in
memory because:
1. B is contained in A, so would normally be deleted along with A.
2. C references B, therefore B won't be deleted.
3. And because B references A, A won't be deleted.


> If you can make what i am sending you work, (without modifying the
> pipeline
> layout), then it would solve our problem !
> 

How to make it work really depends on what you want to do with the
different pieces of data. The 2 options remain:
1. make a deepcopy of B, then transform that, and hook up the output of
the transformpolydatafilter to another mapper and actor to render the
transformed cube.  This way your pipeline is intact, you just have a
second pipeline siphoning off B, or
2. insert a transform filter into your pipeline.  You still will have
access to the untransformed polydata, that's just the output of A, and
that doesn't go away.  You can always grab the original if that's want
you needed.  And if you don't need to transform the cube, just leave
vtkTransform in its identity state, and nothing would be changed.

Sorry, but that's the best answer I can give you given the way VTK
works.










More information about the vtkusers mailing list