Showing posts with label STL. Show all posts
Showing posts with label STL. Show all posts

Wednesday, July 23, 2008

STL taking shape

Just a quick note tonight about my progress with STL export.  I spent some of this afternoon mocking up the export and it went just as easily as I expected.  I nearly finished the whole thing, just need to implement Trimmed Surface tessellation, which I think I can knock out tomorrow.  So, hopefully by end of day tomorrow, we will have nicely working STL output.  As soon as I can I will post a sample output file on the download page.  If you want to try it out tonight, from the Part Designer screen just press 'x' and output.stl will be written to the same directory as the Wildcat root directory.  Obviously, we will need to eventually get a proper window to choose an output file name etc.

One question for those that know STL.  The top level object in the STL file appears to be "solid", with facets below that.  It is very easy to generate multiple separate solid bodies in Wildcat, how should I handle this?  Can you have more than one "solid" in a single STL file?  Should the user have to select a single body in Wildcat?  If anyone knows, please post a comment.

Cheers,
   Graham

Monday, July 14, 2008

Argh, more topology

I am out the other side of a busy work week last week.  Sorry for not making many updates or posts; this week should be better.  Despite being out last week I continued to receive a lot of comments regarding RepRap and STL files.  I want to talk about that for a bit and then a quick update on what I am working on this week.

I have now been contacted by several people that are either directly or loosely affiliated with the RepRap project.  This project looks great and I am very very supportive of their objectives and approach.  They have been using Art of Illusion as the "CAD" package, but it really doesn't seem to be meeting many of their needs.  I believe that in due time Wildcat will be an ideal partner.  I say in due time because Wildcat is still quite limited in its modeling abilities, boolean operations being the biggest omission currently.

After a bit of education, I now realize that exporting a Wildcat model to an STL file will be quite easy.  I need to write one routine to fully tessellate trimmed surfaces and then write a routine to output an entire part into an STL formatted file.

Full tessellation of a trimmed surface can be difficult, but I think that I have an easy and efficient way to do it.  Wildcat can already generate tessellated NURBS surfaces, trimming textures, and bounding curves.  This is really all we need.  Here are the steps as I envision this algorithm:
  1. Generate tessellation of underlying NURBS surface
  2. Generate trimming texture
  3. Generate bounding curve points and place into triangle.c array and mark as boundary (if you are not familiar with triangle.c please see this - very fast Delaunay triangulator)
  4. Test every underlying surface point against the trim texture (basically do a quick reverse lookup to see if for a given [u,v] it is in the filled portion of the trim texture - if it is in the texture then add it to the "output" list and mark as interior
  5. Now we have a list of all tessellation points (either marked as boundary or interior) - pass this list to triangle.c and let it output the best triangulation.  And we are done!
Not too bad eh?  Should be very little code to write and should be at least moderately efficient.  There could be some complications in making sure that all of the surface-surface boundaries align nicely, but I think that I have ways of dealing with this.  This approach will also let Wildcat do nice LOD scaling on all types of surfaces.  Hopefully I can get this working in beta form in the later portion of this week.  Once this is done then all I have to do it write everything out to an STL file.  Then test, test, test.

So, what am I working on now?  As I mentioned last week, I really want to get topology working for Part Pad operations.  I continue to be amazed at how complex this is for such a conceptually simple operation (I am really not looking forward to topology for swept solids!).  I spent my downtime last week working on the algorithm and I am implementing it this week.  After a day of working on it, I am about half way done, but I have left the really tough part for last.  My brain is numb.  Working on STL output will serve as a good distraction.  Once this is done I can finally start working on some of the boolean routines.

Talk to you all tomorrow.  Cheers,
   Graham


Wednesday, July 9, 2008

I must be full of BS

My post yesterday highlighted how little I actually know.  I had a number of readers post comments pointing out that the STL format is not at all what I said.  Yes, it is the standard format for rapid prototyping, but no, it has nothing to do with taking thin slices.

After a bit more reading  (something I should have done before yesterday), I see now that the STL format only requires the tessellated surface geometry of the part itself, no sectioning.  There are very easy routines within Wildcat (see WCNurbsSurface::GenerateClientBuffers for example) that can already provide this (even to a nearly-arbitrary accuracy thanks to native 64-bit NURBS geometry).  Since trimmed NURBS surfaces are not actually fully tessellated for display it would require some work to get them to output triangles, but not too much.  I think that I could write that routine in a couple of days.

An outline of an STL exporter would look something like this:
  1. User generates part and executes exporter
  2. Query surfaces of the WCPart object to get list of surfaces
  3. Generate appropriately accurate tessellation for each surface (already includes normals for each triangle)
  4. Order output and write to file
It really should be that easy.  I think.  I was looking around online for documentation of the STL format and only came across one document that looked semi-official, here.  Is this still accurate?

If this is a priority for uses, I can move this up.  It would be way too cool to see parts from Wildcat.  Of course they will be very simple parts, but parts none the less.   Let me know.

Cheers,
   Graham

Tuesday, July 8, 2008

CAM and STL

I got an interesting comment yesterday with some discussion about one of the emerging low-cost rapid prototyping machines (www.reprap.org).  As with almost all RP machines this one takes input in the form of an STL file.  STL is a plain text format that defines each of the thin layers that compose the object.

Once I get basic Boolean operations running in Wildcat, it should be straightforward to generate STL files.  The basic approach is to intersect the model with a flat plane and get the intersection polygon.  Then move the plane up a bit and intersect again.  Repeat a lot.  So, should be easy, right?

As I mentioned before, I am very busy with my real job this week so I probably won't get much of a chance to work on Wildcat.  I am hoping to finalize the topology algorithm for Pad and then implement early next week.  We will have to see if that holds up.

Cheers,
   Graham