Tool path generation based on offset surface ?

Dear everybody,

I am doing NC Machining simulation. I have successfully generated an offset surface by a specified distance (a STL model). The problem I got in that I want draw lines around any model that fit the shape of model.

Is there any ideal or any similiar example ? please help me

For a case similar to your example images, I would do this :

preprocess step, do do only once, hidden from the user (simple way: right after, glclear and no swapbuffers, or better way: do it on a FBO) :

  • render offset surface, from above, with an orthographic view
  • read depth values, along lines

then, display step for each frame :

  • render blue object
  • render lines using depth values stored from above

Here’s what I would do:

  • Create a black alpha texture with white lines along the x-direction at regular intervals in the y-direction.

  • Align the alpha texture to the blue rectangle in your example images.

  • Enable blending so that your filled mesh values get multiplied with the alpha texture values and you get lines as a result.

You can just draw one white line in the black alpha texture, set the texture coordinate wrapping mode to repeat and play with the texture coordinates to get a more sparse/dense displaying of these virtual lines without having to recompute the actual lines.

PS. You can also do this easily in fragment shaders without the need for an alpha texture.

N.

Nico’s method is much simpler, but you may have artefacts when multiple layers of line overlap, such as between the cylinder an the cube in the top image.

thanks every body :slight_smile: ,

I’ll try. My idea is creat a plane of lines, then project it on the surface, but I don’t know how to project it? (maybe use a Texture mapping ?? )

after creating toolpath, the cutter will move on it !

If the machine has 3 axis. A possible solution would be to render the the object from the top into a heightmap. The next step should be to filter the heightmap with a filter kernel that describes the cutter. The kernel is a smaller heightmap from the cutters bottom side. The lowest distance have to be written into the output texture. The result can be used as Z value for the cutter for a given (X,Y) position.

Dear -NiCo-,[/b]

You have any tutorials about creating an alpha texture? or any code that similiar this. I’m not good at texture mapping

this is exactly what I want :frowning:

I’ve written a small program for you that uses GLSL shaders to do what you need without having to create/use alpha maps. You can download it here.

Use the f/F and r/R keys to change the fraction and repeat values.
Change vpos.y in toolpath.frag to vpos.x or vpos.z in order to change the orientation of the lines.

This tool requires the original mesh and the offset mesh. I’m assuming that you’re already able to create this offset mesh. If not, you can take a look at implicit surfaces e.g. using radial basis functions. With implicit surfaces it is fairly easy to generate an offset mesh, you only need the mesh vertices end their corresponding normals to create an implicit function.

Hope this helps,
N.

@ZbuffeR: I’m not sure what you meant with the artefacts. But if it is what I think you meant, that shouldn’t be a problem if you enable alpha testing, right?

There is one artefact however. Each of the lines represent a slice, so if a mesh triangle coincides with a slice it will be colored completely e.g. it’s possible that a cube face will be fully colored instead of just a line.

N.

Dear -NiCo- ,

I’m very thankful for your help. But I completely don’t have knowledge of GLSL shaders :slight_smile: , I’ve just learned OpenGL for 2 months.

thank you again.

You can find a GLSL tutorial here. Enjoy :slight_smile:

N.

You are right. I only thought about alpha blending, and overlooked alpha test.

There is one artefact however. Each of the lines represent a slice, so if a mesh triangle coincides with a slice it will be colored completely e.g. it’s possible that a cube face will be fully colored instead of just a line.

That is why I think the best is to reconstruct real lines from the reading the depth of offset surface. But it may be more difficult to program, and slower too.