1 /**
2  * @class   F3DOptions
3  * @brief   The class that holds and manages options
4  *
5  */
6 
7 #ifndef vtkF3DOptions_h
8 #define vtkF3DOptions_h
9 
10 #include "Config.h"
11 
12 #include <memory>
13 #include <vector>
14 
15 class ConfigurationOptions;
16 
17 struct F3DOptions
18 {
19   bool Axis = false;
20   bool Bar = false;
21   bool Cells = false;
22   bool Denoise = false;
23   bool DepthPeeling = false;
24   bool DryRun = false;
25   bool Edges = false;
26   bool FPS = false;
27   bool Filename = false;
28   bool MetaData = false;
29   bool FXAA = false;
30   bool GeometryOnly = false;
31   bool Grid = false;
32   bool Progress = false;
33   bool Raytracing = false;
34   bool SSAO = false;
35   bool Verbose = false;
36   bool NoRender = false;
37   bool Quiet = false;
38   bool PointSprites = false;
39   bool FullScreen = false;
40   bool ToneMapping = false;
41   bool Volume = false;
42   bool InverseOpacityFunction = false;
43   bool NoBackground = false;
44   bool BlurBackground = false;
45   bool Trackball = false;
46   double CameraViewAngle;
47   double CameraAzimuthAngle = 0.0;
48   double CameraElevationAngle = 0.0;
49   double Metallic = 0.0;
50   double Opacity = 1.0;
51   double PointSize = 10.0;
52   double LineWidth = 1.0;
53   double RefThreshold = 0.1;
54   double Roughness = 0.3;
55   int Component = -1;
56   int Samples = 5;
57   std::string Up = "+Y";
58   int AnimationIndex = 0;
59   int CameraIndex = -1;
60   std::string UserConfigFile = "";
61   std::string Output = "";
62   std::string Reference = "";
63   std::string Scalars = f3d::F3DReservedString;
64   std::string InteractionTestRecordFile = "";
65   std::string InteractionTestPlayFile = "";
66   std::vector<double> BackgroundColor = { 0.2, 0.2, 0.2 };
67   std::vector<double> CameraPosition;
68   std::vector<double> CameraFocalPoint;
69   std::vector<double> CameraViewUp;
70   std::vector<double> LookupPoints = { 0.0, 0.0, 0.0, 0.0, 0.4, 0.9, 0.0, 0.0, 0.8, 0.9, 0.9, 0.0,
71     1.0, 1.0, 1.0, 1.0 };
72   std::vector<double> Range;
73   std::vector<double> SolidColor = { 1., 1., 1. };
74   std::vector<int> WindowSize = { 1000, 600 };
75   std::string HDRIFile;
76   std::string BaseColorTex;
77   std::string ORMTex;
78   std::string EmissiveTex;
79   std::vector<double> EmissiveFactor = { 1., 1., 1. };
80   std::string NormalTex;
81   double NormalScale = 1.0;
82 };
83 
84 class F3DOptionsParser
85 {
86 public:
87   void Initialize(int argc, char** argv);
88 
89    /**
90    * Find and parse a config file, if any, into the config file dictionnary.
91    * If a non-empty userConfigFile is provided, it will be considered instead
92    * of standard settings config file
93    */
94   void InitializeDictionaryFromConfigFile(const std::string& userConfigFile);
95 
96   /**
97    * Parse the command line and return the options passed
98    * The provided inputs arguments will also be filled by the
99    * positional inputs or inputs arguments from command line.
100    * This will also reset the FilePathForConfigFile in order to
101    * ignore config file options.
102    * Returns the resulting options.
103    */
104   F3DOptions GetOptionsFromCommandLine(std::vector<std::string>& inputs);
105 
106   /**
107    * Use the config file dictionnary using the provided filepath
108    * to match the regexp from the config files.
109    * Then parse the command line for any supplemental.
110    * Returns the resulting options.
111    */
112   F3DOptions GetOptionsFromConfigFile(const std::string& filePath);
113 
114   F3DOptionsParser();
115   ~F3DOptionsParser();
116 
117 private:
118   F3DOptionsParser(F3DOptionsParser const&) = delete;
119   void operator=(F3DOptionsParser const&) = delete;
120 
121   std::unique_ptr<ConfigurationOptions> ConfigOptions;
122 };
123 
124 #endif
125