Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem changing line_width_ or point_size_ for LineSet #6952

Open
3 tasks done
cwreynolds opened this issue Sep 7, 2024 · 4 comments
Open
3 tasks done

problem changing line_width_ or point_size_ for LineSet #6952

cwreynolds opened this issue Sep 7, 2024 · 4 comments
Labels
bug Not a build issue, this is likely a bug.

Comments

@cwreynolds
Copy link

cwreynolds commented Sep 7, 2024

Checklist

Describe the issue

I cannot see any obvious change when I try to increase line_width_ or point_size_ for LineSet.

I am setting vis.GetRenderOption().line_width_ = 10.0; My code calls Open3D from C++ using a version I built from source in the last new weeks. The main branch minus a few of the most recent commits.

Steps to reproduce the bug

// Test code:

void LineWidthPointSizeTest()
{
    open3d::PrintOpen3DVersion();
    auto lineset = std::make_shared<open3d::geometry::LineSet>();
    lineset->points_ = {{5, 0, 0}, {-5, 0, 0}, {0, 5, 0}, {0, -5, 0}, {0, 0, 5}, {0, 0, -5}};
    lineset->lines_ = {{0, 1}, {2, 3}, {4, 5}};
    lineset->colors_ = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
    
    auto vis = open3d::visualization::Visualizer();
    vis.CreateVisualizerWindow();
    vis.AddGeometry(lineset);
    vis.GetRenderOption().line_width_ = 10.0;
    vis.GetRenderOption().point_size_ = 20.0;
    vis.Run();
}

Error message

(visual problem)

Expected behavior

I wanted thicker lines. Setting vis.GetRenderOption().line_width_ = 10.0 made no obvious difference. I also tried setting vis.GetRenderOption().point_size_ = 20.0 and the vertices do not appear any larger than the lines, which themselves appear no wider than the default.

Screenshot 2024-09-07 at 11 44 16 AM

Open3D, Python and System information

- Operating system: macOS 14.6.1
- Python version: 
- Open3D version: 0.18.0+18a47ef
- System architecture: arm64
- Is this a remote workstation?: no
- How did you install Open3D?: build from source
- Compiler version (if built from source): Apple clang version 15.0.0 (clang-1500.3.9.4)

Additional information

By the way, is there a way to use open3d::PrintOpen3DVersion() to get the exact version string "version+main_commit"? (Like: 0.18.0+18a47ef) Does this work from open3d.__version__ in Python?

@cwreynolds cwreynolds added the bug Not a build issue, this is likely a bug. label Sep 7, 2024
@weixi234
Copy link

weixi234 commented Sep 14, 2024

I have the similar confusion ,I find the changes invalid:
open3d::visualization::Visualizer visualizer;
visualizer.GetRenderOption().ChangeLineWidth(50.0);
visualizer.GetRenderOption().SetPointSize(5.0);
visualizer.GetRenderOption().line_width_=10.0;
More i find that the documentation for using C++ is particularly poor...

@cwreynolds
Copy link
Author

Thanks @weixi234. I don't know how to fix this or work around it. So far, I have just been using the default tiny sizes. For future reference, RenderOption.h lists this information about the ranges and units of these line drawing parameters:

    const double POINT_SIZE_MAX = 25.0;
    const double POINT_SIZE_MIN = 1.0;
    const double POINT_SIZE_STEP = 1.0;
    const double POINT_SIZE_DEFAULT = 5.0;
    const double LINE_WIDTH_MAX = 10.0;
    const double LINE_WIDTH_MIN = 1.0;
    const double LINE_WIDTH_STEP = 1.0;
    const double LINE_WIDTH_DEFAULT = 1.0;

I am new to using Open3D from c++, and yes, the c++ API doc is often unhelpful. Open3D has many helpful usage examples, but they use the Python API. So a c++ user needs to translate, which can be error prone.

@cwreynolds
Copy link
Author

Thinking about this just now, I recall a bug in Open3D 0.17.0 (?) where GetViewControl() returned a copy of the ViewControl object, so modifying it had no effect on the view. I tried a quick experiment to verify that my code was in fact modifying the RenderOption object. It looks like it is:

Before:

vis.GetRenderOption().line_width_ = 1
vis.GetRenderOption().point_size_ = 5

After:

vis.GetRenderOption().line_width_ = 10
vis.GetRenderOption().point_size_ = 20

@cwreynolds
Copy link
Author

I was reminded of this issue by a comment by @YuYuCodeNoob on #5637. That issue (from 2022, since closed) appears to be about the same kind of symptom as this issue: setting line width and point size. @YuYuCodeNoob's suggestion is to use O3DVisualizer instead of (plain old?) Visualizer as used in my sample code above.

So I tried to follow @YuYuCodeNoob's example, which is written in Python, by translating it to c++, using a lot of trial and error:

void LineWidthPointSizeTest2()
{
    open3d::PrintOpen3DVersion();
    auto lineset = std::make_shared<open3d::geometry::LineSet>();
    lineset->points_ = {{5, 0, 0}, {-5, 0, 0}, {0, 5, 0}, {0, -5, 0}, {0, 0, 5}, {0, 0, -5}};
    lineset->lines_ = {{0, 1}, {2, 3}, {4, 5}};
    lineset->colors_ = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
    open3d::visualization::gui::Application::GetInstance().Initialize();
    auto vis = open3d::visualization::visualizer::O3DVisualizer("name", 500, 500);
    vis.AddGeometry("lines", {lineset});
    vis.SetLineWidth(10);
    vis.SetPointSize(20);
    open3d::visualization::gui::Application::GetInstance().Run();
}

I was able to get it to compile, but running it hit a problem with “resource directory”:

libc++abi: terminating due to uncaught exception of type std::runtime_error: [Open3D Error] (std::string (anonymous namespace)::FindResourcePath(int, const char **)) /Users/cwr/Documents/code/Open3D/cpp/open3d/visualization/gui/Application.cpp:96: Could not find resource directory.

I see that I can supply a path for resource directory in an overload of open3d::visualization::gui::Application::Initialize() but have no idea what value I should supply. Two of the three overloads do not have an explicit resource_path arg, so I hoped they would default to whatever it needs.

Can anyone either tell me how to run LineWidthPointSizeTest2(), or point me to a c++ code example for a simple use case, or explain the correct way to set line/point sizes in either Visualizer or O3DVisualizer from c++?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not a build issue, this is likely a bug.
Projects
None yet
Development

No branches or pull requests

2 participants