protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); obj["Points"] = Points.getJson(this, options); if (mSegments.Count > 0) { JArray array = new JArray(); obj["Segments"] = array; foreach (IfcSegmentIndexSelect seg in Segments) { IfcArcIndex ai = seg as IfcArcIndex; JObject jobj = new JObject(); if (ai != null) { jobj["IfcArcIndex"] = ai[0] + " " + ai[1] + " " + ai[2]; } else { IfcLineIndex li = seg as IfcLineIndex; jobj["IfcLineIndex"] = string.Join(" ", li.ConvertAll(x => x.ToString())); } array.Add(jobj); } } if (mSelfIntersect != IfcLogicalEnum.UNKNOWN) { obj["SelfIntersect"] = mSelfIntersect.ToString(); } }
internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed) { base.SetXML(xml, host, processed); xml.AppendChild(Points.GetXML(xml.OwnerDocument, "Points", this, processed)); if (mSegments.Count > 0) { XmlElement element = xml.OwnerDocument.CreateElement("Segments"); xml.AppendChild(element); foreach (IfcSegmentIndexSelect seg in Segments) { XmlElement s = xml.OwnerDocument.CreateElement(seg.GetType().Name + "-wrapper"); element.AppendChild(s); IfcArcIndex ai = seg as IfcArcIndex; if (ai != null) { s.InnerText = ai.mA + " " + ai.mB + " " + ai.mC; } else { IfcLineIndex li = seg as IfcLineIndex; s.InnerText = string.Join(" ", li.mIndices.ConvertAll(x => x.ToString())); } } } }
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.mA - 1], points.ElementAt(arc.mB - 1), pts[arc.mC - 1]))); } else { IfcLineIndex line = seg as IfcLineIndex; if (line != null) { for (int icounter = 1; icounter < line.mIndices.Count; icounter++) { segs.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, new IfcPolyline(pts[line.mIndices[icounter - 1] - 1], pts[line.mIndices[icounter] - 1]))); } } } } return(new IfcCompositeCurve(segs)); } return(new IfcIndexedPolyCurve(new IfcCartesianPointList2D(db, points), segments)); }