title: Checking if path is simple and closed using cairo
body: <p>I am using cairomm together with gtkmm for a GUI project. I have defined a <code>GeometricShape</code> abstract widget (which inherits from <code>Gtk::DrawingArea</code>) to inherit from if one needs to draw a square, a circle, etc. This class defines three regions:</p>
  
  <ol>
  <li>a fill (or body area);</li>
  <li>a border;</li>
  <li>a background area.</li>
  </ol>
  
  <p>The fill area is used to fill in the shape with a certain body color. The border (usually black) defines the shape and the background area is used to fill the remaining space (everything but the border and its related fill area) with a color. Here is an example of how it looks for a circle:</p>
  
  <p><a href="https://i.stack.imgur.com/yL1lIs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yL1lIs.png" alt="enter image description here"></a></p>
  
  <p>In this case, the background color is green, the border color is blue and the fill region is red (just to be clear). Now one of my class invariants would need to be that the path represented by the border is a <a href="http://www.mathwords.com/s/simple_closed_curve.htm" rel="nofollow noreferrer">simple closed curve</a>. How could I enforce this invariant?</p>
  
  <p>I though about adding some underlying non-cairo logic to check this, for example by providing some kind of <code>SimpleClosedPath</code> object to pass on to cairo (which would itself check the invariant), but I'm not sure how this would be possible, since I want to allow both polygons and curved based shapes, like a circle.</p>
  
  <p>I though about using cairo to perform the check, but the methods for checking paths seem pretty limited. I feel like cairo is not intended to solve this kind of problem.</p>
  
  <p>Do you have any idea how I could ensure this invariant would be respected?</p>
  
  <p>I'm not really looking for code, but more for an idea, something to try. </p>