void write_complex(PlanarComplex complex, StreamWriter w)
 {
     foreach (var elem in complex.ElementsItr())
     {
         List <IParametricCurve2d> curves = CurveUtils2.Flatten(elem.source);
         foreach (IParametricCurve2d c in curves)
         {
             if (c is Segment2d)
             {
                 write_line(new Segment2dBox((Segment2d)c), w);
             }
             else if (c is Circle2d)
             {
                 write_circle(c as Circle2d, w);
             }
             else if (c is Polygon2DCurve)
             {
                 write_polygon((c as Polygon2DCurve).Polygon, w);
             }
             else if (c is PolyLine2DCurve)
             {
                 write_polyline((c as PolyLine2DCurve).Polyline, w);
             }
             else if (c is Arc2d)
             {
                 write_arc(c as Arc2d, w);
             }
         }
     }
 }
 public static void LaplacianSmoothConstrained(GeneralPolygon2d solid, double alpha, int iterations, double max_dist, bool bAllowShrink, bool bAllowGrow)
 {
     LaplacianSmoothConstrained(solid.Outer, alpha, iterations, max_dist, bAllowShrink, bAllowGrow);
     foreach (Polygon2d hole in solid.Holes)
     {
         CurveUtils2.LaplacianSmoothConstrained(hole, alpha, iterations, max_dist, bAllowShrink, bAllowGrow);
     }
 }
 /// <summary>
 /// iterate through "leaf" curves, ie all the IParametricCurve2D's
 /// embedded in loops that do not contain any child curves
 /// </summary>
 public IEnumerable <IParametricCurve2d> LoopLeafComponentsItr()
 {
     foreach (Element e in vElements)
     {
         if (e is SmoothLoopElement)
         {
             IParametricCurve2d source = e.source;
             if (source is IMultiCurve2d)
             {
                 foreach (var c in CurveUtils2.LeafCurvesIteration(source))
                 {
                     yield return(c);
                 }
             }
             else
             {
                 yield return(source);
             }
         }
     }
 }