public IEnumerable <Tuple <TriangleMesh, TriangleMesh, double> > EqualRTree(IEnumerable <Pair <TriangleMesh, List <TriangleMesh> > > enumerable) { var modiMeshes = spatialRepository.TriangleMeshesSet2; var modiMeshTuple = modiMeshes.Select(m => new Tuple <TriangleMesh, TriangleMesh, double>(m, null, 0)); var stopwatch1 = new Stopwatch(); stopwatch1.Start("RTree Version"); foreach (var mesh in spatialRepository.TriangleMeshes) { pointSampler.ResetSessionPointCount(); foreach (var triangle in mesh.Triangles) { pointSampler.DistributePoints(triangle, settings.Equal.SamplePerSquareMeter); } mesh.SampleCount = pointSampler.SessionPointCount; } var outList = new List <Tuple <TriangleMesh, TriangleMesh, double> >(); foreach (var pair in enumerable) { var mainMesh = pair.First; var otherMeshes = pair.Second; var pairs = otherMeshes.Select(om => { double distanceAB; int numberOfUnmatchedAB; var isInTreshholdAB = EqualRTree(mainMesh, om, out distanceAB, out numberOfUnmatchedAB); double distanceBA; int numberOfUnmatchedBA; var isInTreshholdBA = EqualRTree(om, mainMesh, out distanceBA, out numberOfUnmatchedBA); if (isInTreshholdAB & isInTreshholdBA) { var dist = distanceAB * distanceAB + distanceBA * distanceBA + (numberOfUnmatchedAB * numberOfUnmatchedAB) + (numberOfUnmatchedBA * numberOfUnmatchedBA); return(new Tuple <TriangleMesh, TriangleMesh, double>(mainMesh, om, dist)); } return(null); }).Where(p => p != null && !double.IsNaN(p.Item3)).ToList(); var minDist = pairs.Min(t => t.Item3); var tempList = pairs.Where(p => Math.Abs(p.Item3 - minDist) < 0.000000001).ToList(); outList.AddRange(tempList); //outList.AddRange(pairs); } stopwatch1.Stop(); return(outList.OrderBy(t => t.Item3).Where(t => Math.Abs(t.Item3) < 0.000000001)); }
private bool DirectionStrict(TriangleMesh meshA, TriangleMesh meshB, Axis axis, bool positiveDirection) { var opositeDirection = !positiveDirection; var box1 = meshA.Bounds; var box2 = meshB.Bounds; var intersectsColumm = box2.IntersectsColumm(box1, axis, opositeDirection); if (!intersectsColumm) { return(false); } var transLength = Box.Union(box1, box2).GetInterval(axis).Length; foreach (var triangle2 in meshB.Triangles) { var tree2BoxExtended = triangle2.Bounds.ExtendInDirection(box1, axis, opositeDirection); var tree1TrianglesCandidates = meshA.RTreeRoot.FindOverlap(tree2BoxExtended).ToList(); if (tree1TrianglesCandidates.Count == 0) { return(false); } var prism = new Prism(triangle2, transLength, axis, opositeDirection); var intersetingTree1Tris = tree1TrianglesCandidates.Where(t1 => prismTriangleIntersection.Test(prism, t1)).ToList(); if (intersetingTree1Tris.Count == 0) { return(false); } pointSampler.DistributePoints(triangle2, settings.Direction.RaysPerSquareMeter); var allRaysOk = EmitRays(triangle2, intersetingTree1Tris, meshA, axis, opositeDirection); if (!allRaysOk) { return(false); } } return(true); }
public IEnumerable <Tuple <TriangleMesh, TriangleMesh, double> > EqualOctree(IEnumerable <Pair <TriangleMesh, List <TriangleMesh> > > enumerable) { var stopwatch1 = new Stopwatch(); stopwatch1.Start("Octree Version"); foreach (var mesh in repository.TriangleMeshes) { pointSampler.ResetSessionPointCount(); foreach (var triangle in mesh.Triangles) { pointSampler.DistributePoints(triangle, settings.Equal.SamplePerSquareMeter); } mesh.SampleCount = pointSampler.SessionPointCount; } return(null); }