Exemplo n.º 1
0
    This example illustrates the following operations:

    * Generating a control points grid
    * Generating a B-Spline surface and using the generated grid as its control points input
    * Splitting the B-Spline surface
    * Plotting the split surface using Plotly
"""

from geomdl import BSpline
from geomdl import CPGen
from geomdl import utilities
from geomdl.visualization import VisPlotly

# Generate a control points grid
surfgrid = CPGen.Grid(50, 100)

# This will generate a32x32 grid
surfgrid.generate(32, 32)

# Generate bumps on the grid
surfgrid.bumps(num_bumps=4,
               all_positive=True,
               bump_height=45,
               base_extent=4,
               base_adjust=1)

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

# Set degrees
def test_grid_generate4():
    test_grid = CPGen.GridWeighted(7, 13)
    with pytest.warns(UserWarning):
        test_grid.generate(3, 4.2)
Exemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    Examples for the NURBS-Python Package
    Released under MIT License
    Developed by Onur Rauf Bingol (c) 2017
"""
import os
from geomdl import CPGen

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

# Generate a 50x100 rectangle
mygrid = CPGen.GridWeighted(50, 100)

# Split the width into 5 equal pieces and the height into 10 equal pieces
mygrid.generate(15, 20)

# Generate 4 bumps on the grid
mygrid.bumps(num_bumps=4, bump_height=50)

# Add weight
mygrid.weight = 2.3

# Modify weight
mygrid.weight = 1.0

# Get the grid points for plotting
grid_data = mygrid.grid
def gridw():
    """ Generates a weighted control points grid """
    surfgrid = CPGen.GridWeighted(7, 13)
    surfgrid.generate(3, 4)
    return surfgrid
def test_grid_generate2():
    test_grid = CPGen.GridWeighted(7, 13)
    with pytest.raises(ValueError):
        test_grid.generate(5, -1)
def test_bumps4():
    test_grid = CPGen.Grid(5, 7)
    with pytest.raises(RuntimeError):
        # bumps before calling generate()
        test_grid.bumps(num_bumps=3)
def grid2():
    """ Generates a 6x6 control points grid """
    surfgrid = CPGen.Grid(7, 13)
    surfgrid.generate(16, 16)
    return surfgrid
Exemplo n.º 8
0
    * Generating a control points grid
    * Generating a B-Spline surface and using the generated grid as its control points input
    * Plotting the surface using Matplotlib
    * Exporting the surface as a .stl file
"""


from geomdl import BSpline
from geomdl import CPGen
from geomdl import utilities
from geomdl.visualization import VisMPL as vis
from geomdl import exchange

# Generate a control points grid
surfgrid = CPGen.Grid(100, 100)

# This will generate a 10x10 grid
surfgrid.generate(8, 8)

# Generate 1 bump at the center of the grid and generate some padding with a padding between the bumps
surfgrid.bumps(num_bumps=1, bump_height=20, base_extent=4, base_adjust=1)

# surfgrid.rotate_x(10.0)
# surfgrid.rotate_y(7.5)

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

# Set degrees
surf.degree_u = 3
def grid():
    """ Generates a 3x4 control points grid """
    surfgrid = CPGen.Grid(7, 13)
    surfgrid.generate(3, 4)
    return surfgrid
    Examples for the NURBS-Python Package
    Released under MIT License
    Developed by Onur Rauf Bingol (c) 2018
"""

from geomdl import BSpline
from geomdl import multi
from geomdl import CPGen
from geomdl import utilities
from geomdl import construct
from geomdl.visualization import VisMPL as vis

# Required for multiprocessing module
if __name__ == "__main__":
    # Generate control points grid for Surface #1
    sg01 = CPGen.Grid(15, 10, z_value=0.0)
    sg01.generate(8, 8)

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

    # Set degrees
    surf01.degree_u = 1
    surf01.degree_v = 1

    # Get the control points from the generated grid
    surf01.ctrlpts2d = sg01.grid

    # Set knot vectors
    surf01.knotvector_u = utilities.generate_knot_vector(
        surf01.degree_u, surf01.ctrlpts_size_u)
Exemplo n.º 11
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
    Examples for the NURBS-Python Package
    Released under MIT License
    Developed by Onur Rauf Bingol (c) 2017
"""
import os
from geomdl import CPGen

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

# Generate a 50x100 rectangle
mygrid = CPGen.Grid(50, 100)

# Split the width into 5 equal pieces and the height into 10 equal pieces
mygrid.generate(15, 20)

# Generate 4 bumps on the grid
mygrid.bumps(num_bumps=4, bump_height=50)

# Save the file, by default as grid.txt
mygrid.save()

# Get the grid points for plotting
grid_data = mygrid.grid

# Good to have something here to put a breakpoint
pass
Exemplo n.º 12
0
def test_grid_rotate_z2():
    test_grid = CPGen.Grid(7, 13)
    with pytest.raises(RuntimeError):
        test_grid.rotate_z(15)
Exemplo n.º 13
0
def test_grid_translate2():
    test_grid = CPGen.Grid(7, 13)
    with pytest.raises(RuntimeError):
        # translate before generating the grid
        test_grid.translate(pos=(1, 2, 3))
Exemplo n.º 14
0
def test_grid_save2():
    test_grid = CPGen.Grid(5, 7)
    with pytest.raises(RuntimeError):
        # trying to save before generate()
        test_grid.save()