public bool AreConnected(IFeature feature1, IFeature feature2, LineEnd feature1LineEndToTest) { Assert.ArgumentCondition( !GdbObjectUtils.IsSameObject(feature1, feature2, ObjectClassEquality.SameTableSameVersion), "The specified features are the same"); // NOTE: Touches(polyline1, polyline2) is not enough, because Touches() is true when one end // is snapped to the other line's interior var polyline1 = (IPolyline)feature1.Shape; var polyline2 = (IPolyline)feature2.Shape; bool fromPointTouches = false, toPointTouches = false; if (feature1LineEndToTest == LineEnd.From || feature1LineEndToTest == LineEnd.Both) { fromPointTouches = GeometryUtils.Touches(polyline1.FromPoint, polyline2); } if (feature1LineEndToTest == LineEnd.To || feature1LineEndToTest == LineEnd.Both) { toPointTouches = GeometryUtils.Touches(polyline1.ToPoint, polyline2); } bool result = fromPointTouches || toPointTouches; Marshal.ReleaseComObject(polyline1); Marshal.ReleaseComObject(polyline2); return(result); }
private static IPath GetSharedBoundaryProlongation( [NotNull] ICurve curveToReshape, [NotNull] IPath sharedBoundary, [NotNull] IPoint sourceConnectPoint, [NotNull] IPath reshapePath, double tolerance, [CanBeNull] out IPoint targetConnectPoint) { // try elongate the shared boundary's last segment ISegment sourceSegment = GetConnectSegment(sharedBoundary, sourceConnectPoint, tolerance); LineEnd segmentEndToProlong = GeometryUtils.AreEqualInXY(sourceSegment.FromPoint, sourceConnectPoint) ? LineEnd.From : LineEnd.To; IPath result = ReshapeUtils.GetProlongation(curveToReshape, sourceSegment, reshapePath, segmentEndToProlong, out targetConnectPoint); if (result != null && segmentEndToProlong == LineEnd.From) { result.ReverseOrientation(); } // TODO: The ITopoOp.Difference with the source performed in ReshapeUtils.GetProlongation might handle some // difficult situations, but also prevent a solution where the source intersection is on the // interiour of a segment in one polygon and on a vertex in the other. Currently this must be // dealt with by the user (placing a target intersection point). return(result); }
public IList <IFeature> GetConnectedEdgeFeatures(IFeature toEdgeFeature, IPolyline edgeGeometry, LineEnd atEnd) { Assert.ArgumentNotNull(toEdgeFeature, nameof(toEdgeFeature)); IPolyline polyline = edgeGeometry ?? (IPolyline)toEdgeFeature.Shape; var result = new List <IFeature>(); IPoint fromPoint = polyline.FromPoint; IPoint toPoint = polyline.ToPoint; if (atEnd == LineEnd.From || atEnd == LineEnd.Both) { result.AddRange(FindPolylinesAt( fromPoint, IsConnected(toEdgeFeature, fromPoint))); } if (atEnd == LineEnd.To || atEnd == LineEnd.Both) { result.AddRange(FindPolylinesAt( toPoint, IsConnected(toEdgeFeature, toPoint))); } return(result); }
public SerialTerminal(ref SerialPort port, LineEnd lineEnd, bool echo) { serialPort = port; serialPort.ReadTimeout = READ_TIMEOUT_MS; serialPort.DataReceived += new SerialDataReceivedEventHandler(OnReceiveData); LineEnding = lineEnd; this.echo = echo; }
private static SvgStrokeLineCap MapLineEnd(LineEnd lineEnd) { switch (lineEnd) { case LineEnd.Butt: return SvgStrokeLineCap.Butt; case LineEnd.Round: return SvgStrokeLineCap.Round; default: return SvgStrokeLineCap.Square; } }
public static string GetLineEnd(LineEnd lineEndValue) { switch (lineEndValue) { case LineEnd.CRLF: return("\r\n"); case LineEnd.LF: return("\n"); case LineEnd.NONE: return(String.Empty); } throw new ArgumentException("Invalid LineEnd value"); }
protected IList <IFeature> GetConnectedNonReshapedEdges( [NotNull] IFeature withFeature, [NotNull] IPolyline originalPolyline, LineEnd atLineEnd) { IList <IFeature> connectedEdges = NetworkFeatureFinder.GetConnectedEdgeFeatures( withFeature, originalPolyline, atLineEnd); IList <IFeature> connectedNonReshapedEdges = connectedEdges.Where( connectedEdge => ExcludeFromEndpointRelocation == null || !ExcludeFromEndpointRelocation.Contains(connectedEdge)) .ToList(); return(connectedNonReshapedEdges); }
private void OnGUI() { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("选择文件夹")) { fileOrFolderPath = EditorUtility.OpenFolderPanel("选择文件夹", Application.dataPath, "gkd"); } if (GUILayout.Button("选择文件")) { fileOrFolderPath = EditorUtility.OpenFilePanel("选择文件", Application.dataPath, extension); } EditorGUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(fileOrFolderPath)) { EditorGUILayout.LabelField("Path:", fileOrFolderPath); } extension = EditorGUILayout.TextField("Extension:", extension); lineEnd = (LineEnd)EditorGUILayout.EnumPopup("Target:", lineEnd); if (GUILayout.Button("生成")) { logs.Clear(); if (!Regex.IsMatch(extension, @"\w+")) { extension = "cs"; EditorUtility.DisplayDialog("", "formate is error!", "我错了"); return; } SetLineEnd(); DealFolderOrFile(fileOrFolderPath); if (logs.Count <= 0) { logs.Add("没有发现文件,注意检查后缀名..."); } } foreach (var log in logs) { EditorGUILayout.LabelField("", log); } }
private static int ValidateConnections([NotNull] IFeature feature, LineEnd atLineEnd, [NotNull] ILinearNetworkFeatureFinder featureFinder, ref bool hasCorrectOrientation, ref bool hasWrongOrientation) { IPolyline polyline = (IPolyline)feature.Shape; IList <IFeature> connectedEdgeFeatures = featureFinder.GetConnectedEdgeFeatures(feature, polyline, atLineEnd); IPoint thisLineEndPoint = atLineEnd == LineEnd.From ? polyline.FromPoint : polyline.ToPoint; foreach (IFeature connectedAtFrom in connectedEdgeFeatures) { IPolyline connectedPolyline = (IPolyline)connectedAtFrom.Shape; IPoint otherLineEndPoint = atLineEnd == LineEnd.From ? connectedPolyline.ToPoint : connectedPolyline.FromPoint; if (GeometryUtils.AreEqual(otherLineEndPoint, thisLineEndPoint)) { // correct orientation hasCorrectOrientation = true; } else { hasWrongOrientation = true; } } return(connectedEdgeFeatures.Count); }
public static List <BoxBeam> Arrange(double StartStation, double EndStation, Line Left0, Line Right0, Line Left1, Line Right1, ref Align StAlign, ref Align EdAlign, double StartC2C, double EndC2C, double Side = 1.65, double BearingH = 0.3, double BeamH = 1.6, double SurfaceH = 0.170) { if (StartStation == 19645) { ; } List <BoxBeam> res = new List <BoxBeam>(); Line LineStart = new Line(Left0.EndPoint, Right0.EndPoint); Line LineEnd = new Line(Left1.EndPoint, Right1.EndPoint); if ((StAlign.Name.StartsWith("R1K") || StAlign.Name.StartsWith("L1K")) || (EdAlign.Name.StartsWith("R1K") || EdAlign.Name.StartsWith("L1K"))) { Side = 1.2; } var Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.4, 1, Side); var Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.4, 1, Side); var tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); if (tmp.Count == 0) { Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.3, 1.1, Side); Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.3, 1.1, Side); tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); } if (tmp.Count == 0) { Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.3, 1.35, Side); Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.3, 1.35, Side); tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); } int aa; double delt0 = 0; // = (LineStart.Length() - 2 * Side) / (Num1.Max() - 1); double delt1 = 0; // = (LineEnd.Length() - 2 * Side) / (Num2.Max() - 1); if (Num1.Count == 0 || Num2.Count == 0) { return(res); } if (tmp.Count == 0) { if (Num1.Max() > Num2.Max()) { // 匝道分出 if ((Left0.Length() - Left1.Length()) > (Right0.Length() - Right1.Length())) { // 左侧分出 LineStart = new Line(Right0.EndPoint, Left0.EndPoint); LineEnd = new Line(Right1.EndPoint, Left1.EndPoint); } aa = Num2.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa + 2); delt1 = (LineEnd.Length() - 2 * Side) / (aa - 1); } else { // 匝道汇入 if ((Left1.Length() - Left0.Length()) > (Right1.Length() - Right0.Length())) { // 左侧匝道汇入 LineStart = new Line(Right0.EndPoint, Left0.EndPoint); LineEnd = new Line(Right1.EndPoint, Left1.EndPoint); } aa = Num1.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa - 1); delt1 = (LineEnd.Length() - 2 * Side) / (aa + 2); } } else { aa = tmp.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa - 1); delt1 = (LineEnd.Length() - 2 * Side) / (aa - 1); } BoxBeam cc; Vector2 stend, edend; Vector2 stpin, edpin; double StandardH = SurfaceH + BeamH + BearingH; double H0_St = StAlign.curSQX.GetBG(StartStation) - StandardH; double H0_Ed = EdAlign.curSQX.GetBG(EndStation) - StandardH; List <double[]> HPListCB = new List <double[]>() { StAlign.curCG.GetHP(StartStation), EdAlign.curCG.GetHP(EndStation) }; double HLeftSt = H0_St - HPListCB[0][0] * Left0.Length() * 0.01; double HLeftEd = H0_Ed - HPListCB[1][0] * Left1.Length() * 0.01; double slop; for (int i = 0; i < aa; i++) { bool isSide = i == 0 || i == aa - 1; Vector2 Cdir0 = LineStart.Direction.Convert2D(); Cdir0.Normalize(); Vector2 Cdir1 = LineEnd.Direction.Convert2D(); Cdir1.Normalize(); stend = LineStart.StartPoint.Convert2D() + Cdir0 * Side + Cdir0 * (i) * delt0; edend = LineEnd.StartPoint.Convert2D() + Cdir1 * Side + Cdir1 * (i) * delt1; Vector2 BeamDir = edend - stend; BeamDir.Normalize(); stpin = stend + BeamDir * StartC2C; edpin = edend - BeamDir * EndC2C; double Hbot_st = StAlign.GetSurfaceBG(stpin.X, stpin.Y) - SurfaceH - BeamH; double Hbot_ed = EdAlign.GetSurfaceBG(edpin.X, edpin.Y) - SurfaceH - BeamH; double HCB_st = 0; double HCB_ed = 0; var VecSt = (stpin.Convert2DS() - new Vector2D(Left0.StartPoint.X, Left0.StartPoint.Y)); var VecEd = (edpin.Convert2DS() - new Vector2D(Left1.StartPoint.X, Left1.StartPoint.Y)); Vector2D dirForwoard = new Vector2D(StAlign.curPQX.GetDir(StartStation)[0], StAlign.curPQX.GetDir(StartStation)[1]); if (VecSt.SignedAngleTo(dirForwoard).Degrees <= 180) { // 使用右坡 HCB_st = H0_St + HPListCB[0][1] * 0.01 * VecSt.Length; slop = -2.5; } else { // 左坡 HCB_st = H0_St - HPListCB[0][0] * 0.01 * VecSt.Length; slop = 2.5; } if (aa % 2 == 1 && i == (int)(0.5 * aa)) { slop = 0; } dirForwoard = new Vector2D(EdAlign.curPQX.GetDir(EndStation)[0], EdAlign.curPQX.GetDir(EndStation)[1]); if (VecEd.SignedAngleTo(dirForwoard).Degrees <= 180) { HCB_ed = H0_Ed + HPListCB[1][1] * 0.01 * VecEd.Length; } else { HCB_ed = H0_Ed - HPListCB[1][0] * 0.01 * VecEd.Length; } Vector2D BeamAxis = (edpin - stpin).Convert2DS(); double startA = 90 - Cdir0.Convert2DS().SignedAngleTo(BeamAxis).Degrees; double endA = 90 - Cdir1.Convert2DS().SignedAngleTo(BeamAxis).Degrees; cc = new BoxBeam(stpin.Convert3D().Convert3DS(0, 0, Hbot_st), edpin.Convert3D().Convert3DS(0, 0, Hbot_ed), (Hbot_st - HCB_st), (Hbot_ed - HCB_ed), 0.5, 0.5, startA, endA, isSide, slop); //(int)(StartStation*100)+i cc.ID = (int)(StartStation * 100) + i; res.Add(cc); } return(res); }
public static List <BoxBeam> ArrangePlan(double StartStation, double EndStation, Line Left0, Line Right0, Line Left1, Line Right1, ref Align StAlign, ref Align EdAlign, double StartC2C, double EndC2C, bool isStPub, bool isEdPub, double Side = 1.65) { if (StartStation == 19645) { ; } List <BoxBeam> res = new List <BoxBeam>(); if (isStPub || isEdPub) { return(res); } Line LineStart = new Line(Left0.EndPoint, Right0.EndPoint); Line LineEnd = new Line(Left1.EndPoint, Right1.EndPoint); var xx = LineEnd.Length(); if ((StAlign.Name.StartsWith("R1K") || StAlign.Name.StartsWith("L1K")) || (EdAlign.Name.StartsWith("R1K") || EdAlign.Name.StartsWith("L1K"))) { Side = 1.2; } var Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.4, 1, Side); var Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.4, 1, Side); var tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); if (tmp.Count == 0) { Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.3, 1.1, Side); Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.3, 1.1, Side); tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); } if (tmp.Count == 0) { Num1 = AvilibleBeamNum(LineStart.Length(), 2.4, 0.3, 1.35, Side); Num2 = AvilibleBeamNum(LineEnd.Length(), 2.4, 0.3, 1.35, Side); tmp = (from a in Num1 where Num2.Contains(a) select a).ToList(); } int aa; double delt0 = 0; // = (LineStart.Length() - 2 * Side) / (Num1.Max() - 1); double delt1 = 0; // = (LineEnd.Length() - 2 * Side) / (Num2.Max() - 1); if (Num1.Count == 0 || Num2.Count == 0) { return(res); } if (tmp.Count == 0) { if (Num1.Max() > Num2.Max()) { // 匝道分出 if ((Left0.Length() - Left1.Length()) > (Right0.Length() - Right1.Length())) { // 左侧分出 LineStart = new Line(Right0.EndPoint, Left0.EndPoint); LineEnd = new Line(Right1.EndPoint, Left1.EndPoint); } aa = Num2.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa + 2); delt1 = (LineEnd.Length() - 2 * Side) / (aa - 1); } else { // 匝道汇入 if ((Left1.Length() - Left0.Length()) > (Right1.Length() - Right0.Length())) { // 左侧匝道汇入 LineStart = new Line(Right0.EndPoint, Left0.EndPoint); LineEnd = new Line(Right1.EndPoint, Left1.EndPoint); } aa = Num1.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa - 1); delt1 = (LineEnd.Length() - 2 * Side) / (aa + 2); } } else { aa = tmp.Max(); delt0 = (LineStart.Length() - 2 * Side) / (aa - 1); delt1 = (LineEnd.Length() - 2 * Side) / (aa - 1); } BoxBeam cc; Vector2 stend, edend; Vector2 stpin, edpin; for (int i = 0; i < aa; i++) { Vector2 Cdir0 = LineStart.Direction.Convert2D(); Cdir0.Normalize(); Vector2 Cdir1 = LineEnd.Direction.Convert2D(); Cdir1.Normalize(); stend = LineStart.StartPoint.Convert2D() + Cdir0 * Side + Cdir0 * (i) * delt0; edend = LineEnd.StartPoint.Convert2D() + Cdir1 * Side + Cdir1 * (i) * delt1; Vector2 BeamDir = edend - stend; BeamDir.Normalize(); stpin = stend + BeamDir * StartC2C; edpin = edend - BeamDir * EndC2C; var VecSt = (stpin.Convert2DS() - new Vector2D(Left0.StartPoint.X, Left0.StartPoint.Y)); var VecEd = (edpin.Convert2DS() - new Vector2D(Left1.StartPoint.X, Left1.StartPoint.Y)); Vector2D BeamAxis = (edpin - stpin).Convert2DS(); double startA = 90 - Cdir0.Convert2DS().SignedAngleTo(BeamAxis).Degrees; double endA = 90 - Cdir1.Convert2DS().SignedAngleTo(BeamAxis).Degrees; cc = new BoxBeam(stpin.Convert3D().Convert3DS(0, 0, 0), edpin.Convert3D().Convert3DS(0, 0, 0), 0, 0, 0.5, 0.5, startA, endA, false, 0); cc.ID = i; res.Add(cc); } return(res); }