/***************************************************/ /**** Public Methods - IRender ****/ /***************************************************/ public static Text3d ToRhino(this RenderText renderText) { if (renderText == null) { return(null); } RHG.Vector3d xdir = (RHG.Vector3d)renderText.Cartesian.X.IToRhino(); RHG.Vector3d ydir = (RHG.Vector3d)renderText.Cartesian.Y.IToRhino(); RHG.Point3d pos = (RHG.Point3d)renderText.Cartesian.Origin.IToRhino(); RHG.Plane textPlane = new RHG.Plane(pos, xdir, ydir); Text3d text3D = new Text3d(renderText.Text, textPlane, renderText.Height); if (renderText.FontName.Contains("Italic")) { text3D.Italic = true; } if (renderText.FontName.Contains("Bold")) { text3D.Bold = true; } text3D.FontFace = renderText.FontName.Replace("Italic", "").Replace("Bold", "").Trim(); return(text3D); }
public static void drawText(Rectangle3d tempBoundingBox, Text3d textToDraw, double tempScaleFactor, System.Windows.Point tempOrigin, ref Canvas UnitPlanCanvas, double fontSize, Brush foreGround) { System.Windows.Point tempTransformedPoint = pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin); Border tempBorder = new Border(); tempBorder.Height = 200; tempBorder.Width = 200; Canvas.SetLeft(tempBorder, pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin).X - 200 / 2); Canvas.SetTop(tempBorder, pointConverter(tempBoundingBox, textToDraw.TextPlane.Origin, tempScaleFactor, tempOrigin).Y - 200 / 2); TextBlock textBlockToDraw = new TextBlock(); textBlockToDraw.Text = textToDraw.Text; textBlockToDraw.Foreground = foreGround; textBlockToDraw.FontSize = fontSize; textBlockToDraw.VerticalAlignment = VerticalAlignment.Center; textBlockToDraw.HorizontalAlignment = HorizontalAlignment.Center; RotateTransform tempRotater = new RotateTransform(getAngle(textToDraw.TextPlane.XAxis) * 180 / Math.PI); textBlockToDraw.RenderTransform = tempRotater; textBlockToDraw.RenderTransformOrigin = new System.Windows.Point(.5, .5); tempBorder.Child = textBlockToDraw; UnitPlanCanvas.Children.Add(tempBorder); }
private void setText(int num) { Plane txtPln = new Plane(gridPlane.Origin + gridPlane.XAxis * parameters.width, gridPlane.XAxis, gridPlane.YAxis); string sNum = num.ToString(); if (num < 10) { sNum = "0" + sNum; } sectionNum = new Text3d(sNum, txtPln, 1000); }
private void setBaseGrid() { for (int y = 0; y < 2; y++) { Vector3d shiftY = referencePlane.YAxis * y * parameters.yCell; //add the base grid line Line bGrid = new Line(referencePlane.Origin + shiftY, referencePlane.XAxis, parameters.yCell); baseGrid.Add(bGrid); Plane txtPn = new Plane(bGrid.From, referencePlane.XAxis, referencePlane.YAxis); string baynum = (bayNum + y).ToString(); if (bayNum < 10) { baynum = "0" + baynum; } Text3d text3D = new Text3d("bay_" + baynum, txtPn, 500); txt.Add(text3D); } }
public override void DrawViewportWires(IGH_PreviewArgs args) { args.Viewport.GetFrustumFarPlane(out Plane plane); RhinoViewport viewport = args.Viewport; ///軸外力の描画用関数******************************************************************************* for (int i = 0; i < _arrow.Count; i++) { if (VisualizeModel.VisualizeModel.Value == 1) { var size = VisualizeModel.VisualizeModel.fontsize; Point3d point = _arrow[i].From; plane.Origin = point; viewport.GetWorldToScreenScale(point, out double pixPerUnit); size /= pixPerUnit; Text3d drawText = new Text3d(_text[i] + "kN", plane, size); args.Display.Draw3dText(drawText, Color.MintCream); drawText.Dispose(); } Line arrow = _arrow[i]; args.Display.DrawLine(arrow, Color.MintCream, 2); args.Display.DrawArrowHead(arrow.To, arrow.Direction, Color.MintCream, 25, 0); } }
private void addcavepanels2d(List <StructuralCell> scs, File3dm file, Plane plnA, double minX) { int col = 0; int row = 0; Vector3d shift = new Vector3d(plnA.Origin); shift.Z = shift.Z - 100; Vector3d panelShift = new Vector3d(); foreach (StructuralCell sc in scs) { //intersect the cave face with the plan if (sc.cellType == StructuralCell.CellType.SkinCell) { if (sc.caveFace != null) { attCavepanels.ObjectColor = sc.displayColor; panelShift = new Vector3d(col * 2500, (row + 1) * -2500, 0); Plane txtpln = Plane.WorldXY; txtpln.Transform(Transform.Translation(shift + panelShift)); Text3d modulecode = new Text3d(sc.id, txtpln, 200); var g = file.Objects.AddText(modulecode, attAnnotation); Mesh cavepanel2d = new Mesh(); cavepanel2d.Vertices.AddVertices(mapAndTranslatePts(sc.midPlane, sc.caveFace.Vertices.ToPoint3dArray().ToList(), shift + panelShift)); cavepanel2d.Faces.AddFaces(sc.caveFace.Faces); file.Objects.AddMesh(cavepanel2d, attCavepanels); col++; if (col > 10) { col = 0; row++; } } } } }
public Guid AddText(Text3d text3d, ObjectAttributes attributes) { throw NotSupportedExceptionHelp(); }
public Guid AddText(Text3d text3d) { throw NotSupportedExceptionHelp(); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { Plane plane = Plane.WorldXY; string text = ""; double height = 0.0; Color color = Color.Black; bool boldIt = false; bool italyIt = false; string Font = ""; int justi = 0; DA.GetData("Location", ref plane); DA.GetData("Text", ref text); DA.GetData("Size", ref height); DA.GetData("Color", ref color); DA.GetData("Bold", ref boldIt); DA.GetData("Italy", ref italyIt); DA.GetData("Font", ref Font); DA.GetData("Justification", ref justi); Text3d text3d = new Text3d(text, Plane.WorldXY, height); BoundingBox boundingBox = text3d.BoundingBox; double u = 0.0; double v = 0.0; switch (justi) { case 1: case 2: case 3: v = -1.0 * boundingBox.Diagonal.Y; break; case 4: case 5: case 6: v = -0.5 * boundingBox.Diagonal.Y; break; } switch (justi) { case 2: case 5: case 8: u = -0.5 * boundingBox.Diagonal.X; break; case 3: case 6: case 9: u = -1.0 * boundingBox.Diagonal.X; break; } plane.Origin = plane.PointAt(u, v); text3d.TextPlane = plane; clip.Union(text3d.BoundingBox); txt.Add(text); col.Add(color); pln.Add(plane); hgt.Add(height); font.Add(Font); bold.Add(boldIt); italy.Add(italyIt); }
/***************************************************/ /**** Public Methods - Representations ****/ /***************************************************/ public static void RenderRhinoWires(Text3d text3D, Rhino.Display.DisplayPipeline pipeline, Color bhColour, int thickness) { pipeline.Draw3dText(text3D, bhColour, text3D.TextPlane); }
private void DrawRestraint(GH_PreviewWireArgs args, GsaNode node, bool selected = false) { if (node.Node.Restraint.X == false & node.Node.Restraint.Y == false & node.Node.Restraint.Z == false & node.Node.Restraint.XX == false & node.Node.Restraint.YY == false & node.Node.Restraint.ZZ == false) { return; } // colour System.Drawing.Color col; if (selected) { col = UI.Colour.NodeSelected; } else { if ((System.Drawing.Color)node.Colour != System.Drawing.Color.FromArgb(0, 0, 0)) { col = node.Colour; } else { col = UI.Colour.Support; } } // pin if (node.Node.Restraint.X == true & node.Node.Restraint.Y == true & node.Node.Restraint.Z == true & node.Node.Restraint.XX == false & node.Node.Restraint.YY == false & node.Node.Restraint.ZZ == false) { Plane plane = node.LocalAxis.Clone(); if (!plane.IsValid) { plane = Plane.WorldXY; } plane.Origin = node.Point; Cone pin = new Cone(plane, -0.4, 0.4); DisplayMaterial material = new DisplayMaterial() { Diffuse = System.Drawing.Color.FromArgb(255, col.R, col.G, col.B), Emission = System.Drawing.Color.FromArgb(255, 50, 50, 50), Transparency = 0.2 }; args.Pipeline.DrawBrepShaded(pin.ToBrep(true), material); args.Pipeline.DrawCone(pin, col); } else if (node.Node.Restraint.X == true & node.Node.Restraint.Y == true & node.Node.Restraint.Z == true & node.Node.Restraint.XX == true & node.Node.Restraint.YY == true & node.Node.Restraint.ZZ == true) { Plane plane = node.LocalAxis.Clone(); plane.Origin = node.Point; Box fix = new Box(plane, new Interval(-0.3, 0.3), new Interval(-0.3, 0.3), new Interval(-0.2, 0)); DisplayMaterial material = new DisplayMaterial() { Diffuse = System.Drawing.Color.FromArgb(255, col.R, col.G, col.B), Emission = System.Drawing.Color.FromArgb(255, 50, 50, 50), Transparency = 0.2 }; args.Pipeline.DrawBrepShaded(fix.ToBrep(), material); args.Pipeline.DrawBox(fix, col); } else { Plane plane = node.LocalAxis.Clone(); plane.Origin = node.Point; string rest = ""; if (node.Node.Restraint.X == true) { rest += "X"; } if (node.Node.Restraint.Y == true) { rest += "Y"; } if (node.Node.Restraint.Z == true) { rest += "Z"; } if (node.Node.Restraint.XX == true) { rest += "XX"; } if (node.Node.Restraint.YY == true) { rest += "YY"; } if (node.Node.Restraint.ZZ == true) { rest += "ZZ"; } Rhino.Display.Text3d text = new Text3d(rest, plane, 0.3); text.HorizontalAlignment = Rhino.DocObjects.TextHorizontalAlignment.Left; text.VerticalAlignment = Rhino.DocObjects.TextVerticalAlignment.Top; args.Pipeline.Draw3dText(text, col); } }
protected override void PreDrawObjects(DrawEventArgs e) { var box = BoundingBox.Empty; foreach (var mesh in DisplayMeshes) { var b = mesh.GetBoundingBox(false); box.Union(b); e.Display.DrawMeshWires(mesh, Color.AliceBlue); e.Display.DrawMeshFalseColors(mesh); } e.Viewport.GetFrustumFarPlane(out Plane plane); foreach (var text in DisplayText) { string t = text.Value.ToString("f2"); Point3d point = text.Key; plane.Origin = point; Text3d drawText = new Text3d(t, plane, 0.5); e.Display.Draw3dText(drawText, Color.Black); drawText.Dispose(); } foreach (var line in DisplayPolyline) { e.Display.DrawPolyline(line, Color.Black); } foreach (var obj in Geometries) { if (obj == null) { continue; } var mat = new DisplayMaterial { Diffuse = Color.AliceBlue, Transparency = 0.5 }; var b = obj.GetBoundingBox(false); box.Union(b); switch (obj.ObjectType) { case ObjectType.Brep: { var mesh = new Mesh(); Array.ForEach(Mesh.CreateFromBrep(obj as Brep, MeshingParameters.FastRenderMesh), m => mesh.Append(m)); e.Display.DrawMeshShaded(mesh, mat); break; } case ObjectType.Curve: e.Display.DrawCurve(obj as Curve, Color.AliceBlue); break; case ObjectType.Point: e.Display.DrawPoint((obj as Rhino.Geometry.Point).Location, Color.AliceBlue); break; case ObjectType.Surface: { var mesh = Mesh.CreateFromSurface(obj as Surface, MeshingParameters.FastRenderMesh); e.Display.DrawMeshShaded(mesh, mat); break; } case ObjectType.Mesh: e.Display.DrawMeshShaded(obj as Mesh, mat); break; default: break; } } e.Viewport.SetClippingPlanes(box); }
public void map3dToWorldXY(MeshVoxeliser mvox) { File3dm file = setupFile(); Plane mapFrom = new Plane(mvox.structuralSpans[0].minPlane.Origin, mvox.structuralSpans[0].minPlane.XAxis, Vector3d.ZAxis); Transform transform = Transform.PlaneToPlane(mapFrom, Plane.WorldXY); foreach (StructuralSpan sp in mvox.structuralSpans) { foreach (StructuralBay sb in sp.structuralBays) { double maxX = 0.0; Point3d origin = new Point3d(sb.minPlane.Origin); Plane plnA = new Plane(origin + sb.minPlane.YAxis * mvox.parameters.memberSize, sb.minPlane.XAxis, Vector3d.ZAxis); //shift to end of module Plane plnB = new Plane(origin + sb.minPlane.YAxis * sb.parameters.yCell, sb.minPlane.XAxis, Vector3d.ZAxis); plnA.Flip(); plnA.Transform(transform); plnB.Transform(transform); string baytitle = sb.baynum.ToString(); if (sb.baynum < 10) { baytitle = "0" + baytitle; } setClippingPlanes(plnA, plnB, file, "bay_" + baytitle, sb.parameters.width, sb.parameters.height); Text3d title = new Text3d("bay_" + baytitle, new Plane(plnA.Origin, Vector3d.ZAxis), 500); file.Objects.AddText(title, attAnnotation); foreach (List <StructuralCell> sc in sb.voxels) { foreach (StructuralCell c in sc) { if (c.cellType != StructuralCell.CellType.InsideCell && c.cellType != StructuralCell.CellType.Undefined) { attCavepanels.ObjectColor = c.displayColor; if (c.id == "06_00_0_17_0") { int g = 0; } if (c.caveFace != null) { c.caveFace.Transform(transform); c.midPlane.Transform(transform); file.Objects.AddMesh(c.caveFace, attCavepanels); } foreach (Curve cl in c.centreLines) { cl.Transform(transform); if (cl.PointAtStart.X > maxX) { maxX = cl.PointAtStart.X; } file.Objects.AddCurve(cl, attCentrelines); } foreach (Curve d in c.diagonals) { d.Transform(transform); file.Objects.AddCurve(d, attDiagonals); } //if (c.GSAmesh != null) //{ // c.GSAmesh.Transform(transform); // file.Objects.AddMesh(c.GSAmesh, attGsamesh); //} } } } addcavepanels2d(sb.voxels.SelectMany(x => x).ToList(), file, plnA, maxX); } } string cavepart = mvox.parameters.sectionNum.ToString(); if (mvox.parameters.sectionNum < 10) { cavepart = "0" + cavepart; } file.Write(@"C:\Users\r.hudson\Documents\WORK\projects\passageProjects\caveparts\cavepart" + cavepart + "_BaySections.3dm", 5); }
private void addBaySection2d(File3dm file, StructuralBay bay, Point3d location) { int pWidth = 35000; Point3d origin = new Point3d(bay.minPlane.Origin); Plane plnA = new Plane(origin + bay.minPlane.YAxis * bay.parameters.yCell / 2, bay.minPlane.XAxis, Vector3d.ZAxis); Vector3d shift = new Vector3d(location); Vector3d panelShift = new Vector3d(location.X + pWidth, location.Y, location.Z); Plane titlepln = Plane.WorldXY; titlepln.Transform(Transform.Translation(shift)); string baytitle = bay.baynum.ToString(); if (bay.baynum < 10) { baytitle = "0" + baytitle; } Text3d title = new Text3d("bay_" + baytitle, titlepln, 300); var id = file.Objects.AddText(title); int col = 0; int row = 0; foreach (List <StructuralCell> scs in bay.voxels) { foreach (StructuralCell sc in scs) { //intersect the cave face with the plan if (sc.cellType != StructuralCell.CellType.InsideCell && sc.cellType != StructuralCell.CellType.Undefined) { if (sc.cellType == StructuralCell.CellType.SkinCell) { attCavepanels.ObjectColor = sc.displayColor; var intersect = Rhino.Geometry.Intersect.Intersection.MeshPlane(sc.caveFace, plnA); if (intersect != null) { foreach (Polyline pl in intersect) { Polyline mapped = new Polyline(mapAndTranslatePts(plnA, pl.ToList(), shift)); file.Objects.AddPolyline(mapped, attCavepanels); } panelShift = new Vector3d(col * 2500, row * 2500, 0); panelShift.X = panelShift.X + pWidth / 2; Plane txtpln = Plane.WorldXY; txtpln.Transform(Transform.Translation(shift + panelShift)); Text3d modulecode = new Text3d(sc.id, txtpln, 100); var g = file.Objects.AddText(modulecode, attAnnotation); Mesh cavepanel2d = new Mesh(); cavepanel2d.Vertices.AddVertices(mapAndTranslatePts(sc.midPlane, sc.caveFace.Vertices.ToPoint3dArray().ToList(), shift + panelShift)); cavepanel2d.Faces.AddFaces(sc.caveFace.Faces); file.Objects.AddMesh(cavepanel2d, attCavepanels); col++; if (col > 5) { col = 0; row++; } } } //diagonals addCurves(file, sc.diagonals, plnA, attDiagonals, shift); //centrelines addCurves(file, sc.centreLines, plnA, attCentrelines, shift); } } } }