You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.6 KiB
47 lines
1.6 KiB
using MODELING_DEF_DES_MI_VI.Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace MODELING_DEF_DES_MI_VI.Controllers
|
|
{
|
|
public class ConnectedPoreReportGenerator
|
|
{
|
|
public MaterialModel Material { get; }
|
|
public ReportGenerator ReportGenerator { get; }
|
|
|
|
public ConnectedPoreReportGenerator(MaterialModel material, ReportGenerator reportGenerator)
|
|
{
|
|
Material = material;
|
|
ReportGenerator = reportGenerator;
|
|
}
|
|
|
|
public void CreateReport(IList<Pore> pores, int index)
|
|
{
|
|
IList<Tuple<Pore,Pore>> report = new List<Tuple<Pore, Pore>>();
|
|
foreach(Pore p1 in pores)
|
|
foreach(Pore p2 in pores)
|
|
if (!p1.Id.Equals(p2.Id))
|
|
if (!report.Any(a => a.Item1.Id == p2.Id && a.Item2.Id == p1.Id))
|
|
if (IsTwoPoresConnecting(p1, p2))
|
|
report.Add(Tuple.Create(p1, p2));
|
|
ReportGenerator.Save(report, ReportGenerator.AddOther("report_connected_pores_" + index));
|
|
}
|
|
|
|
public double DistanceBetweenTwoPoints(Point3D point1, Point3D point2)
|
|
{
|
|
return Math.Sqrt(
|
|
Math.Pow(point2.X - point1.X, 2) +
|
|
Math.Pow(point2.Y - point1.Y, 2) +
|
|
Math.Pow(point2.Z - point1.Z, 2)
|
|
);
|
|
}
|
|
|
|
public bool IsTwoPoresConnecting(Pore pore1, Pore pore2)
|
|
{
|
|
if (DistanceBetweenTwoPoints(pore1.Point, pore2.Point) > pore1.Radius + pore2.Radius)
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|