def ReadRotateWrite(infile):
    orig = GWLobject()
    orig.readGWL(infile)
    for alpha_deg in numpy.linspace(0, 45, 10):
        obj = copy.deepcopy(orig)
        obj.rotate([0, 0, 0], [0, 0, 1], alpha_deg)
        outfile = infile + '.alpha_' + str(alpha_deg) + '.gwl'
        obj.writeGWL(outfile)
    return
예제 #2
0
    def __init__(self):
        self.Nlines = 11
        self.angle_deg = 60
        self.line_width = 1
        self.line_height = 2
        self.line_length = 10
        self.period = 2
        self.connected = False

        GWLobject.__init__(self)
 def setAttributesFromParsedOptions(self, options):
     GWLobject.setAttributesFromParsedOptions(self, options)
     self.maxHeight = options.maxHeight
     self.radius = options.radius
     self.N_Discontinuities = options.N_Discontinuities
     self.phiStep = options.phiStep
     self.radialStep = options.radialStep
     self.heightStep = options.heightStep
     self.N_HeightSteps = options.N_HeightSteps
     self.truncateBottom = options.truncateBottom
     self.minZ = options.minZ
     return
 def get_argument_parser(self):
     parser = argparse.ArgumentParser(
         description=self.__doc__.split('\n')[0], fromfile_prefix_chars='@')
     parser.add_argument('-d',
                         '--outdir',
                         action="store",
                         dest="outdir",
                         default=tempfile.gettempdir(),
                         help='output directory')
     parser.add_argument('-b',
                         '--basename',
                         action="store",
                         dest="basename",
                         default='SpiralPhasePlate',
                         help='output basename')
     GWLobject.add_arguments(self, parser)
     self.add_arguments(parser)
     return parser
예제 #5
0
def main():
    alpha = 2 * pi / 5
    r_outer = 1
    r_inner = r_outer * cos(alpha) / cos(alpha / 2)
    #r_inner = 0.5

    P_outer = 5 * [0]
    P_inner = 5 * [0]
    pentagram = []
    pentagram_star = []
    for idx in range(5):
        theta_outer = pi / 2 + idx * alpha
        P_outer[idx] = r_outer * array([cos(theta_outer), sin(theta_outer), 0])
        theta_inner = -pi / 2 - 2 * alpha + idx * alpha
        P_inner[idx] = r_inner * array([cos(theta_inner), sin(theta_inner), 0])
        pentagram_star.append(P_outer[idx])
        pentagram_star.append(P_inner[idx])

    pentagram_star.append(P_outer[0])
    pentagram_star.append(P_inner[0])

    pentagram = [
        P_outer[0], P_outer[3], P_outer[1], P_outer[4], P_outer[2], P_outer[0]
    ]

    obj = GWLobject()
    obj.setVoxels([
        P_outer,
        P_inner,
        pentagram_star,
        pentagram,
    ])
    obj.writeGWL('pentagram.gwl')

    return 0
def testSpirals():

    obj = SpiralPhasePlate()
    obj.maxHeight = 0.85 / 1.52
    obj.radius = 4.275
    obj.phiStep = 2
    obj.radialStep = 0.2
    obj.heightStep = 0.3
    obj.N_HeightSteps = 7
    obj.truncateBottom = False
    obj.minZ = -0.001

    for i in [1, 2, 3, 4]:
        obj.N_Discontinuities = i
        obj.computePoints()
        obj.updateLimits()
        outfile1 = tempfile.gettempdir() + os.sep + 'spiralphaseplate_' + str(
            i) + '.gwl'
        outfile2 = tempfile.gettempdir() + os.sep + 'spiralphaseplate_' + str(
            i) + '.PP.gwl'
        obj.writeGWLWithPowerCompensation(outfile1)

        a = GWLobject()
        a.readGWL(outfile1)
        a.writeGWLWithPowerCompensation(outfile2)

    obj = SpiralPhasePlate()
    obj.truncateBottom = True
    obj.minZ = -1
    obj.computePoints()
    obj.writeGWLWithPowerCompensation('foo.gwl')
    return
