   [SlimDX] Direct2D: Combine geometries (solved)
  Hey there.  I threw together a sample app to play around with Direct2D using SlimDX.  Everything works, except I don't know how to combine geometries.  I'm trying to combine a path with an ellipse — perhaps this isn't possible, but in the MS sample they combine two ellipses and store the result in a path.Here is my path generation code:private void CreateDeviceIndependentResources(){    GeometrySink sink;    // Create Direct2D factory    d2dFactory = new Factory(FactoryType.SingleThreaded);    // Create closed path    path = new PathGeometry(d2dFactory);    sink = path.Open();    sink.BeginFigure(   new Point(20,20),   FigureBegin.Filled);    sink.AddLine(new Point(120,20));    sink.AddBezier(   new BezierSegment()   {  Point1 = new PointF(120, 20),  Point2 = new PointF(170, 70),  Point3 = new PointF(120, 120)   });    sink.AddLine(new Point(20, 120));    sink.AddBezier(   new BezierSegment()   {  Point1 = new PointF(20, 120),  Point2 = new PointF(70, 70),  Point3 = new PointF(20, 20)   });    sink.EndFigure(FigureEnd.Closed);   sink.Close();    // Create ellipse    Ellipse e = new Ellipse()    {   Center = new PointF(170, 70),   RadiusX = 50,   RadiusY = 50    };    ellipse = new EllipseGeometry(d2dFactory, e);    Result res = Geometry.Combine(path, ellipse, CombineMode.Intersect, sink);    if (res.Code != 0)   MessageBox.Show(res.Description);}The sink must be closed before the combine or it throws an exception.  Any help is appreciated.[Edited by - Tom on May 15, 2009 8:21:55 AM]
  I don't know for sure, but my guess is that you can't do a combine on a path and another figure and then store the result back onto the same path. Try creating a separate path to hold the result and see what happens.   ;  That did the trick, thanks!  One thing to note is that the sink needs to be closed, or it'll throw an exception at EndDraw.  The result code from Combine makes no indication of this.  Just a heads up.sink = pathCombine.Open();Result res = Geometry.Combine(path, ellipse, CombineMode.Union, sink);if (res.Code != 0)    MessageBox.Show(res.Description);sink.Close();