Пример #1
0
        private void PopulateVoxel(object voxel_notifier_resolution)
        {
            List <object>            param    = (List <object>)voxel_notifier_resolution;
            OrderedVoxel <SeedPoint> voxel    = (OrderedVoxel <SeedPoint>)param[0];
            ManualResetEvent         notifier = (ManualResetEvent)param[1];
            int    resolution = (int)param[2];
            double diameter   = voxel.GetVoxelDimension();
            float  step       = (float)(diameter / resolution);

            for (int x = 0; x < resolution; x++)
            {
                for (int y = 0; y < resolution; y++)
                {
                    semaphore.WaitOne();
                    for (int z = 0; z < resolution; z++)
                    {
                        Vector3 pos = new Vector3((x * step) + voxel.vertices[3].X,
                                                  (y * step) + voxel.vertices[3].Y,
                                                  (z * step) + voxel.vertices[3].Z);
                        SeedPoint sp = Interpolator <SeedPoint> .IWDInterpolatePoint(pos, bulkList, diameter);

                        if (sp == null)
                        {
                            sp = Interpolator <SeedPoint> .NNInterpolatePoint(pos, bulkList);
                        }
                        voxel.AddPoint(sp);
                        voxel.AddPointAt(sp, x, y, z);
                    }
                    semaphore.Release();
                }
            }
            notifier.Set();
        }
Пример #2
0
        public FTLEField(InputDataSet ids, int resolution)
        {
            Vector3 min = new Vector3(float.PositiveInfinity);
            Vector3 max = new Vector3(float.NegativeInfinity);

            foreach (Voxel <Point> v in ids.Voxels)
            {
                if (v.vertices[3].X < min.X)
                {
                    min.X = v.vertices[3].X;
                }
                if (v.vertices[3].Y < min.Y)
                {
                    min.Y = v.vertices[3].Y;
                }
                if (v.vertices[3].Z < min.Z)
                {
                    min.Z = v.vertices[3].Z;
                }

                if (v.vertices[4].X > max.X)
                {
                    max.X = v.vertices[4].X;
                }
                if (v.vertices[4].Y > max.Y)
                {
                    max.Y = v.vertices[4].Y;
                }
                if (v.vertices[4].Z > max.Z)
                {
                    max.Z = v.vertices[4].Z;
                }

                voxels.Add(new OrderedVoxel <SeedPoint>(v.vertices, resolution));
            }
            float   size       = (float)voxels.First().GetVoxelDimension();
            Vector3 matrixSize = Vector3.Divide(Vector3.Subtract(max, min), size);

            voxelsMatrix = new OrderedVoxel <SeedPoint> [(int)matrixSize.X, (int)matrixSize.Y, (int)matrixSize.Z];
            foreach (OrderedVoxel <SeedPoint> v in voxels)
            {
                int x = (int)Math.Round((v.vertices[3].X - min.X) / size);
                int y = (int)Math.Round((v.vertices[3].Y - min.Y) / size);
                int z = (int)Math.Round((v.vertices[3].Z - min.Z) / size);
                voxelsMatrix[x, y, z] = v;
            }
            Debug.WriteLine("Min " + min + " Max " + max);
            squares = new List <Square <SeedPoint> >();
        }