[vtkusers] Re: vtkusers Digest, Vol 12, Issue 4

Jeffrey Meng mengjinjie at gmail.com
Fri Apr 1 16:21:43 EST 2005


Hi Amy,

Basically, I am new to VTK, so I am really stupid. 

What I want to do is: I want to be able to iterate through a volume 
data as triangles, then change each triangle's color separately.
And that's why I need vtkTriangleFilter. As to vtkStripper, I really
don't know if I need it or not. :(

So assume I have a vtkTriangleFilter object, I pass it to vtkPolyDataMapper.
Now, the problem is how I iterate through the triangles? 

The code I wrote below was to iterate through the cells, hoping each
cell is a triangle
instead of a triangle strip, but looking at the execution, a Cell
isn't a Triangle here. (It seems like a Cell is still a Triangle
Strips, instead)

---------------------------------------------------------------------------------------

	vtkPolyData* pPolyData = pTriangles->GetOutput(); //skinMapper->GetInput();
        vtkCellData* pCellData = pPolyData->GetCellData();
        vtkDataArray* pCellArray = pCellData->GetScalars(); 
        
       
	int nTuples = pCellArray->GetNumberOfTuples();
	for (int i = 0; i < nTuples / 2; ++i)
	{
		pCellArray->SetTuple(i, scalar);
	}
			
	pCellArray->Modified();
        pPolyData->Modified();

---------------------------------------------------------------------------------------
     
Thanks a lot.

Best,
Jeffrey


> Hi Jeffrey,
> 
> Why are you passing your data through vtkStripper and then through
> vtkTriangleFilter?  This creates triangle strips and then breaks them back
> apart.  When vtkTriangleFilter breaks the triangle strips apart, it copies
> the cell data values of the entire triangle strip to each triangle that was
> a part of that strip.  In VTK, a triangle strip is a single cell; there is
> not separate cell data per triangle composing that strip.  If what you mean
> by "the cell data still seems like triangle strips" is that the same value
> is repeated for each triangle that was in a particular strip, this should
> explain why.  If that is not what you mean, please clarify.
> 
> - Amy
>



More information about the vtkusers mailing list