Summary: Viviani’s theorem states that the sum of distances from any point inside an equilateral triangle to its sides is constant. Here, in an extension of this result, the author shows, using linear programming, that any convex polygon can be divided into parallel line segments on which the sum of the distances to the sides of the polygon is constant. A polygon has the CVS property if the sum of distances from any inner point to its sides is constant. An amazing converse of Viviani’s theorem is deduced: if just three non-collinear points inside a convex polygon have equal sums of distances then the polygon has the CVS property. For concave polygons the situation is quite different. For polyhedra analogous results are deduced.