Exemple #1
0
def generate(polygon_vertices: np.ndarray,
             title: str = "polygon_name",
             DNAout: bool = False,
             PLOTout: bool = False):
    print(f"{title}: Making polygon...")
    polygon = BoundaryPolygon(polygon_vertices)
    print(f"{title}: ...constructing scaffolding lattice...")
    lattice = polygon.dna_snake(straightening_factor=5,
                                start_side="left",
                                grid_size=[0.34, 2.5])
    print(f"{title}: ...calculating route.")
    route = lattice.route()

    if PLOTout:
        print(f"{title}: Generating and saving lattice plot.")
        plot_list = [lattice.quantised_array, lattice.crossover_coords]
        lattice.plot(plot_list,
                     poly=True,
                     fout=title,
                     root=ROOT + "/lattice-plot_out/",
                     aspect=6)
    route.plot()

    if DNAout:
        system = route.system()
        print(f"{title}: Generating and saving oxDNA files.")
        system.write_oxDNA(prefix=title, root=ROOT + "/oxDNA_out/")
        print(f"{title}: Generating and saving LAMMPS files.")
        system.write_LAMMPS(prefix=title, root=ROOT + "/LAMMPS_out/")
Exemple #2
0
def generate(polygon_vertices: np.ndarray,
             DNAout: str = None,
             PLOTout: str = None):
    polygon = BoundaryPolygon(polygon_vertices)
    lattice = polygon.dna_snake(straightening_factor=5, start_side="left")
    route = lattice.route()

    if PLOTout:
        plot_list = [lattice.quantised_array, lattice.crossover_coords]
        lattice.plot(plot_list, poly=True)
    route.plot()
Exemple #3
0
def test_BoundaryPolygon():
    square = BoundaryPolygon(
        np.array([
            [1, 0, 0],
            [1, 1, 0],
            [0, 1, 0],
            [0, 0, 0],
        ]))

    assert square.n_edges == len(square.edges)
    assert square.x.sum() == 2
    assert square.y.sum() == 2
    assert square.z.sum() == 0
    assert isinstance(square.edges[0], Edge)

    # square.plot2D(show=False)
    # square.write_STL(f"{ROOT}/square.stl")
    square.write_PLY(f"{ROOT}/square.ply")
Exemple #4
0
def main():
    # read file
    mesh = meshio.read("/home/shanil/drawNA/polygons/STL/hexagon.stl")
    # output vertices
    mesh = mesh.points
    # use only vertices on the z = 0 plane
    mesh = mesh[mesh[:, 2] == 0]

    mesh = np.random.permutation(np.array(mesh))

    permutations = itertools.permutations(range(0, mesh.shape[0]))

    SHAPE = BoundaryPolygon(mesh)
    SHAPE2 = SHAPE
    SHAPE2 = np.vstack((SHAPE.vertices, SHAPE.vertices))

    # make_polygon(mesh)

    print(f"mesh shape is {mesh.shape[0]} \n and SHAPE2 is {SHAPE2}")

    def shapeIsSimple(SHAPE3):
        # make_polygon(SHAPE3)
        return LineString(SHAPE3).is_simple

    perm = next(permutations)

    for j in range(0, math.factorial(mesh.shape[0])):

        SHAPE3 = SHAPE2[perm[0]]

        for i in range(1, mesh.shape[0]):
            SHAPE3 = np.vstack((SHAPE3, SHAPE2[perm[i]]))

        if shapeIsSimple(SHAPE3):  # no intersections
            print(f"Finally \n Updated orientation: {SHAPE3}")
            break

        perm = next(permutations)

    print(f"Permutation: {perm}")

    make_polygon(SHAPE3)
Exemple #5
0
import numpy as np
from drawNA.polygons import BoundaryPolygon, make_polygon

###---stored arrays of some shapes---###
square = np.array([[0, 0, 0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0],
                   [1.0, 0.0, 0.0]])
trapezium = np.array([[0, 0, 0], [1.0, 10.0, 0.0], [11.0, 10.0, 0.0],
                      [15.0, 0.0, 0.0]])

no = 0.866025
hexagon = np.array([[0, 1, 0], [no, 0.5, 0], [no, -0.5, 0], [0, -1, 0],
                    [-no, -0.5, 0], [-no, 0.5, 0]])

star = np.array([
    [0, 300, 0],
    [100, 110, 0],
    [300, 70, 0],
    [160, -90, 0],
    [190, -300, 0],
    [0, -210, 0],
    [-190, -300, 0],
    [-160, -90, 0],
    [-300, 70, 0],
    [-100, 110, 0],
])

###---run the program---###
SHAPE = BoundaryPolygon(star)
make_polygon(star, SHAPE)
Exemple #6
0
###---stored arrays of some shapes---###
square = np.array([[0, 0, 0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0]])
trapezium = np.array([[0, 0, 0], [1.0, 10.0, 0.0], [11.0, 10.0, 0.0], [15.0, 0.0, 0.0]])

no = 0.866025
hexagon = np.array(
    [[0, 1, 0], [no, 0.5, 0], [no, -0.5, 0], [0, -1, 0], [-no, -0.5, 0], [-no, 0.5, 0]]
)

star = np.array(
    [
        [0, 300, 0],
        [100, 110, 0],
        [300, 70, 0],
        [160, -90, 0],
        [190, -300, 0],
        [0, -210, 0],
        [-190, -300, 0],
        [-160, -90, 0],
        [-300, 70, 0],
        [-100, 110, 0],
    ]
)

 if __name__ == "__main__":
    print("Generating polygon object...")
    polygon = BoundaryPolygon(star)
    print("Plotting object...")
    polygon.plot2D()
def square():
    square = np.array([[0, 0, 0], [0.0, 1.0, 0.0], [1.0, 1.0, 0.0], [1.0, 0.0, 0.0]])
    polygon = BoundaryPolygon(square * 20)
    return polygon
Exemple #8
0
 def __init__(self, polygon_array, lattice, gridsize=0.1):
     self.polygon = np.concatenate(
         [polygon_array, np.array([polygon_array[0, :]])], axis=0)
     self.lattice = lattice
     self.obj = BoundaryPolygon(polygon_array)
     _ = self.inside