예제 #7
0
    def __init__(self):
        GWLobject.__init__(self)

        self.centro = [0, 0, 0]
        self.inner_radius = 0.5
        self.outer_radius = 1
        self.height = 1

        self.z_step = 0.1
        self.theta_step_deg = 1
        self.r_step = 1

        self.truncationDistanceFromCentro = 0.7
        self.startAngle_deg = 0
        self.endAngle_deg = 360

        self.voxel_width = 0.100
        self.voxel_height = 0.200

        self.closed_loop = False

        return
    def __init__(self):
        GWLobject.__init__(self)
        self.radius = 1
        self.rstart = 1

        self.thickness = 3
        self.hole_radius = 2.5

        self.ZtoX_radius_ratio = 0.6

        self.deltaR = 0.2
        self.deltaP = 6

        self.phi_start = 0

        self.voxelX = 0.3
        self.overlap = 0.5

        self.deltaR_direction = -1
        self.theta_direction = 1

        self.TopHemiparabola = True
예제 #9
0
    def __init__(self):
        self.centro = [0, 0, 0]
        self.inner_radius = 1
        self.outer_radius = 2
        self.height = 3
        self.method = 'circles'

        self.PointDistance_r = 0.150
        self.PointDistance_theta = 0.150
        self.PointDistance_z = 2.7 * 0.150

        self.downwardWriting = True
        self.zigzag = True

        self.rotateSpirals = False
        self.add_flat_ends = True
        self.closed_loop = False

        self.power = -1

        GWLobject.__init__(self)
        return
예제 #10
0
def main():
    if len(sys.argv) > 4:
        INFILE = sys.argv[1]
        OUTFILE = sys.argv[2]
        LP0 = float(sys.argv[3])
        K = float(sys.argv[4])
    else:
        print('Usage: ' + sys.argv[0] + ' INFILE OUTFILE LP0 K',
              file=sys.stderr)
        sys.exit(-1)

    obj = GWLobject()
    obj.readGWL(INFILE)
    obj.addPowerCompensation(LP0, K)
    obj.writeGWL(OUTFILE)
예제 #11
0
 def getMeshData(self, position=[0, 0, 0]):
     self.computePoints()
     return (GWLobject.getMeshData(self, position))
예제 #12
0
 def writeGWL(self, filename, writingOffset=[0, 0, 0, 0]):
     print('SpiralParabola.writeGWL')
     self.computePoints()
     GWLobject.writeGWL(self, filename, writingOffset)
     return
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# rotation example
from GWL.GWL_parser import GWLobject

if __name__ == '__main__':
    axis_point = [1, 2, 3]
    axis_direction = [1, 1, 1]
    angle_degrees = 45

    filename_in = 'woodpile06um.gwl'
    filename_out = 'rotated.gwl'

    obj = GWLobject()
    obj.readGWL(filename_in)
    obj.rotate(axis_point, axis_direction, angle_degrees)
    obj.write_GWL(filename_out)
예제 #14
0
from numpy import array, cos, sin, tan, degrees, radians, arccos, arcsin, arctan, floor, ceil, ones, zeros, pi, linspace, log10


def addCylinder(sim, obj, voxel_step, cylinder_radius,
                refractive_index_cylinder):
    L = len(obj.GWL_voxels[-1]) - 1
    if L >= voxel_step and (L - 1) % (voxel_step - 1) == 0:
        cyl = Cylinder()
        cyl.setRefractiveIndex(refractive_index_cylinder)
        cyl.setStartEndPoints(obj.GWL_voxels[-1][-voxel_step],
                              obj.GWL_voxels[-1][-1])
        cyl.setOuterRadius(cylinder_radius)
        sim.appendGeometryObject(cyl)


obj = GWLobject()
sim = BFDTDobject()
sim.setDefaultRefractiveIndex(2)
sim.setSizeAndResolution([10, 10, 10], [100, 100, 100])

