示例#1
0
        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));
        }
示例#2
0
        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);
        }