# Is there an easy vtkTexture shallow copy from vtkOBJImporter to a vtkClipClosedSurface or a vtkFrustumSource

**URL:** https://discourse.vtk.org/t/is-there-an-easy-vtktexture-shallow-copy-from-vtkobjimporter-to-a-vtkclipclosedsurface-or-a-vtkfrustumsource/7518
**Category:** Support
**Created:** [December 29, 2021, 3:45am UTC](https://discourse.vtk.org/t/is-there-an-easy-vtktexture-shallow-copy-from-vtkobjimporter-to-a-vtkclipclosedsurface-or-a-vtkfrustumsource/7518 "2021-12-29T03:45:19Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Joel\_Mckay](https://discourse.vtk.org/user_avatar/discourse.vtk.org/joel_mckay/32/4443_2.png) [@Joel\_Mckay](https://discourse.vtk.org/u/Joel_Mckay)
#### Post date: [December 29, 2021, 3:45am UTC](https://discourse.vtk.org/t/is-there-an-easy-vtktexture-shallow-copy-from-vtkobjimporter-to-a-vtkclipclosedsurface-or-a-vtkfrustumsource/7518/1 "2021-12-29T03:45:19Z")

</div>

This [old site](http://scylardor.fr/2013/05/06/making-multi-texturing-work-with-vtk/) has described an import/export method, but I suspect there must be an easier generic way of handling this common task in libvtk. As the initial texture/map is not being modified, it makes sense someone likely encountered this performance constraint already at some point.

I am trying to tile planes created by clipping an obj file, extract the texture mapped edge color/alpha information, and create a mine-craft style voxel world (similar method to vtkMarchingSquares).

As the memory requirement balloons rather quickly, I am planning to only keep 3 planes resident while decomposing the 3D obj into a smaller set of colored glyphs.

My current horrible design will apply vtkImageHistogram to the rendered camera/light angles perpendicular to each face in the 3D region of interest (cut surfaces are filled with black polygons), and use the dominant RGB histograms to down-sample the texture information.

This is not going to win any speed or beauty contests, but should work for my toy project. 😉

Cheers,  
J

Examples I am currently looking at:  
[TextureCutSphere](https://kitware.github.io/vtk-examples/site/Cxx/Texture/TextureCutSphere/)  
[ClipClosedSurface](https://kitware.github.io/vtk-examples/site/Cxx/Meshes/ClipClosedSurface/)  
[ClipFrustum](https://kitware.github.io/vtk-examples/site/Cxx/Meshes/ClipFrustum/)

The following does not work as expected, and is based on the ClipClosedSurface Example:  
`

```
	vtkActor* actor = actors->GetNextActor(); //parsing obj actors with textures

	vtkPolyData* polyDataTmp = dynamic_cast<vtkPolyData*>(actor->GetMapper()->GetInput());

	auto localCenter = polyDataTmp->GetCenter();
	vtkNew<vtkPlane> planeClip1;

	planeClip1->SetOrigin(localCenter[COORDS_X], localCenter[COORDS_Y], localCenter[COORDS_Z]);

	planeClip1->SetNormal(0.0, -1.0, 0.0);

	vtkNew<vtkPlane> planeClip2;

	planeClip2->SetOrigin(localCenter[COORDS_X], localCenter[COORDS_Y], localCenter[COORDS_Z]);

	planeClip2->SetNormal(0.0, 0.0, 1.0);

	vtkNew<vtkPlane> planeClip3;

	planeClip3->SetOrigin(localCenter[COORDS_X], localCenter[COORDS_Y], localCenter[COORDS_Z]);

	planeClip3->SetNormal(-1.0, 0.0, 0.0);

	vtkNew<vtkPlaneCollection> planeClips;

	planeClips->AddItem(planeClip1);

	planeClips->AddItem(planeClip2);

	planeClips->AddItem(planeClip3);

	vtkNew<vtkClipClosedSurface> clipper;

	clipper->SetInputData(polyDataTmp);

	clipper->SetClippingPlanes(planeClips);

	clipper->SetActivePlaneId(2);

	clipper->SetScalarModeToColors();

	//clipper->SetClipColor(colors->GetColor3d("Banana").GetData());

	//clipper->SetBaseColor(colors->GetColor3d("Tomato").GetData());

	//clipper->SetActivePlaneColor(colors->GetColor3d("Blue").GetData());

	vtkNew<vtkDataSetMapper> clipMapper;

	clipMapper->SetInputConnection(clipper->GetOutputPort());

	vtkNew<vtkActor> clipActor;

	clipActor->SetMapper(clipMapper);

	clipActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);

	clipActor->GetProperty()->SetInterpolationToFlat();

	vtkSmartPointer<vtkTexture> texture = actor->GetTexture(); //todo: fix shallow copy of vtkTexture obj

	clipActor->SetTexture(texture);

	renderer->AddActor(clipActor); 
//no display of texture on new mesh slice

```

`
