forked from CRBS/PyIMOD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImodContour.py
More file actions
executable file
·34 lines (29 loc) · 982 Bytes
/
ImodContour.py
File metadata and controls
executable file
·34 lines (29 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import struct
class ImodContour(object):
def __init__(self,
fid = None,
nPoints = 0,
flags = 0,
type = 0,
iSurface = 0,
points = [],
pointSizes = [],
**kwargs):
self.__dict__.update(kwargs)
self.__dict__.update(locals())
if self.fid:
self.read_file()
def read_file(self):
fid = self.fid
self.nPoints = struct.unpack('>l', fid.read(4))[0]
self.flags = struct.unpack('>l', fid.read(4))[0]
self.type = struct.unpack('>l', fid.read(4))[0]
self.iSurface = struct.unpack('>l', fid.read(4))[0]
self.points = struct.unpack('>{0}f'.format(3 * self.nPoints),
fid.read(12 * self.nPoints))
return self
def dump(self):
from collections import OrderedDict as od
for key, value in od(sorted(self.__dict__.items())).iteritems():
print key, value
print "\n"