# Contour isosurfaces for positive and negative values: orientation

**URL:** https://discourse.vtk.org/t/contour-isosurfaces-for-positive-and-negative-values-orientation/800
**Category:** Support
**Created:** [April 20, 2019, 8:51am UTC](https://discourse.vtk.org/t/contour-isosurfaces-for-positive-and-negative-values-orientation/800 "2019-04-20T08:51:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jellby](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jellby/32/135_2.png) [@Jellby](https://discourse.vtk.org/u/Jellby)
#### Post date: [April 20, 2019, 8:51am UTC](https://discourse.vtk.org/t/contour-isosurfaces-for-positive-and-negative-values-orientation/800/1 "2019-04-20T08:51:44Z")

</div>

I have some scalar field for which I want to represent contours for +v and -v simultaneously, with different colors, with the caveat that the contours for -v should be “reversed”, i.e., they enclose the volume for which the field is \> -v (rather than \< -v). This could be done by representing abs(field), and coloring according to sign(field). However, I’d also like to be able to show/hide the two signs separately, for which actually having two contour values is more convenient.

Actually just displaying the contours for +v and -v looks fine… with the surface representation. But with wireframe/points, or by enabling backface culling the problems show up and it is evident that the contours for -v are reversed. Is there some solution for this? Can I have a ReverseSense filter that affects only the negative contours? Other ideas?

---

<div class="post-metadata">

### Author: ![Jellby](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jellby/32/135_2.png) [@Jellby](https://discourse.vtk.org/u/Jellby)
#### Post date: [April 20, 2019, 12:27pm UTC](https://discourse.vtk.org/t/contour-isosurfaces-for-positive-and-negative-values-orientation/800/2 "2019-04-20T12:27:25Z")

</div>

So far, the following seems to work (python syntax). Where I had:

```
c = vtk.vtkContourFilter()
c.SetInputData(points)
m = vtk.vtkPolyDataMapper()
m.SetInputConnection(c.GetOutputPort())

```

I replace it with:

```
c = vtk.vtkContourFilter()
c.SetInputData(points)

# Now split positive and negative parts
pos = vtk.vtkClipPolyData()
pos.SetInputConnection(c.GetOutputPort())
neg = vtk.vtkClipPolyData()
neg.InsideOutOn()
neg.SetInputConnection(c.GetOutputPort())
# Reverse the negative part
rvneg = vtk.vtkReverseSense()
rvneg.SetInputConnection(neg.GetOutputPort())
rvneg.ReverseCellsOn()
rvneg.ReverseNormalsOn()
# Join both parts again
tot = vtk.vtkAppendPolyData()
tot.AddInputConnection(pos.GetOutputPort())
tot.AddInputConnection(rvneg.GetOutputPort())

# And continue as before
m = vtk.vtkPolyDataMapper()
m.SetInputConnection(tot.GetOutputPort())

```

But I wonder if there is a more direct path. Ideally, one should be able to reverse individual contours generated by ContourFilter, since the user may have a good idea of what should be “inside” or “outside” for each one.
