/// <summary> /// Given an unrolled text dot, returns the index of the source, or following text dot. /// </summary> /// <param name="dot">An unrolled text dot returned by Unroller.PerformUnroll.</param> /// <returns>The index of the text dot added by Unroller.AddFollowingGeometry if successful, otherwise -1.</returns> /// <since>6.0</since> public int FollowingGeometryIndex(TextDot dot) { if (dot == null) { throw new ArgumentNullException("dot"); } IntPtr ptr_const_textdot = dot.ConstPointer(); return(UnsafeNativeMethods.CRhinoUnrollResults_FollowingGeometryIndex(ptr_const_textdot)); }
/// <summary> /// Executes unrolling operations. /// </summary> /// <param name="unrolledCurves">An array of unrolled curves is assigned during the call in this out parameter.</param> /// <param name="unrolledPoints">An array of unrolled points is assigned during the call in this out parameter.</param> /// <param name="unrolledDots">An array of unrolled text dots is assigned during the call in this out parameter.</param> /// <returns>An array of breps. This array can be empty.</returns> /// <since>5.0</since> public Brep[] PerformUnroll(out Curve[] unrolledCurves, out Point3d[] unrolledPoints, out TextDot[] unrolledDots) { unrolledCurves = new Curve[0]; unrolledPoints = new Point3d[0]; unrolledDots = new TextDot[0]; IntPtr ptr_unroller = IntPtr.Zero; if (m_surface != null) { IntPtr const_ptr_surface = m_surface.ConstPointer(); ptr_unroller = UnsafeNativeMethods.CRhinoUnroll_NewSrf(const_ptr_surface, m_absolute_tolerance, m_relative_tolerance); } else if (m_brep != null) { IntPtr const_ptr_brep = m_brep.ConstPointer(); ptr_unroller = UnsafeNativeMethods.CRhinoUnroll_NewBrp(const_ptr_brep, m_absolute_tolerance, m_relative_tolerance); } if (ptr_unroller == IntPtr.Zero) { throw new Exception("Unable to access input surface or brep"); } var rc = new Brep[0]; if (0 == UnsafeNativeMethods.CRhinoUnroll_PrepareFaces(ptr_unroller)) { if (m_curves.Count > 0) { var crvs = new Runtime.InteropWrappers.SimpleArrayCurvePointer(m_curves); IntPtr const_ptr_curves = crvs.ConstPointer(); UnsafeNativeMethods.CRhinoUnroll_PrepareCurves(ptr_unroller, const_ptr_curves); } if (m_points.Count > 0) { Point3d[] pts = m_points.ToArray(); UnsafeNativeMethods.CRhinoUnroll_PreparePoints(ptr_unroller, pts.Length, pts); } if (m_dots.Count > 0) { using (var dots = new Runtime.InteropWrappers.SimpleArrayGeometryPointer(m_dots)) { IntPtr const_ptr_dots = dots.ConstPointer(); UnsafeNativeMethods.CRhinoUnroll_PrepareDots(ptr_unroller, const_ptr_dots); } } int brep_count = 0; int curve_count = 0; int point_count = 0; int dot_count = 0; double explode_dist = -1; if (m_explode_output) { explode_dist = m_explode_spacing; } IntPtr ptr_results = UnsafeNativeMethods.CRhinoUnroll_CreateFlatBreps(ptr_unroller, explode_dist, ref brep_count, ref curve_count, ref point_count, ref dot_count); if (ptr_results != IntPtr.Zero) { if (brep_count > 0) { rc = new Brep[brep_count]; for (int i = 0; i < brep_count; i++) { IntPtr ptr_brep = UnsafeNativeMethods.CRhinoUnrollResults_GetBrep(ptr_results, i); if (ptr_brep != IntPtr.Zero) { rc[i] = new Brep(ptr_brep, null); } } } if (curve_count > 0) { unrolledCurves = new Curve[curve_count]; for (int i = 0; i < curve_count; i++) { IntPtr ptr_curve = UnsafeNativeMethods.CRhinoUnrollResults_GetCurve(ptr_results, i); if (ptr_curve != IntPtr.Zero) { unrolledCurves[i] = new Curve(ptr_curve, null); } } } if (point_count > 0) { unrolledPoints = new Point3d[point_count]; UnsafeNativeMethods.CRhinoUnrollResults_GetPoints(ptr_results, point_count, unrolledPoints); } if (dot_count > 0) { unrolledDots = new TextDot[dot_count]; for (int i = 0; i < dot_count; i++) { IntPtr ptr_dots = UnsafeNativeMethods.CRhinoUnrollResults_GetDot(ptr_results, i); if (ptr_dots != IntPtr.Zero) { unrolledDots[i] = new TextDot(ptr_dots, null); } } } UnsafeNativeMethods.CRhinoUnrollResults_Delete(ptr_results); } } UnsafeNativeMethods.CRhinoUnroll_Delete(ptr_unroller); return(rc); }
/// <summary> /// Adds a text dot that should be unrolled along with the surface/brep. /// </summary> /// <param name="dot">A text dot.</param> /// <since>5.0</since> public void AddFollowingGeometry(TextDot dot) { m_dots.Add(dot); }
/// <summary> /// Adds a text dot that should be unrolled along with the surface/brep. /// </summary> /// <param name="dotLocation">A dot point.</param> /// <param name="dotText">A dot text.</param> /// <since>5.0</since> public void AddFollowingGeometry(Point3d dotLocation, string dotText) { var dot = new TextDot(dotText, dotLocation); AddFollowingGeometry(dot); }
internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobjectIndex) { if (IntPtr.Zero == pGeometry) { return(null); } var type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry); if (type < 0) { return(null); } GeometryBase rc = null; switch (type) { case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Curve: //1 rc = new Curve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsCurve: //2 rc = new NurbsCurve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolyCurve: // 3 rc = new PolyCurve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PolylineCurve: //4 rc = new PolylineCurve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ArcCurve: //5 rc = new ArcCurve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_LineCurve: //6 rc = new LineCurve(pGeometry, parent, subobjectIndex); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Mesh: //7 rc = new Mesh(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Point: //8 rc = new Point(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_TextDot: //9 rc = new TextDot(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Surface: //10 rc = new Surface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Brep: //11 rc = new Brep(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_NurbsSurface: //12 rc = new NurbsSurface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_RevSurface: //13 rc = new RevSurface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PlaneSurface: //14 rc = new PlaneSurface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_ClippingPlaneSurface: //15 rc = new ClippingPlaneSurface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Hatch: // 17 rc = new Hatch(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SumSurface: //19 rc = new SumSurface(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepFace: //20 { int faceindex = -1; IntPtr ptr_brep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex); if (ptr_brep != IntPtr.Zero && faceindex >= 0) { Brep b = new Brep(ptr_brep, parent); rc = b.Faces[faceindex]; } } break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepEdge: // 21 { int edgeindex = -1; IntPtr ptr_brep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex); if (ptr_brep != IntPtr.Zero && edgeindex >= 0) { Brep b = new Brep(ptr_brep, parent); rc = b.Edges[edgeindex]; } } break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_InstanceReference: // 23 rc = new InstanceReferenceGeometry(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Extrusion: //24 rc = new Extrusion(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointCloud: // 26 rc = new PointCloud(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DetailView: // 27 rc = new DetailView(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Light: //32 rc = new Light(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_PointGrid: //33 rc = new Point3dGrid(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_MorphControl: //34 rc = new MorphControl(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepLoop: //35 { int loopindex = -1; IntPtr ptr_brep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex); if (ptr_brep != IntPtr.Zero && loopindex >= 0) { Brep b = new Brep(ptr_brep, parent); rc = b.Loops[loopindex]; } } break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_BrepTrim: // 36 { int trimindex = -1; IntPtr ptr_brep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex); if (ptr_brep != IntPtr.Zero && trimindex >= 0) { Brep b = new Brep(ptr_brep, parent); rc = b.Trims[trimindex]; } } break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Leader: // 38 rc = new Leader(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_SubD: // 39 rc = new SubD(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimLinear: //40 rc = new LinearDimension(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimAngular: //41 rc = new AngularDimension(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimRadial: //42 rc = new RadialDimension(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_DimOrdinate: //43 rc = new OrdinateDimension(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Centermark: //44 rc = new Centermark(pGeometry, parent); break; case UnsafeNativeMethods.OnGeometryTypeConsts.ON_Text: //45 rc = new TextEntity(pGeometry, parent); break; default: rc = new UnknownGeometry(pGeometry, parent, subobjectIndex); break; } return(rc); }