Exemplo n.º 1
0
        public void Dispose()
        {
            m_stopwatch.Stop();
            m_progressManager.Update(1.0f);

            BufferManager.ReleaseBuffers(m_id);

            //int i = 0;
            //ProgressManagerProcess proc = this;
            //while ((proc = proc.Parent) != null)
            //    i++;

            m_progressManager.EndProcess(this);

            //Context.WriteLine(string.Format("{0}{1} -> End", string.Empty.PadRight(2 * i), m_id));
            //Context.WriteLine("{0}{1}", string.Empty.PadRight(2 * i), "}");
        }
Exemplo n.º 2
0
        public ProgressManagerProcess(ProgressManager progressManager, ProgressManagerProcess parent, string name)
        {
            m_progressManager = progressManager;
            m_id = IdentityManager.AcquireIdentity(name, IdentityType.Process);
            m_stopwatch = new Stopwatch();

            m_parent = parent;
            m_children = new List<ProgressManagerProcess>();

            m_progressManager.Update(0.0f);
            m_stopwatch.Start();

            int i = 0;
            ProgressManagerProcess proc = this;
            while ((proc = proc.Parent) != null)
                i++;

            //Context.WriteLine(string.Format("{0}{1} -> Start", string.Empty.PadRight(2 * i), m_id));
            //Context.WriteLine("{0}{1} {2}", string.Empty.PadRight(2 * i), m_id, "{");
            ContextManager.WriteLine("{0}{1}", string.Empty.PadRight(2 * i), m_id);
        }
Exemplo n.º 3
0
        public ProgressManagerProcess(ProgressManager progressManager, ProgressManagerProcess parent, string name)
        {
            m_progressManager = progressManager;
            m_id        = IdentityManager.AcquireIdentity(name, IdentityType.Process);
            m_stopwatch = new Stopwatch();

            m_parent   = parent;
            m_children = new List <ProgressManagerProcess>();

            m_progressManager.Update(0.0f);
            m_stopwatch.Start();

            int i = 0;
            ProgressManagerProcess proc = this;

            while ((proc = proc.Parent) != null)
            {
                i++;
            }

            //Context.WriteLine(string.Format("{0}{1} -> Start", string.Empty.PadRight(2 * i), m_id));
            //Context.WriteLine("{0}{1} {2}", string.Empty.PadRight(2 * i), m_id, "{");
            ContextManager.WriteLine("{0}{1}", string.Empty.PadRight(2 * i), m_id);
        }
Exemplo n.º 4
0
        private void OnBackgroundDoWork(object sender, DoWorkEventArgs e)
        {
            PointCloudTileSource tileSource = e.Argument as PointCloudTileSource;
            Jacere.Core.Geometry.Extent3D extent = tileSource.Extent;

            m_overviewTextureBrush = new ImageBrush(tileSource.Preview.Image);
            m_overviewTextureBrush.ViewportUnits = BrushMappingMode.Absolute;
            m_overviewTextureBrush.Freeze();

            m_overviewMaterial = new DiffuseMaterial(m_overviewTextureBrush);
            m_overviewMaterial.Freeze();

            if (tileSource != null)
            {
                previewImageGrid.MouseMove -= OnViewportGridMouseMove;

                Action<string> logAction = value => Context.WriteLine(value);
                m_progressManager = new BackgroundWorkerProgressManager(m_backgroundWorker, e, logAction, null);

                m_gridDimensionLowRes = (ushort)Math.Sqrt(VERTEX_COUNT_FAST / tileSource.TileSet.ValidTileCount);
                //m_gridDimensionHighRes = (ushort)Math.Sqrt(VERTEX_COUNT_LARGE / tileSource.TileSet.ValidTileCount);

                m_gridDimensionHighRes = (ushort)(Math.Sqrt(tileSource.TileSet.Density.MedianTileCount) / 3);

                //m_gridDimensionLowRes = (ushort)20;
                //m_gridDimensionHighRes = (ushort)40;

                Jacere.Core.Geometry.Point3D centerOfMass = tileSource.CenterOfMass;
                m_overallCenteredExtent = new Rect3D(extent.MinX - extent.MidpointX, extent.MinY - extent.MidpointY, extent.MinZ - centerOfMass.Z, extent.RangeX, extent.RangeY, extent.RangeZ);

                // load tiles
                KeyValuePair<Grid<int>, Grid<float>> gridsLowRes = tileSource.GenerateGrid(m_gridDimensionLowRes);
                m_gridLowRes = gridsLowRes.Value;
                m_quantizedGridLowRes = gridsLowRes.Key;

                KeyValuePair<Grid<int>, Grid<float>> gridsHighRes = tileSource.GenerateGrid(m_gridDimensionHighRes);
                m_gridHighRes = gridsHighRes.Value;
                m_quantizedGridHighRes = gridsHighRes.Key;

                foreach (PointCloudTile tile in tileSource.TileSet)
                {
                    tileSource.LoadTileGrid(tile, m_buffer, m_gridLowRes, m_quantizedGridLowRes);
                    if (ENABLE_HEIGHT_EXAGGERATION)
                        m_gridLowRes.Multiply(m_heightExaggerationFactor, (float)centerOfMass.Z);

                    Jacere.Core.Geometry.Extent3D tileExtent = tile.Extent;
                    MeshGeometry3D mesh = tileSource.GenerateMesh(m_gridLowRes, tileExtent);

                    DiffuseMaterial material = new DiffuseMaterial();
                    if (USE_LOW_RES_TEXTURE)
                    {
                        material.Brush = m_overviewTextureBrush;
                        mesh.TextureCoordinates = MeshUtils.GeneratePlanarTextureCoordinates(mesh, m_overallCenteredExtent, MathUtils.ZAxis);
                    }
                    else
                    {
                        material.Brush = m_solidBrush;
                    }

                    material.Freeze();
                    GeometryModel3D geometryModel = new GeometryModel3D(mesh, material);
                    geometryModel.Freeze();

                    TileInfo3D tileInfo = new TileInfo3D(tile, geometryModel, m_gridLowRes);
                    m_tileInfo.Add(tile, tileInfo);

                    // add mappings
                    m_meshTileMap.Add(geometryModel, tile);
                    //m_lowResMap.Add(tile, geometryModel);

                    if (!m_progressManager.Update(tile, geometryModel))
                        break;
                }

                //// test
                //foreach (double level in new double[] { centerOfMass.Z })
                //{
                //    Grid<float> grid0 = new Grid<float>(20, 20, extent, false);
                //    grid0.FillVal = (float)level;
                //    grid0.Reset();
                //    grid0.FillVal = float.MinValue;
                //    MeshGeometry3D mesh0 = tileSource.GenerateMesh(grid0, extent);
                //    DiffuseMaterial material0 = new DiffuseMaterial(m_solidBrush);
                //    material0.Freeze();
                //    GeometryModel3D geometryModel0 = new GeometryModel3D(mesh0, material0);
                //    geometryModel0.Freeze();
                //    m_progressManager.Update(1.0f, geometryModel0);
                //}

                if (ENABLE_STITCHING)
                {
                    int validStitchingIndex = 0;
                    foreach (PointCloudTile tile in tileSource.TileSet)
                    {
                        TileInfo3D tileInfo = m_tileInfo[tile];
                        Model3DGroup stitchingGroup = GenerateTileStitching(tileSource, tileInfo);

                        if (stitchingGroup != null)
                            ++validStitchingIndex;

                        if (!m_progressManager.Update(1.0f, stitchingGroup))
                            break;
                    }
                }
            }
        }