def writeGTS(fn, coords, edges, faces): """Write a mesh of triangles to a file in GTS format. Parameters: - `fn`: file name, by preference ending on '.gts' - `coords`: float array with shape (ncoords,3), with the coordinates of `ncoords` vertices - `edges`: int array with shape (nedges,2), with the definition of `nedges` edges in function of the vertex indices - `faces`: int array with shape (nfaces,3), with the definition of `nfaces` triangles in function of the edge indices """ if coords.dtype.kind != 'f' or coords.ndim != 2 or coords.shape[ 1] != 3 or edges.dtype.kind != 'i' or edges.ndim != 2 or edges.shape[ 1] != 2 or faces.dtype.kind != 'i' or faces.ndim != 2 or faces.shape[ 1] != 3: raise RuntimeError("Invalid type or shape of argument(s)") fil = open(fn, 'w') fil.write("%d %d %d\n" % (coords.shape[0], edges.shape[0], faces.shape[0])) writeData(fil, coords, fmt='%f ') writeData(fil, edges + 1, fmt='%i ') writeData(fil, faces + 1, fmt='%i ') fil.write("#GTS file written by %s\n" % pf.Version()) fil.close()
def fmtHeadingComm(text=''): """Format the heading of the Code Aster command file (.comm).""" out = """# # Code Aster command file created by %s (%s) # %s """ % (pf.Version(), pf.Url, text) return out
def fmtHeadingMesh(text=''): """Format the heading of the Code Aster mesh file (.mail).""" out = """TITRE Code Aster mail file created by %s (%s) %s FINSF """ % (pf.Version(), pf.Url, text) return out
def about(): """Display short information about pyFormex.""" version = pf.Version() draw.showInfo(""".. %s %s A tool for generating, manipulating and transforming 3D geometrical models by sequences of mathematical operations. %s Distributed under the GNU GPL version 3 or later """ % (version, '=' * len(version), pf.Copyright))
def initialize(): """Initialize the image module.""" global image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps, gl2ps, _producer, _gl2ps_types # Find interesting supporting software utils.hasExternal('imagemagick') # Set some globals pf.debug("Loading Image Formats", pf.DEBUG.IMAGE) image_formats_qt = [ str(f) for f in QtGui.QImageWriter.supportedImageFormats() ] image_formats_qtr = [ str(f) for f in QtGui.QImageReader.supportedImageFormats() ] ## if pf.cfg.get('imagesfromeps',False): ## pf.image_formats_qt = [] if utils.hasModule('gl2ps'): import gl2ps _producer = pf.Version() + ' (%s)' % pf.cfg.get('help/website', '') _gl2ps_types = { 'ps': gl2ps.GL2PS_PS, 'eps': gl2ps.GL2PS_EPS, 'tex': gl2ps.GL2PS_TEX, 'pdf': gl2ps.GL2PS_PDF, } if utils.checkVersion('gl2ps', '1.03') >= 0: _gl2ps_types.update({ 'svg': gl2ps.GL2PS_SVG, 'pgf': gl2ps.GL2PS_PGF, }) image_formats_gl2ps = _gl2ps_types.keys() image_formats_fromeps = [ 'ppm', 'png', 'jpeg', 'rast', 'tiff', 'xwd', 'y4m' ] pf.debug( """ Qt image types for saving: %s Qt image types for input: %s gl2ps image types: %s image types converted from EPS: %s""" % (image_formats_qt, image_formats_qtr, image_formats_gl2ps, image_formats_fromeps), pf.DEBUG.IMAGE | pf.DEBUG.INFO)
def __init__(self, name=_name_, datasize={'U': 3, 'S': 6, 'COORD': 3}): self.name = name self.datasize = datasize.copy() self.about = { 'creator': pf.Version(), 'created': pf.StartTime, } self.modeldone = False self.labels = {} self.nelems = 0 self.nnodes = 0 self.dofs = None self.displ = None self.nodid = None self.nodes = None self.elems = None self.nset = None self.nsetkey = None self.eset = None self.res = None self.hdr = None self.nodnr = 0 self.elnr = 0
def __init__(self, filename): self.file = open(filename, 'w') self.file.write("# .obj file written by %s\n" % pf.Version())