Online3DViewer icon indicating copy to clipboard operation
Online3DViewer copied to clipboard

implement a geometry slicer

Open yvanblanchard opened this issue 2 years ago • 1 comments

Hello,

I would like to implement a mesh slicer (C++ library) and visualize results with your website viewer.

I would like to:

  • call the slicer (C++ lib) from website dialog control (button)
  • display slices (polygon contours) ; with a slider control, for progressive display
  • display infill path points ; with a slider control, for progressive display NB: I expect the slicer (C++ lib) to run on a remote server, for performances reason (what do you think?).

Could you please tell me the rough (best) methodology to follow, using your code architecture ? Thank you very much.

yvanblanchard avatar May 29 '22 14:05 yvanblanchard

There are two options for clipping.

1. Doing view-only clipping

In this case the goal is to visualize slicing without touching the model (slicing won't affect export and calculations).

It's pretty easy to do the slicing with three.js using material clipping planes. The complexity here lies in drawing the infills, but there are also solutions for that. See this discussion or this repository for great examples.

2. Actually cut the model

In this case the goal is to really cut the model by the plane, and create a new model from the result (so it will affect export and calculations).

The cut can be done easily, but generating the infill polygons can be really tricky. Since the models are represented as a bunch of triangles, it's not trivial to build a data structure that allows you to calculate the infills. I don't think that C++ would introduce a lot of performance gain, I would go with JavaScript, but of course compiling C++ to WebAssembly can be an option, too.

Also, this solution would introduce the concept model editing in the viewer, and at the moment there are no best practices for this. It raises a lot of questions that are hard to answer, and even harder to implement.

Summary

I would go with the first (view-only) solution, I don't see at the moment how the second solution would fit in the mindset and the architecture of the website.

kovacsv avatar May 29 '22 14:05 kovacsv