From e4aeba9421880f6c615662c34a5bdcc375e1b5db Mon Sep 17 00:00:00 2001 From: _ <_> Date: Sun, 13 May 2018 02:44:05 -0700 Subject: [PATCH] Added init and show for Meshes --- bindings/py3devil1.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/bindings/py3devil1.py b/bindings/py3devil1.py index 6554ed5..4a60930 100755 --- a/bindings/py3devil1.py +++ b/bindings/py3devil1.py @@ -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()