Open3D (C++ API)
RenderOption.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2018 www.open3d.org
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in
16 // all copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 // IN THE SOFTWARE.
25 // ----------------------------------------------------------------------------
26 
27 #pragma once
28 
29 #include <Eigen/Core>
30 
32 
33 namespace open3d {
34 namespace visualization {
35 
40 public:
41  // Global options
43  Nearest = 0,
44  Linear = 1,
45  };
46 
47  enum class DepthFunc {
48  Never = 0,
49  Less = 1,
50  Equal = 2,
51  LEqual = 3,
52  Greater = 4,
53  NotEqual = 5,
54  GEqual = 6,
55  Always = 7
56  };
57 
61  enum class PointColorOption {
62  Default = 0,
63  Color = 1,
64  XCoordinate = 2,
65  YCoordinate = 3,
66  ZCoordinate = 4,
67  Normal = 9,
68  };
69 
70  const double POINT_SIZE_MAX = 25.0;
71  const double POINT_SIZE_MIN = 1.0;
72  const double POINT_SIZE_STEP = 1.0;
73  const double POINT_SIZE_DEFAULT = 5.0;
74  const double LINE_WIDTH_MAX = 10.0;
75  const double LINE_WIDTH_MIN = 1.0;
76  const double LINE_WIDTH_STEP = 1.0;
77  const double LINE_WIDTH_DEFAULT = 1.0;
78 
82  enum class MeshShadeOption {
83  FlatShade = 0,
84  SmoothShade = 1,
85  };
86 
90  enum class MeshColorOption {
91  Default = 0,
92  Color = 1,
93  XCoordinate = 2,
94  YCoordinate = 3,
95  ZCoordinate = 4,
96  Normal = 9,
97  };
98 
99  // Image options
100  enum class ImageStretchOption {
101  OriginalSize = 0,
102  StretchKeepRatio = 1,
103  StretchWithWindow = 2,
104  };
105 
106 public:
109  // VS2013 does not fully support C++11
110  // Array initialization has to be done in constructors.
111  light_position_relative_[0] = Eigen::Vector3d(0, 0, 2);
112  light_position_relative_[1] = Eigen::Vector3d(0, 0, 2);
113  light_position_relative_[2] = Eigen::Vector3d(0, 0, -2);
114  light_position_relative_[3] = Eigen::Vector3d(0, 0, -2);
115  light_color_[0] = Eigen::Vector3d::Ones();
116  light_color_[1] = Eigen::Vector3d::Ones();
117  light_color_[2] = Eigen::Vector3d::Ones();
118  light_color_[3] = Eigen::Vector3d::Ones();
119  light_diffuse_power_[0] = 0.66;
120  light_diffuse_power_[1] = 0.66;
121  light_diffuse_power_[2] = 0.66;
122  light_diffuse_power_[3] = 0.66;
123  light_specular_power_[0] = 0.2;
124  light_specular_power_[1] = 0.2;
125  light_specular_power_[2] = 0.2;
126  light_specular_power_[3] = 0.2;
127  light_specular_shininess_[0] = 100.0;
128  light_specular_shininess_[1] = 100.0;
129  light_specular_shininess_[2] = 100.0;
130  light_specular_shininess_[3] = 100.0;
131  }
132  ~RenderOption() override {}
133 
134 public:
135  bool ConvertToJsonValue(Json::Value &value) const override;
136  bool ConvertFromJsonValue(const Json::Value &value) override;
137 
138 public:
143  } else {
145  }
146  }
147  void ChangePointSize(double change);
148  void SetPointSize(double size);
149  void ChangeLineWidth(double change);
154  } else {
156  }
157  }
160  }
163  }
167  } else if (image_stretch_option_ ==
170  } else {
172  }
173  }
174 
175  int GetGLDepthFunc() const;
176 
177 public:
178  // global options
180  Eigen::Vector3d background_color_ = Eigen::Vector3d::Ones();
184 
185  // Phong lighting options
187  bool light_on_ = true;
188  Eigen::Vector3d light_position_relative_[4];
189  Eigen::Vector3d light_color_[4];
190  Eigen::Vector3d light_ambient_color_ = Eigen::Vector3d::Zero();
194 
195  // PointCloud options
201  bool point_show_normal_ = false;
202 
203  // TriangleMesh options
209  bool mesh_show_back_face_ = false;
210 
211  bool mesh_show_wireframe_ = false;
212  Eigen::Vector3d default_mesh_color_ = Eigen::Vector3d(0.7, 0.7, 0.7);
213 
214  // LineSet options
217 
218  // Image options
221  int image_max_depth_ = 3000;
222 
223  // Coordinate frame
226 };
227 
228 } // namespace visualization
229 } // namespace open3d
MeshShadeOption
Enum class for mesh shading for TriangleMesh.
Definition: RenderOption.h:82
TextureInterpolationOption interpolation_option_
Definition: RenderOption.h:181
const double POINT_SIZE_DEFAULT
Definition: RenderOption.h:73
const double POINT_SIZE_STEP
Definition: RenderOption.h:72
bool point_show_normal_
Whether to show normal for PointCloud.
Definition: RenderOption.h:201
Eigen::Vector3d default_mesh_color_
Definition: RenderOption.h:212
void ToggleMeshShowBackFace()
Definition: RenderOption.h:158
ImageStretchOption
Definition: RenderOption.h:100
ImageStretchOption image_stretch_option_
Definition: RenderOption.h:219
Eigen::Vector3d light_ambient_color_
Definition: RenderOption.h:190
void SetPointSize(double size)
Definition: RenderOption.cpp:263
MeshColorOption mesh_color_option_
Color option for TriangleMesh.
Definition: RenderOption.h:207
void ToggleShadingOption()
Definition: RenderOption.h:151
const double LINE_WIDTH_MIN
Definition: RenderOption.h:75
bool show_coordinate_frame_
Whether to show coordinate frame.
Definition: RenderOption.h:225
void ChangePointSize(double change)
Definition: RenderOption.cpp:257
bool ConvertToJsonValue(Json::Value &value) const override
Definition: RenderOption.cpp:39
int size
Definition: FilePCD.cpp:57
RenderOption()
Default Constructor.
Definition: RenderOption.h:108
Eigen::Vector3d light_color_[4]
Definition: RenderOption.h:189
bool mesh_show_wireframe_
Definition: RenderOption.h:211
double light_specular_shininess_[4]
Definition: RenderOption.h:193
int image_max_depth_
Definition: RenderOption.h:221
int GetGLDepthFunc() const
Definition: RenderOption.cpp:273
Defines rendering options for visualizer.
Definition: RenderOption.h:39
const double LINE_WIDTH_STEP
Definition: RenderOption.h:76
void ToggleInterpolationOption()
Definition: RenderOption.h:140
MeshShadeOption mesh_shade_option_
Mesh shading option for TriangleMesh.
Definition: RenderOption.h:205
DepthFunc depthFunc_
Definition: RenderOption.h:183
void ChangeLineWidth(double change)
Definition: RenderOption.cpp:267
bool mesh_show_back_face_
Whether to show back faces for TriangleMesh.
Definition: RenderOption.h:209
Eigen::Vector3d light_position_relative_[4]
Definition: RenderOption.h:188
bool ConvertFromJsonValue(const Json::Value &value) override
Definition: RenderOption.cpp:122
MeshColorOption
Enum class for color for TriangleMesh.
Definition: RenderOption.h:90
Definition: Open3DViewer.h:29
void ToggleLightOn()
Definition: RenderOption.h:139
~RenderOption() override
Definition: RenderOption.h:132
void TogglePointShowNormal()
Definition: RenderOption.h:150
PointColorOption
Enum class for point color for PointCloud.
Definition: RenderOption.h:61
const double LINE_WIDTH_MAX
Definition: RenderOption.h:74
bool light_on_
Whether to turn on Phong lighting.
Definition: RenderOption.h:187
PointColorOption point_color_option_
Point color option for PointCloud.
Definition: RenderOption.h:199
void ToggleMeshShowWireframe()
Definition: RenderOption.h:161
double light_specular_power_[4]
Definition: RenderOption.h:192
double light_diffuse_power_[4]
Definition: RenderOption.h:191
const double LINE_WIDTH_DEFAULT
Definition: RenderOption.h:77
double line_width_
Line width for LineSet.
Definition: RenderOption.h:216
Eigen::Vector3d background_color_
Background RGB color.
Definition: RenderOption.h:180
const double POINT_SIZE_MIN
Definition: RenderOption.h:71
void ToggleImageStretchOption()
Definition: RenderOption.h:164
DepthFunc
Definition: RenderOption.h:47
const double POINT_SIZE_MAX
Definition: RenderOption.h:70
TextureInterpolationOption
Definition: RenderOption.h:42
double point_size_
Point size for PointCloud.
Definition: RenderOption.h:197
Definition: IJsonConvertible.h:42