# vtkImprintFilter leaving holes and non-manifold edges

**URL:** <https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073>\
**Category:** Development\
**Created:** [August 3, 2022, 3:24pm UTC](https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073 "2022-08-03T15:24:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Connor.Bowley](https://discourse.vtk.org/user_avatar/discourse.vtk.org/connor.bowley/32/3933_2.png) [@Connor.Bowley](https://discourse.vtk.org/u/Connor.Bowley)\
**Post date:** [August 3, 2022, 3:24pm UTC](https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073/1 "2022-08-03T15:24:52Z")

</div>

I am trying to use vtkImprintFilter to imprint flat text on a box. Most of the time it works well, but occasionally it will leave holes and non-manifold in its output. This seems to happen most often when an edge of the text line up closely with an edge on the target. See the following example:

OutputType is MergedImprint (the orange part is a back-facing cell from the other side of the box)

 ![image](https://discourse.vtk.org/uploads/default/original/2X/f/f38ee75b54345d30ce0a0be533995348250ec9db.png)

When looking at just the ImprintedCells for the same example, the cells that are missing in the MergedImprint are still there

OutputType is ImprintedCells

 ![image](https://discourse.vtk.org/uploads/default/original/2X/9/9c0d447eb8abb09b8d1f30fd9e2cf3ebfaf0d9af.png)

The following image is the same as above but, with the “ImprintedCells” scalars visible

 ![image](https://discourse.vtk.org/uploads/default/original/2X/7/70c97a910f9e058a952bac05bf839ff04ea775b2.png)

Zooming into the point indicated by the red circle we can see that it successfully imprinted the near coincident line.

OutputType is ImprintedCells

 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/dd06128287db19188ca519edba487a12677bba5f.png)

The following image is the same shot as above, but of the MergedImprinted rather than the ImprintedCells. Notice the cell that is missing (the orange part is a back-facing cell from the other side of the box).

 ![image](https://discourse.vtk.org/uploads/default/original/2X/d/dcc56d9b90fb8ce486683856a805b5ebfe08ae3a.jpeg)

My current hypothesis is that because the cell that is marked with the `F-1` point is not labeled as a transition cell (in green) and the original cell from the original target is not the same (as it was split during the imprint), that when merging the ImprintedCells into the original target neither side can account for that area.

If someone (possibly @will.schroeder since I think you are the main author and maintainer of this filter) could take a look, I would greatly appreciate it.

Extra info:

- The box is being generated by creating a `vtkRectilinearGrid` of the size I want and running that through a `vtkDataSetSurfaceFilter` and a `vtkTriangleFilter` to get the box polydata.
- The text is being generated via `vtkVectorText` and running that through a `vtkTriangleFilter`
- Turning `BoundaryEdgeInsertion` on or off does not seem to make a difference

I am using the following code to run the imprint

```auto
imprint = vtk.vtkImprintFilter()
imprint.SetTargetData(boxPolyData)
imprint.SetImprintData(textPolyData)
imprint.SetOutputTypeToMergedImprint()
imprint.BoundaryEdgeInsertionOn()
imprint.SetTolerance(1.0e-6)
imprint.SetMergeTolerance(1e-6)
imprint.SetMergeToleranceTypeToAbsolute()
imprint.Update()

```

---

<div class="post-metadata">

**Author:** ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)\
**Post date:** [August 3, 2022, 3:34pm UTC](https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073/2 "2022-08-03T15:34:59Z")

</div>

Conner, I’ll take a look later today/tomorrow morning and see if I can make progress. Imprint is unfortunately a geometric modeling operator and occasionally fiddling with the tolerances is necessary - I don’t like this but there is a reason that robust geometric modeling engines take lots of time to create…

Also, there may be a race condition that was recently reported, so it’s time to get back into this beast.

---

<div class="post-metadata">

**Author:** ![Connor.Bowley](https://discourse.vtk.org/user_avatar/discourse.vtk.org/connor.bowley/32/3933_2.png) [@Connor.Bowley](https://discourse.vtk.org/u/Connor.Bowley)\
**Post date:** [August 3, 2022, 3:42pm UTC](https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073/3 "2022-08-03T15:42:15Z")

</div>

Yes I am the one who reported the race condition after stumbling across it while trying to look into this 🙂. I tried adjusting the tolerances some, but was unable to get something stable.

---

<div class="post-metadata">

**Author:** ![mau\_igna\_06](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mau_igna_06/32/8064_2.png) [@mau\_igna\_06](https://discourse.vtk.org/u/mau_igna_06)\
**Post date:** [August 3, 2022, 4:43pm UTC](https://discourse.vtk.org/t/vtkimprintfilter-leaving-holes-and-non-manifold-edges/9073/4 "2022-08-03T16:43:34Z")

</div>

Hi. I didn’t know about this filter

I was able to imprint text in the past by using the text source, then linear extrusion, then boolean difference or union (from vtkbool) to the targetModel

Hope it helps
