Example #1
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);
        }
Example #2
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);
        }