single Texture sample:
when we zoom in, we can see that there is squeezed repeats along rows of textures:
so I tried to repeat vtkTexture on a tubeActor, but there appears glitches, which I am pretty sure are squeezed textures.
Since I used vtkTransformTextureCoords to arrange texture coordinates, it should have generated exact number of repeats every row as I set. Now I don’t know where the problem is.
int number = points.size();
vtkSmartPointer<vtkPoints> pointsdata = vtkSmartPointer<vtkPoints>::New();
int count = 0;
for(auto it = points.begin(); it != points.end(); ++it,++count)//遍历点集并转换VTKpoints
{
auto current = *it;
pointsdata->InsertPoint(count,current[0],current[1],current[2]);
}
vtkSmartPointer<vtkCellArray> lines=vtkSmartPointer<vtkCellArray>::New();
lines->InsertNextCell(number);
for(int i=0;i<number;i++)
{
lines->InsertCellPoint(i);
}
vtkSmartPointer<vtkPolyData> polyData=vtkSmartPointer<vtkPolyData>::New();
polyData->SetPoints(pointsdata);
polyData->SetLines(lines);
vtkSmartPointer<vtkDoubleArray> tubeRadius=vtkSmartPointer<vtkDoubleArray>::New();
tubeRadius->SetName("TubeRadius");
tubeRadius->SetNumberOfTuples(number);
auto itr = radiuslist.begin();
for(int i=0;i<number;i++,++itr)//设置半径列表
{
double radius = *itr;
tubeRadius->SetTuple1(i,radius);
}
polyData->GetPointData()->AddArray(tubeRadius);//将半径列表匹配vtkPolyData
polyData->GetPointData()->SetActiveScalars("TubeRadius");
vtkSmartPointer<vtkTubeFilter> tube=vtkSmartPointer<vtkTubeFilter>::New();
tube->SetInputData(polyData);
tube->SetNumberOfSides(64);
tube->SetVaryRadiusToVaryRadiusByAbsoluteScalar();
tube->SetGenerateTCoords(1);
vtkSmartPointer<vtkTransformTextureCoords> xform = vtkSmartPointer<vtkTransformTextureCoords>::New();;
xform->SetInputConnection(tube->GetOutputPort());
xform->SetScale(number,7,0);
xform->Update();
auto mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(xform->GetOutputPort());
mapper->ScalarVisibilityOff();
vtkSmartPointer<vtkPNGReader> reader = vtkSmartPointer<vtkPNGReader>::New();
reader->SetFileName("C:/Users/Administrator/Desktop/test.png");
reader->Update();
vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(reader->GetOutputPort());
texture->RepeatOn();
texture->SetEdgeClamp(true);
auto actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);
actor->SetTexture(texture);