"""
    Examples for the NURBS-Python Package
    Released under MIT License
    Developed by Onur Rauf Bingol (c) 2016-2018
"""

import os
from geomdl import BSpline
from geomdl import exchange
from geomdl.visualization import VisVTK as vis


def main():
    # Fix file path
    os.chdir(os.path.dirname(os.path.realpath(__file__)))

    # Create a BSpline surface instance
    surf = BSpline.Surface()

    # Set degrees
    surf.degree_u = 3
    surf.degree_v = 3

    # Set control points
    surf.set_ctrlpts(*exchange.import_txt("ex_surface01.cpt",
                                          two_dimensional=True))

    # Set knot vectors
    surf.knotvector_u = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0]
    surf.knotvector_v = [0.0, 0.0, 0.0, 0.0, 1.0, 2.0, 3.0, 3.0, 3.0, 3.0]

    # Set evaluation delta
    surf.delta = 0.025

    # Evaluate surface points
    surf.evaluate()

    # Import and use Matplotlib's colormaps
    from matplotlib import cm

    # Plot the control point grid and the evaluated surface
    vis_comp = vis.VisSurface()
    surf.vis = vis_comp
    surf.render(colormap=cm.cool)

    # Good to have something here to put a breakpoint
    pass
