final changes
This commit is contained in:
@@ -10,24 +10,26 @@ namespace TMI_practicum
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
//CheckAlgo();
|
||||
GetChartData();
|
||||
if (args.Length < 1)
|
||||
if (args.Length == 0 && !File.Exists("input.txt"))
|
||||
{
|
||||
Console.WriteLine("Please enter a file.");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
if (!File.Exists(args[0]))
|
||||
var inputFile = "input.txt";
|
||||
if (args.Length != 0) inputFile = args[0];
|
||||
|
||||
if (!File.Exists(inputFile))
|
||||
{
|
||||
Console.WriteLine("File {0} not found.", args[0]);
|
||||
Console.WriteLine("File {0} not found.", inputFile);
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
var (algorithm, _, circles) = ParseFile(args[0]);
|
||||
|
||||
(byte algorithm, _, IList<Circle> circles) = ParseFile(inputFile);
|
||||
|
||||
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
var stopwatch = new Stopwatch();
|
||||
IEnumerable<Intersection> solved;
|
||||
|
||||
stopwatch.Start();
|
||||
@@ -44,6 +46,16 @@ namespace TMI_practicum
|
||||
solved = SweepLineEffAlgorithm.Solve(circles);
|
||||
break;
|
||||
default:
|
||||
if (File.Exists(OutputFile))
|
||||
{
|
||||
File.Delete(OutputFile);
|
||||
}
|
||||
|
||||
using (StreamWriter sw = File.CreateText(OutputFile))
|
||||
{
|
||||
sw.WriteLine("Dit algoritme is niet ge ̈ımplementeerd.");
|
||||
}
|
||||
|
||||
throw new ArgumentException("Algorithm with id: " + algorithm + " is not defined!");
|
||||
}
|
||||
|
||||
@@ -79,7 +91,8 @@ namespace TMI_practicum
|
||||
solved.Contains(new Intersection(intersection.X, intersection.Y - 1e-15))
|
||||
) continue;
|
||||
|
||||
bool found = solved.Any(ints => Math.Abs(ints.X - intersection.X) < 1e-12 && Math.Abs(ints.Y - intersection.Y) < 1e-12);
|
||||
bool found = solved.Any(ints =>
|
||||
Math.Abs(ints.X - intersection.X) < 1e-12 && Math.Abs(ints.Y - intersection.Y) < 1e-12);
|
||||
|
||||
if (found) continue;
|
||||
|
||||
@@ -92,6 +105,7 @@ namespace TMI_practicum
|
||||
{
|
||||
Console.WriteLine("{0}\t{1}", intersection1.X, intersection1.Y);
|
||||
}
|
||||
|
||||
Console.WriteLine("wrong");
|
||||
foreach (var intersection1 in solved)
|
||||
{
|
||||
@@ -108,9 +122,9 @@ namespace TMI_practicum
|
||||
{
|
||||
Console.WriteLine("{0} {1} {2}", circle.X, circle.Y, circle.R);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,7 +136,7 @@ namespace TMI_practicum
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
circles.Add(new Circle(Math.Round(rnd.NextDouble() * 1.0, 15), Math.Round(rnd.NextDouble() * 1.0, 15),
|
||||
Math.Round(rnd.NextDouble() * (1.0/amount), 15)));
|
||||
Math.Round(rnd.NextDouble() * (1.0 / amount), 15)));
|
||||
}
|
||||
|
||||
return circles;
|
||||
@@ -175,7 +189,9 @@ namespace TMI_practicum
|
||||
int i = 0;
|
||||
while ((line = file.ReadLine()) != null)
|
||||
{
|
||||
double[] parts = line.Split(' ').Select(double.Parse).ToArray();
|
||||
double[] parts = line.Split(' ').Where(x => x.Length != 0).Select(double.Parse).ToArray();
|
||||
if (parts.Length == 0) continue;
|
||||
|
||||
circles[i++] = new Circle(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
}
|
||||
@@ -201,7 +217,7 @@ namespace TMI_practicum
|
||||
|
||||
using (StreamWriter sw = File.CreateText(OutputFile))
|
||||
{
|
||||
foreach (var intersection in intersections)
|
||||
foreach (Intersection intersection in intersections)
|
||||
{
|
||||
sw.WriteLine("{0:0.000000000000000}\t{1:0.000000000000000}", intersection.X, intersection.Y);
|
||||
}
|
||||
|
Reference in New Issue
Block a user