source code cleanup
This commit is contained in:
@@ -7,7 +7,6 @@ namespace PointCloudWeb.Server.Tests.Services
|
||||
{
|
||||
public class ScanConverterServiceTest
|
||||
{
|
||||
|
||||
[Theory]
|
||||
[InlineData(2, 2, 2)]
|
||||
[InlineData(2, 1, 1)]
|
||||
@@ -22,19 +21,16 @@ namespace PointCloudWeb.Server.Tests.Services
|
||||
[InlineData(0, 1, 1)]
|
||||
[InlineData(1, 0, 1)]
|
||||
[InlineData(1, 1, 1)]
|
||||
|
||||
[InlineData(-1, 1, 1)]
|
||||
[InlineData(1, -1, 1)]
|
||||
[InlineData(-1, -1, 1)]
|
||||
[InlineData(-5, 12, 7)]
|
||||
[InlineData(-5, -12, 7)]
|
||||
[InlineData(-22, 13, 11)]
|
||||
|
||||
[InlineData(0, 0, -1)]
|
||||
[InlineData(0, -1, -1)]
|
||||
[InlineData(-1, 0, -1)]
|
||||
[InlineData(-1, -1, -1)]
|
||||
|
||||
[InlineData(1, 1, -1)]
|
||||
[InlineData(5, 12, -7)]
|
||||
[InlineData(-1, 1, -1)]
|
||||
@@ -70,7 +66,6 @@ namespace PointCloudWeb.Server.Tests.Services
|
||||
var service = new ScanConverterService();
|
||||
var point = service.Transform(scan);
|
||||
Assert.Equal(expected, point);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,4 @@ namespace PointCloudWeb.Server.Controllers
|
||||
_scanDataService.AddScan(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,4 @@ namespace PointCloudWeb.Server.Controllers
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,12 +6,10 @@ namespace PointCloudWeb.Server.Models
|
||||
{
|
||||
public class Point
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Z { get; set; }
|
||||
public Point() : this(0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public Point() : this(0, 0, 0) { }
|
||||
public Point(int x, int y, int z)
|
||||
{
|
||||
X = x;
|
||||
@@ -19,6 +17,10 @@ namespace PointCloudWeb.Server.Models
|
||||
Z = z;
|
||||
}
|
||||
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int Z { get; set; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if ((obj == null) || !GetType().Equals(obj.GetType()))
|
||||
@@ -30,33 +32,27 @@ namespace PointCloudWeb.Server.Models
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y, Z);
|
||||
|
||||
public override string ToString() => (X.ToString() + " " + Y.ToString() + " " + Z.ToString());
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y, Z);
|
||||
}
|
||||
|
||||
|
||||
public class PointCloud
|
||||
{
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public IList<Point> Points { get; private set; }
|
||||
|
||||
public PointCloud(String name, Guid id)
|
||||
{
|
||||
Points = new List<Point>();
|
||||
Id = id;
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public Guid Id { get; private set; }
|
||||
public string Name { get; set; }
|
||||
public IList<Point> Points { get; private set; }
|
||||
}
|
||||
|
||||
public class PointCloudCollection : List<PointCloud>
|
||||
{
|
||||
public PointCloud GetById(Guid id)
|
||||
{
|
||||
return this.First(pc => pc.Id == id);
|
||||
}
|
||||
|
||||
public PointCloud AddNew()
|
||||
{
|
||||
var id = Guid.NewGuid();
|
||||
@@ -70,6 +66,11 @@ namespace PointCloudWeb.Server.Models
|
||||
return this.Any(pc => pc.Id == id);
|
||||
}
|
||||
|
||||
public PointCloud GetById(Guid id)
|
||||
{
|
||||
return this.First(pc => pc.Id == id);
|
||||
}
|
||||
|
||||
public void RemoveById(Guid id)
|
||||
{
|
||||
Remove(GetById(id));
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PointCloudWeb.Server.Models
|
||||
{
|
||||
public class ScanDataList
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public IList<ScanDataPoint> ScanPoints { get; set; }
|
||||
}
|
||||
|
||||
public class ScanDataPoint
|
||||
{
|
||||
//RotationAngle on {X, Y} Axis
|
||||
public double RAX { get; set; }
|
||||
public double RAY { get; set; }
|
||||
public float DistanceMM { get; set; }
|
||||
|
||||
public ScanDataPoint()
|
||||
{
|
||||
RAY = 0;
|
||||
@@ -24,11 +24,12 @@ namespace PointCloudWeb.Server.Models
|
||||
RAY = ray;
|
||||
DistanceMM = distanceMM;
|
||||
}
|
||||
}
|
||||
|
||||
public class ScanDataList
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public IList<ScanDataPoint> ScanPoints { get; set; }
|
||||
public float DistanceMM { get; set; }
|
||||
|
||||
//RotationAngle on {X, Y} Axis
|
||||
public double RAX { get; set; }
|
||||
|
||||
public double RAY { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,9 @@ namespace PointCloudWeb.Server
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public string Summary { get; set; }
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string Summary { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,16 +11,16 @@ namespace PointCloudWeb.Server
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder =>
|
||||
{
|
||||
webBuilder.UseStartup<Startup>();
|
||||
});
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,11 @@ namespace PointCloudWeb.Server.Services
|
||||
{
|
||||
public interface IPointCloudRegistation
|
||||
{
|
||||
class TransformationMatrix { }
|
||||
|
||||
public TransformationMatrix RegisterPointCloud(PointCloud pc1, PointCloud pc2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
class TransformationMatrix { }
|
||||
}
|
||||
}
|
||||
@@ -13,15 +13,34 @@ namespace PointCloudWeb.Server.Services
|
||||
_pointClouds = new PointCloudCollection();
|
||||
}
|
||||
|
||||
public void AddPoints(Guid id, IList<Point> points)
|
||||
private void RaiseIfNotExists(Guid id)
|
||||
{
|
||||
if (!_pointClouds.Contains(id))
|
||||
throw new ArgumentOutOfRangeException("The Id {0} was not found!", id.ToString());
|
||||
}
|
||||
|
||||
public void AddPoints(Guid id, IList<Point> points)
|
||||
{
|
||||
RaiseIfNotExists(id);
|
||||
|
||||
var pc = _pointClouds.GetById(id);
|
||||
|
||||
foreach (var point in points)
|
||||
pc.Points.Add(point);
|
||||
}
|
||||
|
||||
public void RegisterPointCloud(Guid id)
|
||||
{
|
||||
RegisterPointClouds(new List<Guid>() { id });
|
||||
}
|
||||
|
||||
public void RegisterPointClouds(IList<Guid> ids)
|
||||
{
|
||||
//ensure that every element in "ids" is in "_pointClouds"
|
||||
foreach (var id in ids)
|
||||
RaiseIfNotExists(id);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace PointCloudWeb.Server.Services
|
||||
public class ScanConverterService
|
||||
{
|
||||
private int Round(double value) => (int)Math.Round(double.IsNaN(value) ? 0 : value, 0, MidpointRounding.AwayFromZero);
|
||||
|
||||
public Point Transform(ScanDataPoint scan)
|
||||
{
|
||||
var factorZ = 1;
|
||||
@@ -43,7 +44,6 @@ namespace PointCloudWeb.Server.Services
|
||||
* Math.Pow(scan.DistanceMM, 2)
|
||||
);
|
||||
|
||||
|
||||
var p = new Point()
|
||||
{
|
||||
X = Round(z * sinYB / sinYA),
|
||||
|
||||
@@ -15,11 +15,6 @@ namespace PointCloudWeb.Server.Services
|
||||
_scanConverterService = scanConverterService;
|
||||
}
|
||||
|
||||
public void AddScan(ScanDataList scanData)
|
||||
{
|
||||
_pointCloudService.AddPoints(scanData.Id, ConvertToPoints(scanData));
|
||||
}
|
||||
|
||||
private IList<Point> ConvertToPoints(ScanDataList scanData)
|
||||
{
|
||||
var list = new List<Point>();
|
||||
@@ -31,5 +26,10 @@ namespace PointCloudWeb.Server.Services
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public void AddScan(ScanDataList scanData)
|
||||
{
|
||||
_pointCloudService.AddPoints(scanData.Id, ConvertToPoints(scanData));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,12 +21,6 @@ namespace PointCloudWeb.Server
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
@@ -44,5 +38,11 @@ namespace PointCloudWeb.Server
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user