def LoadSurfaceWithList(fn, workplane):
    class Wrapper:
        def __init__(self, fssurf, workplane):
            if workplane:
                self.fs = STLTools.FacetTrans(workplane, fssurf)
            else:
                self.fs = fssurf
            self.trialist = []

        def PushTriangle(self, x0, y0, z0, x1, y1, z1, x2, y2, z2):
            self.trialist.append((x0, y0, z0, x1, y1, z1, x2, y2, z2))
            self.fs.PushTriangle(x0, y0, z0, x1, y1, z1, x2, y2, z2)

    fssurf = fsp.FsSurf.New()  # surface object
    w = Wrapper(fssurf, workplane)

    # read STL file and call PushTriangle (method in fssurf) for each triangle
    r = STLTools.reader(fn)
    fl = open(fn, r.isascii and "r" or "rb")
    try:
        if r.isascii:
            r.AsciiReadFacets(fl, w)
        else:
            r.BinaryReadFacets(fl, w)
    except:
        sys.stderr.write("Failed to read STL file: %s" % fn)
        fl.close()
        return
    fl.close()

    fssurf.Build(1.0)  # build surface boxing
    return (fssurf, w.trialist)
def LoadSurfaceWithList(fn, workplane):
    class Wrapper:
        def __init__(self, fssurf, workplane):
            if workplane:
                self.fs = STLTools.FacetTrans(workplane, fssurf)
            else:
                self.fs = fssurf
            self.trialist = []

        def PushTriangle(self, x0, y0, z0, x1, y1, z1, x2, y2, z2):
            self.trialist.append((x0, y0, z0, x1, y1, z1, x2, y2, z2))
            self.fs.PushTriangle(x0, y0, z0, x1, y1, z1, x2, y2, z2)

    fssurf = fsp.FsSurf.New()  # surface object
    w = Wrapper(fssurf, workplane)

    # read STL file and call PushTriangle (method in fssurf) for each triangle
    r = STLTools.reader(fn)
    fl = open(fn, r.isascii and "r" or "rb")
    try:
        if r.isascii:
            r.AsciiReadFacets(fl, w)
        else:
            r.BinaryReadFacets(fl, w)
    except:
        sys.stderr.write("Failed to read STL file: %s" % fn)
        fl.close()
        return
    fl.close()

    fssurf.Build(1.0)  # build surface boxing
    return (fssurf, w.trialist)
def LoadSurface(fn, workplane):
    fssurf = fsp.FsSurf.New()  # surface object

    # read STL file and call PushTriangle (method in fssurf) for each triangle
    r = STLTools.reader(fn)
    if workplane:
        fs = STLTools.FacetTrans(workplane, fssurf)
    else:
        fs = fssurf

    fl = open(fn, r.isascii and "r" or "rb")
    try:
        if r.isascii:
            r.AsciiReadFacets(fl, fs)
        else:
            r.BinaryReadFacets(fl, fs)
    except:
        sys.stderr.write("Failed to read STL file: %s" % fn)
        fl.close()
        return
    fl.close()

    fssurf.Build(1.0)  # build surface boxing
    return fssurf
def LoadSurface(fn, workplane):
    fssurf = fsp.FsSurf.New()  # surface object

    # read STL file and call PushTriangle (method in fssurf) for each triangle
    r = STLTools.reader(fn)
    if workplane:
        fs = STLTools.FacetTrans(workplane, fssurf)
    else:
        fs = fssurf

    fl = open(fn, r.isascii and "r" or "rb")
    try:
        if r.isascii:
            r.AsciiReadFacets(fl, fs)
        else:
            r.BinaryReadFacets(fl, fs)
    except:
        sys.stderr.write("Failed to read STL file: %s" % fn)
        fl.close()
        return
    fl.close()

    fssurf.Build(1.0)  # build surface boxing
    return fssurf
 def __init__(self, fssurf, workplane):
     if workplane:
         self.fs = STLTools.FacetTrans(workplane, fssurf)
     else:
         self.fs = fssurf
     self.trialist = []