Post

Visualizzazione dei post da marzo, 2020

VTK Textured Map Plane + Image Data

Ref: https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TextureMapPlane   Ref: https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TextureMapImageData  ...    vtkImageCanvasSource2D *imageSource; vtkNEW(imageSource);     imageSource->SetScalarTypeToUnsignedChar();     imageSource->SetExtent(0, 10, 0, 10, 0, 0);     imageSource->SetNumberOfScalarComponents(3);     imageSource->SetDrawColor(127, 255, 100);     imageSource->FillBox(0, 10, 0, 10);     imageSource->SetDrawColor(20, 20, 20);     imageSource->DrawSegment(0, 0, 9, 9);     imageSource->DrawSegment(9, 0, 0, 9);     imageSource->Update();         texture->SetInput(imageSource->GetOutput());     // Create a plane     vtkPlaneSource *plane; vtkNEW(plane);     plane->SetCenter(0.0, 0.0, 0.0);     plane->SetNormal(0.0, 0.0, -1.0);     vtkPolyDataMapper *planeMapper; vtkNEW(planeMapper);     plane->GetOutput()->GetPointData()->SetTCoords(textureCoordinates);     planeMapper-&g

vtk textured polygon

Ref: https://vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TextureMapQuad // Read the image which will be the texture vtkSmartPointer < vtkJPEGReader > jPEGReader = vtkSmartPointer < vtkJPEGReader >:: New (); jPEGReader -> SetFileName ( inputFilename . c_str () ); // Create a plane vtkSmartPointer < vtkPoints > points = vtkSmartPointer < vtkPoints >:: New (); points -> InsertNextPoint ( 0.0 , 0.0 , 0.0 ); points -> InsertNextPoint ( 1.0 , 0.0 , 0.0 ); points -> InsertNextPoint ( 1.0 , 1.0 , 0.0 ); points -> InsertNextPoint ( 0.0 , 2.0 , 0.0 ); vtkSmartPointer < vtkCellArray > polygons = vtkSmartPointer < vtkCellArray >:: New (); vtkSmartPointer < vtkPolygon > polygon = vtkSmartPointer < vtkPolygon >:: New (); polygon -> GetPointIds () -> SetNumberOfIds ( 4 ); //make a quad polygon -> GetPointIds () -> SetId ( 0 , 0 ); polygon -