fgebhart / mapa

Create 3d-printable STLs from satellite 🌍 elevation data
MIT License
25 stars 4 forks source link

Bug: bottom surface not connected #50

Closed sevenoffline closed 2 years ago

sevenoffline commented 2 years ago

The generated model's bottom surface has two flaws:

  1. It is not connected to the side walls so those edges down there are all open. This was reported in the slicer and I verified it in an 3D-tool.
  2. It is not triangulated properly (only once into two triangles): all those edges coming down the side walls from the top relief end and are not continued further to e.g. a center vertex. This results in two massive n-gons the bottom surface is made of.

Maybe these two issues are related?

sevenoffline commented 2 years ago

To further clarify what I'm trying to express, here a picture to illustrate: https://imgur.com/a/4ei2K9s

fgebhart commented 2 years ago

Thanks for adding the screenshots. I still need to need to investigate this. Is there any free mesh analyzing tool you would recommend (for unix systems?).

sevenoffline commented 2 years ago

I'm only familiar with 3D on Win, unfortunately. But Blender should be more than capable to show & filter edgeflow and open edges.

Sidenote: maybe not the most economical approach but how about duplicating the top relief, moving it downwards by the z-offset value, flatten it and create the side walls by connecting the (same numbered) edge-vertices?

fgebhart commented 2 years ago

how about duplicating the top relief, moving it downwards by the z-offset value, flatten it and create the side walls by connecting the (same numbered) edge-vertices?

Yes, I do basically have the top relief already at hand before even "extruding the 3d shape". Thus I could simply copy that and put it to z=0. However, that will likely blow up the STL file in size, as it almost duplicates the number of triangles.

Originally I simply went with only 2 triangles for the button surface and I still wonder why this is okay for two sides of the model but not for the other two. :thinking:

sevenoffline commented 2 years ago

Well, right now all four sides are connected to the top relief! But no side is connected to the bottom - maybe because it's only made of only two triangles?! Is it possible to create one center vertex on the bottom surface and connect all side-vertices with that one? That would result in the most efficient triangulation possible for the bottom side.

fgebhart commented 2 years ago

Ah, from your image reading "GOOD" I assumed two sides are in fact connected to the bottom.

Unfortunately the STL file format does not have such thing as "connect to". It consists of triangles, which consist of coordinates only. With that I assume having the same number of triangles in the bottom as in the top relief is the way forward for solving this issue.

fgebhart commented 2 years ago

Ok, I am able to verify the bottom not being closed with any of the sides using blender. Orange highlighted are open connections:

Screenshot from 2022-04-01 11-03-26

sevenoffline commented 2 years ago

See? So if all polygons have to be triangles, those edges coming down the sides must be connected to some vertex on the bottom side (like the typical cylinder-primitive).

fgebhart commented 2 years ago

I gave duplicating the top mesh a try. Unsurprisingly it does double the size of the STL file. Even though the implementation is rather straight forward and easy to maintain I don't like the solution. A laptop with 8GB ram quickly comes into out of memory issues when post processing files of a few hundreds of MB in blender.

Which is why I'm looking for a more efficient way to construct the bottom side with less triangles. Did a quick sketch and think I found something. It also seems to work with rectangles :slightly_smiling_face:

2022-04-01 21 39 54

However, still need to find a performant implementation.

fgebhart commented 2 years ago

Just putting this here for future reference:

Plot of the bottom triangles:

Screenshot 2022-04-05 at 21 37 43

Created using branch: https://github.com/fgebhart/mapa/tree/plot_bottom_triangulation

fgebhart commented 2 years ago

The issue should be fixed by https://github.com/fgebhart/mapa/pull/53 and https://github.com/fgebhart/mapa/pull/55.

However, a new mapa version is not yet released and not integration into the streamlit app. Should be done soon, though.

fgebhart commented 2 years ago

Have released mapa v0.8.0 and rolled the changes out in mapa-streamlit v0.6.0.

-> check it out as usual here 🎈

Let me know if there are still issues with unclosed connections between triangles.

sevenoffline commented 2 years ago

Perfect! Flawless, great job!