Is There A 500 Element Limit?

Discussion in 'ShapeJS' started by skwirrel, Mar 15, 2017.

  1. skwirrel
    skwirrel Member
    Hi There,

    I'm trying to use shapeJS to render a model which I have built using my own software (see https://www.npmjs.com/package/frameworx ). I have modified my code so that it outputs a dataset consisting of the start and end points of a series of "sticks". Then some ShapeJS code parses this data and adds a cylinder for each stick.

    This works fine (very well in fact) in shapeJS up to 500 sticks. Then when I add the 501st stick the preview box just shows a spinner and nothing happens. Trying to upload a large file just results in it hanging on the "Creating your custom 3D model file." page

    There isn't really any sign of a gradual slow down - it works fine up to 500 then just stops working completely. This feels to me like a limit coded in somewhere (deliberately or perhaps not)

    Does anyone know if this ought to work?

    Ben

    I tried to attach the file to this post (as .txt) but the upload wasn't working (uploaded but nothing happened) so I've pasted it below.
    ... oh... that doesn't work either (message too long) so here's a dropbox link...
    https://www.dropbox.com/s/s9vvytqg82yn21f/bracelet.shape.js?dl=0
     
  2. mkroeker
    mkroeker Well-Known Member
    Depending on the default cylinder complexity you may have scored an indirect hit on the 1 million triangle limit.
     
  3. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    There is not a limit by design, but you've found one anyway. Two factors here. One you've found the maximum local memory on the graphics cards we are using at 500 datasources. Wasn't something we were aware of so we'll need to see if we can optimize that. The second issue is that each datasource takes about 3ms to render so your clocking around a 1500ms render time right now. We have an answer for that soon called thin layer data source which will bake all those datasources into one for faster rendering but it would likely still need to render the first time.
     
    AMoors likes this.
  4. skwirrel
    skwirrel Member
    Thanks for the detailed response Alan.

    I was hoping that ShapeJS might be the answer to my CSG->mesh conversion woes but looks like it isn't - or not just yet, and not for such complex models at least.

    The challenge I'm facing is in converting my complex models which I generate essentially as CSG (basically a lot of cylinders and spheres) into something I can upload to Shapeways without hitting the face or file size limit.

    The best I have managed so far is either converting each CSG object to a mesh not bothering to do the unions at all (which has generally worked very well but can only do unions not subtractions), or a tweaked version of BRL-CAD (tweaked so it doesn't just give up when it finds things it doesn't like). BRL-CAD does a really good job of handling the boolean unions (and subtractions, intersections) and generates a very clean single mesh object but it takes _forever_ (6-8 hours for my 4000 object model).

    Is there anything you can suggest for uploading complex (multi-thousand elements) CSG models?

    Despite these challenges (which are inevitable with any emerging technology) I continue to be amazed by the quality and service from Shapeways - keep up the good work!

    P.S.
    In my research I stumbled across this which looked pretty cool - going from CSG to slicer totally skipping the mesh model...
    https://members.loria.fr/Sylvain.Lefebvre/icesl/icesl-whitepaper.pdf
     
    AMoors likes this.
  5. AlanHudson
    AlanHudson Shapeways Employee Dev Team
    Couple of thoughts.

    Using cubes instead of cylinders would help the triangle count. But yea it's going to get big regardless.

    In terms of using ShapeJS you could do it in passes. Seems like around 400 cylinders is near our limits right now. So you could output multiple files of 400 points and union those together and export as stl. Then use the ModelLoader to load the sub stl files together into one final mesh. Then you'll need to play with the voxel size or mesh decimation params to keep the final mesh below our upload limits.

    Sadly we can't use slicer level tricks as not all our printers use slicers.
     
    AMoors likes this.
  6. mkroeker
    mkroeker Well-Known Member
    Two hackish things I have done in the past for similar ball-and-stick models:
    1. create a WRL file using the VRML primitives "sphere" and "cylinder", then use the free but closed-source "meshconv" program to convert it to STL - it lets you specify the desired complexity of sphere and cylinder to avoid the 1m triangle limit and is quite fast
    or
    2. create an input file for the free OpenSCAD program (again using the provided primitives for sphere and cylinder, and again with the option to specify the desired tesselation level) and export to STL from there

    A drawback of (2) is that it uses the CGAL library, which can be extremely slow and memory-hungry in some cases
     
    AMoors likes this.
  7. skwirrel
    skwirrel Member
    Thanks Alan and Mkroeker for the pointers. I'll give the routes a go.

    It's kind of good to know that I'm not doing missing anything obvious.
     
    AMoors likes this.