rsheldiii / KeyV2

KeyV2: A Parametric Mechanical Keycap Library
GNU General Public License v3.0
1.41k stars 180 forks source link

Error using `sa_row(1) key();` #207

Open archonoff opened 3 months ago

archonoff commented 3 months ago

I'm currently learning how to use the KeyV2 project and have encountered some unexpected errors that I can't figure out.

For example, when I input sa_row(2) key(); into keys.scad and press F6, I successfully get the key rendered. However, changing it to sa_row(1) key(); results in the following error and no key is rendered:

ERROR: CGAL error in CGALUtils::applyUnion3D: CGAL ERROR: assertion violation!
Expr: G.mark(v1,0)==G.mark(v2,0)&& G.mark(v1,1)==G.mark(v2,1)
File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_S2/SM_overlayer.h
Line: 294

image

Interestingly, modifying the code to sa_row(1) 2u() key(); still results in errors:

ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation!
Expr: e_below != SHalfedge_handle()
File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_FM_decorator.h
Line: 418
ERROR: CGAL error in CGAL_Nef_polyhedron3(): CGAL ERROR: assertion violation!
Expr: e_below != SHalfedge_handle()
File: /mxe/usr/x86_64-w64-mingw32.static.posix/include/CGAL/Nef_3/SNC_FM_decorator.h
Line: 418

However, in this case, the key is at least rendered. image

Could anyone help me understand what I might be missing?

Additionally, here's another example that demonstrates a similar issue I'm facing. I'm attempting to render keys with various profiles using the following code:

for (x = [0:1:4]) {
  translate_u(0,-x) oem_row(x) key();
}
for (x = [0:1:4]) {
  translate_u(1,-x) cherry_row(x) key();
}
for (x = [0:1:4]) {
  translate_u(2,-x) sa_row(x) key();
}
for (x = [0:1:4]) {
  translate_u(3,-x) dcs_row(x) key();
}
for (x = [0:1:4]) {
  translate_u(4,-x) mt3_row(x) key();
}

The result should display a series of keys with OEM, Cherry, SA, MT3, and DCS profiles. However, while the OEM, Cherry, and DCS profiles render as expected, only two keys for the SA profile are rendered correctly. And for the MT3 profile one key is missing and most of the rendered ones are floating above the ground plane. image image

This issue seems to specifically affect the SA and MT3 profiles rendering under certain conditions, similar to the previous error I mentioned. Could this be related, or is there another explanation?

I use OpenSCAD-2024.03.23 64bit on Windows 11

cmandlbaur commented 2 months ago

I was trying to get the SA profiles working and ran into the same issue.

What helped me was setting $hull_shape_type = "skin"; before generating any of the keys. Found the details in the TIPS_AND_TRICKS.md file.

cmandlbaur commented 2 months ago

Actually looks like that gets them to render, but geometry is deformed in the corners.

cmandlbaur commented 2 months ago

Did a bit of digging and found - https://github.com/openscad/openscad/issues/4313

Last comment mentions using manifold fixes the error.

In preferences > features, enable manifold.

That seems to have solved it for me.