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

Basic cone generates bugged geometry #916

Open
MatthiasJ1 opened this issue Feb 27, 2025 · 4 comments
Open

Basic cone generates bugged geometry #916

MatthiasJ1 opened this issue Feb 27, 2025 · 4 comments
Labels
can't reproduce The problem can't be fully investigated as it isn't reproducable.

Comments

@MatthiasJ1
Copy link
Contributor

Cone(10, 0, 20)

Gives:
Image

@gumyr
Copy link
Owner

gumyr commented Mar 4, 2025

It seems like the problem may be in display and not in the object itself. If I do:

sections = [section(c, Plane.XY.offset(height)) for height in [8, 9, 9.5, 9.75]]

calculated_volume = pi * 10**2 * 20 / 3

print(calculated_volume, c.volume, abs(calculated_volume - c.
2094.3951023931954 2094.395102393195 4.547473508864641e-13

the volumes are the same and the sections look as follows:

Image

Any suggestion on how to isolate this to a build123d vs display problem?

@gumyr gumyr added the can't reproduce The problem can't be fully investigated as it isn't reproducable. label Mar 4, 2025
@gumyr gumyr added this to the Not Gating Release 1.0.0 milestone Mar 4, 2025
@snoyer
Copy link
Contributor

snoyer commented Mar 5, 2025

Any suggestion on how to isolate this to a build123d vs display problem?

F3D can open both .brep and .vtp files so you could compare the OCCT dump and the VTK conversion

from pathlib import Path
from build123d import Cone, export_brep
from build123d.vtk_tools import to_vtkpoly_string

cone = Cone(10, 0, 20)
export_brep(cone, "/tmp/cone.brep")
Path("/tmp/cone.vtp").write_text(to_vtkpoly_string(cone))

Triangulation looks ok on both .brep and .vtp files but they both show the same kind of issue near the tip which looks like it's due to the normals (not really sure what's up with that tho, F3D uses face normals from OCCT for the .brep, and the .vtp has normals computed by VTK on export via build123d).

On the build123d side, changing the FeatureAngle param to 90 seems to fix the tip artifact but the normals aren't smoothed as nicely everywhere

n_filter.SetFeatureAngle(360)

@gumyr
Copy link
Owner

gumyr commented Mar 5, 2025

When I "porcupine" the cone the normals all look good well into the zone that would have trouble:

Image

Does OCCT have some special logic when tessellating a cone to handle the tip? Maybe we're seeing an artifact of that.

@snoyer
Copy link
Contributor

snoyer commented Mar 5, 2025

Looks like the cone itself is fine but there's something going on when exporting through VTK.
For example, exporting to .vtp after changing the n_filter.SetFeatureAngle(360) line as mentioned in my earlier message I see (visualizing the Y-component of the normals because F3D doesn't do hedgehogs yet):

Image
Image
Image
Image
Image

with 360 (current default) and 180 there is a discontinuity at the tip and the reflection/highlight "bends" the same as in the original screenshot. With lower values this discontinuity goes away but the rest of the normals aren't as smooth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
can't reproduce The problem can't be fully investigated as it isn't reproducable.
Projects
None yet
Development

No branches or pull requests

3 participants