Exemple #1
0
        public Params(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Invalid number of Parameters, model folder required");
                WriteSyntax();
                return;
            }

            TestFileRoot = args[0];

            if (!Directory.Exists(TestFileRoot))
            {
                Console.WriteLine("Invalid model folder {0}", TestFileRoot);
                return;
            }

            Timeout = DefaultTimeout;

            CompoundParameter paramType = CompoundParameter.None;

            foreach (string arg in args.Skip(1))
            {
                switch (paramType)
                {
                case CompoundParameter.None:
                    switch (arg.ToLowerInvariant())
                    {
                    case "/timeout":
                        paramType = CompoundParameter.Timeout;
                        break;

                    case "/caching":
                        Caching = true;
                        break;

                    case "/geometryv1":
                        GeometryV1 = true;
                        break;

                    default:
                        Console.WriteLine("Skipping un-expected argument '{0}'", arg);
                        break;
                    }
                    break;

                case CompoundParameter.Timeout:
                    int timeout;
                    if (int.TryParse(arg, out timeout))
                    {
                        Timeout = timeout * 1000;
                    }
                    paramType = CompoundParameter.None;
                    break;
                }
            }

            IsValid = true;
        }
Exemple #2
0
        public Params(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Invalid number of Parameters, model folder required");
                WriteSyntax();
                return;
            }

            TestFileRoot = args[0];

            // work out what are the files to process and the report file
            //
            if (Directory.Exists(TestFileRoot))
            {
                var di = new DirectoryInfo(TestFileRoot);
                FilesToProcess = di.GetFiles("*.IFC", SearchOption.AllDirectories).Where(y => y.Extension.ToLowerInvariant() == ".ifc");
                ResultsFile    = Path.Combine(TestFileRoot, string.Format("XbimRegression_{0:yyyyMMdd-hhmmss}.csv", DateTime.Now));
            }
            else if (File.Exists(TestFileRoot))
            {
                var ext = Path.GetExtension(TestFileRoot).ToLowerInvariant();
                if (ext == ".ifc")
                {
                    FilesToProcess = new[] { new FileInfo(TestFileRoot) };
                    ResultsFile    = Path.ChangeExtension(TestFileRoot, "regression.csv");
                }
                else if (ext == ".txt")
                {
                    var justLines = File.ReadAllLines(TestFileRoot).Where(x => !x.StartsWith("#"));
                    FilesToProcess = justLines.Where(name => File.Exists(name)).Select(x => new FileInfo(x)).ToArray();
                    ResultsFile    = string.Format("XbimRegression_{0:yyyyMMdd-hhmmss}.csv", DateTime.Now);
                }
                else
                {
                    Console.WriteLine("Invalid source file {0}", TestFileRoot);
                    return;
                }
            }
            else
            {
                Console.WriteLine("Invalid model folder {0}", TestFileRoot);
                return;
            }

            Timeout = DefaultTimeout;
            CompoundParameter paramType = CompoundParameter.None;

            var eval = args.Skip(1).ToList();

            for (int i = 0; i < eval.Count; i++)
            {
                string arg = eval[i];
                switch (paramType)
                {
                case CompoundParameter.None:
                    switch (arg.ToLowerInvariant())
                    {
                    case "/singlethread":
                        MaxThreads = 1;
                        break;

                    case "/lowthreadscount":
                        MaxThreads = Environment.ProcessorCount / 2;
                        break;

                    case "/writebreps":
                    case "/breps":
                    case "/brep":
                        WriteBreps = WriteBreps ?? new List <int>();
                        paramType  = CompoundParameter.Breps;
                        break;

                    case "/timeout":
                        paramType = CompoundParameter.Timeout;
                        break;

                    case "/maxthreads":
                        paramType = CompoundParameter.MaxThreads;
                        break;

                    case "/caching":
                        Caching = true;
                        break;

                    case "/progress":
                        ReportProgress = true;
                        break;

                    case "/geometryv1":
                        GeometryV1 = true;
                        break;

                    default:
                        Console.WriteLine("Skipping un-expected argument '{0}'", arg);
                        break;
                    }
                    break;

                case CompoundParameter.Timeout:
                    int timeout;
                    if (int.TryParse(arg, out timeout))
                    {
                        Timeout = timeout * 1000;
                    }
                    paramType = CompoundParameter.None;
                    break;

                case CompoundParameter.MaxThreads:
                    int mt;
                    if (int.TryParse(arg, out mt))
                    {
                        MaxThreads = mt;
                    }
                    paramType = CompoundParameter.None;
                    break;

                case CompoundParameter.Breps:
                    int brepv;
                    if (int.TryParse(arg, out brepv))
                    {
                        WriteBreps.Add(brepv);
                    }
                    else
                    {
                        paramType = CompoundParameter.None;
                        i--;
                    }
                    break;
                }
            }
            IsValid = true;
        }
Exemple #3
0
        private Params(string[] args)
        {
            // init behaviour
            ProcessSubDir      = false;
            GeometryGeneration = GeometryGenerationOptions.ExcludeIfcFeatures;

            if (args.Length < 1)
            {
                Console.WriteLine("Invalid number of Parameters, filename required");
                Console.WriteLine("Syntax: XbimConvert source [-quiet|-q] [-generatescene|-gs[:options]] [-nogeometry|-ng] [-keepextension|-ke] [-filter|-f <elementid|elementtype>] [-sanitiselog] [-occ] [-geomVersion|-gv]");
                Console.Write("-geomversion options are: 1 or 2, 2 is the latest and default version supporting maps");
                Console.Write("-generatescene options are: ");
                //foreach (var i in Enum.GetValues(typeof(GenerateSceneOption)))
                //    Console.Write(" " + i.ToString());
                return;
            }
            Specdir = Path.GetDirectoryName(args[0]);
            if (Specdir == "")
            {
                Specdir = Directory.GetCurrentDirectory();
            }
            Specpart = Path.GetFileName(args[0]);

            //GenerateSceneOptions =
            //            GenerateSceneOption.IncludeRegions |
            //            GenerateSceneOption.IncludeStoreys |
            //            GenerateSceneOption.IncludeSpaces;

            CompoundParameter paramType = CompoundParameter.None;

            foreach (string arg in args.Skip(1))
            {
                switch (paramType)
                {
                case CompoundParameter.None:
                    string[] argNames = arg.ToLowerInvariant().Split(new[] { ":" }, StringSplitOptions.RemoveEmptyEntries);
                    switch (argNames[0])
                    {
                    case "-caching":
                    case "-c":
                        Caching = true;
                        break;

                    case "-quiet":
                    case "-q":
                        IsQuiet = true;
                        break;

                    case "-keepextension":
                    case "-ke":
                        KeepFileExtension = true;
                        break;

                    case "-generatescene":
                    case "-gs":
                        GenerateScene = true;

                        if (argNames.Length > 1)
                        {
                            //foreach (var i in Enum.GetValues(typeof(GenerateSceneOption)))
                            //{
                            //    if (CultureInfo.CurrentCulture.CompareInfo.IndexOf((string)argNames[1], i.ToString(), CompareOptions.IgnoreCase) >= 0)
                            //    {
                            //        GenerateSceneOptions = GenerateSceneOptions | (GenerateSceneOption)i;
                            //    }
                            //}
                        }
                        break;

                    case "-nogeometry":
                    case "-ng":
                        GeometryGeneration = GeometryGenerationOptions.None;
                        break;

                    case "-allgeometry":
                    case "-ag":
                        GeometryGeneration = GeometryGenerationOptions.All;
                        break;

                    case "-filter":
                    case "-f":
                        paramType = CompoundParameter.Filter;
                        // need to read next param
                        break;

                    case "-subdir":
                    case "-s":
                        ProcessSubDir = true;
                        break;

                    case "-sanitiselog":
                        SanitiseLogs = true;
                        break;

                    case "-occ":
                        Occ = true;
                        break;

                    case "-geomversion":
                    case "-gv":
                        if (argNames.Length > 1 && Convert.ToInt32(argNames[1]) == 1)
                        {
                            GeomVersion = 1;
                        }
                        break;

                    default:
                        Console.WriteLine("Skipping un-expected argument '{0}'", arg);
                        break;
                    }
                    break;
                }
            }
            // Parameters are valid
            IsValid = true;
        }