def AddPlot(self, plot_cmd):
     if plot_cmd == "cplot":
         plt.cplot(self.nurbs)
     elif plot_cmd == "kplot":
         plt.kplot(self.nurbs)
     elif plot_cmd == "plot":
         plt.plot(self.nurbs)
     elif plot_cmd == "curve":
         plt.curve(self.nurbs)
     elif plot_cmd == "surface":
         plt.surface(self.nurbs)
     elif plot_cmd == "cpoint":
         plt.cpoint(self.nurbs)
     elif plot_cmd == "cwire":
         plt.cwire(self.nurbs)
     elif plot_cmd == "kpoint":
         plt.kpoint(self.nurbs)
     elif plot_cmd == "kwire":
         plt.kwire(self.nurbs)
Ejemplo n.º 2
0
from igakit.cad import *

c1 = line().reverse()
c2 = circle(center=(0, 1), angle=Pi)
S = ruled(c1, c2)

# ---

from igakit.plot import plt
import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass
#plt.use('mayavi')
#plt.use('matplotlib')

plt.figure()
plt.curve(c1, color=(1, 0, 0))
plt.curve(c2, color=(1, 0, 0))
plt.cplot(S)
plt.plot(S)

plt.show()
Ejemplo n.º 3
0
import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass

vol = make_vol()

plt.figure()
plt.cpoint(vol)
plt.cwire(vol)

plt.figure()
plt.kpoint(vol)
plt.kwire(vol)

plt.figure()
plt.curve(vol)

plt.figure()
plt.surface(vol)

plt.figure()
plt.cplot(vol)
plt.kplot(vol)
plt.plot(vol)

plt.show()
Ejemplo n.º 4
0
from igakit.cad import *

c1 = line().reverse()
c2 = circle(center=(0,1), angle=Pi)
S = ruled(c1, c2)

# ---

from igakit.plot import plt
import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass
#plt.use('mayavi')
#plt.use('matplotlib')

plt.figure()
plt.curve(c1, color=(1,0,0))
plt.curve(c2, color=(1,0,0))
plt.cplot(S)
plt.plot(S)

plt.show()
Ejemplo n.º 5
0
bentpipe[:,0,:] = t0(circle)
bentpipe[:,1,:] = t1(circle)
bentpipe[:,2,:] = t2(circle)
bentpipe[:,3,:] = t3(circle)
bentpipe[:,4,:] = t4(circle)

Pw = bentpipe
U = [0,0,0, 1,1, 2,2, 3,3, 4,4,4]
W = [0,0,0, 1,1, 2,2,2]
nrb = NURBS(Pw, [U,W])


import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass

plt.figure()
plt.plot(nrb)

n1,n2,n3,n4,n5 = VolumifyInterior(nrb)
plt.figure()
for i in range(1,6):
    s = 'plt.plot(n%d)' % i
    eval(s)
    s = 'plt.kplot(n%d)' % i
    eval(s)
plt.show()
Ejemplo n.º 6
0
elbow    = revolve(annulus, point=(Rb,0,0),
                   axis=(0,-1,0), angle=Pi/2)
bentpipe = join(pipe.reverse(2), elbow, axis=2)

# ---

nrb = bentpipe

from igakit.plot import plt
import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass
#plt.use('mayavi')
#plt.use('matplotlib')

plt.figure()
plt.cpoint(nrb)
plt.cwire(nrb, mode='tube')
plt.kpoint(nrb)
plt.kwire(nrb, mode='tube')
plt.plot(nrb, opacity=0.1)

plt.figure()
plt.kplot(nrb, color=(0,0,1))
plt.plot(nrb)

plt.show()
Ejemplo n.º 7
0
P[6, 1, :] = [5.24524, 50.0859]
P[7, 1, :] = [42.1936, 50.0884]
P[8, 1, :] = [95.7095, 50.0937]
P[9, 1, :] = [128.203, 50.0974]
P[10, 1, :] = [183.546, 47.168]
P[11, 1, :] = [335.568, 38.9067]
P[12, 1, :] = [782.636, 12.9908]
P[13, 1, :] = [1120.1, -10.3521]

# Adjust control points such that the length scale is 1
delx = P[:, :, 0].max() - P[:, :, 0].min()
minx = P[:, :, 0].min()
P -= minx
P /= delx

tube = NURBS(P, [U, V])
tube.elevate(0, 1)

# Determine which knots to insert
res = 32
insert_U = InsertUniformly(U, 4 * res)
insert_V = InsertUniformly(V, res)
tube.refine(insert_U, insert_V)

plt.use('mayavi')

plt.figure()
plt.plot(tube)

plt.show()
Ejemplo n.º 8
0
P[6,1,:] = [5.24524, 50.0859]
P[7,1,:] = [42.1936, 50.0884]
P[8,1,:] = [95.7095, 50.0937]
P[9,1,:] = [128.203, 50.0974]
P[10,1,:] = [183.546, 47.168]
P[11,1,:] = [335.568, 38.9067]
P[12,1,:] = [782.636, 12.9908]
P[13,1,:] = [1120.1, -10.3521]

# Adjust control points such that the length scale is 1
delx=P[:,:,0].max()-P[:,:,0].min()
minx=P[:,:,0].min()
P -= minx
P /= delx

