Skip to content

Commit

Permalink
Add torodial surface example
Browse files Browse the repository at this point in the history
  • Loading branch information
Onur Rauf Bingol committed Sep 1, 2018
1 parent c53d16f commit a86bcf9
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
9 changes: 9 additions & 0 deletions surface/ex_torus.cptw
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-125.0,0.0,0.0,1.0;-125.0,0.0,125.0,1.0;0.0,0.0,125.0,1.0;125.0,0.0,125.0,1.0;125.0,0.0,0.0,1.0;125.0,0.0,-125.0,1.0;0.0,0.0,-125.0,1.0;-125.0,0.0,-125.0,1.0;-125.0,0.0,0.0,1.0
-88.375,70.7,0.0,0.707;-88.375,70.7,88.375,0.707;0.0,70.7,88.375,0.707;88.375,70.7,88.375,0.707;88.375,70.7,0.0,0.707;88.375,70.7,-88.375,0.707;0.0,70.7,-88.375,0.707;-88.375,70.7,-88.375,0.707;-88.375,70.7,0.0,0.707
-225.0,100.0,0.0,1.0;-225.0,100.0,225.0,1.0;0.0,100.0,225.0,1.0;225.0,100.0,225.0,1.0;225.0,100.0,0.0,1.0;225.0,100.0,-225.0,1.0;0.0,100.0,-225.0,1.0;-225.0,100.0,-225.0,1.0;-225.0,100.0,0.0,1.0
-229.775,70.7,0.0,0.707;-229.775,70.7,229.775,0.707;0.0,70.7,229.775,0.707;229.775,70.7,229.775,0.707;229.775,70.7,0.0,0.707;229.775,70.7,-229.775,0.707;0.0,70.7,-229.775,0.707;-229.775,70.7,-229.775,0.707;-229.775,70.7,0.0,0.707
-325.0,0.0,0.0,1.0;-325.0,0.0,325.0,1.0;0.0,0.0,325.0,1.0;325.0,0.0,325.0,1.0;325.0,0.0,0.0,1.0;325.0,0.0,-325.0,1.0;0.0,0.0,-325.0,1.0;-325.0,0.0,-325.0,1.0;-325.0,0.0,0.0,1.0
-229.775,-70.7,0.0,0.707;-229.775,-70.7,229.775,0.707;0.0,-70.7,229.775,0.707;229.775,-70.7,229.775,0.707;229.775,-70.7,0.0,0.707;229.775,-70.7,-229.775,0.707;0.0,-70.7,-229.775,0.707;-229.775,-70.7,-229.775,0.707;-229.775,-70.7,0.0,0.707
-225.0,-100.0,0.0,1.0;-225.0,-100.0,225.0,1.0;0.0,-100.0,225.0,1.0;225.0,-100.0,225.0,1.0;225.0,-100.0,0.0,1.0;225.0,-100.0,-225.0,1.0;0.0,-100.0,-225.0,1.0;-225.0,-100.0,-225.0,1.0;-225.0,-100.0,0.0,1.0
-88.375,-70.7,0.0,0.707;-88.375,-70.7,88.375,0.707;0.0,-70.7,88.375,0.707;88.375,-70.7,88.375,0.707;88.375,-70.7,0.0,0.707;88.375,-70.7,-88.375,0.707;0.0,-70.7,-88.375,0.707;-88.375,-70.7,-88.375,0.707;-88.375,-70.7,0.0,0.707
-125.0,0.0,0.0,1.0;-125.0,0.0,125.0,1.0;0.0,0.0,125.0,1.0;125.0,0.0,125.0,1.0;125.0,0.0,0.0,1.0;125.0,0.0,-125.0,1.0;0.0,0.0,-125.0,1.0;-125.0,0.0,-125.0,1.0;-125.0,0.0,0.0,1.0
49 changes: 49 additions & 0 deletions surface/ex_torus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Examples for the NURBS-Python Package
Released under MIT License
Developed by Onur Rauf Bingol (c) 2018
Toroidal surface is contributed by Harshil Shah (@harshilsofeshah)
"""

import os
from geomdl import NURBS
from geomdl import exchange
from geomdl.visualization import VisMPL


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

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

# Set degress
surf.degree_u = 2
surf.degree_v = 2

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

# Set knot vectors
surf.knotvector_u = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1]
surf.knotvector_v = [0, 0, 0, 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1, 1, 1]

# Set sample size and evaluate surface
surf.sample_size = 25
surf.evaluate()

# Import colormaps
from matplotlib import cm

# Plot the surface
vis_config = VisMPL.VisConfig(ctrlpts=True, axes=True, legend=False)
vis_comp = VisMPL.VisSurfTriangle(vis_config)
surf.vis = vis_comp
surf.render(colormap=cm.coolwarm)

# Good to have something here to put a breakpoint
pass

0 comments on commit a86bcf9

Please sign in to comment.