cylinder_radius = 0.1
refractive_index_cylinder = 3

voxel_step = 3

ellipse_factor_x = 1
ellipse_factor_y = 2

XOffset = 0.7
YOffset = 0.7
ZOffset = 0.26
예제 #15
0
def block_example():

    main_obj = GWLobject()

    size = 10
    height = 5
    width = 2
    angle_deg = 170
    e3_horiz = numpy.cos(numpy.radians(angle_deg))
    e3_vert = -1 * numpy.sin(numpy.radians(angle_deg))

    distFromCentre = 0.5 * size - 0.5 * e3_horiz * height

    obj = Parallelepiped()
    obj.e1_vec3 = [0, 1, 0]
    obj.e2_vec3 = [1, 0, 0]
    obj.e3_vec3 = [-e3_horiz, 0, e3_vert]
    obj.size_vec3 = [size, width, height]
    obj.center_vec3 = [distFromCentre, 0, 0]
    obj.computePoints()
    obj.writeGWL('blockxp.gwl')
    main_obj.addGWLobject(obj)

    obj = Parallelepiped()
    obj.e1_vec3 = [0, 1, 0]
    obj.e2_vec3 = [1, 0, 0]
    obj.e3_vec3 = [e3_horiz, 0, e3_vert]
    obj.size_vec3 = [size, width, height]
    obj.center_vec3 = [-distFromCentre, 0, 0]
    obj.computePoints()
    obj.writeGWL('blockxm.gwl')
    main_obj.addGWLobject(obj)

    obj = Parallelepiped()
    obj.e1_vec3 = [1, 0, 0]
    obj.e2_vec3 = [0, 1, 0]
    obj.e3_vec3 = [0, -e3_horiz, e3_vert]
    obj.size_vec3 = [size, width, height]
    obj.center_vec3 = [0, distFromCentre, 0]
    obj.computePoints()
    obj.writeGWL('blockyp.gwl')
    main_obj.addGWLobject(obj)

    obj = Parallelepiped()
    obj.e1_vec3 = [1, 0, 0]
    obj.e2_vec3 = [0, 1, 0]
    obj.e3_vec3 = [0, e3_horiz, e3_vert]
    obj.size_vec3 = [size, width, height]
    obj.center_vec3 = [0, -distFromCentre, 0]
    obj.computePoints()
    obj.writeGWL('blockym.gwl')
    main_obj.addGWLobject(obj)

    main_obj.writeGWL('tilted_box.gwl')

    return
예제 #16
0
 def getMeshData(self):
     self.computePoints()
     return (GWLobject.getMeshData(self))
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# rotation example
from GWL.GWL_parser import GWLobject

axis_point = [1,2,3]
axis_direction = [1,1,1]
angle_degrees = 45

filename_in = 'woodpile06um.gwl'
filename_out = 'rotated.gwl'

obj = GWLobject()
obj.readGWL(filename_in)
obj.rotate(axis_point, axis_direction, angle_degrees)
obj.write_GWL(filename_out)
예제 #18
0
 def writeGWL(self, filename, writingOffset=[0, 0, 0, 0]):
     print('TubePapa.writeGWL')
     self.computePoints()
     GWLobject.writeGWL(self, filename, writingOffset)
     return
예제 #19
0
 def getMeshData(self, position=[0, 0, 0]):
     self.computePoints()
     #print(self.GWL_voxels[0][0])
     return (GWLobject.getMeshData(self, position))
예제 #20
0
 def __init__(self):
     GWLobject.__init__(self)
예제 #21
0
#!/usr/bin/env python3

import sys
from GWL.GWL_parser import GWLobject

obj = GWLobject()
obj.readGWL(sys.argv[1])
obj.writeGWL(sys.argv[2])
예제 #22
0
 def writeGWL(self, filename, writingOffset=[0, 0, 0, 0]):
     self.computePoints()
     GWLobject.writeGWL(self, filename, writingOffset)
     return