Shape modifiers

The following classes modify an existing shape. They are Shapes themselves, executing a certain algorithm on an original_shape parameter. They can be used to transform (i.e., round, grow, shrink) geometrical elements.

ShapeRound Returns a shape with rounded corners based on a given shape.
ShapeStub Stubs the corners of a given shape
ShapeSample Creates a shape sampling points on another shape along specified distances between the sampling point.
ShapeSamplePeriodic Creates a shape sampling points on another shape along specified periodic distances from the start point of the shape.
ShapeShorten Shortens a shape on both ends by given trim lengths.
ShapeSerif Puts a bump on the corners of a given shape.
ShapeGrow Generates a shape which uniformly grows.
ShapeVariableOffset Generates a shape with a variable offset from its original shape.
ShapeExtendEnds Stubs the corners of a given shape.
ShapeFit Fits a shape in a given box.
ShapeRoundAdiabaticSpline Returns a shape with adiabatic spline corners
SplineRoundingAlgorithm Rounding algorithm that is an extension of i3.ShapeRound.

ShapeRound

class ipkiss3.all.ShapeRound(original_shape, **kwargs)

Returns a shape with rounded corners based on a given shape.

The corners are rounded using a circular arc with a certain radius.

Used as the default rounding algorithm for traces (waveguides).

Parameters:

radius: float and Real, number and number >= 0, required

original_shape: Shape, required

angle_step: float, optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

