Ejemplo n.º 1
0
        /// <summary>
        /// Offset of current tile center from main header center
        /// </summary>
        private static Vector3 GetCurrentTileOffset()
        {
            CHeaderInfo mainHeader = CProjectData.mainHeader;

            //in rxp no main header is assigned
            if (mainHeader == null)
            {
                return(Vector3.Zero);
            }

            Vector3 diff = mainHeader.Center - CProjectData.currentTileHeader.Center;

            diff.Y *= -1;             //to match coord style //TODO: check..weird - checked => correct
            return(diff);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Calculates estimated file size
        /// </summary>
        private static float GetResultFileSize()
        {
            CHeaderInfo header = CProjectData.sourceFileHeader;

            if (header == null)
            {
                return(0);
            }

            arrayHeight = header.Height;
            arrayWidth  = header.Width;
            if ((ESplitMode)CParameterSetter.GetIntSettings(ESettings.currentSplitMode) == ESplitMode.Manual)
            {
                SSplitRange range = CParameterSetter.GetSplitRange();
                arrayWidth  = range.RangeX;
                arrayHeight = range.RangeY;
            }

            float area = arrayWidth * arrayHeight;

            const float treeStructure = .05f;
            const float reftreeSize   = 1;
            const float treeBoxSize   = .01f;

            const float treeDensity = .1f;    //1 tree per 10 squared meters
            float       groundSize  = 5;      //its just small, no reason to count it in

            float totalSize = groundSize;


            if (CParameterSetter.GetBoolSettings(ESettings.exportTreeStructures))
            {
                totalSize += area * treeDensity * treeStructure;
            }
            if (CParameterSetter.GetBoolSettings(ESettings.exportTreeBoxes))
            {
                totalSize += area * treeDensity * treeBoxSize;
            }
            if (CParameterSetter.GetBoolSettings(ESettings.exportRefTrees))
            {
                totalSize += area * treeDensity * reftreeSize;
            }
            return(totalSize);
        }
Ejemplo n.º 3
0
        internal static void TransformArrayIndexToBitmapIndex(ref Tuple <int, int> pArrayIndex,
                                                              CHeaderInfo pArrayHeader, float pStepSize, Bitmap pMap)
        {
            float xPercent = pArrayIndex.Item1 * pStepSize / pArrayHeader.Width;
            float yPercent = pArrayIndex.Item2 * pStepSize / pArrayHeader.Height;

            yPercent = 1 - yPercent;             //bitmap has different orientation than our array

            if (xPercent < 0 || xPercent > 1 || yPercent < 0 || yPercent > 1)
            {
                CDebug.Error($"wrong transformation! x = {xPercent}, y = {yPercent}");
                xPercent = 0;
                yPercent = 0;
            }

            int bitmapXindex = (int)((pMap.Width - 1) * xPercent);
            int bitmapYindex = (int)((pMap.Height - 1) * yPercent);

            //array is oriented from bot to top, bitmap top to bot
            bitmapYindex = pMap.Height - bitmapYindex - 1;

            pArrayIndex = new Tuple <int, int>(bitmapXindex, bitmapYindex);
        }
Ejemplo n.º 4
0
        private static EProcessResult ProcessTile(string pTilePath, int pTileIndex)
        {
            //has to reinit first for the correct progress output
            CDebug.ReInit();

            DateTime startTime = DateTime.Now;

            currentTileIndex = pTileIndex;


            List <Tuple <EClass, Vector3> > parsedLines;

            if (CRxpParser.IsRxp)
            {
                CRxpInfo rxpInfo = CRxpParser.ParseFile(pTilePath);
                parsedLines = rxpInfo.ParsedLines;
                //for now we expect only one tile in rxp processing
                CProjectData.currentTileHeader = rxpInfo.Header;
                CProjectData.mainHeader        = rxpInfo.Header;
            }
            else
            {
                string[] lines   = CProgramLoader.GetFileLines(pTilePath);
                bool     linesOk = lines != null && lines.Length > 0 && !string.IsNullOrEmpty(lines[0]);
                if (linesOk && CHeaderInfo.HasHeader(lines[0]))
                {
                    //todo: where to init header?
                    CProjectData.currentTileHeader = new CHeaderInfo(lines);
                }
                else
                {
                    const string noHeaderMsg = "Processed tile has no header";
                    CDebug.Error(noHeaderMsg);
                    throw new Exception(noHeaderMsg);
                }
                parsedLines = CProgramLoader.ParseLines(lines, true);
            }

            //has to be called after currentTileHeader is assigned
            CProjectData.ReInit(pTileIndex);             //has to reinit after each tile is processed
            CTreeManager.Reinit();

            if (CProjectData.backgroundWorker.CancellationPending)
            {
                return(EProcessResult.Cancelled);
            }

            CProgramLoader.ProcessParsedLines(parsedLines);

            if (CProjectData.backgroundWorker.CancellationPending)
            {
                return(EProcessResult.Cancelled);
            }

            CTreeManager.DebugTrees();

            CDebug.Step(EProgramStep.Export3D);
            CObjPartition.ExportPartition("", "tile" + pTileIndex);

            if (CProjectData.backgroundWorker.CancellationPending)
            {
                return(EProcessResult.Cancelled);
            }

            //has to be called after ExportPartition where final folder location is determined
            try
            {
                CDebug.Step(EProgramStep.Bitmap);
                CBitmapExporter.Export(pTileIndex);
            }
            catch (Exception e)
            {
                CDebug.Error("exception: " + e.Message);
            }

            CAnalytics.totalDuration = CAnalytics.GetDuration(startTime);
            CDebug.Duration("total time", startTime);

            CDebug.Step(EProgramStep.Dart);
            CDartTxt.ExportTile();

            CDebug.Step(EProgramStep.Shp);
            CShpController.ExportCurrent();

            CDebug.Step(EProgramStep.Las);
            CLasExporter.ExportTile();

            CDebug.Step(EProgramStep.Analytics);
            CAnalytics.Write(true);

            return(EProcessResult.Done);
        }
Ejemplo n.º 5
0
        //public static string[] GetDebugHeaderLines()
        //{
        //	string[] result = new string[19];
        //	for(int i = 0; i <= 14; i++)
        //	{
        //		result[i] = "%";
        //	}

        //	result[15] = "% scale factor x y z         1 1 1";
        //	result[16] = "% offset x y z               0 0 0";
        //	result[17] = "% min x y z               0 0 0";
        //	result[18] = "% max x y z               0 0 0";
        //	//result[19] = "-20.10000	-3.21350	631.06150	0";
        //	return result;
        //}

        public static CRxpInfo ParseFile(string pFile)
        {
            int    sync_to_pps = 0;
            IntPtr h3ds        = IntPtr.Zero;

            int opened = scanifc_point3dstream_open(pFile, ref sync_to_pps, ref h3ds);

            Console.WriteLine($"opened = {opened}, h3ds = {h3ds}");

            uint       PointCount = 1;
            int        EndOfFrame = 1;
            const uint BLOCK_SIZE = 1000;

            scanifc_xyz32[]      BufferXYZ  = new scanifc_xyz32[BLOCK_SIZE];
            scanifc_attributes[] BufferMISC = new scanifc_attributes[BLOCK_SIZE];
            ulong[] BufferTIME = new ulong[BLOCK_SIZE];

            List <Tuple <EClass, Vector3> > fileLines = new List <Tuple <EClass, Vector3> >();

            //fileLines.AddRange(GetDebugHeaderLines().ToList<string>());

            Vector3 min = new Vector3(int.MaxValue, int.MaxValue, int.MaxValue);
            Vector3 max = new Vector3(int.MinValue, int.MinValue, int.MinValue);

            int      readIteration      = 0;
            DateTime debugStart         = DateTime.Now;
            DateTime previousDebugStart = DateTime.Now;

            int maxLinesToLoad = int.MaxValue;             //5000000

            while (PointCount != 0 || EndOfFrame != 0)
            {
                //debug smaller batch
                if (fileLines.Count >= maxLinesToLoad)
                {
                    break;
                }

                if (CProjectData.backgroundWorker.CancellationPending)
                {
                    break;
                }

                readIteration++;
                CDebug.Progress(readIteration, int.MaxValue, 1000, ref previousDebugStart, debugStart, "Parsing Rxp file (size unknown)");
                int read = scanifc_point3dstream_read(
                    h3ds, BLOCK_SIZE,
                    BufferXYZ, BufferMISC, BufferTIME,
                    ref PointCount, ref EndOfFrame);
                for (int i = 0; i < PointCount; i++)
                {
                    scanifc_xyz32 xyz = BufferXYZ[i];
                    //Console.WriteLine($"BufferXYZ = {xyz.x},{xyz.y},{xyz.z}");

                    RefreshMinMax(xyz, ref min, ref max);

                    fileLines.Add(new Tuple <EClass, Vector3>(EClass.Undefined, xyz.ToVector()));
                }
            }

            CHeaderInfo header = new CHeaderInfo(new Vector3(1, 1, 1), new Vector3(0, 0, 0), min, max);

            CRxpInfo rxpInfo = new CRxpInfo(fileLines, header);

            return(rxpInfo);
        }
Ejemplo n.º 6
0
 public CRxpInfo(List <Tuple <EClass, Vector3> > pParsedLines, CHeaderInfo pHeader)
 {
     ParsedLines = pParsedLines;
     Header      = pHeader;
 }