PDA

View Full Version : Tool path generation based on offset surface ?



HaVyThoai
12-13-2007, 03:58 AM
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

http://www.ugs.pl/images/un_nx3/nx17.jpg

ZbuffeR
12-13-2007, 05:56 AM
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

-NiCo-
12-13-2007, 06:55 AM
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.

ZbuffeR
12-13-2007, 10:14 AM
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.

HaVyThoai
12-13-2007, 08:03 PM
thanks every body :) ,

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 !

oc2k1
12-14-2007, 07:43 AM
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.

HaVyThoai
12-15-2007, 03:30 AM
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.

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 :( http://www.anderswallin.net/wp-content/2007_08dropcutter/dropcutter.png

-NiCo-
12-15-2007, 08:24 AM
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 (http://www.esat.kuleuven.be/~ncorneli/toolpath.zip).

http://www.esat.kuleuven.be/~ncorneli/toolpath.jpg

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.

-NiCo-
12-15-2007, 08:57 AM
@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.

HaVyThoai
12-15-2007, 12:23 PM
Dear -NiCo- ,

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

thank you again.

-NiCo-
12-15-2007, 02:09 PM
You can find a GLSL tutorial here (http://www.lighthouse3d.com/opengl/glsl/). Enjoy :)

N.

ZbuffeR
12-15-2007, 03:04 PM
@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?
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.