radii: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
rounded_shape = i3.ShapeRound(original_shape=shape,
                              radius=5.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(rounded_shape.x_coords(), rounded_shape.y_coords(), 'r-', label='rounded shape')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-1.png

ShapeSample

class ipkiss3.all.ShapeSample(original_shape, **kwargs)

Creates a shape sampling points on another shape along specified distances between the sampling point.

Parameters:

sampling_distances: list<number > 0>, required

original_shape: Shape, required

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
sampled_shape = i3.ShapeSample(original_shape=shape,
                               sampling_distances=[1.0, 3.0, 3.5, 4.0, 7.0, 7.8, 10.0, 12.0, 15.0, 17.0, 25.0])
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(sampled_shape.x_coords(), sampled_shape.y_coords(), 'ro', label='sampled shape', markersize=7)
plt.legend()
plt.show()
../../../_images/shape_modifiers-2.png

ShapeSamplePeriodic

class ipkiss3.all.ShapeSamplePeriodic(original_shape, **kwargs)

Creates a shape sampling points on another shape along specified periodic distances from the start point of the shape.

Parameters:

sampling_period: float and number > 0, required

original_shape: Shape, required

exclude_ends: Coord2, optional

Lengths not taken into account on both ends

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

sampling_distances: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
sampled_shape = i3.ShapeSamplePeriodic(original_shape=shape,
                                       sampling_period=0.5,
                                       exclude_ends=(1.0, 2.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(sampled_shape.x_coords(), sampled_shape.y_coords(), 'ro', label='sampled shape', markersize=7)
plt.legend()
plt.show()
../../../_images/shape_modifiers-3.png

ShapeStub

class ipkiss3.all.ShapeStub(original_shape, **kwargs)

Stubs the corners of a given shape

On closed shapes, all corners are stubbed Open shapes are left open: the edge corners are not stubbed

Parameters:

stub_width: float and Real, number and number >= 0, required

original_shape: Shape, required

only_sharp_angles: ( bool, bool_, bool or int ), optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
stubbed_shape = i3.ShapeStub(original_shape=shape,
                             only_sharp_angles=False,
                             stub_width=5.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(stubbed_shape.x_coords(), stubbed_shape.y_coords(), 'r-', label='stubbed shape')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-4.png

ShapeShorten

class ipkiss3.all.ShapeShorten(original_shape, **kwargs)

Shortens a shape on both ends by given trim lengths.

Parameters:

original_shape: Shape, required

trim_lengths: Coord2, optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
short_shape = i3.ShapeShorten(original_shape=shape,
                              trim_lengths=(1.0, 2.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(short_shape.x_coords(), short_shape.y_coords(), 'ro--', label='shortened shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-5.png

ShapeSerif

class ipkiss3.all.ShapeSerif(**kwargs)

Puts a bump on the corners of a given shape.

Parameters:

stub_height: float and number > 0, required

stub_width: float and number > 0, required

tip_width: float and Real, number and number >= 0, required

original_shape: Shape, required

only_sharp_angles: ( bool, bool_, bool or int ), optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
serif_shape = i3.ShapeSerif(original_shape=shape,
                            stub_width=3.0,
                            stub_height=2.0,
                            tip_width=2.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(serif_shape.x_coords(), serif_shape.y_coords(), 'r-', label='serif shape')
plt.xlim([0, 30.0])
plt.ylim([0, 15.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-6.png

ShapeGrow

class ipkiss3.all.ShapeGrow(original_shape, amount, **kwargs)

Generates a shape which uniformly grows.

Parameters:

amount: float, required

original_shape: Shape, required

offset: optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
grown_shape = i3.ShapeGrow(original_shape=shape,
                           amount=2.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(grown_shape.x_coords(), grown_shape.y_coords(), 'ro--', label='grown shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-7.png

ShapeVariableOffset

class ipkiss3.all.ShapeVariableOffset(original_shape, offsets, **kwargs)

Generates a shape with a variable offset from its original shape.

Parameters:

offsets: list<Real, number>, required

original_shape: Shape, required

remove_loopbacks: ( bool, bool_, bool or int ), optional

end_face_angle: float, optional

start_face_angle: float, optional

points: optional

points of this shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
offset_shape = i3.ShapeVariableOffset(original_shape=shape,
                                      offsets=[-1.0, 2.0, 3.0, -1.0, 0.0])
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=2)
plt.plot(offset_shape.x_coords(), offset_shape.y_coords(), 'ro--', label='offset shape', markersize=2, linewidth=6)
plt.legend()
plt.show()
../../../_images/shape_modifiers-8.png

ShapeExtendEnds

class ipkiss3.all.ShapeExtendEnds(original_shape, start_extension, end_extension, **kwargs)

Stubs the corners of a given shape.

Parameters:

end_extension: float, required

start_extension: float, required

original_shape: Shape, required

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Examples

import ipkiss3.all as i3
import numpy as np

shape = i3.Shape([(5.0, 5.0), (10.0, 10.0), (15.0, 5.0), (20.0, 10.0), (25.0, 5.0)])
extended_shape = i3.ShapeExtendEnds(original_shape=shape,
                                    start_extension=1.0,
                                    end_extension=3.0)
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-', label='original_shape', markersize=2, linewidth=6)
plt.plot(extended_shape.x_coords(), extended_shape.y_coords(), 'ro--', label='extended shape', markersize=2, linewidth=3)
plt.legend()
plt.show()
../../../_images/shape_modifiers-9.png

ShapeFit

class ipkiss3.all.ShapeFit(original_shape, south_west, north_east, **kwargs)

Fits a shape in a given box.

Parameters:

north_east: Coord2, required

south_west: Coord2, required

original_shape: Shape, required

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

ShapeRoundAdiabaticSpline

class ipkiss3.all.ShapeRoundAdiabaticSpline(original_shape, **kwargs)

Returns a shape with adiabatic spline corners

Parameters:

radius: float and Real, number and number >= 0, required

original_shape: Shape, required

adiabatic_angles: tuple2, optional

angle_step: float, optional

end_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the end of an open shape

points: optional

points of this shape

start_face_angle: ( float ), optional, *None allowed*

Use this to overrule the ‘dangling’ angle at the start of an open shape

Other Parameters:
 

adiabatic_angles_list: locked

radii: locked

closed: locked

size_info: SizeInfo, locked

get the size information on this Shape

Notes

Do not use this as a rounding algorithm in routing functions or connectors. Use SplineRoundingAlgorithm instead.

Examples

import ipkiss3.all as i3
shape = i3.Shape([(10.0, 10.0), (30.0, 10.0), (60.0, 35.0), (10.0, 40.0)])
rounded_shape = i3.ShapeRoundAdiabaticSpline(original_shape=shape,
                                             radius=3.0,
                                             adiabatic_angles=(10.0, 10.0))
rounded_shape2 = i3.ShapeRoundAdiabaticSpline(original_shape=shape,
                                             radius=3.0,
                                             adiabatic_angles=(40.0, 40.0))
import matplotlib.pyplot as plt

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original_shape')
plt.plot(rounded_shape.x_coords(), rounded_shape.y_coords(), 'r-', label='rounded shape (10 degrees)')
plt.plot(rounded_shape2.x_coords(), rounded_shape2.y_coords(), 'g-', label='rounded shape (40 degrees)')
plt.xlim([0, 70.0])
plt.ylim([0, 50.0])
plt.legend()
plt.show()
../../../_images/shape_modifiers-10.png

SplineRoundingAlgorithm

class ipkiss3.all.SplineRoundingAlgorithm(**kwargs)

Rounding algorithm that is an extension of i3.ShapeRound. An adiabatic angle is the part of the bend arc over which the bend curvature is gradually decreasing from infinity (the straight waveguide it connects to) to the required curvature (1/bend_radius).

For example, using SplineRoundingAlgorithm((30,30)) on a 90 degree bend results in the first 30 degrees being covered with a spline, then 30 degrees with a circular bend (constant curvature 1/bend_radius) and then again 30 degrees with a spline.

Parameters:adiabatic_angles: tuple2, optional

Examples

import ipkiss3.all as i3
import matplotlib.pyplot as plt

shape = i3.Shape([(0.0, 0.0), (30.0, 0.0), (30.0, 30.0)])
ra = i3.SplineRoundingAlgorithm(adiabatic_angles=(30, 30))
rounded_shape = ra(original_shape=shape, radius=5.)

plt.figure()
plt.plot(shape.x_coords(), shape.y_coords(), 'bo-.', label='original shape')
plt.plot(rounded_shape.x_coords(), rounded_shape.y_coords(), 'r-', label='rounded shape')
plt.legend()
plt.show()
../../../_images/adiabatic_angles.png