# 3D Mesh & Texture

**URL:** https://discourse.vtk.org/t/3d-mesh-texture/6286
**Category:** Support
**Created:** [August 3, 2021, 5:41am UTC](https://discourse.vtk.org/t/3d-mesh-texture/6286 "2021-08-03T05:41:45Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![herman](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/h/eada6e/32.png) [@herman](https://discourse.vtk.org/u/herman)
#### Post date: [August 3, 2021, 5:41am UTC](https://discourse.vtk.org/t/3d-mesh-texture/6286/1 "2021-08-03T05:41:45Z")

</div>

I have a height map(with NAN value) and a 2d image.  
Part of my code:

vtkSmartPointer imageImport = vtkSmartPointer::New();  
imageImport-\>SetDataSpacing(1, 1, 1);  
imageImport-\>SetDataOrigin(0, 0, 0);  
imageImport-\>SetWholeExtent(0, cols - 1, 0, rows - 1, 0, 0);  
imageImport-\>SetDataExtentToWholeExtent();  
imageImport-\>SetDataScalarTypeToUnsignedChar();  
imageImport-\>SetNumberOfScalarComponents(3);  
imageImport-\>SetImportVoidPointer((void\*)imgPtr);  
imageImport-\>Update();

```
vtkSmartPointer<vtkDelaunay2D> delaunay = vtkSmartPointer<vtkDelaunay2D>::New();
delaunay->SetInputData(polydata);
delaunay->Update();

vtkSmartPointer<vtkSmoothPolyDataFilter> smoothFilter = vtkSmartPointer<vtkSmoothPolyDataFilter>::New();
smoothFilter->SetInputConnection(delaunay->GetOutputPort());
smoothFilter->SetNumberOfIterations(30);
smoothFilter->SetRelaxationFactor(0.05);
smoothFilter->FeatureEdgeSmoothingOff();
smoothFilter->BoundarySmoothingOn();
smoothFilter->Update();

// Update normals on newly smoothed polydata
vtkSmartPointer<vtkPolyDataNormals> normalGenerator = vtkSmartPointer<vtkPolyDataNormals>::New();
normalGenerator->SetInputConnection(smoothFilter->GetOutputPort());
normalGenerator->ComputePointNormalsOn();
normalGenerator->ComputeCellNormalsOn();
normalGenerator->Update();

vtkSmartPointer<vtkPolyDataMapper> smoothedMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
smoothedMapper->SetInputConnection(normalGenerator->GetOutputPort());

vtkSmartPointer<vtkActor> smoothedActor = vtkSmartPointer<vtkActor>::New();
   vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture>::New();
texture->SetInputConnection(imageImport->GetOutputPort());

double bounds[6];
smoothFilter->GetOutput()->GetBounds(bounds);
smoothFilter->SetEdgeAngle(60.0);
smoothFilter->SetFeatureAngle(60);
vtkSmartPointer<vtkTextureMapToPlane> texturemap = vtkSmartPointer<vtkTextureMapToPlane>::New();
texturemap->SetInputData(smoothFilter->GetOutput());
texturemap->SetOrigin(bounds[0], bounds[2], bounds[4]);
texturemap->SetPoint1(bounds[1], bounds[2], bounds[4]);
texturemap->SetPoint2(bounds[0], bounds[3], bounds[4]);

smoothedMapper->SetInputConnection(texturemap->GetOutputPort());
smoothedActor->SetMapper(smoothedMapper);
smoothedActor->SetTexture(texture);

```

but the effect is just so so !  
Now I do not know how to process can get the effect picture is as below:

![lALPDiQ3PXWKaaTNAb3NAas_427_445](https://discourse.vtk.org/uploads/default/original/2X/5/54e1aa74f3c3b3a9b485e42b24e32775a91c1d38.png)
