Added init and show for Meshes

This commit is contained in:
_ 2018-05-13 02:44:05 -07:00
parent 49a3c8f0b7
commit e4aeba9421

View File

@ -333,6 +333,31 @@ class MEShHeader:
def show(self):
devil1geo.printmeshheader(self.cstruct)
def getbatchno(self):
return self.cstruct.contents.numBatch
class MEsh:
def __init__(self, i, filedata):
self.cstruct = Mesh()
if filedata:
mh = MEShHeader(i, filedata)
# allocate memory for the size of batch * number of batches
memsize = ctypes.sizeof(Batch) * mh.getbatchno()
self.cstruct.b = ctypes.cast(ctypes.create_string_buffer(memsize),
ctypes.POINTER(Batch))
if not devil1geo.getmesh(ctypes.byref(self.cstruct),
i,
filedata,
len(filedata)):
print("failed to get mesh")
return
def show(self):
if self.cstruct.b:
devil1geo.printbatch(self.cstruct.b)
else:
print("nothing to show")
#--------------------------------------+
# Regular Python
#--------------------------------------+
@ -418,7 +443,8 @@ if __name__ == "__main__":
gh.show()
mh = MEShHeader(3, data)
mh.show()
m = MEsh(0, data)
m.show()
#---------------------------------------+
# main()
mainx()