Esempio n. 1
0
def create_grating(col, row, width, pitch):
    height = pitch // 2
    columnar_matrix = structure_methods.columnar_generator(col, row, width, height)

    # Make a numpy array    
    columnar_matrix_numpy =  numpy.array(columnar_matrix)

    # This line sets the threshold to NaN rather than 0 (flat grating)
    numpy.set_printoptions(threshold = numpy.nan)

    #print(columnar_matrix_numpy)

    # Making the .stl file
    fn = "default.stl"
    stl_tools.numpy2stl(columnar_matrix_numpy, fn, scale=1, mask_val = 1, force_python=True, square_corners=True)
Esempio n. 2
0
                        help="Number of rows in total structure")
    parser.add_argument("slit_width", type=int, help="Width of one slit")
    parser.add_argument("pitch", type=int, help="Diffraction grating pitch")
    parser.add_argument("--strut_width",
                        type=int,
                        help="Specifies slit width, defaults to 1 unit")
    parser.add_argument(
        "--frame_boarder",
        type=int,
        help="Specifies frame boarder width, defaults to 1 unit")
    parser.add_argument(
        "--file_name",
        help="Specifies output file name, defaults to 'default.stl'")
    args = parser.parse_args()

    columnar_matrix = structure_methods.columnar_generator(
        args.no_columns, args.no_rows, args.slit_width, args.pitch)

    # Make a numpy array
    columnar_matrix_numpy = numpy.array(columnar_matrix)

    # This line sets the threshold to NaN rather than 0 (flat grating)
    numpy.set_printoptions(threshold=numpy.nan)

    #print(columnar_matrix_numpy)

    # Making the .stl file
    fn = "bigger_default.stl"
    stl_tools.numpy2stl(columnar_matrix_numpy,
                        fn,
                        scale=1,
                        mask_val=1,
import math
import structure_methods
import argparse

if __name__ == "__main__":

    # Processing user input
    parser = argparse.ArgumentParser()
    parser.add_argument("no_columns", type=int, help="Number of columns in total structure")
    parser.add_argument("no_rows", type=int, help="Number of rows in total structure")
    parser.add_argument("slit_width", type=int, help="Width of one slit")
    parser.add_argument("pitch", type=int, help="Diffraction grating pitch")
    parser.add_argument("--strut_width", type=int, help="Specifies slit width, defaults to 1 unit")
    parser.add_argument("--frame_boarder", type=int, help="Specifies frame boarder width, defaults to 1 unit")
    parser.add_argument("--file_name", help="Specifies output file name, defaults to 'default.stl'")
    args = parser.parse_args()

    columnar_matrix = structure_methods.columnar_generator(args.no_columns, args.no_rows, args.slit_width, args.pitch)

    # Make a numpy array
    columnar_matrix_numpy = numpy.array(columnar_matrix)

    # This line sets the threshold to NaN rather than 0 (flat grating)
    numpy.set_printoptions(threshold=numpy.nan)

    # print(columnar_matrix_numpy)

    # Making the .stl file
    fn = "bigger_default.stl"
    stl_tools.numpy2stl(columnar_matrix_numpy, fn, scale=1, mask_val=1, force_python=True, square_corners=True)