public static IEnumerable <NXOpen.Curve> ToNXCurves(PolyCurve value, double factor) { int segmentCount = value.SegmentCount; for (int s = 0; s < segmentCount; ++s) { foreach (var segment in ToNXCurves(value.SegmentCurve(s), factor)) { yield return(segment); } } }
/***************************************************/ public static List <ICurve> SubParts(this PolyCurve curve) { List <ICurve> exploded = new List <ICurve>(); List <ICurve> curves = curve.Curves; for (int i = 0; i < curves.Count; i++) { exploded.AddRange(curves[i].ISubParts()); } return(exploded); }
/// <summary> /// Create a Revit Floor given it's curve outline and Level /// </summary> /// <param name="outlineCurves"></param> /// <param name="floorType"></param> /// <param name="level"></param> /// <returns>The floor</returns> public static Floor ByOutlineTypeAndLevel(Curve[] outlineCurves, FloorType floorType, Level level) { if (outlineCurves == null) { throw new ArgumentNullException("outlineCurves"); } var floor = ByOutlineTypeAndLevel(PolyCurve.ByJoinedCurves(outlineCurves), floorType, level); DocumentManager.Regenerate(); return(floor); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static bool IsPolylinear(this PolyCurve curve) { foreach (ICurve c in curve.SubParts()) { if (!(c is Line)) { return(false); } } return(true); }
/// <summary> /// SpecklePolyline to DS Rectangle if closed , four points and sides parallel; /// DS Polygon if closed or DS Polycurve otherwise /// </summary> /// <param name="polyline"></param> /// <returns></returns> public DS.Curve PolylineToNative(Polyline polyline) { var points = ArrayToPointList(polyline.value, polyline.units); if (polyline.closed) { return(DS.PolyCurve.ByPoints(points).CloseWithLine() .SetDynamoProperties <DS.PolyCurve>(GetDynamicMembersFromBase(polyline))); } return(PolyCurve.ByPoints(points).SetDynamoProperties <PolyCurve>(GetDynamicMembersFromBase(polyline))); }
public static IEnumerable <DB.Curve> ToCurveMany(this PolyCurve value, double factor) { int segmentCount = value.SegmentCount; for (int s = 0; s < segmentCount; ++s) { foreach (var segment in value.SegmentCurve(s).ToCurveMany(factor)) { yield return(segment); } } }
public override List <object> CreateGeometryObjects(List <Node> allNodes) { List <Point> points = new List <Point>(); for (int i = 0; i < NodeCount; i++) { points.Add(allNodes[NodeIndices[i]].Position.ToPoint()); } return(new List <object> { PolyCurve.ByPoints(points, Loop) }); }
public static Autodesk.DesignScript.Geometry.PolyCurve ToProtoType(this Autodesk.Revit.DB.PolyLine geom, bool performHostUnitConversion = true) { var converted = PolyCurve.ByPoints(geom.GetCoordinates().Select(x => Autodesk.DesignScript.Geometry.Point.ByCoordinates(x.X, x.Y, x.Z)).ToArray()); if (performHostUnitConversion) { UnitConverter.ConvertToDynamoUnits(ref converted); } return(converted); }
/***************************************************/ public static bool IsInPlane(this PolyCurve curve, Plane plane, double tolerance = Tolerance.Distance) { foreach (ICurve c in curve.Curves) { if (!c.IIsInPlane(plane, tolerance)) { return(false); } } return(true); }
public void SubdomainByCentreTest() { var polyCrv = new PolyCurve(new Line(0, 0, 10, 10)); polyCrv.AddArc(new Vector(10, 0)); polyCrv.Add(new PolyLine(new Vector(10, 0), new Vector(5, 0), new Vector(5, -5))); var domain = polyCrv.SubdomainByCentre(0.5, 20); Curve subCrv = polyCrv.Extract(domain); Assert.AreEqual(20, subCrv.Length, 0.00001); }
bool AddPolycurve(PolyCurve pc, double space, bool forceToOpened) { var b = AM_RegionBoundary.Create(pc, space, forceToOpened); if (b != null) { m_Loops.Add(b); return(true); } return(true); }
// Polycurve // Rh Capture/Gh Capture public static SpecklePolycurve ToSpeckle(this PolyCurve p) { SpecklePolycurve myPoly = new SpecklePolycurve(); p.RemoveNesting(); var segments = p.Explode(); myPoly.Segments = segments.Select(s => { return(s.ToSpeckle()); }).ToList(); myPoly.Properties = p.UserDictionary.ToSpeckle(); myPoly.SetHashes(myPoly.Segments.Select(obj => obj.Hash).ToArray()); return(myPoly); }
private Dictionary <string, object> TestCorridorInfo_Old(string code) { IList <string[]> corridorCodes = new List <string[]>(); IList <IList <Featureline> > corridorFeaturelines = new List <IList <Featureline> >(); foreach (Baseline bl in this.Baselines) { IList <Featureline> blFeaturelines = new List <Featureline>(); var b = bl._baseline; foreach (AeccFeatureLines coll in b.MainBaselineFeatureLines.FeatureLinesCol) { foreach (AeccFeatureLine f in coll) { if (f.CodeName == code) { IList <Point> featureline = new List <Point>(); foreach (AeccFeatureLinePoint p in f.FeatureLinePoints) { Point point = Point.ByCoordinates(p.XYZ[0], p.XYZ[1], p.XYZ[2]); featureline.Add(point); } featureline = Point.PruneDuplicates(featureline); PolyCurve pc = PolyCurve.ByPoints(featureline); var offset = bl.GetArrayStationOffsetElevationByPoint(pc.PointAtParameter(0.5))[1]; Featureline.SideType side = Featureline.SideType.Right; if (offset < 0) { side = Featureline.SideType.Left; } blFeaturelines.Add(new Featureline(bl, pc, f.CodeName, side)); } } } corridorFeaturelines.Add(blFeaturelines); } return(new Dictionary <string, object>() { { "Featurelines", corridorFeaturelines } }); }
private IfcBeam GenerateIPE200(STPModelData md, IfcBuilding building, bool tessellated) { IfcElemParams elemParams = new IfcElemParams("0EF5_zZRv0pQPddeofU3KT", "ExampleBeamName", "ExampleBeamDescription", "", "Tag"); if (tessellated) { List <Point3d> coords = new List <Point3d>() { new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 14.8, -91.5), new Point3d(0.0, 2.8, -79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(1000.0, 2.8, -79.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(500.0, 2.8, -79.5), new Point3d(500.0, 2.8, 79.5), new Point3d(0.0, 2.8, 79.5), new Point3d(0.0, 14.8, 91.5), new Point3d(1000.0, 2.8, 79.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(500.0, 2.8, 79.5), new Point3d(500.0, 14.8, 91.5), new Point3d(0.0, 14.8, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(1000.0, 14.8, 91.5), new Point3d(1000.0, 50.0, 91.5), new Point3d(500.0, 14.8, 91.5), new Point3d(500.0, 50.0, 91.5), new Point3d(0.0, 50.0, 91.5), new Point3d(0.0, 50.0, 100.0), new Point3d(1000.0, 50.0, 91.5), new Point3d(1000.0, 50.0, 100.0), new Point3d(500.0, 50.0, 91.5), new Point3d(500.0, 50.0, 100.0), new Point3d(0.0, 50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(1000.0, 50.0, 100.0), new Point3d(1000.0, -50.0, 100.0), new Point3d(500.0, 50.0, 100.0), new Point3d(500.0, -50.0, 100.0), new Point3d(0.0, -50.0, 100.0), new Point3d(0.0, -50.0, 91.5), new Point3d(1000.0, -50.0, 100.0), new Point3d(1000.0, -50.0, 91.5), new Point3d(500.0, -50.0, 100.0), new Point3d(500.0, -50.0, 91.5), new Point3d(0.0, -50.0, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(1000.0, -50.0, 91.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(500.0, -50.0, 91.5), new Point3d(500.0, -14.8, 91.5), new Point3d(0.0, -14.8, 91.5), new Point3d(0.0, -2.8, 79.5), new Point3d(1000.0, -14.8, 91.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(500.0, -14.8, 91.5), new Point3d(500.0, -2.8, 79.5), new Point3d(0.0, -2.8, 79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(1000.0, -2.8, 79.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(500.0, -2.8, 79.5), new Point3d(500.0, -2.8, -79.5), new Point3d(0.0, -2.8, -79.5), new Point3d(0.0, -14.8, -91.5), new Point3d(1000.0, -2.8, -79.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(500.0, -2.8, -79.5), new Point3d(500.0, -14.8, -91.5), new Point3d(0.0, -14.8, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(1000.0, -14.8, -91.5), new Point3d(1000.0, -50.0, -91.5), new Point3d(500.0, -14.8, -91.5), new Point3d(500.0, -50.0, -91.5), new Point3d(0.0, -50.0, -91.5), new Point3d(0.0, -50.0, -100.0), new Point3d(1000.0, -50.0, -91.5), new Point3d(1000.0, -50.0, -100.0), new Point3d(500.0, -50.0, -91.5), new Point3d(500.0, -50.0, -100.0), new Point3d(0.0, -50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(1000.0, -50.0, -100.0), new Point3d(1000.0, 50.0, -100.0), new Point3d(500.0, -50.0, -100.0), new Point3d(500.0, 50.0, -100.0), new Point3d(0.0, 50.0, -100.0), new Point3d(0.0, 50.0, -91.5), new Point3d(1000.0, 50.0, -100.0), new Point3d(1000.0, 50.0, -91.5), new Point3d(500.0, 50.0, -100.0), new Point3d(500.0, 50.0, -91.5), new Point3d(0.0, 50.0, -91.5), new Point3d(0.0, 14.8, -91.5), new Point3d(1000.0, 50.0, -91.5), new Point3d(1000.0, 14.8, -91.5), new Point3d(500.0, 50.0, -91.5), new Point3d(500.0, 14.8, -91.5) }; IfcCartesianPointList3D cartesianPointList3D = new IfcCartesianPointList3D(md, coords); cartesianPointList3D.Comments.Add("the geometric representation of the beam is provided as a triangulated face set"); cartesianPointList3D.Comments.Add("the meshing depends on the creating software system"); List <CoordIndex> coordIndex = new List <CoordIndex>() { new CoordIndex(6, 5, 4), new CoordIndex(15, 8, 6), new CoordIndex(6, 4, 3), new CoordIndex(10, 11, 9), new CoordIndex(16, 10, 7), new CoordIndex(14, 11, 10), new CoordIndex(7, 8, 16), new CoordIndex(6, 2, 15), new CoordIndex(2, 3, 1), new CoordIndex(3, 2, 6), new CoordIndex(10, 16, 14), new CoordIndex(14, 13, 12), new CoordIndex(11, 14, 12), new CoordIndex(8, 15, 16), new CoordIndex(24, 23, 22), new CoordIndex(17, 26, 24), new CoordIndex(22, 21, 20), new CoordIndex(28, 29, 27), new CoordIndex(32, 28, 25), new CoordIndex(30, 29, 28), new CoordIndex(18, 25, 26), new CoordIndex(24, 20, 17), new CoordIndex(20, 21, 19), new CoordIndex(32, 31, 30), new CoordIndex(28, 32, 30), new CoordIndex(33, 34, 37), new CoordIndex(36, 35, 38), new CoordIndex(40, 44, 43), new CoordIndex(41, 43, 44), new CoordIndex(46, 50, 49), new CoordIndex(47, 49, 50), new CoordIndex(56, 55, 51), new CoordIndex(55, 56, 54), new CoordIndex(57, 58, 62), new CoordIndex(60, 59, 61), new CoordIndex(63, 64, 68), new CoordIndex(66, 65, 67), new CoordIndex(69, 70, 74), new CoordIndex(72, 71, 73), new CoordIndex(80, 79, 75), new CoordIndex(79, 80, 78), new CoordIndex(81, 82, 86), new CoordIndex(84, 83, 85), new CoordIndex(88, 92, 91), new CoordIndex(89, 91, 92), new CoordIndex(94, 98, 97), new CoordIndex(95, 97, 98), new CoordIndex(104, 103, 99), new CoordIndex(103, 104, 102), new CoordIndex(105, 106, 110), new CoordIndex(108, 107, 109), new CoordIndex(111, 112, 116), new CoordIndex(114, 113, 115), new CoordIndex(117, 118, 122), new CoordIndex(120, 119, 121), new CoordIndex(128, 127, 123), new CoordIndex(127, 128, 126), new CoordIndex(22, 20, 24), new CoordIndex(32, 25, 18), new CoordIndex(18, 26, 17), new CoordIndex(33, 37, 38), new CoordIndex(36, 38, 37), new CoordIndex(40, 43, 39), new CoordIndex(41, 44, 42), new CoordIndex(46, 49, 45), new CoordIndex(47, 50, 48), new CoordIndex(56, 51, 52), new CoordIndex(55, 54, 53), new CoordIndex(57, 62, 61), new CoordIndex(60, 61, 62), new CoordIndex(63, 68, 67), new CoordIndex(66, 67, 68), new CoordIndex(69, 74, 73), new CoordIndex(72, 73, 74), new CoordIndex(80, 75, 76), new CoordIndex(79, 78, 77), new CoordIndex(81, 86, 85), new CoordIndex(84, 85, 86), new CoordIndex(88, 91, 87), new CoordIndex(89, 92, 90), new CoordIndex(94, 97, 93), new CoordIndex(95, 98, 96), new CoordIndex(104, 99, 100), new CoordIndex(103, 102, 101), new CoordIndex(105, 110, 109), new CoordIndex(108, 109, 110), new CoordIndex(111, 116, 115), new CoordIndex(114, 115, 116), new CoordIndex(117, 122, 121), new CoordIndex(120, 121, 122), new CoordIndex(128, 123, 124), new CoordIndex(127, 126, 125) }; IfcTriangulatedFaceSet triangulatedFaceSet = new IfcTriangulatedFaceSet(md, cartesianPointList3D, null, true, coordIndex, null); return(new IfcBeam(building, elemParams, triangulatedFaceSet)); } List <Point3d> points = new List <Point3d>() { new Point3d(2.8, -79.5, 0), new Point3d(2.8, 79.5, 0), new Point3d(6.314719, 87.985281, 0), new Point3d(14.8, 91.5, 0), new Point3d(50.0, 91.5, 0), new Point3d(50.0, 100.0, 0), new Point3d(-50.0, 100.0, 0), new Point3d(-50.0, 91.5, 0), new Point3d(-14.8, 91.5, 0), new Point3d(-6.314719, 87.985281, 0), new Point3d(-2.8, 79.5, 0), new Point3d(-2.8, -79.5, 0), new Point3d(-6.314719, -87.985281, 0), new Point3d(-14.8, -91.5, 0), new Point3d(-50.0, -91.5, 0), new Point3d(-50.0, -100.0, 0), new Point3d(50.0, -100.0, 0), new Point3d(50.0, -91.5, 0), new Point3d(14.8, -91.5, 0), new Point3d(6.314719, -87.985281, 0) }; PolyCurve pc = new PolyCurve(); pc.Append(new Line(points[0], points[1])); pc.Append(new Arc(points[1], points[2], points[3])); pc.Append(new Line(points[3], points[4])); pc.Append(new Line(points[4], points[5])); pc.Append(new Line(points[5], points[6])); pc.Append(new Line(points[6], points[7])); pc.Append(new Line(points[7], points[8])); pc.Append(new Arc(points[8], points[9], points[10])); pc.Append(new Line(points[10], points[11])); pc.Append(new Arc(points[11], points[12], points[13])); pc.Append(new Line(points[13], points[14])); pc.Append(new Line(points[14], points[15])); pc.Append(new Line(points[15], points[16])); pc.Append(new Line(points[16], points[17])); pc.Append(new Line(points[17], points[18])); pc.Append(new Arc(points[18], points[19], points[0])); IfcBoundedCurve boundedCurve = IfcBoundedCurve.ConvertCurve(md, pc); IfcArbitraryClosedProfileDef arbitraryClosedProfileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA, "IPE200", boundedCurve); IfcAxis2Placement3D axis2Placement3D = new IfcAxis2Placement3D(new IfcCartesianPoint(md, 0, 0, 0), new IfcDirection(md, 0, 1, 0), new IfcDirection(md, 1, 0, 0)); IfcExtrudedAreaSolid extrudedAreaSolid = new IfcExtrudedAreaSolid(arbitraryClosedProfileDef, axis2Placement3D, new IfcDirection(md, 0, 0, 1), 1000); return(new IfcBeam(building, elemParams, extrudedAreaSolid)); }
public IList <LandFeatureline> GetLandFeaturelines(string xmlPath = "") { Utils.Log(string.Format("CivilDocument.GetLandFeaturelines started...", "")); if (string.IsNullOrEmpty(xmlPath)) { xmlPath = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "LandFeatureLinesReport.xml"); } bool result = this.SendCommand("-ExportLandFeatureLinesToXml\n"); IList <LandFeatureline> output = new List <LandFeatureline>(); if (result) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(xmlPath); AcadDatabase db = this._document as AcadDatabase; AcadModelSpace ms = db.ModelSpace; foreach (AcadEntity e in ms) { if (e.EntityName.ToLower().Contains("featureline")) { AeccLandFeatureLine f = e as AeccLandFeatureLine; XmlElement fe = xmlDoc.GetElementsByTagName("FeatureLine").Cast <XmlElement>().First(x => x.Attributes["Name"].Value == f.Name); IList <Point> points = new List <Point>(); foreach (XmlElement p in fe.GetElementsByTagName("Point")) { double x = Convert.ToDouble(p.Attributes["X"].Value); double y = Convert.ToDouble(p.Attributes["Y"].Value); double z = Convert.ToDouble(p.Attributes["Z"].Value); points.Add(Point.ByCoordinates(x, y, z)); } PolyCurve pc = PolyCurve.ByPoints(points); string style = fe.Attributes["Style"].Value; output.Add(new LandFeatureline(f, pc, style)); } } Utils.Log(string.Format("CivilDocument.GetLandFeaturelines completed.", "")); } return(output); }
public void AreaCalculationTest() { var polyCrv = new PolyCurve(new Line(0, 0, 10, 10)); polyCrv.AddArc(new Vector(10, 0)); polyCrv.Add(new PolyLine(new Vector(10, 0), new Vector(5, 0), new Vector(5, -5))); polyCrv.Close(); Vector centroid; double area = polyCrv.CalculateEnclosedArea(out centroid); Assert.AreEqual(205.309725, area, 0.0001); }
public void DuplicateTest() { var polyCrv = new PolyCurve(new Line(0, 0, 10, 10)); polyCrv.AddArc(new Vector(10, 0)); polyCrv.Add(new PolyLine(new Vector(10, 0), new Vector(5, 0), new Vector(5, -5))); for (int i = 0; i < 1000; i++) { var polyCrv2 = polyCrv.Duplicate(); Assert.AreEqual(polyCrv.Length, polyCrv2.Length); } }
public GsaMember1d(List <Point3d> topology, List <string> topo_type = null) { m_member = new Member { Type = MemberType.GENERIC_1D }; m_crv = Util.GH.Convert.BuildCurve(topology, topo_type); m_topo = topology; m_topoType = topo_type; Topology = m_topo; TopologyType = m_topoType; }
/// <summary> /// Creates a Radiance Polygon. /// </summary> /// <param name="material">Material of the Polygon</param> /// <param name="name">Name of the Polygon</param> /// <param name="points">List of Points that define the Polygon (need to be planar).</param> /// <returns></returns> public static Objects.Polygon Polygon(string material, string name, List <Point> points) { //Check if points are planar var pcurve = PolyCurve.ByPoints(points); if (!pcurve.IsPlanar) { throw new ArgumentException("Points do not define a planar polygon!"); } //Create new Polygon. return(new Objects.Polygon(material, name, points)); }
/***************************************************/ public static Point StartPoint(this PolyCurve curve) { foreach (ICurve c in curve.Curves) { Point start = c.IStartPoint(); if (start != null) { return(start); } } return(null); }
/***************************************************/ public static List <Point> CurveIntersections(this PolyCurve curve1, PolyCurve curve2, double tolerance = Tolerance.Distance) { List <Point> result = new List <Point>(); foreach (ICurve c1 in curve1.SubParts()) { foreach (ICurve c2 in curve2.SubParts()) { result.AddRange(CurveIntersections(c1 as dynamic, c2 as dynamic, tolerance)); } } return(result.CullDuplicates(tolerance)); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private static bool SimpleIsContaining(PolyCurve crv, Plane plane, Point pt) { Point end = pt.Translate(Engine.Geometry.Create.RandomVectorInPlane(plane, true)); Line ray = new Line { Start = pt, End = end }; ray.Infinite = true; List <Point> interPts = crv.Curves.SelectMany(x => x.ILineIntersections(ray, true)).ToList(); return(interPts.Count % 2 != 0); }
/// <summary> /// Convert a Nucleus polyCurve into a RhinoCommon one /// </summary> /// <param name="curve"></param> /// <returns></returns> public static RC.PolyCurve Convert(PolyCurve curve) { RC.PolyCurve result = new RC.PolyCurve(); foreach (Curve subCrv in curve.SubCurves) { RC.Curve rCrv = Convert(subCrv); if (rCrv != null) { result.Append(rCrv); } } return(result); }
private Topologic.Topology ByCurve(Curve ghCurve) { LineCurve ghLine = ghCurve as LineCurve; if (ghLine != null) { return(ByLine(ghLine.Line)); } Rhino.Geometry.NurbsCurve ghNurbsCurve = ghCurve as Rhino.Geometry.NurbsCurve; if (ghNurbsCurve != null) { return(ByNurbsCurve(ghNurbsCurve)); } ArcCurve ghArcCurve = ghCurve as ArcCurve; if (ghArcCurve != null) { return(ByArcCurve(ghArcCurve)); } BrepEdge ghBrepEdge = ghCurve as BrepEdge; if (ghBrepEdge != null) { return(ByBrepEdge(ghBrepEdge)); } //BrepTrim ghBrepTrim = ghCurve as BrepTrim; //if (ghBrepTrim != null) //{ // return ByBrepTrim(ghBrepTrim); //} PolylineCurve ghPolylineCurve = ghCurve as PolylineCurve; if (ghPolylineCurve != null) { return(ByPolylineCurve(ghPolylineCurve)); } PolyCurve ghPolyCurve = ghCurve as PolyCurve; if (ghPolyCurve != null) { return(ByPolyCurve(ghPolyCurve)); } throw new Exception("This type of curve is not yet supported."); }
public PolyCurve PolycurveToNative(Polycurve polycurve) { DS.Curve[] curves = new DS.Curve[polycurve.segments.Count]; for (var i = 0; i < polycurve.segments.Count; i++) { switch (polycurve.segments[i]) { case Line curve: curves[i] = LineToNative(curve); break; case Arc curve: curves[i] = ArcToNative(curve); break; case Circle curve: curves[i] = CircleToNative(curve); break; case Ellipse curve: curves[i] = EllipseToNative(curve); break; case Spiral curve: curves[i] = PolylineToNative(curve.displayValue); break; case Polycurve curve: curves[i] = PolycurveToNative(curve); break; case Polyline curve: curves[i] = PolylineToNative(curve); break; case Curve curve: curves[i] = CurveToNative(curve); break; } } PolyCurve polyCrv = null; if (curves.Any()) { polyCrv = PolyCurve.ByJoinedCurves(curves); polyCrv = polyCrv.SetDynamoProperties <PolyCurve>(GetDynamicMembersFromBase(polycurve)); } return(polyCrv); }
protected Curve ReconstructPath(int[] cameFrom, int currentNode, out int[] nodes, out int[] edges, out bool[] edgeDir, out double totLength) { List <int> resultNodes = new List <int>(); for (; ;) { if (currentNode == -1) { break; } resultNodes.Add(currentNode); currentNode = cameFrom[currentNode]; } resultNodes.Reverse(); nodes = resultNodes.ToArray(); List <int> resultEdges = new List <int>(); List <bool> resultEdgesRev = new List <bool>(); currentNode = nodes[0]; for (int i = 1; i < nodes.Length; i++) { int nxt = nodes[i]; bool rev; int edgeIndex = FindEdge(currentNode, nxt, out rev); resultEdges.Add(edgeIndex); resultEdgesRev.Add(rev); currentNode = nxt; } edges = resultEdges.ToArray(); edgeDir = resultEdgesRev.ToArray(); totLength = 0; PolyCurve pc = new PolyCurve(); for (int i = 0; i < resultEdges.Count; i++) { int ei = resultEdges[i]; var cv = m_top.CurveAt(ei).DuplicateCurve(); if (!resultEdgesRev[i]) { cv.Reverse(); } pc.Append(cv); totLength += m_dist[ei]; } pc.RemoveNesting(); return(pc); }
public static Topology ToTopologic(this Curve curve) { if (curve == null) { return(null); } LineCurve lineCurve = curve as LineCurve; if (lineCurve != null) { return(lineCurve.Line.ToTopologic()); } Rhino.Geometry.NurbsCurve nurbsCurve = curve as Rhino.Geometry.NurbsCurve; if (nurbsCurve != null) { return(nurbsCurve.ToTopologic()); } ArcCurve arcCurve = curve as ArcCurve; if (arcCurve != null) { return(arcCurve.ToTopologic()); } BrepEdge brepEdge = curve as BrepEdge; if (brepEdge != null) { return(brepEdge.ToTopologic()); } PolylineCurve ghPolylineCurve = curve as PolylineCurve; if (ghPolylineCurve != null) { return(ghPolylineCurve.ToTopologic()); } PolyCurve ghPolyCurve = curve as PolyCurve; if (ghPolyCurve != null) { return(ghPolyCurve.ToTopologic()); } return(null); }
public override bool CustomGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex ci) { bool rc = false; if (null != geometry) { PolyCurve poly_curve = geometry as PolyCurve; if (null != poly_curve) { rc = true; } } return(rc); }
public static bool IsVertical <TEdge, TOpening>(this IPanel <TEdge, TOpening> panel, double tolerance = Tolerance.Angle) where TEdge : IEdge where TOpening : IOpening <TEdge> { PolyCurve polycurve = ExternalPolyCurve(panel); if (!polycurve.IsPlanar()) { return(false); } Vector polycurveNormal = polycurve.Normal(); return(polycurveNormal.IsInPlane(Plane.XY, tolerance)); }
/***************************************************/ public static Polyline CollapseToPolyline(this PolyCurve curve, double angleTolerance, int maxSegmentCount = 100) { List <Point> controlPoints = new List <Point> { curve.StartPoint() }; foreach (ICurve c in curve.SubParts()) { controlPoints.AddRange(c.ICollapseToPolylineVertices(angleTolerance, maxSegmentCount).Skip(1)); } return(new Polyline { ControlPoints = controlPoints }); }
/// <summary> /// create nesting layout of closed polycurve profiles within a closed polycurve sheet with given spacing /// </summary> /// <param name="Surfaces">list of closed planar surface arrays</param> /// <param name="spacing">(double) spacing between circles</param> /// <param name="sheet">closed planar polycurve of sheet outline</param> /// <returns>new instance of nesting</returns> public static Nesting BySurfacesInPolyCurve(List<Surface[]> Surfaces, double spacing, PolyCurve sheet) { // error for sheet not closed or planar if (!sheet.IsClosed && !sheet.IsPlanar) { throw new ArgumentException("invalid sheet"); } // error for empty list of surfaces to nest if (Surfaces.Count <= 0) { throw new ArgumentException("no surfaces in array"); } // NEEDS WORK: // error for input result not fitting inside sheet return new Nesting(Surfaces, spacing, sheet); }
//**CREATE /// <summary> /// create nesting layout of closed polycurve profiles within a closed polycurve sheet with given spacing /// </summary> /// <param name="circles">list of closed planar circles</param> /// <param name="spacing">(double) spacing between circles</param> /// <param name="sheet">closed planar polycurve of sheet outline</param> /// <returns>new instance of nesting</returns> public static Nesting ByPolyCurvesInPolyCurve(List<PolyCurve> polycurves, double spacing, PolyCurve sheet) { // error for sheet not closed or planar if (!sheet.IsClosed && !sheet.IsPlanar) { throw new ArgumentException("invalid sheet"); } // error for empty list of input result to nest if (polycurves.Count <= 0) { throw new ArgumentException("no curves to array"); } // error for input result not closed or planar for (int i = 0; i < polycurves.Count; i++) { if (!polycurves[i].IsClosed && !polycurves[i].IsPlanar) { throw new ArgumentException("invalid curves"); } } // NEEDS WORK: // error for input result not fitting inside sheet return new Nesting(polycurves, spacing, sheet); }
public ExportToDXF AddPolyCurvesAsLines(PolyCurve[][] polycurves, string layerName = "0", short ACADcolor = (short) 7) { CheckLayer(layerName, ACADcolor); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Length; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); for (int i = 0; i < Curves.Count; i++) { DXFLibrary.Line line = new DXFLibrary.Line("PROFILES", Curves[i].StartPoint.X, Curves[i].StartPoint.Y, Curves[i].StartPoint.Z, Curves[i].EndPoint.X, Curves[i].EndPoint.Y, Curves[i].EndPoint.Z); dxf.add(line); } Curves.ForEach(c => c.Dispose()); return this; }
/// <summary> /// Create a Revit Floor given it's curve outline and Level /// </summary> /// <param name="outline"></param> /// <param name="floorType"></param> /// <param name="level"></param> /// <returns>The floor</returns> public static Floor ByOutlineTypeAndLevel(PolyCurve outline, FloorType floorType, Level level) { if (outline == null) { throw new ArgumentNullException("outline"); } if (floorType == null) { throw new ArgumentNullException("floorType"); } if ( level == null ) { throw new ArgumentNullException("level"); } if (!outline.IsClosed) { throw new ArgumentException("The input PolyCurve is not closed"); } var ca = new CurveArray(); outline.Curves().ForEach(x => ca.Append(x.ToRevitType())); return new Floor(ca, floorType.InternalFloorType, level.InternalLevel ); }
//**CONSTRUCTORS /// <summary> /// get nesting of circles within a set sheet /// </summary> /// <param name="circles">input result to be cut</param> /// <param name="spacing">spacing between input result</param> /// <param name="sheet">closed curve of sheet</param> internal Nesting(List<PolyCurve> polycurves, double spacing, PolyCurve sheet) { ListPolyCurve = TileVertical(MapToXYPlane(polycurves), spacing); Sheet = sheet; Spacing = spacing; }
/// <summary> /// get nesting of circles within a set sheet /// </summary> /// <param name="surfaces">input planar surfaces to be cut</param> /// <param name="spacing">spacing between input result</param> /// <param name="sheet">closed curve of sheet</param> internal Nesting(List<Surface[]> surfaces, double spacing, PolyCurve sheet) { ListPolyCurve = TileVertical(MapToXYPlane(surfaces), spacing); Sheet = sheet; Spacing = spacing; }
//**METHODS - **ACTIONS public ExportToDXF AddPolyCurvesAsArcsLines(PolyCurve[][] polycurves, string layerName = "0", short ACADcolor = (short) 7) { CheckLayer(layerName, ACADcolor); List<Curve> Curves = new List<Curve>(); for (int i = 0; i < polycurves.Length; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++) Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments()); Vector stTan = null; Vector endTan = null; Point stpt = null; Point endpt = null; for (int i = 0; i < Curves.Count; i++) { stTan = Curves[i].TangentAtParameter(0); endTan = Curves[i].TangentAtParameter(Curves[i].EndParameter()); stpt = Curves[i].StartPoint; endpt = Curves[i].EndPoint; if (stTan.IsParallel(endTan)) { DXFLibrary.Line line = new DXFLibrary.Line(layerName, stpt.X, stpt.Y, endpt.X, endpt.Y); dxf.add(line); } else { Arc arc = Arc.ByStartPointEndPointStartTangent(stpt, endpt, stTan); arc = Arc.ByCenterPointStartPointEndPoint(arc.CenterPoint, endpt, stpt); CoordinateSystem cs = arc.CoordinateSystemAtParameter(0); double rotate = cs.XAxis.AngleBetween(Vector.XAxis()); double signY = cs.XAxis.Y; double signX = cs.XAxis.X; double startAngle = rotate; if (signY < 0) startAngle = -rotate; if (signX > 0) startAngle = 180 - startAngle; DXFLibrary.Arc arcs = new DXFLibrary.Arc(arc.CenterPoint.X, arc.CenterPoint.Y, arc.Radius, -startAngle - arc.SweepAngle, -startAngle, layerName); dxf.add(arcs); arc.Dispose(); cs.Dispose(); } } if (stTan != null) stTan.Dispose(); if (endTan != null) endTan.Dispose(); if (stpt != null) stpt.Dispose(); if (endpt != null) endpt.Dispose(); Curves.ForEach(c => c.Dispose()); return this; }