The Shell File (SHL) is used for describing 3D solids and surfaces as a combination of points, and face indices into that point list. The standard format is:
PointCount, FaceCount X_0, Z_0, Y_0 X_1, Z_1, Y_1 ... X_n, Z_n, Y_n F0 F1 ... Fn
where X_n, Z_n and Y_n are points and Fn is an face index into the point list. The point list and face list follow the standard definitions defined in the grail.ag's Standard Definitions section.
If used with the grail.mstype module, you will be able to read/write binary data without converting it to a python structure.
The following snippet illustrates how to read from a SHL file,
At this point the point_list and face_list contain the standard point and face lists as defined in the grail.ag module's Standard Definitions.
An example of writing the contents would be as follows,
If the grail.mstype module is active, then the read/write operations will occur without converting the data to Python objects, if and only if you don't access the contents of the point list and face list.
open(path [,mode])
Opens a file at the given path. The mode can be either "r" for read-only or "w" for write-only. If you want to create a new file use the "w" option. Using the
If you are attempting to open a file in "r" mode and it does not exist, an IOError is generated.
ShlFile
Use the open function to load/create a ShlFile object. For the most part this object behaves as a regular file like object in Python.
Methods
close()
This closes the file handle to the object. If you fail to close the file explicitly, the file will be closed implicitly when object falls out of scope.read_shell()
Returns a Point List and Face List tuple as defined by the standard point and face lists in the grail.ag module's Standard Definitions.write_shell(point_list, face_list)
Accepts a point_list and face_list as defined by the standard point and face lists in the grail.ag module's Standard Definitions.Attributes
mode
Read-only. Indicates the mode that the file is in. For example this would be "w" (write-only) or "r" (read-only).name
This is the path to the file.closed
Is True when the object has been closed.