Пример #1
0
def partial_cylinder(x1, y1, z1, x2, y2, z2, radius, angle):
  L = math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
  direction = Common.gp_Dir((x2 - x1)/L, (y2 - y1)/L, (z2 - z1)/L)
  axis = Common.gp_Ax2(Common.gp_Pnt(x1, y1, z1), direction)
  if angle < 360:
    angle = angle*math.pi/180
    shape = BRepPrimAPI.BRepPrimAPI_MakeCylinder(axis, radius, L, angle).Shape()
  else:
    shape = BRepPrimAPI.BRepPrimAPI_MakeCylinder(axis, radius, L).Shape()
  return shape
Пример #2
0
def partial_cylinder(x1, y1, z1, x2, y2, z2, radius, angle):
    L = math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
    direction = Common.gp_Dir((x2 - x1) / L, (y2 - y1) / L, (z2 - z1) / L)
    axis = Common.gp_Ax2(Common.gp_Pnt(x1, y1, z1), direction)
    if angle < 360:
        angle = angle * math.pi / 180
        shape = BRepPrimAPI.BRepPrimAPI_MakeCylinder(axis, radius, L,
                                                     angle).Shape()
    else:
        shape = BRepPrimAPI.BRepPrimAPI_MakeCylinder(axis, radius, L).Shape()
    return shape
Пример #3
0
def solid(faces):
  sewing = BRepBuilderAPI_Sewing()
  for face in faces:
    pts = []
    for node in face:
      pts.append(Common.gp_Pnt(node[0], node[1], node[2]))
    try:
      sewing.Add(Construct.make_face(Construct.make_closed_polygon(pts)))
    except AssertionError:
      print pts
      exit(1)
  sewing.Perform()
  sewed_shape = sewing.SewedShape() 
  return sewed_shape
Пример #4
0
def solid(faces):
    sewing = BRepBuilderAPI_Sewing()
    for face in faces:
        pts = []
        for node in face:
            pts.append(Common.gp_Pnt(node[0], node[1], node[2]))
        try:
            sewing.Add(Construct.make_face(Construct.make_closed_polygon(pts)))
        except AssertionError:
            print pts
            exit(1)
    sewing.Perform()
    sewed_shape = sewing.SewedShape()
    return sewed_shape
Пример #5
0
def scale(shape, x, y, z, factor):
  return Construct.scale(shape, Common.gp_Pnt(x,y,z), factor)
Пример #6
0
def move_z(shape, dz):
  return Construct.translate_topods_from_vector(shape, Common.gp_Vec(0, 0, dz))
Пример #7
0
def move_y(shape, dy):
  return Construct.translate_topods_from_vector(shape, Common.gp_Vec(0, dy, 0))
Пример #8
0
def move_x(shape, dx):
  return Construct.translate_topods_from_vector(shape, Common.gp_Vec(dx, 0, 0))
Пример #9
0
def move_x(shape, dx):
    return Construct.translate_topods_from_vector(shape,
                                                  Common.gp_Vec(dx, 0, 0))
Пример #10
0
def rotate(shape, x1, y1, z1, x2, y2, z2, angle):
    L = math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
    direction = Common.gp_Dir((x2 - x1) / L, (y2 - y1) / L, (z2 - z1) / L)
    axis = Common.gp_Ax1(Common.gp_Pnt(x1, y1, z1), direction)
    return Construct.rotate(shape, axis, angle)
Пример #11
0
def box(x1, y1, z1, x2, y2, z2):
    return BRepPrimAPI.BRepPrimAPI_MakeBox(Common.gp_Pnt(x1, y1, z1),
                                           Common.gp_Pnt(x2, y2, z2)).Shape()
Пример #12
0
def scale(shape, x, y, z, factor):
    return Construct.scale(shape, Common.gp_Pnt(x, y, z), factor)
Пример #13
0
def move_z(shape, dz):
    return Construct.translate_topods_from_vector(shape,
                                                  Common.gp_Vec(0, 0, dz))
Пример #14
0
def move_y(shape, dy):
    return Construct.translate_topods_from_vector(shape,
                                                  Common.gp_Vec(0, dy, 0))
Пример #15
0
def box(x1, y1, z1, x2, y2, z2):
  return BRepPrimAPI.BRepPrimAPI_MakeBox(Common.gp_Pnt(x1, y1, z1), Common.gp_Pnt(x2, y2, z2)).Shape()
Пример #16
0
def move(shape, dx, dy, dz):
  return Construct.translate_topods_from_vector(shape, Common.gp_Vec(dx, dy, dz))
Пример #17
0
def rotate(shape, x1, y1, z1, x2, y2, z2, angle):
  L = math.sqrt((x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2)
  direction = Common.gp_Dir((x2 - x1)/L, (y2 - y1)/L, (z2 - z1)/L)
  axis = Common.gp_Ax1(Common.gp_Pnt(x1, y1, z1), direction)
  return Construct.rotate(shape, axis, angle)
Пример #18
0
def move(shape, dx, dy, dz):
    return Construct.translate_topods_from_vector(shape,
                                                  Common.gp_Vec(dx, dy, dz))