Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into aabb
Browse files Browse the repository at this point in the history
  • Loading branch information
mattj23 committed May 25, 2021
2 parents b2deefe + ff11ad2 commit 6339692
Show file tree
Hide file tree
Showing 79 changed files with 1,212 additions and 624 deletions.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ the open-source community.
[![Ubuntu CI](https://github.com/intel-isl/Open3D/workflows/Ubuntu%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22Ubuntu+CI%22)
[![macOS CI](https://github.com/intel-isl/Open3D/workflows/macOS%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22macOS+CI%22)
[![Windows CI](https://github.com/intel-isl/Open3D/workflows/Windows%20CI/badge.svg)](https://github.com/intel-isl/Open3D/actions?query=workflow%3A%22Windows+CI%22)
[![Build Status](https://travis-ci.org/intel-isl/Open3D.svg?branch=master)](https://travis-ci.org/intel-isl/)

**Core features of Open3D include:**

Expand All @@ -49,12 +48,9 @@ Pre-built pip and conda packages support Ubuntu 18.04+, macOS 10.14+ and
Windows 10 (64-bit) with Python 3.6, 3.7 and 3.8.

```bash
# Install Open3D stable release with pip
# Install Open3D stable release with pip (including in conda virtual environments)
$ pip install open3d

# Install Open3D stable release with Conda
$ conda install -c open3d-admin -c conda-forge open3d

# Test the installation
$ python -c "import open3d as o3d; print(o3d)"

Expand All @@ -69,7 +65,7 @@ To compile Open3D from source, refer to

Checkout the following links to get started with Open3D C++ API

* [Compiling Open3D frrom source](http://www.open3d.org/docs/release/compilation.html)
* [Compiling Open3D from source](http://www.open3d.org/docs/release/compilation.html)
* [Open3D C++ API](http://www.open3d.org/docs/release/cpp_api.html)

To use Open3D in your C++ project, checkout the following examples
Expand Down
34 changes: 30 additions & 4 deletions cpp/open3d/pipelines/registration/ColoredICP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,22 @@ Eigen::Matrix4d TransformationEstimationForColoredICP::ComputeTransformation(
const geometry::PointCloud &source,
const geometry::PointCloud &target,
const CorrespondenceSet &corres) const {
if (corres.empty() || !target.HasNormals() || !target.HasColors() ||
!source.HasColors()) {
return Eigen::Matrix4d::Identity();
if (corres.empty()) {
utility::LogError(
"No correspondences found between source and target "
"pointcloud.");
}
if (!target.HasNormals()) {
utility::LogError(
"ColoredICP requires target pointcloud to have normals.");
}
if (!target.HasColors()) {
utility::LogError(
"ColoredICP requires target pointcloud to have colors.");
}
if (!source.HasColors()) {
utility::LogError(
"ColoredICP requires source pointcloud to have colors.");
}

double sqrt_lambda_geometric = sqrt(lambda_geometric_);
Expand Down Expand Up @@ -228,9 +241,22 @@ RegistrationResult RegistrationColoredICP(
double max_distance,
const Eigen::Matrix4d &init /* = Eigen::Matrix4d::Identity()*/,
const TransformationEstimationForColoredICP &estimation
/*TransformationEstimationForColoredICP()*/,
/* = TransformationEstimationForColoredICP()*/,
const ICPConvergenceCriteria
&criteria /* = ICPConvergenceCriteria()*/) {
if (!target.HasNormals()) {
utility::LogError(
"ColoredICP requires target pointcloud to have normals.");
}
if (!target.HasColors()) {
utility::LogError(
"ColoredICP requires target pointcloud to have colors.");
}
if (!source.HasColors()) {
utility::LogError(
"ColoredICP requires source pointcloud to have colors.");
}

auto target_c = InitializePointCloudForColoredICP(
target, geometry::KDTreeSearchParamHybrid(max_distance * 2.0, 30));
return RegistrationICP(source, *target_c, max_distance, init, estimation,
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ Widget::DrawResult Button::Draw(const DrawContext& context) {
auto& frame = GetFrame();
auto result = Widget::DrawResult::NONE;

ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));

bool was_on = impl_->is_on_;
if (was_on) {
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/Checkbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ Size Checkbox::CalcPreferredSize(const LayoutContext& context,

Widget::DrawResult Checkbox::Draw(const DrawContext& context) {
auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));
auto result = Widget::DrawResult::NONE;

// ImGUI doesn't offer styling specific to checkboxes other than the
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/ColorEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ Size ColorEdit::CalcPreferredSize(const LayoutContext& context,

ColorEdit::DrawResult ColorEdit::Draw(const DrawContext& context) {
auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));

auto new_value = impl_->value_;
DrawImGuiPushEnabledState();
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/Combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ Combobox::DrawResult Combobox::Draw(const DrawContext& context) {
bool did_open = false;

auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));

ImGui::PushStyleColor(
ImGuiCol_Button,
Expand Down
5 changes: 4 additions & 1 deletion cpp/open3d/visualization/gui/ImageWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ Widget::DrawResult ImageWidget::Draw(const DrawContext& context) {
if (params.texture != visualization::rendering::TextureHandle::kBad) {
ImTextureID image_id =
reinterpret_cast<ImTextureID>(params.texture.GetId());
ImGui::SetCursorScreenPos(ImVec2(params.pos_x, params.pos_y));
ImGui::SetCursorScreenPos(
ImVec2(params.pos_x, params.pos_y - ImGui::GetScrollY()));
ImGui::Image(image_id, ImVec2(params.width, params.height),
ImVec2(params.u0, params.v0),
ImVec2(params.u1, params.v1));
} else {
// Draw error message if we don't have an image, instead of
// quietly failing or something.
Rect frame = GetFrame(); // hide reference with a copy...
frame.y -= ImGui::GetScrollY(); // ... so we can adjust for scrolling
const char* error_text = " Error\nloading\n image";
Color fg(1.0, 1.0, 1.0);
ImGui::GetWindowDrawList()->AddRectFilled(
Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ Size Label::CalcPreferredSize(const LayoutContext& context,

Widget::DrawResult Label::Draw(const DrawContext& context) {
auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));
ImGui::PushItemWidth(float(frame.width));
bool is_default_color = (impl_->color_ == DEFAULT_COLOR);
if (!is_default_color) {
Expand Down
84 changes: 71 additions & 13 deletions cpp/open3d/visualization/gui/Layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,29 @@ void Layout1D::Layout(const LayoutContext& context) {
}
}
}
} else if (num_grow > 0 && frame_size < total) {
auto total_excess = total - (frame_size - impl_->margins_.GetVert() -
total_spacing);
auto excess = total_excess / num_grow;
auto leftover = total_excess - excess * num_stretch;
for (size_t i = 0; i < major.size(); ++i) {
if (major[i] >= Widget::DIM_GROW) {
major[i] -= excess;
if (leftover > 0) {
major[i] -= 1;
leftover -= 1;
} else if (frame_size < total) {
int n_shrinkable = num_grow;
if (impl_->dir_ == VERT) {
for (auto child : GetChildren()) {
if (std::dynamic_pointer_cast<ScrollableVert>(child)) {
n_shrinkable++;
}
}
}
if (n_shrinkable > 0) {
auto total_excess = total - (frame_size - total_spacing);
auto excess = total_excess / n_shrinkable;
auto leftover = total_excess - excess * num_stretch;
for (size_t i = 0; i < major.size(); ++i) {
if (major[i] >= Widget::DIM_GROW ||
(impl_->dir_ == VERT &&
std::dynamic_pointer_cast<ScrollableVert>(
GetChildren()[i]) != nullptr)) {
major[i] -= excess;
if (leftover > 0) {
major[i] -= 1;
leftover -= 1;
}
}
}
}
Expand All @@ -330,7 +342,9 @@ void Layout1D::Layout(const LayoutContext& context) {
if (impl_->dir_ == VERT) {
int minor = frame.width - impl_->margins_.GetHoriz();
for (size_t i = 0; i < children.size(); ++i) {
children[i]->SetFrame(Rect(x, y, minor, major[i]));
int h = std::max(children[i]->CalcMinimumSize(context).height,
major[i]);
children[i]->SetFrame(Rect(x, y, minor, h));
y += major[i] + impl_->spacing_;
}
} else {
Expand Down Expand Up @@ -443,7 +457,8 @@ Widget::DrawResult CollapsableVert::Draw(const DrawContext& context) {
bool was_open = impl_->is_open_;

auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));
ImGui::PushItemWidth(float(frame.width));

auto padding = ImGui::GetStyle().FramePadding;
Expand Down Expand Up @@ -474,6 +489,49 @@ Widget::DrawResult CollapsableVert::Draw(const DrawContext& context) {
}
return result;
}

// ----------------------------------------------------------------------------
struct ScrollableVert::Impl {
ImGuiID id_;
};

ScrollableVert::ScrollableVert() : ScrollableVert(0, Margins(), {}) {}

ScrollableVert::ScrollableVert(int spacing /*= 0*/,
const Margins& margins /*= Margins()*/)
: ScrollableVert(spacing, margins, {}) {}

ScrollableVert::ScrollableVert(
int spacing,
const Margins& margins,
const std::vector<std::shared_ptr<Widget>>& children)
: Vert(spacing, margins, children), impl_(new ScrollableVert::Impl) {
static int g_next_id = 1;
impl_->id_ = g_next_id++;
}

ScrollableVert::~ScrollableVert() {}

Widget::DrawResult ScrollableVert::Draw(const DrawContext& context) {
auto& frame = GetFrame();
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));
ImGui::PushStyleColor(ImGuiCol_FrameBg,
ImGui::GetStyleColorVec4(ImGuiCol_WindowBg));
ImGui::PushStyleColor(ImGuiCol_Border,
colorToImgui(Color(0.0f, 0.0f, 0.0f, 0.0f)));
ImGui::PushStyleColor(ImGuiCol_BorderShadow,
colorToImgui(Color(0.0f, 0.0f, 0.0f, 0.0f)));

ImGui::BeginChildFrame(impl_->id_, ImVec2(frame.width, frame.height));
auto result = Super::Draw(context);
ImGui::EndChildFrame();

ImGui::PopStyleColor(3);

return result;
}

// ----------------------------------------------------------------------------
std::shared_ptr<Layout1D::Fixed> Horiz::MakeFixed(int size) {
return std::make_shared<Layout1D::Fixed>(size, HORIZ);
Expand Down
19 changes: 19 additions & 0 deletions cpp/open3d/visualization/gui/Layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,25 @@ class CollapsableVert : public Vert {
std::unique_ptr<Impl> impl_;
};

/// This a vertical layout that scrolls if it is smaller than its contents
class ScrollableVert : public Vert {
using Super = Vert;

public:
ScrollableVert();
ScrollableVert(int spacing, const Margins& margins = Margins());
ScrollableVert(int spacing,
const Margins& margins,
const std::vector<std::shared_ptr<Widget>>& children);
virtual ~ScrollableVert();

Widget::DrawResult Draw(const DrawContext& context) override;

private:
struct Impl;
std::unique_ptr<Impl> impl_;
};

/// Lays out widgets horizontally.
class Horiz : public Layout1D {
public:
Expand Down
7 changes: 6 additions & 1 deletion cpp/open3d/visualization/gui/ListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,14 @@ Size ListView::CalcPreferredSize(const LayoutContext &context,
return Size(int(std::ceil(size.x + 2.0f * padding.x)), Widget::DIM_GROW);
}

Size ListView::CalcMinimumSize(const LayoutContext &context) const {
return Size(0, 3 * context.theme.font_size);
}

Widget::DrawResult ListView::Draw(const DrawContext &context) {
auto &frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) + ImGui::GetScrollY()));
ImGui::PushItemWidth(float(frame.width));

ImGui::PushStyleColor(ImGuiCol_FrameBg,
Expand Down
2 changes: 2 additions & 0 deletions cpp/open3d/visualization/gui/ListView.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class ListView : public Widget {
Size CalcPreferredSize(const LayoutContext& context,
const Constraints& constraints) const override;

Size CalcMinimumSize(const LayoutContext& context) const override;

DrawResult Draw(const DrawContext& context) override;

/// Calls onValueChanged(const char *selectedText, bool isDoubleClick)
Expand Down
18 changes: 11 additions & 7 deletions cpp/open3d/visualization/gui/Materials/unlitLine.mat
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,27 @@ material {

vertex {
void materialVertex(inout MaterialVertexInputs material) {
float4 pos = getPosition();
float4 next = getCustom0();
float4 resolution = getResolution();
float aspect = resolution.x / resolution.y;
float4 pos = getPosition();
// next.xyz is the position of the end of the line used to compute the direction of
// the line.
// next.w is the sign of the direction perpendicular to the line along which the
// vertex will be moved to create the line's width.
float4 next = getCustom0();

// Project current vertex and next vertex to screen
float4 projected_pos = getClipFromWorldMatrix() * float4(pos.xyz - getWorldOffset(), 1.0);
float4 projected_next = getClipFromWorldMatrix() * float4(next.xyz - getWorldOffset(), 1.0);
float4 world_pos = getWorldFromModelMatrix() * pos;
float4 world_pos_next = getWorldFromModelMatrix() * float4(next.xyz, 1.0);
float4 projected_pos = getClipFromWorldMatrix() * world_pos;
float4 projected_next = getClipFromWorldMatrix() * world_pos_next;
float2 screen_pos = projected_pos.xy / projected_pos.w;
screen_pos.x *= aspect;
float2 screen_next = projected_next.xy / projected_next.w;
screen_next.x *= aspect;

// now compute offset for the desired line width
float2 dir = normalize(screen_next - screen_pos);
float4 normal = float4(-dir.y, dir.x, 0.0, 1.0);
normal.xy *= (materialParams.lineWidth * resolution.z * 0.5);
normal.xy *= (materialParams.lineWidth * resolution.z * 0.5 * aspect);
normal *= getClipFromViewMatrix();
normal.xy *= projected_pos.w;

Expand Down
3 changes: 2 additions & 1 deletion cpp/open3d/visualization/gui/NumberEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ Size NumberEdit::CalcPreferredSize(const LayoutContext& context,

Widget::DrawResult NumberEdit::Draw(const DrawContext& context) {
auto& frame = GetFrame();
ImGui::SetCursorScreenPos(ImVec2(float(frame.x), float(frame.y)));
ImGui::SetCursorScreenPos(
ImVec2(float(frame.x), float(frame.y) - ImGui::GetScrollY()));

ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding,
0.0); // macOS doesn't round text edit borders
Expand Down
8 changes: 0 additions & 8 deletions cpp/open3d/visualization/gui/SceneWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ class RotateIBLInteractor : public SceneWidget::MouseInteractor {
return *ibl_.get();
}

void ShowSkybox(bool is_on) { ibl_->ShowSkybox(is_on); }

void SetOnChanged(std::function<void(const rendering::Camera::Transform&)>
on_changed) {
on_rotation_changed_ = on_changed;
Expand Down Expand Up @@ -629,8 +627,6 @@ class Interactors {
sun_->SetOnSunLightChanged(onChanged);
}

void ShowSkybox(bool isOn) { ibl_->ShowSkybox(isOn); }

void SetSunInteractorEnabled(bool enable) {
sun_interactor_enabled_ = enable;
}
Expand Down Expand Up @@ -925,10 +921,6 @@ void SceneWidget::SetOnSunDirectionChanged(
});
}

void SceneWidget::ShowSkybox(bool is_on) {
impl_->controls_->ShowSkybox(is_on);
}

void SceneWidget::SetSunInteractorEnabled(bool enable) {
impl_->controls_->SetSunInteractorEnabled(enable);
}
Expand Down
2 changes: 0 additions & 2 deletions cpp/open3d/visualization/gui/SceneWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ class SceneWidget : public Widget {
/// only needed if other things need to be updated (like a UI).
void SetOnSunDirectionChanged(
std::function<void(const Eigen::Vector3f&)> on_dir_changed);
/// Enables showing the skybox while in skybox ROTATE_IBL mode.
void ShowSkybox(bool is_on);

void SetScene(std::shared_ptr<rendering::Open3DScene> scene);
std::shared_ptr<rendering::Open3DScene> GetScene() const;
Expand Down
Loading

0 comments on commit 6339692

Please sign in to comment.