Skip to content

Commit

Permalink
read nml files using geo.read()
Browse files Browse the repository at this point in the history
  • Loading branch information
ratnani committed Nov 29, 2016
1 parent 40d5575 commit a7df79d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion caid-gui/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ def printViewer(self):
height = int(height)
glPixelStorei(GL_PACK_ALIGNMENT, 1)
data = glReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE)
image = Image.fromstring( "RGB", (width, height), data )
# image = Image.fromstring( "RGB", (width, height), data )
image = Image.frombytes( "RGB", (width, height), data )
image = image.transpose( Image.FLIP_TOP_BOTTOM)
image.save( filename, fmt )
self.statusbar.SetStatusText("Image has been saved in " + filename)
Expand Down
16 changes: 13 additions & 3 deletions caid/cad_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from numpy import linspace
from igakit.nurbs import NURBS
from .op_nurbs import opNURBS
from .io import XML, TXT
from .io import XML, TXT, NML
import sys
from caid.core import bspline as bsplinelib

Expand Down Expand Up @@ -1114,8 +1114,8 @@ def __init__(self, file, mode="r"):
print("cad_io : mode must be r or w")
raise

if self.__format__ not in ["xml","zip","txt"]:
print("cad_io : format must be xml, zip or txt")
if self.__format__ not in ["xml","zip","txt", "nml"]:
print("cad_io : format must be xml, nml, zip or txt")
raise

def read(self, geo):
Expand Down Expand Up @@ -1144,6 +1144,16 @@ def read(self, geo):
print("Unexpected error:", sys.exc_info()[0])
raise

if self.__format__=="nml":
try:
rw = NML()
return rw.read(self.__filename__, geo)
except IOError as e:
print("I/O error({0}): {1}".format(e.errno, e.strerror))
except:
print("Unexpected error:", sys.exc_info()[0])
raise

def write(self, geo):
"""
Write the given cad_geometry geo
Expand Down

0 comments on commit a7df79d

Please sign in to comment.