public static Section CreateSection(Brep brp, Plane pln) { var sec = new Section(); string id = "P101"; var tx = Transform.ChangeBasis(Plane.WorldYZ, Util.SofiSectionBasePlane) * Transform.ChangeBasis(Plane.WorldXY, pln); int pointIndex = 0; foreach (var lp in brp.Loops) { var crv = lp.To3dCurve(); crv.Transform(tx); var polyLine = Util.CreatePolyLine(crv); if (polyLine != null) { var secLp = new SectionLoop(); secLp.Type = lp.LoopType == BrepLoopType.Outer ? SectionLoopType.Outer : SectionLoopType.Inner; int firstIndex = -1; int i = 0; foreach (var pt in polyLine) { if (i < polyLine.Count - 1) { var secPt = new SectionPoint() { Id = id, EType = EdgeTransitionType.Fillet, EdgeTransitionValue1 = 0.0, EdgeTransitionValue2 = 0.0, Y = pt.Y, Z = pt.Z, }; id = Util.CountStringUp(id); if (i++ == 0) { firstIndex = pointIndex; } secLp.Add(pointIndex++); sec.Points.Add(secPt); } } if (firstIndex > -1) { secLp.Add(firstIndex); } sec.Loops.Add(secLp); } } return(sec); }
public SectionLoop Duplicate() { var res = new SectionLoop() { Type = Type, MaterialId = MaterialId, ConstructionStage = ConstructionStage, }; foreach (var i in this) { res.Add(i); } return(res); }