CurveArray Convert( EdgeArrayArray eaa )
{
CurveArray ca = new CurveArray();
List<XYZ> pts = new List<XYZ>();
XYZ q;
string s;
int iLoop = 0;
foreach( EdgeArray ea in eaa )
{
q = null;
s = string.Empty;
pts.Clear();
foreach( Edge e in ea )
{
IList<XYZ> a = e.Tessellate();
bool first = true;
//XYZ p0 = null;
foreach( XYZ p in a )
{
if( first )
{
if( null == q )
{
s += Util.PointString( p );
pts.Add( p );
}
else
{
Debug.Assert( p.IsAlmostEqualTo( q ), "expected connected sequential edges" );
}
first = false;
//p0 = p;
q = p;
}
else
{
s += " --> " + Util.PointString( p );
//ca.Append( Line.get_Bound( q, p ) );
pts.Add( p );
q = p;
}
}
//ca.Append( Line.get_Bound( q, p0 ) );
}
Debug.Print( "{0}: {1}", iLoop++, s );
// test case: break after first edge loop,
// which we assume to be the outer:
//break;
{
// try reversing all the inner loops:
if( 1 < iLoop )
{
pts.Reverse();
}
bool first = true;
foreach( XYZ p in pts )
{
if( first )
{
first = false;
}
else
{
ca.Append( Line.get_Bound( q, p ) );
}
q = p;
}
}
}
return ca;
}