public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args) { if (Hidden) { return; } if (listArrow != null) { args.Display.DrawLines(listArrow, System.Drawing.Color.Red); } //targetSrf if (listPnt != null) { args.Display.DrawPoints(targetSrf, Rhino.Display.PointStyle.Simple, 1, System.Drawing.Color.White); } //eigenvectors if (crossCyan != null) { args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan); } if (crossMagenta != null) { args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta); } if (listError != null) { foreach (var error in listError) { args.Display.DrawCurve(error, System.Drawing.Color.Red, 10); } } /*if (listSlice != null) * { * foreach (var slice in listSlice.Values) * { * var pl = slice.pl; * args.Display.DrawPolygon(new Rhino.Geometry.Point3d[] { pl.PointAt(-2, -2), pl.PointAt(-2, 2), pl.PointAt(2, 2), pl.PointAt(2, -2) }, System.Drawing.Color.Azure, true); * } * }*/ foreach (var branch in listBranch) { switch (branch.branchType) { case Mothra4.branch.type.fix: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Orange, 3); break; case Mothra4.branch.type.reinforce: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Cyan, 3); break; case Mothra4.branch.type.kink: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Purple, 3); break; case Mothra4.branch.type.open: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Green, 3); break; } } foreach (var leaf in listLeaf) { if (leaf.airySrf != null) { var srf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zScale); srf.Transform(zDown2); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } foreach (var leaf in listLeaf) { if (leaf.shellSrf != null) { var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } /*foreach (var branch in listBranch) * { * if (branch.airyCrv != null) * { * var crv = branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; * crv.Transform(zScale); * args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 4); * } * }*/ foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { double x = 0, y = 0, z = branch.slice2.height; for (int i = 0; i < branch.N; i++) { x += branch.crv.Points[i].Location.X; y += branch.crv.Points[i].Location.Y; z += branch.crv.Points[i].Location.Z; } x /= branch.N; y /= branch.N; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } if (branch.branchType == branch.type.open && branch.endTypeL == branch.endtype.fix) { double x = branch.crv.Points[0].Location.X; double y = branch.crv.Points[0].Location.Y; double z = branch.sliceL.height; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } if (branch.branchType == branch.type.open && branch.endTypeR == branch.endtype.fix) { double x = branch.crv.Points[branch.crv.Points.Count - 1].Location.X; double y = branch.crv.Points[branch.crv.Points.Count - 1].Location.Y; double z = branch.sliceR.height; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } } foreach (var branch in listBranch) { if (branch.shellCrv != null) { if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce || branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 3); } } } //find max value of reinforcement if (listBranch != null) { foreach (var branch in listBranch) { if (branch.tuples != null) { if (branch.branchType == branch.type.fix) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); } } else { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0] / 2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Red, 2); } else { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Blue, 2); } } } } } } /* * if (a != null) * { * args.Display.DrawPoints(a, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); * * }*/ if (a2 != null) { args.Display.DrawPoints(a2, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); } }
public override void BakeGeometry(Rhino.RhinoDoc doc, Rhino.DocObjects.ObjectAttributes att, List<Guid> obj_ids) { Rhino.Geometry.Transform zDown_airy = Rhino.Geometry.Transform.Translation(0, 0, 2d); Rhino.DocObjects.ObjectAttributes a2 = att.Duplicate(); a2.LayerIndex = 2; Rhino.DocObjects.ObjectAttributes a3 = att.Duplicate(); a3.LayerIndex = 3; Rhino.DocObjects.ObjectAttributes a4 = att.Duplicate(); a4.LayerIndex = 4; Rhino.DocObjects.ObjectAttributes a5 = att.Duplicate(); a5.LayerIndex = 5; Rhino.DocObjects.ObjectAttributes a6 = att.Duplicate(); a6.LayerIndex = 6; Rhino.DocObjects.ObjectAttributes a7 = att.Duplicate(); a7.LayerIndex = 7; foreach (var leaf in listLeaf) { var airySrf=leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; airySrf.Transform(zScale); airySrf.Transform(zDown_airy); Guid id = doc.Objects.AddSurface(airySrf, a2); obj_ids.Add(id); var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); id = doc.Objects.AddSurface(srf, a3); obj_ids.Add(id); } foreach (var branch in listBranch) { //var airyCrv=branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; //airyCrv.Transform(zDown_airy); //Guid id = doc.Objects.AddCurve(airyCrv, a2); //obj_ids.Add(id); if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce||branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); Guid id = doc.Objects.AddCurve(crv, a7); obj_ids.Add(id); } } if (crossMagenta != null) { foreach (var line in crossMagenta) { Guid id = doc.Objects.AddLine(line, a4); obj_ids.Add(id); } } if (listBranch != null) { foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); Guid id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); } } } if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce||branch.branchType==branch.type.open) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0]/2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); Guid id = doc.Objects.AddLine(line, a5); obj_ids.Add(id); } } } } } } }
public override void DrawViewportWires(Grasshopper.Kernel.IGH_PreviewArgs args) { if (Hidden) { return; } if (listArrow != null) { args.Display.DrawLines(listArrow, System.Drawing.Color.Red); } //targetSrf if (listPnt != null) { args.Display.DrawPoints(targetSrf, Rhino.Display.PointStyle.Simple, 1, System.Drawing.Color.White); } //eigenvectors if (crossCyan != null) { args.Display.DrawLines(crossCyan, System.Drawing.Color.Cyan); } if (crossMagenta != null) { args.Display.DrawLines(crossMagenta, System.Drawing.Color.Magenta); } if (listError != null) { foreach (var error in listError) { args.Display.DrawCurve(error, System.Drawing.Color.Red, 10); } } /*if (listSlice != null) { foreach (var slice in listSlice.Values) { var pl = slice.pl; args.Display.DrawPolygon(new Rhino.Geometry.Point3d[] { pl.PointAt(-2, -2), pl.PointAt(-2, 2), pl.PointAt(2, 2), pl.PointAt(2, -2) }, System.Drawing.Color.Azure, true); } }*/ foreach (var branch in listBranch) { switch (branch.branchType) { case Mothra4.branch.type.fix: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Orange, 3); break; case Mothra4.branch.type.reinforce: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Cyan, 3); break; case Mothra4.branch.type.kink: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Purple, 3); break; case Mothra4.branch.type.open: args.Display.DrawCurve(branch.crv, System.Drawing.Color.Green, 3); break; } } foreach (var leaf in listLeaf) { if (leaf.airySrf != null) { var srf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zScale); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } foreach (var leaf in listLeaf) { if (leaf.shellSrf != null) { var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); args.Display.DrawSurface(srf, System.Drawing.Color.Brown, 3); } } /*foreach (var branch in listBranch) { if (branch.airyCrv != null) { var crv = branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zScale); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 4); } }*/ foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { double x = 0, y = 0, z = branch.slice2.height; for (int i = 0; i < branch.N; i++) { x += branch.crv.Points[i].Location.X; y += branch.crv.Points[i].Location.Y; z += branch.crv.Points[i].Location.Z; } x /= branch.N; y /= branch.N; args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x - 1d, y - 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x + 1d, y - 1d, z), System.Drawing.Color.Blue); args.Display.DrawLine(new Rhino.Geometry.Point3d(x + 1d, y + 1d, z), new Rhino.Geometry.Point3d(x - 1d, y + 1d, z), System.Drawing.Color.Blue); } } foreach (var branch in listBranch) { if (branch.shellCrv != null) { if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce || branch.branchType == branch.type.open) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); args.Display.DrawCurve(crv, System.Drawing.Color.SeaGreen, 3); } } } //find max value of reinforcement if (listBranch != null) { foreach (var branch in listBranch) { if (branch.tuples != null) { if (branch.branchType == branch.type.fix) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); args.Display.DrawCircle(circle, System.Drawing.Color.Yellow, 2); } } else { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0]/2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Red, 2); } else { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); args.Display.DrawLine(line, System.Drawing.Color.Blue, 2); } } } } } } /* if (a != null) { args.Display.DrawPoints(a, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); }*/ if (a2 != null) { args.Display.DrawPoints(a2, Rhino.Display.PointStyle.X, 2, System.Drawing.Color.Blue); } }
public override void BakeGeometry(Rhino.RhinoDoc doc, Rhino.DocObjects.ObjectAttributes att, List <Guid> obj_ids) { Rhino.Geometry.Transform zDown_airy = Rhino.Geometry.Transform.Translation(0, 0, 2d); Rhino.DocObjects.ObjectAttributes a2 = att.Duplicate(); a2.LayerIndex = 2; Rhino.DocObjects.ObjectAttributes a3 = att.Duplicate(); a3.LayerIndex = 3; Rhino.DocObjects.ObjectAttributes a4 = att.Duplicate(); a4.LayerIndex = 4; Rhino.DocObjects.ObjectAttributes a5 = att.Duplicate(); a5.LayerIndex = 5; Rhino.DocObjects.ObjectAttributes a6 = att.Duplicate(); a6.LayerIndex = 6; Rhino.DocObjects.ObjectAttributes a7 = att.Duplicate(); a7.LayerIndex = 7; foreach (var leaf in listLeaf) { var airySrf = leaf.airySrf.Duplicate() as Rhino.Geometry.NurbsSurface; airySrf.Transform(zScale); airySrf.Transform(zDown_airy); Guid id = doc.Objects.AddSurface(airySrf, a2); obj_ids.Add(id); var srf = leaf.shellSrf.Duplicate() as Rhino.Geometry.NurbsSurface; srf.Transform(zDown_eq); id = doc.Objects.AddSurface(srf, a3); obj_ids.Add(id); } foreach (var branch in listBranch) { //var airyCrv=branch.airyCrv.Duplicate() as Rhino.Geometry.NurbsCurve; //airyCrv.Transform(zDown_airy); //Guid id = doc.Objects.AddCurve(airyCrv, a2); //obj_ids.Add(id); if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce) { var crv = branch.shellCrv.Duplicate() as Rhino.Geometry.NurbsCurve; crv.Transform(zDown_eq); Guid id = doc.Objects.AddCurve(crv, a7); obj_ids.Add(id); } } if (crossMagenta != null) { foreach (var line in crossMagenta) { Guid id = doc.Objects.AddLine(line, a4); obj_ids.Add(id); } } if (listBranch != null) { foreach (var branch in listBranch) { if (branch.branchType == branch.type.fix) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), 0.5); circle.Transform(zDown); Guid id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); circle = new Rhino.Geometry.Circle(new Rhino.Geometry.Point3d(tup.x, tup.y, branch.slice2.height), 0.5); circle.Transform(zDown_eq); id = doc.Objects.AddCircle(circle, a6); obj_ids.Add(id); } } } if (branch.branchType == branch.type.kink || branch.branchType == branch.type.reinforce) { if (branch.tuples != null) { foreach (var tup in branch.tuples) { var D = tup.SPK[0, 0] / 2d; if (D > 0) { var line = new Rhino.Geometry.Line(new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z), new Rhino.Geometry.Point3d(tup.x, tup.y, tup.z + D)); line.Transform(zDown); Guid id = doc.Objects.AddLine(line, a5); obj_ids.Add(id); } } } } } } }