/// <summary> /// 绘制当前的墙体 /// </summary> /// <param name="points"></param> protected override void Draw(List <Vector2D> points) { if (start != null && end != null) { var halfThickness = Thickness / 2; List <Vector2D> fillPoints = new List <Vector2D>(); var start3D = new Albert.Geometry.Primitives.Vector3D(Start.X, Start.Y, 0); var end3D = new Albert.Geometry.Primitives.Vector3D(End.X, End.Y, 0); Vector3D lineDir = end3D - start3D; Vector3D offsetDir = lineDir.Cross(new Vector3D(0, 0, 1)).Normalize(); Vector3D offv1 = start3D + halfThickness * offsetDir; Vector3D offv2 = start3D - halfThickness * offsetDir; Vector3D offv3 = end3D - halfThickness * offsetDir; Vector3D offv4 = end3D + halfThickness * offsetDir; Line2D l5 = Line2D.Create(start, end); //钢梁 fillPoints.Add(TransformUtil.Projection(offv1)); fillPoints.Add(TransformUtil.Projection(offv2)); fillPoints.Add(TransformUtil.Projection(offv3)); fillPoints.Add(TransformUtil.Projection(offv4)); fillPoints.Add(TransformUtil.Projection(offv4)); DrawingContext dc = this.RenderOpen(); Pen.Freeze(); //冻结画笔,这样能加快绘图速度 PathGeometry paths = new PathGeometry(); paths.FillRule = FillRule.EvenOdd; PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); pfc.Add(pf); pf.StartPoint = KernelProperty.MMToPix(fillPoints[0]); for (int i = 0; i < fillPoints.Count; i++) { LineSegment ps = new LineSegment(); ps.Point = KernelProperty.MMToPix(fillPoints[i]); pf.Segments.Add(ps); } pf.IsClosed = true; paths.Figures = pfc; PenColor = Colors.Black; dc.DrawGeometry(Brush, Pen, paths); PenColor = Colors.DeepPink; dc.DrawLine(Pen, KernelProperty.MMToPix(l5.Start), KernelProperty.MMToPix(l5.End)); dc.Close(); } }
/// <summary> /// 绘制当前的墙体 /// </summary> /// <param name="points"></param> protected override void Draw(List <Vector2D> points) { if (start != null && end != null) { var halfThickness = Thickness / 2; List <Vector2D> fillPoints = new List <Vector2D>(); var start3D = new Albert.Geometry.Primitives.Vector3D(Start.X, Start.Y, 0); var end3D = new Albert.Geometry.Primitives.Vector3D(End.X, End.Y, 0); Vector3D lineDir = end3D - start3D; Vector3D offsetDir = lineDir.Cross(new Vector3D(0, 0, 1)).Normalize(); Vector3D offv1 = start3D + halfThickness * offsetDir; Vector3D offv2 = start3D - halfThickness * offsetDir; Vector3D offv3 = end3D - halfThickness * offsetDir; Vector3D offv4 = end3D + halfThickness * offsetDir; fillPoints.Add(TransformUtil.Projection(offv1)); fillPoints.Add(TransformUtil.Projection(offv2)); fillPoints.Add(TransformUtil.Projection(offv3)); fillPoints.Add(TransformUtil.Projection(offv4)); base.DrawFill(fillPoints); } }
/// <summary> /// 绘制当前钢梁 /// </summary> public override void Update() { points = new List <Vector2D>(); var halfFW = PlateWidth / 2; var Orgion = new Albert.Geometry.Primitives.Vector3D(Central.X, Central.Y, 0); var Direction = new Albert.Geometry.Primitives.Vector3D(this.face.X, this.face.Y, 0); //当前偏移的方向 Vector3D offsetDir = Direction.Cross(new Vector3D(0, 0, 1)).Normalize(); var v1 = Orgion.Offset(offsetDir * halfFW); var v2 = Orgion.Offset(-offsetDir * halfFW); var v3 = v2.Offset(Direction * 5); var v12 = v1.Offset(Direction * 5); var cent = Orgion.Offset(Direction * 5); //把中心区域向两边偏移 var v4 = cent.Offset(-offsetDir * (SternaSeparation / 2 + 5)); var v5 = v4.Offset(Direction * SternaLength); var v7 = cent.Offset(-offsetDir * (SternaSeparation / 2)); var v6 = v7.Offset(Direction * SternaLength); var v8 = cent.Offset(offsetDir * (SternaSeparation / 2 + 5)); var v9 = v8.Offset(Direction * SternaLength); var v11 = cent.Offset(offsetDir * (SternaSeparation / 2)); var v10 = v11.Offset(Direction * SternaLength); var v13 = v12.Offset(Direction * SternaLength); var v14 = v3.Offset(Direction * SternaLength); points.Add(TransformUtil.Projection(v1)); points.Add(TransformUtil.Projection(v2)); points.Add(TransformUtil.Projection(v3)); points.Add(TransformUtil.Projection(v4)); points.Add(TransformUtil.Projection(v5)); points.Add(TransformUtil.Projection(v6)); points.Add(TransformUtil.Projection(v7)); points.Add(TransformUtil.Projection(v8)); points.Add(TransformUtil.Projection(v9)); points.Add(TransformUtil.Projection(v10)); points.Add(TransformUtil.Projection(v11)); points.Add(TransformUtil.Projection(v12)); DrawingContext dc = this.RenderOpen(); Pen.Freeze(); //冻结画笔,这样能加快绘图速度 PathGeometry paths = new PathGeometry(); PathFigureCollection pfc = new PathFigureCollection(); PathFigure pf = new PathFigure(); pfc.Add(pf); pf.StartPoint = KernelProperty.MMToPix(points[0]); for (int i = 0; i < points.Count; i++) { LineSegment ps = new LineSegment(); ps.Point = KernelProperty.MMToPix(points[i]); pf.Segments.Add(ps); } pf.IsClosed = true; paths.Figures = pfc; dc.DrawGeometry(Brush, Pen, paths); this.Pen.DashStyle = new System.Windows.Media.DashStyle(new double[] { 5, 5 }, 10); dc.DrawLine(Pen, KernelProperty.MMToPix(TransformUtil.Projection(v12)), KernelProperty.MMToPix(TransformUtil.Projection(v13))); dc.DrawLine(Pen, KernelProperty.MMToPix(TransformUtil.Projection(v3)), KernelProperty.MMToPix(TransformUtil.Projection(v14))); dc.DrawLine(Pen, KernelProperty.MMToPix(TransformUtil.Projection(v13)), KernelProperty.MMToPix(TransformUtil.Projection(v14))); dc.Close(); }
/// <summary> /// 更新当前图形 /// </summary> /// <param name="ms"></param> public override void Update() { if (Start != null && End != null) { List <Vector2D> fillPoints = new List <Vector2D>(); var halfFB = 300 / 2; var start3D = new Albert.Geometry.Primitives.Vector3D(Start.X, Start.Y, 0); var end3D = new Albert.Geometry.Primitives.Vector3D(End.X, End.Y, 0); Vector3D lineDir = Line3D.Create(end3D, start3D).Direction; Vector3D offsetDir = lineDir.Cross(new Vector3D(0, 0, 1)).Normalize(); //偏移出上下点 Vector3D offv1 = start3D + halfFB * offsetDir; Vector3D offv2 = start3D - halfFB * offsetDir; Vector3D offv3 = end3D - halfFB * offsetDir; Vector3D offv4 = end3D + halfFB * offsetDir; var HalfYYThinkness = 30 / 2; Vector3D v1 = offv1 + HalfYYThinkness * lineDir; Vector3D v2 = offv1 + HalfYYThinkness * -lineDir; Vector3D v3 = offv2 + HalfYYThinkness * lineDir; Vector3D v4 = offv2 + HalfYYThinkness * -lineDir; var HalfFBThinkness = 30 / 2; Vector3D v5 = v2 + (halfFB - HalfFBThinkness) * -offsetDir; Vector3D v6 = v4 + (halfFB - HalfFBThinkness) * offsetDir; Vector3D v7 = offv3 + HalfYYThinkness * -lineDir; Vector3D v8 = offv3 + HalfYYThinkness * lineDir; Vector3D v9 = offv4 + HalfYYThinkness * -lineDir; Vector3D v10 = offv4 + HalfYYThinkness * lineDir; Vector3D v12 = v8 + (halfFB - HalfFBThinkness) * offsetDir; Vector3D v11 = v10 + (halfFB - HalfFBThinkness) * -offsetDir; fillPoints.Add(TransformUtil.Projection(v1)); fillPoints.Add(TransformUtil.Projection(v2)); fillPoints.Add(TransformUtil.Projection(v5)); fillPoints.Add(TransformUtil.Projection(v11)); fillPoints.Add(TransformUtil.Projection(v8)); fillPoints.Add(TransformUtil.Projection(v7)); fillPoints.Add(TransformUtil.Projection(v9)); fillPoints.Add(TransformUtil.Projection(v10)); fillPoints.Add(TransformUtil.Projection(v12)); fillPoints.Add(TransformUtil.Projection(v6)); fillPoints.Add(TransformUtil.Projection(v4)); fillPoints.Add(TransformUtil.Projection(v3)); this.DrawFill(fillPoints); } }