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 
37 public:
38  // Global options
40  Nearest = 0,
41  Linear = 1,
42  };
43 
44  // PointCloud options
45  enum class PointColorOption {
46  Default = 0,
47  Color = 1,
48  XCoordinate = 2,
49  YCoordinate = 3,
50  ZCoordinate = 4,
51  Normal = 9,
52  };
53 
54  const double POINT_SIZE_MAX = 25.0;
55  const double POINT_SIZE_MIN = 1.0;
56  const double POINT_SIZE_STEP = 1.0;
57  const double POINT_SIZE_DEFAULT = 5.0;
58  const double LINE_WIDTH_MAX = 10.0;
59  const double LINE_WIDTH_MIN = 1.0;
60  const double LINE_WIDTH_STEP = 1.0;
61  const double LINE_WIDTH_DEFAULT = 1.0;
62 
63  // TriangleMesh options
64  enum class MeshShadeOption {
65  FlatShade = 0,
66  SmoothShade = 1,
67  };
68 
69  enum class MeshColorOption {
70  Default = 0,
71  Color = 1,
72  XCoordinate = 2,
73  YCoordinate = 3,
74  ZCoordinate = 4,
75  Normal = 9,
76  };
77 
78  // Image options
79  enum class ImageStretchOption {
80  OriginalSize = 0,
81  StretchKeepRatio = 1,
82  StretchWithWindow = 2,
83  };
84 
85 public:
87  // VS2013 does not fully support C++11
88  // Array initialization has to be done in constructors.
89  light_position_relative_[0] = Eigen::Vector3d(0, 0, 2);
90  light_position_relative_[1] = Eigen::Vector3d(0, 0, 2);
91  light_position_relative_[2] = Eigen::Vector3d(0, 0, -2);
92  light_position_relative_[3] = Eigen::Vector3d(0, 0, -2);
93  light_color_[0] = Eigen::Vector3d::Ones();
94  light_color_[1] = Eigen::Vector3d::Ones();
95  light_color_[2] = Eigen::Vector3d::Ones();
96  light_color_[3] = Eigen::Vector3d::Ones();
97  light_diffuse_power_[0] = 0.66;
98  light_diffuse_power_[1] = 0.66;
99  light_diffuse_power_[2] = 0.66;
100  light_diffuse_power_[3] = 0.66;
101  light_specular_power_[0] = 0.2;
102  light_specular_power_[1] = 0.2;
103  light_specular_power_[2] = 0.2;
104  light_specular_power_[3] = 0.2;
105  light_specular_shininess_[0] = 100.0;
106  light_specular_shininess_[1] = 100.0;
107  light_specular_shininess_[2] = 100.0;
108  light_specular_shininess_[3] = 100.0;
109  }
110  ~RenderOption() override {}
111 
112 public:
113  bool ConvertToJsonValue(Json::Value &value) const override;
114  bool ConvertFromJsonValue(const Json::Value &value) override;
115 
116 public:
121  } else {
123  }
124  }
125  void ChangePointSize(double change) {
126  point_size_ = std::max(std::min(point_size_ + change * POINT_SIZE_STEP,
127  POINT_SIZE_MAX),
128  POINT_SIZE_MIN);
129  }
130  void ChangeLineWidth(double change) {
131  line_width_ = std::max(std::min(line_width_ + change * LINE_WIDTH_STEP,
132  LINE_WIDTH_MAX),
133  LINE_WIDTH_MIN);
134  }
139  } else {
141  }
142  }
145  }
148  }
152  } else if (image_stretch_option_ ==
155  } else {
157  }
158  }
159 
160 public:
161  // global options
162  Eigen::Vector3d background_color_ = Eigen::Vector3d::Ones();
165 
166  // Phong lighting options
167  bool light_on_ = true;
168  Eigen::Vector3d light_position_relative_[4];
169  Eigen::Vector3d light_color_[4];
170  Eigen::Vector3d light_ambient_color_ = Eigen::Vector3d::Zero();
174 
175  // PointCloud options
178  bool point_show_normal_ = false;
179 
180  // TriangleMesh options
183  bool mesh_show_back_face_ = false;
184  bool mesh_show_wireframe_ = false;
185  Eigen::Vector3d default_mesh_color_ = Eigen::Vector3d(0.7, 0.7, 0.7);
186 
187  // LineSet options
189 
190  // Image options
192  int image_max_depth_ = 3000;
193 
194  // Coordinate frame
196 };
197 
198 } // namespace visualization
199 } // namespace open3d
MeshShadeOption
Definition: RenderOption.h:64
TextureInterpolationOption interpolation_option_
Definition: RenderOption.h:163
const double POINT_SIZE_DEFAULT
Definition: RenderOption.h:57
const double POINT_SIZE_STEP
Definition: RenderOption.h:56
bool point_show_normal_
Definition: RenderOption.h:178
Eigen::Vector3d default_mesh_color_
Definition: RenderOption.h:185
void ToggleMeshShowBackFace()
Definition: RenderOption.h:143
ImageStretchOption
Definition: RenderOption.h:79
ImageStretchOption image_stretch_option_
Definition: RenderOption.h:191
Eigen::Vector3d light_ambient_color_
Definition: RenderOption.h:170
MeshColorOption mesh_color_option_
Definition: RenderOption.h:182
void ToggleShadingOption()
Definition: RenderOption.h:136
const double LINE_WIDTH_MIN
Definition: RenderOption.h:59
bool show_coordinate_frame_
Definition: RenderOption.h:195
void ChangePointSize(double change)
Definition: RenderOption.h:125
bool ConvertToJsonValue(Json::Value &value) const override
Definition: RenderOption.cpp:36
RenderOption()
Definition: RenderOption.h:86
Eigen::Vector3d light_color_[4]
Definition: RenderOption.h:169
bool mesh_show_wireframe_
Definition: RenderOption.h:184
double light_specular_shininess_[4]
Definition: RenderOption.h:173
int image_max_depth_
Definition: RenderOption.h:192
Definition: RenderOption.h:36
const double LINE_WIDTH_STEP
Definition: RenderOption.h:60
void ToggleInterpolationOption()
Definition: RenderOption.h:118
MeshShadeOption mesh_shade_option_
Definition: RenderOption.h:181
void ChangeLineWidth(double change)
Definition: RenderOption.h:130
bool mesh_show_back_face_
Definition: RenderOption.h:183
Eigen::Vector3d light_position_relative_[4]
Definition: RenderOption.h:168
bool ConvertFromJsonValue(const Json::Value &value) override
Definition: RenderOption.cpp:119
MeshColorOption
Definition: RenderOption.h:69
Definition: PinholeCameraIntrinsic.cpp:34
void ToggleLightOn()
Definition: RenderOption.h:117
~RenderOption() override
Definition: RenderOption.h:110
void TogglePointShowNormal()
Definition: RenderOption.h:135
PointColorOption
Definition: RenderOption.h:45
const double LINE_WIDTH_MAX
Definition: RenderOption.h:58
bool light_on_
Definition: RenderOption.h:167
PointColorOption point_color_option_
Definition: RenderOption.h:177
void ToggleMeshShowWireframe()
Definition: RenderOption.h:146
double light_specular_power_[4]
Definition: RenderOption.h:172
double light_diffuse_power_[4]
Definition: RenderOption.h:171
const double LINE_WIDTH_DEFAULT
Definition: RenderOption.h:61
double line_width_
Definition: RenderOption.h:188
Eigen::Vector3d background_color_
Definition: RenderOption.h:162
const double POINT_SIZE_MIN
Definition: RenderOption.h:55
void ToggleImageStretchOption()
Definition: RenderOption.h:149
const double POINT_SIZE_MAX
Definition: RenderOption.h:54
TextureInterpolationOption
Definition: RenderOption.h:39
double point_size_
Definition: RenderOption.h:176
Definition: IJsonConvertible.h:42