/// <summary>コピーコンストラクタ。</summary> /// <param name="previous"></param> public CoordinateListPathData(CoordinateListPathData previous) : base(previous) { VirtualShape = new VirtualPolygon(); Centers = previous.Centers; LeftWingWidths = previous.LeftWingWidths; RightWingWidths = previous.RightWingWidths; }
/// <summary>デフォルトコンストラクタ。</summary> public CoordinateListPathData() { VirtualShape = new VirtualPolygon(); Name = "ListPath"; Centers = new PointD[] { new PointD(0, 0), new PointD(1, 0) }; LeftWingWidths = new double[] { 1, 1 }; RightWingWidths = new double[2]; }
/// <summary>コピーコンストラクタ。</summary> /// <param name="previous"></param> public PolarCoordinateFunctionalPathData(PolarCoordinateFunctionalPathData previous) : base(previous) { VirtualShape = new VirtualPolygon(); CenterRadius = previous.CenterRadius; CenterRadius_LastValid = previous.CenterRadius_LastValid; CenterPhase = previous.CenterPhase; CenterPhase_LastValid = previous.CenterPhase_LastValid; LeftWingWidth = previous.LeftWingWidth; LeftWingWidth_LastValid = previous.LeftWingWidth_LastValid; RightWingWidth = previous.RightWingWidth; RightWingWidth_LastValid = previous.RightWingWidth_LastValid; }
/// <summary>デフォルトコンストラクタ。</summary> public PolarCoordinateFunctionalPathData() { VirtualShape = new VirtualPolygon(); Name = "PolarPath"; CenterRadius = "t"; CenterRadius_LastValid = "t"; CenterPhase = "0"; CenterPhase_LastValid = "0"; LeftWingWidth = "1"; LeftWingWidth_LastValid = "1"; RightWingWidth = "0"; RightWingWidth_LastValid = "0"; }
/// <summary>コピーコンストラクタ。</summary> /// <param name="previous"></param> public RectangleCoordinateFunctionalPathData(RectangleCoordinateFunctionalPathData previous) : base(previous) { VirtualShape = new VirtualPolygon(); CenterX = previous.CenterX; CenterX_LastValid = previous.CenterX_LastValid; CenterY = previous.CenterY; CenterY_LastValid = previous.CenterY_LastValid; LeftWingWidth = previous.LeftWingWidth; LeftWingWidth_LastValid = previous.LeftWingWidth_LastValid; RightWingWidth = previous.RightWingWidth; RightWingWidth_LastValid = previous.RightWingWidth_LastValid; }
/// <summary>デフォルトコンストラクタ。</summary> public RectangleCoordinateFunctionalPathData() { VirtualShape = new VirtualPolygon(); Name = "RectPath"; CenterX = "t"; CenterX_LastValid = "t"; CenterY = "0"; CenterY_LastValid = "0"; LeftWingWidth = "1"; LeftWingWidth_LastValid = "1"; RightWingWidth = "0"; RightWingWidth_LastValid = "0"; }
/// <summary>定義されたプロパティに従ってVirtualShapeを更新する。GeometricObjectDataBaseの実装。</summary> /// <returns>全てのプロパティが妥当であり、VirtualShapeの更新に成功したときはtrue。</returns> public override bool UpdateVirtualShape() { VirtualPolygon polygon = (VirtualPolygon)VirtualShape; polygon.Visible = true; double[] centerXList = new double[PointNum + 2], centerYList = new double[PointNum + 2], leftWingWidthList = new double[PointNum + 2], rightWingWidthList = new double[PointNum + 2]; for (int i = 0; i < PointNum; i++) { centerXList[i + 1] = Centers[i].X; centerYList[i + 1] = Centers[i].Y; } LeftWingWidths.CopyTo(LeftWingWidths, 1); RightWingWidths.CopyTo(RightWingWidths, 1); centerXList[0] = Centers[0].X; centerYList[0] = Centers[0].Y; leftWingWidthList[0] = LeftWingWidths[0]; rightWingWidthList[0] = RightWingWidths[0]; centerXList[PointNum + 1] = Centers[PointNum - 1].X; centerYList[PointNum + 1] = Centers[PointNum - 1].Y; leftWingWidthList[PointNum + 1] = LeftWingWidths[PointNum - 1]; rightWingWidthList[PointNum + 1] = RightWingWidths[PointNum - 1]; // VirtualPolygonに頂点を反映 int j; double normalAngle; SizeD normalVector; polygon.Vertices = new PointD[2 * PointNum]; for (int i = 0; i < PointNum; i++) { j = 2 * PointNum - i - 1; normalAngle = Math.Atan2(centerYList[i + 2] - centerYList[i], centerXList[i + 2] - centerXList[i]) + Math.PI / 2; normalVector = new SizeD(Math.Cos(normalAngle), Math.Sin(normalAngle)); polygon.Vertices[i] = new PointD(centerXList[i + 1], centerYList[i + 1]) + leftWingWidthList[i + 1] * normalVector; polygon.Vertices[j] = new PointD(centerXList[i + 1], centerYList[i + 1]) - rightWingWidthList[i + 1] * normalVector; } base.RefreshRenderSetting(); return(IsValid); }
public void WriteProject(WaveguideDesignerProjectData project) { if (project == null) { return; } Type type; EntityObject obj = null; DxfDocument doc = new DxfDocument(); doc.Name = project.Name; Layer dxfLayer; LayerData layerData; foreach (VirtualLayer vLayer in project.VirtualGraphics.Layers) { layerData = null; foreach (LayerData tmp in project.Layers) { if (tmp.VirtualLayer == vLayer) { layerData = tmp; break; } } if (layerData == null) { continue; } dxfLayer = new Layer(layerData.Name); dxfLayer.Color.Index = (short)layerData.LayerNumber; doc.Layers.Add(dxfLayer); foreach (VirtualShapeBase vShape in vLayer.Shapes) { type = vShape.GetType(); if (type == typeof(VirtualRectangle)) { VirtualRectangle rect = (VirtualRectangle)vShape; Polyline dxfrect = new Polyline(); obj = new Polyline(); dxfrect.IsClosed = true; dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y, 0)); dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X + rect.Size.W, rect.Location.Y, 0)); dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X + rect.Size.W, rect.Location.Y + rect.Size.H, 0)); dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y + rect.Size.H, 0)); dxfrect.Vertexes.Add(new PolylineVertex(rect.Location.X, rect.Location.Y, 0)); obj = dxfrect; } else if (type == typeof(VirtualPolygon)) { VirtualPolygon poly = (VirtualPolygon)vShape; Polyline dxfpoly = new Polyline(); dxfpoly.IsClosed = true; foreach (PointD p in poly.Vertices) { dxfpoly.Vertexes.Add(conv(p)); } dxfpoly.Vertexes.Add(conv(poly.Vertices[0])); obj = dxfpoly; } else if (type == typeof(VirtualEllipse)) { VirtualEllipse elli = (VirtualEllipse)vShape; Ellipse dxfelli = new Ellipse(); dxfelli.Center = new netDxf.Vector3(elli.Center.X, elli.Center.Y, 0); dxfelli.StartAngle = 0; dxfelli.EndAngle = 360; dxfelli.MajorAxis = Math.Max(elli.Radius.W, elli.Radius.H); dxfelli.MinorAxis = Math.Min(elli.Radius.W, elli.Radius.H); dxfelli.Rotation = elli.Radius.W >= elli.Radius.H ? 0 : 90; obj = dxfelli; } else if (type == typeof(VirtualPie)) { VirtualPie pie = (VirtualPie)vShape; Ellipse dxfelli = new Ellipse(); dxfelli.Center = new netDxf.Vector3(pie.Center.X, pie.Center.Y, 0); dxfelli.StartAngle = pie.StartAngle; dxfelli.EndAngle = pie.EndAngle; dxfelli.MajorAxis = Math.Max(pie.Radius.W, pie.Radius.H); dxfelli.MinorAxis = Math.Min(pie.Radius.W, pie.Radius.H); dxfelli.Rotation = pie.Radius.W >= pie.Radius.H ? 0 : 90; obj = dxfelli; } else { obj = null; } if (obj == null) { continue; } obj.Layer = dxfLayer; doc.AddEntity(obj); } } doc.Save(FileName); }
/// <summary>定義されたプロパティに従ってVirtualShapeを更新する。GeometricObjectDataBaseの実装。</summary> /// <returns>全てのプロパティが妥当であり、VirtualShapeの更新に成功したときはtrue。</returns> public override bool UpdateVirtualShape() { VirtualPolygon polygon = (VirtualPolygon)VirtualShape; polygon.Visible = true; bool validOX = true, validOY = true, validR = true, validP = true, validLeft = true, validRight = true; double xOffset, yOffset; double[] CenterXList = new double[PointNum + 2], CenterYList = new double[PointNum + 2], CenterRadiusList = new double[PointNum + 2], CenterPhaseList = new double[PointNum + 2], LeftWingWidthList = new double[PointNum + 2], RightWingWidthList = new double[PointNum + 2]; // 検証 ValidateFormula(XOffset, XOffset_LastValid, out xOffset, out validOX); ValidateFormula(YOffset, YOffset_LastValid, out yOffset, out validOY); ValidateFormula(CenterRadius, PointNum, CenterRadius_LastValid, CenterRadiusList, out validR); ValidateFormula(CenterPhase, PointNum, CenterPhase_LastValid, CenterPhaseList, out validP); ValidateFormula(LeftWingWidth, PointNum, LeftWingWidth_LastValid, LeftWingWidthList, out validLeft); ValidateFormula(RightWingWidth, PointNum, RightWingWidth_LastValid, RightWingWidthList, out validRight); // CenterX,CenterYの作成 for (int i = 0; i < PointNum + 2; i++) { CenterXList[i] = CenterRadiusList[i] * Math.Cos(CenterPhaseList[i]); CenterYList[i] = CenterRadiusList[i] * Math.Sin(CenterPhaseList[i]); } // IsValidの評価 IsValid = validOX && validOY && validR && validP && validLeft && validRight; if (validOX) { XOffset_LastValid = XOffset; } if (validOY) { YOffset_LastValid = YOffset; } if (validR) { CenterRadius_LastValid = CenterRadius; } if (validP) { CenterPhase_LastValid = CenterPhase; } if (validLeft) { LeftWingWidth_LastValid = LeftWingWidth; } if (validRight) { RightWingWidth_LastValid = RightWingWidth; } // VirtualPolygonに頂点を反映 int j; double normalAngle; SizeD normalVector; polygon.Vertices = new PointD[2 * PointNum]; for (int i = 0; i < PointNum; i++) { j = 2 * PointNum - i - 1; normalAngle = Math.Atan2(CenterYList[i + 2] - CenterYList[i], CenterXList[i + 2] - CenterXList[i]) + Math.PI / 2; normalVector = new SizeD(Math.Cos(normalAngle), Math.Sin(normalAngle)); polygon.Vertices[i] = new PointD(CenterXList[i + 1] + xOffset, CenterYList[i + 1] + yOffset) + LeftWingWidthList[i + 1] * normalVector; polygon.Vertices[j] = new PointD(CenterXList[i + 1] + xOffset, CenterYList[i + 1] + yOffset) - RightWingWidthList[i + 1] * normalVector; } base.RefreshRenderSetting(); return(IsValid); }