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

Measuring diameters #7741

Closed
2 of 3 tasks
asp1972 opened this issue Dec 14, 2024 · 5 comments · Fixed by #8575
Closed
2 of 3 tasks

Measuring diameters #7741

asp1972 opened this issue Dec 14, 2024 · 5 comments · Fixed by #8575
Labels
bug Something isn't working

Comments

@asp1972
Copy link

asp1972 commented Dec 14, 2024

Is there an existing issue for this problem?

  • I have searched the existing issues

OrcaSlicer Version

2.3.0-dev

Operating System (OS)

Windows

OS Version

Windows 10

Additional system information

No response

Printer

Bambu X1C

How to reproduce

  1. Сreate a primitive cylinder.
  2. Measure the diameter.
  3. Get an unclear result
    scr001

Actual results

Incorrect diameter measurement

Expected results

Сorrect diameter measurement.

p.s. In Bambustudio where did you get the measurement block, the diameter size is shown correctly
scr002

Project file & Debug log uploads

Cylinder.zip

Checklist of files to include

  • Log file
  • Project file

Anything else?

No response

@asp1972 asp1972 added the bug Something isn't working label Dec 14, 2024
@limited660
Copy link

Also seeing this on Windows 11, 2.3.0-dev build 658c4f0.

@LJKraus
Copy link

LJKraus commented Feb 8, 2025

Ditto, Windows 11, 2.3.0-dev, build 06c809c. Works correctly in 2.2.0.
Affects measurements of all curves, tubes, etc.
Measures very thin discs correctly - 0.02mm height, 100 mm diameter.

Diameter error grows with height of the cylinder:
dia 100mm, height 10 mm, measures 162.432mm
dia 100mm, height 25 mm, measures 335.261mm
dia 100mm, height 50 mm, measures 647.765mm
dia 100mm, height 100mm, measures 1283.900mm

@kvikindi
Copy link

kvikindi commented Feb 11, 2025

Similar issue seen here on linux mint debian, flatpak release 4d762c4, as well as Win 10 portable release f11eb34

edit
The flatpak version actually shows diameter value "0" for most cylinders, while the Win10 one seems to follow the weird pattern LJKraus has.

Still apparent in Windows (10) 2.3.0-beta build ae5d7ea
And the Linux Flatpak as well.

@LJKraus
Copy link

LJKraus commented Feb 21, 2025

Still broken
Windows 11
2.3.0 - beta build 2bba98d

@kvikindi
Copy link

kvikindi commented Feb 24, 2025

edit
I may be utterly wrong about this all, and the problem might even lie in /src/libslic3r/Measure... etc instead...
edit

Using my limited understanding of C++, with the help of Claude, and o3 mini, It seems that the culprit might be on line 123:

Vec2d TransformHelper::ndc_to_ss(const Vec3d &ndc, const std::array<int, 4> &viewport)
{
    const double half_w = 0.5 * double(viewport[2]);
    const double half_h = 0.5 * double(viewport[3]);
    return { half_w * ndc.x() + double(viewport[0]) + half_w, half_h * ndc.y() + double(viewport[1]) + half_h };
};

The implication here is that half_w is being added twice - once as part of the scaling (half_w * ndc.x()) and again at the end (+ half_w). This effectively doubles the transformation offset, leading to the consistent scaling factor you're seeing in the measurements (~11.5932x).

Vec2d TransformHelper::ndc_to_ss(const Vec3d &ndc, const std::array<int, 4> &viewport)
{
    const double half_w = 0.5 * double(viewport[2]);
    const double half_h = 0.5 * double(viewport[3]);
    // Remove the extra half_w/half_h offset at the end
    return { half_w * ndc.x() + double(viewport[0]), half_h * ndc.y() + double(viewport[1]) };
}

This modification should fix the scaling issue and return correct diameter measurements. The scaling factor of approximately 11.5932 that you're seeing is roughly 2π × 1.85, which suggests the extra offset was causing a geometric scaling effect in the measurement calculations.

Thus spoke AI.

I'd happily try and pummel through these code changes myself, but child minding and sleep deprivation is kicking in hard.

SoftFever pushed a commit that referenced this issue Feb 26, 2025
According to https://eigen.tuxfamily.org/dox/TopicPitfalls.html one
should just avoid using `auto` as the type of an Eigen expression.

This PR fixes most of them I could found in the project. There might be
cases that I missed, and I might update those later if I noticed.

This should prevent issues like #7741 and hopefully fix some mysterious
crashes happened inside Eigen calls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants