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.
43 lines
1.3 KiB
43 lines
1.3 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 BatchGenerator
|
|
{
|
|
public MaterialModel Material { get; set; }
|
|
|
|
public BatchGenerator(MaterialModel material, ReportGenerator batchSaver)
|
|
{
|
|
Material = material;
|
|
}
|
|
|
|
public IEnumerable<Pore> GenerateBatch(BatchPoint bp, IEnumerable<Pore> pores)
|
|
{
|
|
var p1 = new Point3D()
|
|
{
|
|
X = bp.Center.X - bp.Width / 2,
|
|
Y = bp.Center.Y - bp.Width / 2,
|
|
Z = Math.Abs(bp.Center.Z - bp.Depth)
|
|
};
|
|
var p2 = new Point3D()
|
|
{
|
|
X = bp.Center.X + bp.Width / 2,
|
|
Y = bp.Center.Y + bp.Width / 2,
|
|
Z = bp.Center.Z
|
|
};
|
|
return pores.Where(p => IsPointInsideOfCube(p.Point, p1, p2)).ToList();
|
|
}
|
|
|
|
public bool IsPointInsideOfCube(Point3D p, Point3D vertex1, Point3D vertex2)
|
|
{
|
|
if (vertex1.X <= p.X && p.X <= vertex2.X)
|
|
if (vertex1.Y <= p.Y && p.Y <= vertex2.Y)
|
|
if (vertex1.Z <= p.Z && p.Z <= vertex2.Z)
|
|
return true;
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
|