# Path: ldif/util/base_util.py
# ENVIRONMENT = 'EXTERNAL'
#   FS = StandardFileSystem()
#   LOG = SimpleLog()
# class FileSystem(abc.ABC):
# class StandardFileSystem(FileSystem):
# class Log(abc.ABC):
# class SimpleLog(Log):
#   def open(self, filename, mode):
#   def mkdir(self, path, exist_ok=False):
#   def makedirs(self, path, exist_ok=False):
#   def glob(self, path):
#   def exists(self, path):
#   def cp(self, from_path, to_path):
#   def rm(self, path):
#   def mkdir(self, path, exist_ok=False):
#   def makedirs(self, path, exist_ok=False):
#   def open(self, *args):
#   def glob(self, *args):
#   def exists(self, *args):
#   def cp(self, *args):
#   def rm(self, *args):
#   def log(self, msg, level='info'):
#   def levels(self):
#   def level_index(self, level):
#   def __init__(self):
#   def log(self, msg, level='info'):
#   def verbose(self, msg):
#   def info(self, msg):
#   def warning(self, msg):
#   def error(self, msg):
#   def set_level(self, level):
# 
# Path: ldif/util/mesh_util.py
# def serialize(mesh):
# def deserialize(mesh_str):
# def remove_small_components(mesh, min_volume=5e-05):


import os
import pickle
import struct
import numpy as np
import pandas as pd
from PIL import Image
from ldif.util import base_util
from ldif.util import mesh_util
    points: Numpy array with shape [point_count, 3/4/6]. A set of XYZ points,
      optionally with a weight/value or normals (both simultaneously is not
      supported).

  Returns:
    The path to the written file, with an extension.
  """
  has_df = points.shape[-1] == 4
  has_ext = path_ext_optional[-4] == '.'
  path_no_ext, ext = os.path.splitext(path_ext_optional)
  has_ext = bool(ext)
  if has_df:
    ptspath = path_no_ext + '.sdf'
    if has_ext:
      assert ext == '.sdf'
    points = points.reshape([-1, 4])
    with base_util.FS.open(ptspath, 'wb') as f:
      # GAPS expects the floats serialized to disk to be 32-bit:
      points = points.astype(np.float32)
      f.write(points.tobytes())
  else:
    ptspath = path_no_ext + '.pts'
    if has_ext:
      assert ext == '.pts'
    has_normals = points.shape[-1] == 6
    if not has_normals:
      points = points[..., :3]
      normals = np.zeros_like(points)
      points = np.concatenate([points, normals], axis=-1)
    points = np.reshape(points, [-1, 6])

# Path: ldif/util/base_util.py
# ENVIRONMENT = 'EXTERNAL'
#   FS = StandardFileSystem()
#   LOG = SimpleLog()
# class FileSystem(abc.ABC):
# class StandardFileSystem(FileSystem):
# class Log(abc.ABC):
# class SimpleLog(Log):
#   def open(self, filename, mode):
#   def mkdir(self, path, exist_ok=False):
#   def makedirs(self, path, exist_ok=False):
#   def glob(self, path):
#   def exists(self, path):
#   def cp(self, from_path, to_path):
#   def rm(self, path):
#   def mkdir(self, path, exist_ok=False):
#   def makedirs(self, path, exist_ok=False):
#   def open(self, *args):
#   def glob(self, *args):
#   def exists(self, *args):
#   def cp(self, *args):
#   def rm(self, *args):
#   def log(self, msg, level='info'):
#   def levels(self):
#   def level_index(self, level):
#   def __init__(self):
#   def log(self, msg, level='info'):
#   def verbose(self, msg):
#   def info(self, msg):
#   def warning(self, msg):
#   def error(self, msg):
#   def set_level(self, level):
# 
# Path: ldif/util/mesh_util.py
# def serialize(mesh):
# def deserialize(mesh_str):
# def remove_small_components(mesh, min_volume=5e-05):


# Path: ldif/util/file_util.py
import os
import pickle
import struct
import numpy as np
import pandas as pd
from PIL import Image
from ldif.util import base_util
from ldif.util import mesh_util

    points: Numpy array with shape [point_count, 3/4/6]. A set of XYZ points,
      optionally with a weight/value or normals (both simultaneously is not
      supported).

  Returns:
    The path to the written file, with an extension.
  """
  has_df = points.shape[-1] == 4
  has_ext = path_ext_optional[-4] == '.'
  path_no_ext, ext = os.path.splitext(path_ext_optional)
  has_ext = bool(ext)
  if has_df:
    ptspath = path_no_ext + '.sdf'
    if has_ext:
      assert ext == '.sdf'
    points = points.reshape([-1, 4])
    with base_util.FS.open(ptspath, 'wb') as f:
      # GAPS expects the floats serialized to disk to be 32-bit:
      points = points.astype(np.float32)
      f.write(points.tobytes())
  else:
    ptspath = path_no_ext + '.pts'
    if has_ext:
      assert ext == '.pts'
    has_normals = points.shape[-1] == 6
    if not has_normals:
      points = points[..., :3]
      normals = np.zeros_like(points)
      points = np.concatenate([points, normals], axis=-1)
    points = np.reshape(points, [-1, 6])

    with base_util.FS.open(ptspath, 'wb') as f: