[vtkusers] Weird behavior with vtkPointData::SetTCoords

agerlach agerlach at gmail.com
Wed Nov 16 14:16:41 EST 2011


All,

I have a vtkPolyData that has two different textures with two different sets
of UV coordinates. 

I store the UV coordinates as a vtkFloatArray as follows:
vtkSmartPointer<vtkFloatArray> uv1 = vtkSmartPointer<vtkFloatArray>::New();
uv1->SetNumberOfComponents(3);
ui1->SetName("texCoord1");
// Populate the array

vtkSmartPointer<vtkFloatArray> uv2 = vtkSmartPointer<vtkFloatArray>::New();
uv1->SetNumberOfComponents(3);
ui1->SetName("texCoord2");
// Populate the array

polyData->GetPointData()->AddArray(textureCoords);


Then in my application the user can switch between which texture to use by:
polyData->GetPointData()->SetTCoords(polyData->GetPointData()->GetArray("texCoord1")
// could be "texCoord2" depending on input

I then also change the actors texture. 

But once an array is set as the TCoords it is no longer an array.
polyData->GetPointData()->GetNumberOfArrays(); // = 2
polyData->GetPointData()->SetTCoords(polyData->GetPointData()->GetArray("texCoord1");
polyData->GetPointData()->GetNumberOfArrays(); // now = 1
polyData->GetPointData()->SetTCoords(polyData->GetPointData()->GetArray("texCoord2");
polyData->GetPointData()->GetNumberOfArrays(); // now = 0

I don't understand this behavior. Does anybody have any suggestion, other
than keeping the array's external to the polyData?

Thanks!



polyData->GetPointData()->AddArray(uv1) 
polyData->GetPointData()->AddArray(uv2).

--
View this message in context: http://vtk.1045678.n5.nabble.com/Weird-behavior-with-vtkPointData-SetTCoords-tp4998791p4998791.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list