Esempio n. 1
0
def CreateNet(w, h, alpha):
  mesh = MetaMesh()

  thickness = 0.015

  N_w = int(2*w/alpha)
  N_h = int(h/alpha)
  
  dh = 0

  print(N_h)

  for k in range(0, N_h):
    dh = float(k*alpha)
    mesh.AddBox(0, 0, dh, w, thickness, thickness)

  for k in range(0, N_w):
    dw = float(k*alpha) - w
    mesh.AddBox(dw, 0, h/2, thickness, thickness, h/2)

  fname = "%.3f"%alpha
  fname = fname.replace(".", "_")

  path = "../../data/terrains/"
  os.chdir(path)
  fname = "net_"+fname+".off"
  mesh.write(fname)
def CreateTriRoom(alpha):
    mesh = MetaMesh()

    length_passage = 0.2
    Z_height = 0.1
    width_wall = 0.2
    length_wall = 4

    length_bttm = 1
    max_x = 6

    width_mid = 0.5 * (max_x - length_passage - width_wall)
    x_mid = length_passage + width_mid

    #left wall
    mesh.AddBox(-max_x, 0, 0, width_wall, length_wall, Z_height)
    mesh.AddBox(-x_mid, -length_wall + width_wall, 0, width_mid, width_wall,
                Z_height)
    mesh.AddBox(-x_mid, +length_wall - width_wall, 0, width_mid, width_wall,
                Z_height)

    #right wall
    mesh.AddBox(+max_x, 0, 0, width_wall, length_wall, Z_height)
    mesh.AddBox(+x_mid, -length_wall + width_wall, 0, width_mid, width_wall,
                Z_height)
    mesh.AddBox(+x_mid, +length_wall - width_wall, 0, width_mid, width_wall,
                Z_height)

    ##narrow passage
    width_passage_box = 0.5 * (length_wall - alpha)
    y = alpha + width_passage_box
    mesh.AddBox(0, +y, 0, length_passage, width_passage_box, Z_height)
    mesh.AddBox(0, -y, 0, length_passage, width_passage_box, Z_height)

    fname = "%.2f" % alpha
    fname = fname.replace(".", "_")

    path = "../../data/terrains/narrow_passage/"
    os.chdir(path)
    fname = "narrow_passage_" + fname + ".off"
    mesh.write(fname)
import numpy as np
from shutil import copyfile
import subprocess
from tri_primitives import MetaMesh
import os, sys, re

Z_height = 0.1
radius = 0.15
mesh = MetaMesh()
mesh.AddCylinder(0, 0, 0, radius, Z_height)

path = "../../data/terrains/primitives/"
os.chdir(path)
fname = "manipulatable_disk.off"
mesh.write(fname)
# import subprocess
# subprocess.run(["off2tri", fname])
def CreateTriRoomSequential(alpha):
    mesh = MetaMesh()

    length_passage = 0.2
    Z_height = 0.1
    width_wall = 0.2
    length_wall = 4

    length_bttm = 1
    x_max = 8

    width_mid = 0.5 * (x_max - length_passage - width_wall)
    x_mid = length_passage + width_mid

    #left wall
    mesh.AddBox(-x_max, 0, 0, width_wall, length_wall, Z_height)
    #right wall
    mesh.AddBox(+x_max, 0, 0, width_wall, length_wall, Z_height)

    #top wall
    mesh.AddBox(0, +length_wall - width_wall, 0, x_max, width_wall, Z_height)
    #bottom wall
    mesh.AddBox(0, -length_wall + width_wall, 0, x_max, width_wall, Z_height)

    ##narrow passage
    width_passage_box = 0.5 * (length_wall - alpha)
    y = alpha + width_passage_box
    mesh.AddBox(-0.25 * x_max, +y, 0, length_passage, width_passage_box,
                Z_height)
    mesh.AddBox(-0.25 * x_max, -y, 0, length_passage, width_passage_box,
                Z_height)
    ##narrow passage 2
    mesh.AddBox(+0.25 * x_max, +y, 0, length_passage, width_passage_box,
                Z_height)
    mesh.AddBox(+0.25 * x_max, -y, 0, length_passage, width_passage_box,
                Z_height)

    fname = "%.2f" % alpha
    fname = fname.replace(".", "_")

    path = "../../data/terrains/narrow_passage/"
    os.chdir(path)
    fname = "narrow_passage_sequential_" + fname + ".off"
    mesh.write(fname)
Esempio n. 5
0
def CreateRoom(N, alpha):
    mesh = MetaMesh()

    height = 0.1
    length = 8
    length_inner_box = 0.3 * length
    thickness = 0.5
    passage_length = 1.3
    top_length = 4 * passage_length
    xright = 0.5 * length + thickness
    xleft = -xright

    #(1) bottom element
    mesh.AddBox(0, 0, 0, 0.5 * length + 2 * thickness, thickness, height)
    y = thickness + 0.5 * passage_length
    mesh.AddBox(xleft, y, 0, thickness, 0.5 * passage_length, height)
    mesh.AddBox(xright, y, 0, thickness, 0.5 * passage_length, height)
    #(3) N passage elements
    for k in range(1, N):
        yoffset = thickness + passage_length + 2 * (k - 1) * passage_length
        yk = yoffset + 0.5 * passage_length
        mesh.AddBox(0, yk, 0, 0.5 * length_inner_box, 0.5 * passage_length,
                    height)
        yk = yoffset + passage_length
        mesh.AddBox(xleft, yk, 0, thickness, passage_length, height)
        mesh.AddBox(xright, yk, 0, thickness, passage_length, height)

    #(N+1) top element
    yoffset = thickness + passage_length + 2 * (N - 1) * passage_length
    ytop = yoffset + top_length + thickness
    mesh.AddBox(0, ytop, 0, 0.5 * length + 2 * thickness, thickness, height)
    y = yoffset + 0.5 * top_length
    mesh.AddBox(xleft, y, 0, thickness, 0.5 * top_length, height)
    mesh.AddBox(xright, y, 0, thickness, 0.5 * top_length, height)
    y = yoffset + 0.25 * top_length
    mesh.AddBox(0, y, 0, 0.5 * length_inner_box, 0.25 * top_length, height)

    path = "../../data/terrains/"
    os.chdir(path)
    fname = "spurious_path_N.off"
    mesh.write(fname)
import numpy as np
from shutil import copyfile
import subprocess
from tri_primitives import MetaMesh
import os, sys, re

height = 0.2
radius = 0.8

mesh = MetaMesh()
mesh.AddCylinderWithCut(0, 0, 0, radius, height)

path = "../../data/terrains/primitives/"
os.chdir(path)

fname = "cylinder_height_%.2f_radius_%.2f_cut" % (height, radius)
fname = fname.replace(".", "_")
fname = fname + ".stl"

mesh.write(fname)
# import subprocess
# subprocess.run(["off2tri", fname])