# Path: orbkit/grid.py
# def grid_init(is_vector=False, force=False):
# def get_grid(start='\t'):
# def tolist():
# def todict():
# def get_shape():
# def set_grid(xnew,ynew,znew,is_vector):
# def set_boundaries(is_regular,Nx=None,Ny=None,Nz=None):
# def get_bbox():
# def grid2vector():
# def vector2grid(Nx,Ny,Nz):
# def matrix_grid2vector(matrix): 
# def matrix_vector2grid(matrix,Nx=None,Ny=None,Nz=None): 
# def mv2g(**kwargs):
# def grid_sym_op(symop):
# def grid_translate(dx,dy,dz):
# def rot(ang,axis):
# def reflect(plane):
# def inversion():
# def sph2cart_vector(r,theta,phi):
# def cyl2cart_vector(r,phi,zed):
# def random_grid(geo_spec,N=1e6,scale=0.5):
# def read(filename, comment='#'):
#   def check(i, is_vector):
# def adjust_to_geo(qc,extend=5.0,step=0.1):
# def check_atom_select(atom,geo_info,geo_spec,interactive=True,
#                       display=sys.stdout.write):
# def center_grid(ac,display=sys.stdout.write):
# def reset_grid():
#   N_ = [len(x),len(y),len(z)]
#     N_ = [Nx,Ny,Nz]
#   P=[numpy.zeros((3,1)), numpy.reshape(ac,(3,1))]
#   N_   = [len(grid[0]), len(grid[1]), len(grid[2])]
#   N_   = [ 101,  101,  101]
# N_   = [ 101,  101,  101]   #: Specifies the number of grid points (regular grid).


import gzip
import numpy
from orbkit import grid
from skimage import measure

def obj_creator(data,filename,geo_info,geo_spec,iso=(-0.01,0.01),**kwargs):
  '''Creates a plain text 3D surface file (obj). 
  
  **Parameters:**
  
  data : numpy.ndarray, shape=N
    Contains the output data.
  filename : str
    Contains the base name of the output file.
  geo_info, geo_spec : 
    See :ref:`Central Variables` for details.
  iso : tuple
    Specifies the isovalue for negative and posititve surfaces, respectively.
  '''
  # Shape shall be (Ndrv,Ndata,Nx,Ny,Nz) or (Ndrv,Ndata,Nxyz)
  data = numpy.array(data)
  dims = 3
  ndim = data.ndim
  shape = data.shape
    
  if data.ndim < dims:
    raise AssertionError('data.ndim < ndim of grid')
  if data.ndim > dims + 1:
    raise AssertionError('data.ndim > (ndim of grid) +2')


# Path: orbkit/grid.py
# def grid_init(is_vector=False, force=False):
# def get_grid(start='\t'):
# def tolist():
# def todict():
# def get_shape():
# def set_grid(xnew,ynew,znew,is_vector):
# def set_boundaries(is_regular,Nx=None,Ny=None,Nz=None):
# def get_bbox():
# def grid2vector():
# def vector2grid(Nx,Ny,Nz):
# def matrix_grid2vector(matrix): 
# def matrix_vector2grid(matrix,Nx=None,Ny=None,Nz=None): 
# def mv2g(**kwargs):
# def grid_sym_op(symop):
# def grid_translate(dx,dy,dz):
# def rot(ang,axis):
# def reflect(plane):
# def inversion():
# def sph2cart_vector(r,theta,phi):
# def cyl2cart_vector(r,phi,zed):
# def random_grid(geo_spec,N=1e6,scale=0.5):
# def read(filename, comment='#'):
#   def check(i, is_vector):
# def adjust_to_geo(qc,extend=5.0,step=0.1):
# def check_atom_select(atom,geo_info,geo_spec,interactive=True,
#                       display=sys.stdout.write):
# def center_grid(ac,display=sys.stdout.write):
# def reset_grid():
#   N_ = [len(x),len(y),len(z)]
#     N_ = [Nx,Ny,Nz]
#   P=[numpy.zeros((3,1)), numpy.reshape(ac,(3,1))]
#   N_   = [len(grid[0]), len(grid[1]), len(grid[2])]
#   N_   = [ 101,  101,  101]
# N_   = [ 101,  101,  101]   #: Specifies the number of grid points (regular grid).


# Path: orbkit/output/obj.py
import gzip
import numpy
from orbkit import grid
from skimage import measure


def obj_creator(data,filename,geo_info,geo_spec,iso=(-0.01,0.01),**kwargs):
  '''Creates a plain text 3D surface file (obj). 
  
  **Parameters:**
  
  data : numpy.ndarray, shape=N
    Contains the output data.
  filename : str
    Contains the base name of the output file.
  geo_info, geo_spec : 
    See :ref:`Central Variables` for details.
  iso : tuple
    Specifies the isovalue for negative and posititve surfaces, respectively.
  '''
  # Shape shall be (Ndrv,Ndata,Nx,Ny,Nz) or (Ndrv,Ndata,Nxyz)
  data = numpy.array(data)
  dims = 3
  ndim = data.ndim
  shape = data.shape
    
  if data.ndim < dims:
    raise AssertionError('data.ndim < ndim of grid')
  if data.ndim > dims + 1:
    raise AssertionError('data.ndim > (ndim of grid) +2')


  if shape != tuple(grid.N_):