private MarkGeometryPoint ReadPointAdvance(AdvancedLineStreamReader readerIn) { var result = readerIn.FindConsecutiveLines( MatchDoubleParams, MatchDouble ); if (result.Success) { double X = double.Parse(MatchDouble.Match(result.LineB).Value); result = readerIn.FindConsecutiveLines( MatchDoubleParams, MatchDouble ); double Y = double.Parse(MatchDouble.Match(result.LineB).Value); double Z = 0; if (MatchDoubleParams.IsMatch(readerIn.PeekLine())) { result = readerIn.FindConsecutiveLines( MatchDoubleParams, MatchDouble ); Z = double.Parse(MatchDouble.Match(result.LineB).Value); } return(new MarkGeometryPoint(X, Y, Z)); } return(null); }
private MarkGeometryPoint ReadPointFast(AdvancedLineStreamReader readerIn) { // read doble params 10, 11, etc readerIn.FindLine(MatchDoubleParams); double X = double.Parse(readerIn.ReadLine()); // read doble params 20, 21, etc readerIn.ReadLine(); double Y = double.Parse(readerIn.ReadLine()); double Z = 0; if (MatchDoubleLastParams.IsMatch(readerIn.PeekLine())) { // read doble params 30, 31, etc readerIn.ReadLine(); Z = double.Parse(readerIn.ReadLine()); } return(new MarkGeometryPoint(X, Y, Z)); }
private (string LayerName, List <IMarkGeometry> Path) ParseLWPolyline(AdvancedLineStreamReader readerIn) { var(success, layerName) = ReadLayerName(readerIn, MatchLWPolylineEntity); if (success) { var result1 = readerIn.FindConsecutiveLines( MatchSubClassMarker, MatchLWPolylineEntity ); if (!result1.Success) { return(null, null); } } readerIn.ReadLine(); // consume number of vertices 90 int numberOfVertices = int.Parse(readerIn.ReadLine()); int flag = ReadInteger(readerIn, "70"); var bulges = new List <double>(numberOfVertices); var points = new List <MarkGeometryPoint>(numberOfVertices - 1); for (int i = 0; i < numberOfVertices; i++) { points.Add(ReadPointFast2D(readerIn)); bulges.Add((readerIn.PeekLine().Trim() == "42") ? ReadDouble(readerIn, "42") : 0d); } if (points.Count > 0 && flag == 1) // i.e. is closed { points.Add(points[0]); } var buffer = new List <IMarkGeometry>(); var path = new MarkGeometryPath(); for (int i = 0; i < points.Count - 1; i++) { var p1 = points[i]; var p2 = points[i + 1]; var bulge = bulges[i]; if (Math.Abs(bulge) <= double.Epsilon) { path.Add(p1, true); path.Add(p2, true); } else { if (path.Points.Count > 0) { path.Update(); // force path to re-compute it's properties buffer.Add(path); path = new MarkGeometryPath(); } buffer.Add(new MarkGeometryArc(p1, p2, bulge)); } } if (path.Points.Count > 0) { path.Update(); // force path to re-compute it's properties buffer.Add(path); } return(layerName, buffer); }