public static IfcBoundedCurve Generate(DatabaseIfc db, IEnumerable<Tuple<double,double>> points, List<IfcSegmentIndexSelect> segments)
{
if(db.Release < ReleaseVersion.IFC4)
{
if(segments == null || segments.Count == 0)
return new IfcPolyline(db, points);
List<IfcCompositeCurveSegment> segs = new List<IfcCompositeCurveSegment>();
List<IfcCartesianPoint> pts = points.ToList().ConvertAll(x => new IfcCartesianPoint(db, x.Item1, x.Item2));
foreach(IfcSegmentIndexSelect seg in segments)
{
IfcArcIndex arc = seg as IfcArcIndex;
if(arc != null)
segs.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, new IfcTrimmedCurve(pts[arc[0] - 1], points.ElementAt(arc[1] - 1), pts[arc[2] - 1])));
else
{
IfcLineIndex line = seg as IfcLineIndex;
if(line != null)
{
for(int icounter = 1; icounter < line.Count; icounter++)
segs.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, new IfcPolyline(pts[line[icounter - 1]-1], pts[line[icounter]-1])));
}
}
}
return new IfcCompositeCurve(segs);
}
return new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, points), segments);
}
}