/***************************************************/ public static void RenderRhinoWires(RHG.Plane plane, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawConstructionPlane(new Rhino.DocObjects.ConstructionPlane() { Plane = plane, ThickLineColor = bhColour, ThinLineColor = Color.Black, GridLineCount = 10 }); }
/***************************************************/ public static void RenderRhinoMeshes(this List <object> geometry, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { foreach (object geo in geometry) { RenderRhinoMeshes(geo as dynamic, pipeline, material); } }
/***************************************************/ public static void RenderRhinoWires(this List <object> geometry, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { foreach (object geo in geometry) { RenderRhinoWires(geo as dynamic, pipeline, bhColour, thickness); } }
/***************************************************/ public static void RenderRhinoWires(RHG.PolylineCurve polyline, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { RHG.Polyline poly; if (polyline.TryGetPolyline(out poly)) { pipeline.DrawPolyline(poly, bhColour, thickness); } }
/***************************************************/ public static void RenderMeshes(BHG.PolySurface polySurface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { List <BHG.ISurface> surfaces = polySurface.Surfaces; for (int i = 0; i < surfaces.Count; i++) { pipeline.DrawBrepShaded(RHG.Brep.CreateFromSurface((RHG.Surface)surfaces[i].IToRhino()), material); } }
/***************************************************/ public static void RenderMeshes(BHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { RHG.GeometryBase geometry = surface.ToRhino(); if (geometry is RHG.Surface) { geometry = RHG.Brep.CreateFromSurface((RHG.Surface)geometry); } pipeline.DrawBrepShaded((RHG.Brep)geometry, material); }
/***************************************************/ /**** Public Methods - Mesh ****/ /***************************************************/ public static void RenderRhinoWires(RHG.Mesh mesh, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { if (mesh.VertexColors.Count == 0) { pipeline.DrawMeshWires(mesh, bhColour); } else if (GH.CentralSettings.PreviewMeshEdges) { pipeline.DrawMeshWires(mesh, bhColour); } }
/***************************************************/ /**** Public Methods - Mesh ****/ /***************************************************/ public static void RenderRhinoMeshes(RHG.Mesh mesh, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { if (mesh.VertexColors.Count > 0) { pipeline.DrawMeshFalseColors(mesh); } else { pipeline.DrawMeshShaded(mesh, material); } }
/***************************************************/ public static void RenderMeshes(BHG.CompositeGeometry composite, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { if (composite.Elements.Count == 0) { return; } foreach (BHG.IGeometry geom in composite.Elements) { try { RenderMeshes(geom as dynamic, pipeline, material); } catch (Exception) { } } }
/// <summary> /// Draws one brep. Override this method to add your custom behavior. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="brep">A brep object.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawBrepObject(Rhino.DocObjects.BrepObject brep, DisplayPipeline pipeline ) { }
/// <summary> /// If Style==Wireframe, then the default decomposes the curve object into /// nurbs curve segments and calls the virtual DrawNurbsCurve for each segment. /// </summary> /// <param name="curve">A document curve object.</param> /// <param name="pipeline">The drawing pipeline.</param> protected virtual void DrawCurveObject(Rhino.DocObjects.CurveObject curve, DisplayPipeline pipeline ) { IntPtr pConstThis = ConstPointer(); IntPtr pConstCurve = curve.ConstPointer(); IntPtr pPipeline = pipeline.NonConstPointer(); UnsafeNativeMethods.CRhinoVisualAnalysisMode_DrawCurveObject(pConstThis, pConstCurve, pPipeline); }
/***************************************************/ public static void RenderMeshes(BHG.PlanarSurface surface, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { pipeline.DrawBrepShaded(surface.ToRhino(), material); }
/***************************************************/ /**** Public Methods - Representations ****/ /***************************************************/ public static void RenderRhinoWires(Text3d text3D, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.Draw3dText(text3D, bhColour, text3D.TextPlane); }
/***************************************************/ public static void RenderRhinoWires(RHG.Sphere sphere, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawSphere(sphere, bhColour); }
/***************************************************/ /**** Public Methods - Curves ****/ /***************************************************/ public static void RenderMeshes(BHG.Arc arc, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { return; }
/***************************************************/ public static void RenderMeshes(BHG.CoordinateSystem.Cartesian coordinateSystem, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { return; }
/***************************************************/ /**** Public Methods - Miscellanea ****/ /***************************************************/ public static void RenderMeshes(BHG.BoundingBox bbBox, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { pipeline.DrawBrepShaded(RHG.Brep.CreateFromBox(bbBox.ToRhino()), material); }
/***************************************************/ /**** Public Methods - Mesh ****/ /***************************************************/ public static void RenderMeshes(BHG.Mesh mesh, Rhino.Display.DisplayPipeline pipeline, DisplayMaterial material) { RHG.Mesh rMesh = mesh.ToRhino(); pipeline.DrawMeshShaded(rMesh, material); }
/// <summary> /// Draws a NURBS curve. This is a good function to override for /// analysis modes like curvature hair display. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="obj">A Rhino object corresponding to the curve.</param> /// <param name="curve">The curve geometry.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawNurbsCurve(Rhino.DocObjects.RhinoObject obj, Rhino.Geometry.NurbsCurve curve, DisplayPipeline pipeline) { }
/// <summary> /// Draws a mesh. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="obj">A Rhino object corresponding to the surface.</param> /// <param name="mesh">The mesh geometry.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawMesh(Rhino.DocObjects.RhinoObject obj, Rhino.Geometry.Mesh mesh, DisplayPipeline pipeline ) { }
/***************************************************/ public static void RenderRhinoWires(RHG.ArcCurve arc, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawArc(arc.Arc, bhColour, thickness); }
/***************************************************/ public static void RenderRhinoWires(RHG.Cylinder cylinder, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawCylinder(cylinder, bhColour); }
/***************************************************/ public static void RenderRhinoWires(RHG.Circle circle, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawCircle(circle, bhColour, thickness); }
/***************************************************/ public static void RenderRhinoWires(RHG.Torus torus, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawTorus(torus, bhColour); }
/***************************************************/ /**** Private Methods - Fallback ****/ /***************************************************/ private static void RenderRhinoWires(this object fallback, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { // fallback in case no method is found for the provided runtime type return; }
/***************************************************/ public static void RenderRhinoWires(RHG.Box box, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawBox(box, bhColour, thickness); }
private static void DrawPlane(DisplayPipeline di, RhinoViewport vp, Plane plane) { double num; if (!vp.GetWorldToScreenScale(plane.Origin, out num)) return; var unit = 10.0; if ((unit * num) < 20.0) unit = 20.0 / num; unit *= 0.2; var min = -5; var max = 5; for (var x = min; x <= max; x++) { var p0 = plane.PointAt(min * unit, x * unit); var p1 = plane.PointAt(max * unit, x * unit); if (x == 0) { var origin = plane.Origin; di.DrawLine(p0, origin, Color.Gray); di.DrawLine(origin, p1, Color.DarkRed, 3); di.DrawArrowHead(p1, p1 - origin, Color.DarkRed, 0.0, 1.0 * unit); } else { di.DrawLine(p0, p1, Color.Gray); } } for (var y = min; y <= max; y++) { var p0 = plane.PointAt(y * unit, min * unit); var p1 = plane.PointAt(y * unit, max * unit); if (y == 0) { var origin = plane.Origin; di.DrawLine(p0, origin, Color.Gray); di.DrawLine(origin, p1, Color.DarkGreen, 3); di.DrawArrowHead(p1, p1 - origin, Color.DarkGreen, 0.0, 1.0 * unit); } else { di.DrawLine(p0, p1, Color.Gray); } } }
/***************************************************/ public static void RenderRhinoWires(RHG.Ellipse ellipse, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawCurve(ellipse.ToNurbsCurve(), bhColour, thickness); }
static void OnDrawRhinoObjectProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pRhinoDisplayPipeline) { VisualAnalysisMode mode = FindLocal(am_id); if (mode != null) { var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject); DisplayPipeline dp = new DisplayPipeline(pRhinoDisplayPipeline); try { Rhino.DocObjects.BrepObject brep = rhobj as Rhino.DocObjects.BrepObject; if (brep != null) { mode.DrawBrepObject(brep, dp); return; } Rhino.DocObjects.CurveObject curve = rhobj as Rhino.DocObjects.CurveObject; if (curve != null) { mode.DrawCurveObject(curve, dp); return; } Rhino.DocObjects.MeshObject mesh = rhobj as Rhino.DocObjects.MeshObject; if (mesh != null) { mode.DrawMeshObject(mesh, dp); return; } Rhino.DocObjects.PointCloudObject pointcloud = rhobj as Rhino.DocObjects.PointCloudObject; if (pointcloud != null) { mode.DrawPointCloudObject(pointcloud, dp); return; } Rhino.DocObjects.PointObject pointobj = rhobj as Rhino.DocObjects.PointObject; if (pointobj != null) { mode.DrawPointObject(pointobj, dp); return; } } catch (Exception) { } } }
/***************************************************/ /**** Public Methods - Vectors ****/ /***************************************************/ public static void RenderRhinoWires(RHG.Point3d point, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawPoint(point, bhColour); }
/***************************************************/ public static void RenderRhinoWires(RHG.LineCurve line, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawLine(line.Line, bhColour, thickness); }
internal sealed override void Draw(DisplayPipeline pipeline, System.Drawing.Color color, int thickness) { IntPtr pDisplayPipeline = pipeline.NonConstPointer(); int argb = color.ToArgb(); IntPtr pCurveDisplay = CurveDisplay(); UnsafeNativeMethods.CurveDisplay_Draw(pCurveDisplay, pDisplayPipeline, argb, thickness); }
/***************************************************/ public static void RenderRhinoWires(RHG.NurbsCurve curve, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawCurve(curve, bhColour, thickness); }
static void OnDrawGeometryProc(Guid am_id, IntPtr pConstRhinoObject, IntPtr pConstGeometry, IntPtr pRhinoDisplayPipeline) { VisualAnalysisMode mode = FindLocal(am_id); if (mode != null) { var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pConstRhinoObject); var geom = Rhino.Geometry.GeometryBase.CreateGeometryHelper(pConstGeometry, null); if (geom != null) geom.DoNotDestructOnDispose(); DisplayPipeline dp = new DisplayPipeline(pRhinoDisplayPipeline); Rhino.Geometry.Mesh mesh = geom as Rhino.Geometry.Mesh; try { if (mesh != null) { mode.DrawMesh(rhobj, mesh, dp); return; } Rhino.Geometry.NurbsCurve nurbscurve = geom as Rhino.Geometry.NurbsCurve; if (nurbscurve != null) { mode.DrawNurbsCurve(rhobj, nurbscurve, dp); return; } Rhino.Geometry.NurbsSurface nurbssurf = geom as Rhino.Geometry.NurbsSurface; if (nurbssurf != null) { mode.DrawNurbsSurface(rhobj, nurbssurf, dp); return; } } catch (Exception) { } } }
/***************************************************/ public static void RenderRhinoWires(RHG.Polyline polyline, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawPolyline(polyline, bhColour, thickness); }
/// <summary> /// Draws one mesh. Override this method to add your custom behavior. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="mesh">A mesh object.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawMeshObject(Rhino.DocObjects.MeshObject mesh, DisplayPipeline pipeline ) { }
/***************************************************/ public static void RenderRhinoWires(RHG.NurbsSurface surface, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawSurface(surface, bhColour, thickness); }
/// <summary> /// Draws one point cloud. Override this method to add your custom behavior. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="pointCloud">A point cloud object.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawPointCloudObject(Rhino.DocObjects.PointCloudObject pointCloud, DisplayPipeline pipeline ) { }
/***************************************************/ public static void RenderRhinoWires(RHG.Brep brep, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawBrepWires(brep, bhColour, 0); }
/// <summary> /// Draws a NURBS surface. This is a good function to override /// to display object-related meshes. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="obj">A Rhino object corresponding to the surface.</param> /// <param name="surface">The surface geometry.</param> /// <param name="pipeline">The current display pipeline.</param> protected virtual void DrawNurbsSurface(Rhino.DocObjects.RhinoObject obj, Rhino.Geometry.NurbsSurface surface, DisplayPipeline pipeline) { }
/***************************************************/ /**** Public Methods - Solids ****/ /***************************************************/ public static void RenderRhinoWires(RHG.Cone cone, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.DrawCone(cone, bhColour); }
internal override void Draw(DisplayPipeline pipeline, System.Drawing.Color color, int thickness) { IntPtr ptr = ConstPointer(); IntPtr pDisplayPipeline = pipeline.NonConstPointer(); int argb = color.ToArgb(); UnsafeNativeMethods.ON_LineCurve_Draw(ptr, pDisplayPipeline, argb, thickness); }
internal DisplayPipelineAttributes(DisplayPipeline parent) { m_parent = parent; }