tube = NURBS(P,[U,V])
tube.elevate(0,1)

# Determine which knots to insert
res = 32
insert_U=InsertUniformly(U,4*res)
insert_V=InsertUniformly(V,res)
tube.refine(insert_U,insert_V)

plt.use('mayavi')

plt.figure()
plt.plot(tube)

plt.show()
Ejemplo n.º 9
0
def create_patch(R1, R2, C1, C2, order=2, viewpatch=False):
    """
    Create a single 2d NURBS-patch of the area between two coplanar nested
    circles using igakit.

    Parameters
    ----------
    R1 : float
        Radius of the inner circle.
    R2 : float
        Radius of the outer circle.
    C1 : list of two floats
        Coordinates of the center of the inner circle given as [x1, y1].
    C2 : list of two floats
        Coordinates of the center of the outer circle given as [x2, y2].
    order : int, optional
        Degree of the NURBS basis functions. The default is 2.
    viewpatch : bool, optional
        When set to True, display the NURBS patch. The default is False.

    Returns
    -------
    None.

    """

    from sfepy.discrete.iga.domain_generators import create_from_igakit
    import sfepy.discrete.iga.io as io
    from igakit.cad import circle, ruled
    from igakit.plot import plt as iplt
    from numpy import pi

    # Assert the inner circle is inside the outer one
    inter_centers = nm.sqrt((C2[0] - C1[0])**2 + (C2[1] - C1[1])**2)
    assert R2 > R1, "Outer circle should have a larger radius than the inner one"
    assert inter_centers < R2 - R1, "Circles are not nested"

    # Geometry Creation
    centers_direction = [C2[0] - C1[0], C2[1] - C1[1]]
    if centers_direction[0] == 0 and centers_direction[1] == 0:
        start_angle = 0.0
    else:
        start_angle = nm.arctan2(centers_direction[1], centers_direction[0])
    c1 = circle(radius=R1,
                center=C1,
                angle=(start_angle, start_angle + 2 * pi))
    c2 = circle(radius=R2,
                center=C2,
                angle=(start_angle, start_angle + 2 * pi))
    srf = ruled(c1, c2).transpose()  # make the radial direction first

    # Refinement
    insert_U = insert_uniformly(srf.knots[0], 6)
    insert_V = insert_uniformly(srf.knots[1], 6)
    srf.refine(0, insert_U).refine(1, insert_V)

    # Setting the NURBS-surface degree
    srf.elevate(0, order - srf.degree[0] if order - srf.degree[0] > 0 else 0)
    srf.elevate(1, order - srf.degree[1] if order - srf.degree[1] > 0 else 0)

    # Sfepy .iga file creation
    nurbs, bmesh, regions = create_from_igakit(srf, verbose=True)

    # Save .iga file in sfepy/meshes/iga
    filename_domain = data_dir + '/meshes/iga/concentric_circles.iga'
    io.write_iga_data(filename_domain, None, nurbs.knots, nurbs.degrees,
                      nurbs.cps, nurbs.weights, nurbs.cs, nurbs.conn,
                      bmesh.cps, bmesh.weights, bmesh.conn, regions)

    if viewpatch:
        try:
            iplt.use('mayavi')
            iplt.figure()
            iplt.plot(srf)
            iplt.show()
        except ImportError:
            iplt.use('matplotlib')
            iplt.figure()
            iplt.plot(srf)
            iplt.show()
Ejemplo n.º 10
0
from igakit.cad import *

C = circle(center=-1, angle=(-Pi/2,Pi/2))
T = circle(radius=3, center=3, angle=(Pi,Pi/2)).rotate(Pi/2, 0)

S = sweep(C, T)

# ---

from igakit.plot import plt
import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass
#plt.use('mayavi')
#plt.use('matplotlib')

plt.plot(C, color=(1,0,0))
plt.plot(T, color=(0,0,1))
plt.plot(S, color=(1,1,0))

plt.show()
Ejemplo n.º 11
0
         1, 1, 1, 1,]
    crv = NURBS([U], C)
    return crv

import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass

crv = make_crv()

plt.figure()
plt.cpoint(crv)
plt.cwire(crv)

plt.figure()
plt.kpoint(crv)
plt.kwire(crv)

plt.figure()
plt.curve(crv)

plt.figure()
plt.cplot(crv)
plt.kplot(crv)
plt.plot(crv)

plt.show()
Ejemplo n.º 12
0
    return srf

import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass

srf = make_srf()

plt.figure()
plt.cpoint(srf)
plt.cwire(srf)

plt.figure()
plt.kpoint(srf)
plt.kwire(srf)

plt.figure()
plt.curve(srf)
plt.figure()
plt.surface(srf)

plt.figure()
plt.cplot(srf)
plt.kplot(srf)
plt.plot(srf)

plt.show()
Ejemplo n.º 13
0

import sys
try:
    backend = sys.argv[1]
    plt.use(backend)
except IndexError:
    pass

srf = make_srf()

plt.figure()
plt.cpoint(srf)
plt.cwire(srf)

plt.figure()
plt.kpoint(srf)
plt.kwire(srf)

plt.figure()
plt.curve(srf)
plt.figure()
plt.surface(srf)

plt.figure()
plt.cplot(srf)
plt.kplot(srf)
plt.plot(srf)

plt.show()