[vtkusers] vtkDO2DS and Deconstructors of vtkPolyData

Brad Lowekamp blowek1 at csee.umbc.edu
Tue Jan 22 23:34:17 EST 2002


Hello all,
	I sent this message earlier and it got hung up with the list 
moderator (my fault), so I apologize if it appears twice.
        I have been working on a project where I wish to let the user play 
with different assignments of the data. I would like to keep intact as 
much of the pipeline between changes as possible. After initially 
experiencing some problems, I decided reconstructed the pipeline every 
time. Now I am going back and trying to resolve these issues. I am also 
beginning to dive into the vtk source code in hopes to begin writing my 
own classes. Possible a vtkDataObjectToDataObjectFilter. Has any work been 
done on that? Usefull?
        Anyways, the initial problem of assigning a DataObject to 
PolyData, I have been able to narrow down to the following code:

vtkDataObjectReader ivtkDocReader
ivtkDocReader SetFileName "data/test.vtk"
vtkDataObjectToDataSetFilter do2ds
do2ds SetInput [ivtkDocReader GetOutput]
do2ds SetDataSetTypeToPolyData
do2ds SetPointComponent 0 "X" 0
do2ds SetPointComponent 1 "Y" 0
do2ds SetPointComponent 2 "Z" 0
do2ds Update
puts "Number of Arrays: [[[ivtkDocReader GetOutput] GetFieldData] 
GetNumberOfArrays]"
do2ds Delete
puts "Number of Arrays: [[[ivtkDocReader GetOutput] GetFieldData] 
GetNumberOfArrays]"
ivtkDocReader Update
puts "Number of Arrays: [[[ivtkDocReader GetOutput] GetFieldData] 
GetNumberOfArrays]"

With the output of:

Number of Arrays: 6
Number of Arrays: 0
Number of Arrays: 0


        Well this seems a little wrong to me. This same error accrued 
with vtk3.2 and vtk4.0, I have been doing the in depth checking with 
vtk4.0 I did check to see if  ReleaseDataFlagOn was on and it is not. What 
I am thinking is if some how the do2ds deleted something that is 
shouldn't have, perhaps it did  something wrong with the DataArray 
pointer? Well I am about to dive into the code and such. Is there 
something I am missing? Is this correct behavior or not?
	I have looked in depth into the code of this. I found out that the 
do2ds just uses the pointer to the Input's FieldData. With the following 
command in vtkDataObjectToDataSetFilter::Execute
	this->SetFieldData(input->GetFieldData());
I looked into the macros and I don't see how this increases the reference 
count of the FieldData, but it does. So the rest of the executions appears 
to merely go on by doing deep copies for the construction of points and 
connectivity. I wonder if there should be a option to determine if this is 
a shallow or a deep copy.
	However there appears to be a problem with the deconstructor 
of vtkPolyData and vtkPointSet. They both call their respective 
Initialization. This causes the Initialization to be called for all the 
parental classes and vtkFieldData::Initialize, twice! Just calling it once 
would cause the Initialization of the FieldData with out changing the 
Modified time. Essentialy this resets the do2ds' Input DataObject, without 
letting its Source know that it has been modified. Which is shown to 
happened in the above tcl code.
	It it my belief that this could be fixed by rewriting the 
deconstructors to not call the initialization function, and incorporate 
only the necessary code there, but I don't know what the impact of this 
would be for every thing else. This certainly seems to be a problem that 
has a broad scope that affects several core classes.

Thanks,
>Brad 




More information about the vtkusers mailing list