Example #1
0
 def hole(self,
          hole_start=None,
          hole_depth=None,
          hole_radius=None,
          obj_list=None):
     """
     Makes a hole in the given object list (which all need to be combinations).
     It creates an RCC with the given parameters, and modifies each combination
     by replacing the original combination tree with subtract(original - hole_rcc).
     The only new object added is the hole RCC which will be named "make_hole_X"
     where X is some integer.
     """
     check_missing_params("WDB.hole",
                          hole_start=hole_start,
                          hole_depth=hole_depth,
                          hole_radius=hole_radius,
                          obj_list=obj_list)
     if isinstance(obj_list, str):
         obj_list = [obj_list]
     idb_types, db_internals, dpp_list = zip(
         *[self._lookup_internal(obj) for obj in obj_list])
     if not idb_types:
         raise ValueError("No objects to hole !")
     if any(
             map(lambda idb_type: idb_type != libwdb.ID_COMBINATION,
                 idb_types)):
         raise ValueError(
             "All shapes should be combinations: {}".format(obj_list))
     dir_list = cta.ctypes_array(dpp_list)
     libwdb.make_hole(self.db_fp, cta.point(hole_start),
                      cta.point(hole_depth), hole_radius, len(dpp_list),
                      dir_list)
Example #2
0
 def hole(self, hole_start=None, hole_depth=None, hole_radius=None, obj_list=None):
     """
     Makes a hole in the given object list (which all need to be combinations).
     It creates an RCC with the given parameters, and modifies each combination
     by replacing the original combination tree with subtract(original - hole_rcc).
     The only new object added is the hole RCC which will be named "make_hole_X"
     where X is some integer.
     """
     check_missing_params(
         "WDB.hole", hole_start=hole_start, hole_depth=hole_depth, hole_radius=hole_radius, obj_list=obj_list
     )
     if isinstance(obj_list, str):
         obj_list = [obj_list]
     idb_types, db_internals, dpp_list = zip(*[self._lookup_internal(obj) for obj in obj_list])
     if not idb_types:
         raise ValueError("No objects to hole !")
     if any(map(lambda idb_type: idb_type != libwdb.ID_COMBINATION, idb_types)):
         raise ValueError("All shapes should be combinations: {}".format(obj_list))
     dir_list = cta.ctypes_array(dpp_list)
     libwdb.make_hole(
         self.db_fp,
         cta.point(hole_start),
         cta.point(hole_depth),
         hole_radius,
         len(dpp_list), dir_list
     )
Example #3
0
 def extrude(self, name, sketch=None, base=None, height=None, u_vec=None, v_vec=None):
     libwdb.mk_extrusion(
         self.db_fp, name, sketch.name,
         cta.point((0, 0, 0) if base is None else base),
         cta.point((0, 0, 1) if height is None else height),
         cta.point((1, 0, 0) if u_vec is None else u_vec),
         cta.point((0, 1, 0) if v_vec is None else v_vec),
         0
     )
Example #4
0
 def revolve(self, name, sketch=None, revolve_center=None, revolve_axis=None, radius=None, angle=None):
     ri = cta.brlcad_new(libwdb.struct_rt_revolve_internal)
     ri.magic = libwdb.RT_REVOLVE_INTERNAL_MAGIC
     ri.v3d = cta.point((0, 0, 0) if revolve_center is None else revolve_center)
     ri.axis3d = cta.point((0, 0, 1) if revolve_axis is None else revolve_axis)
     ri.r = cta.point((1, 0, 0) if radius is None else radius)
     ri.ang = 180 if angle is None else angle
     ri.sketch_name = cta.str_to_vls(sketch.name)
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(ri), libwdb.ID_REVOLVE, 1)
Example #5
0
 def superell(self, name, center=(0, 0, 0), a=(1, 0, 0), b=(0, 1, 0), c=(0, 0, 1), n=0, e=0):
     s = cta.brlcad_new(libwdb.struct_rt_superell_internal)
     s.magic = libwdb.RT_SUPERELL_INTERNAL_MAGIC
     s.v = cta.point(center)
     s.a = cta.point(a)
     s.b = cta.point(b)
     s.c = cta.point(c)
     s.e = e
     s.n = n
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(s), libwdb.ID_SUPERELL, 1)
Example #6
0
 def sketch(self, name, sketch=None):
     if not sketch:
         sketch = primitives.Sketch(name)
     si = libwdb.struct_rt_sketch_internal()
     si.magic = libwdb.RT_SKETCH_INTERNAL_MAGIC
     si.V = cta.point(sketch.base)
     si.u_vec = cta.point(sketch.u_vec)
     si.v_vec = cta.point(sketch.v_vec)
     si.curve, vertices = sketch.build_curves()
     si.vert_count = len(vertices)
     si.verts = cta.points2D(vertices, point_count=len(vertices))
     libwdb.mk_sketch(self.db_fp, name, libwdb.byref(si))
Example #7
0
 def sketch(self, name, sketch=None):
     if not sketch:
         sketch = primitives.Sketch(name)
     si = libwdb.struct_rt_sketch_internal()
     si.magic = libwdb.RT_SKETCH_INTERNAL_MAGIC
     si.V = cta.point(sketch.base)
     si.u_vec = cta.point(sketch.u_vec)
     si.v_vec = cta.point(sketch.v_vec)
     si.curve, vertices = sketch.build_curves()
     si.vert_count = len(vertices)
     si.verts = cta.points2D(vertices, point_count=len(vertices))
     libwdb.mk_sketch(self.db_fp, name, libwdb.byref(si))
Example #8
0
 def extrude(self,
             name,
             sketch=None,
             base=None,
             height=None,
             u_vec=None,
             v_vec=None):
     libwdb.mk_extrusion(self.db_fp, name, sketch.name,
                         cta.point((0, 0, 0) if base is None else base),
                         cta.point((0, 0, 1) if height is None else height),
                         cta.point((1, 0, 0) if u_vec is None else u_vec),
                         cta.point((0, 1, 0) if v_vec is None else v_vec),
                         0)
Example #9
0
 def rpc(self,
         name,
         base=(0, 0, 0),
         height=(-1, 0, 0),
         breadth=(0, 0, 1),
         half_width=0.5):
     libwdb.mk_rpc(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(breadth), half_width)
Example #10
0
 def ellipsoid(self,
               name,
               center=(0, 0, 0),
               a=(1, 0, 0),
               b=(0, 1, 0),
               c=(0, 0, 1)):
     libwdb.mk_ell(self.db_fp, name, cta.point(center), cta.direction(a),
                   cta.direction(b), cta.direction(c))
Example #11
0
 def particle(self,
              name,
              base=(0, 0, 0),
              height=(0, 0, 1),
              r_base=0.5,
              r_end=0.2):
     libwdb.mk_particle(self.db_fp, name, cta.point(base),
                        cta.direction(height), r_base, r_end)
Example #12
0
 def torus(self,
           name,
           center=(0, 0, 0),
           n=(0, 0, 1),
           r_revolution=1,
           r_cross=0.2):
     libwdb.mk_tor(self.db_fp, name, cta.point(center), cta.direction(n),
                   r_revolution, r_cross)
Example #13
0
 def eto(self,
         name,
         center=(0, 0, 0),
         n=(0, 0, 1),
         s_major=(0, 0.5, 0.5),
         r_revolution=1,
         r_minor=0.2):
     libwdb.mk_eto(self.db_fp, name, cta.point(center), cta.direction(n),
                   cta.direction(s_major), r_revolution, r_minor)
Example #14
0
 def hyperboloid(self,
                 name,
                 base=(0, 0, 0),
                 height=(0, 0, 1),
                 a_vec=(0, 1, 0),
                 b_mag=0.5,
                 base_neck_ratio=0.2):
     libwdb.mk_hyp(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(a_vec), b_mag, base_neck_ratio)
Example #15
0
 def epa(self,
         name,
         base=(0, 0, 0),
         height=(0, 0, 1),
         n_major=(0, 1, 0),
         r_major=1,
         r_minor=0.5):
     libwdb.mk_epa(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(n_major), r_major, r_minor)
Example #16
0
 def rhc(self,
         name,
         base=(0, 0, 0),
         height=(-1, 0, 0),
         breadth=(0, 0, 1),
         half_width=0.5,
         asymptote=0.1):
     libwdb.mk_rhc(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(breadth), half_width, asymptote)
Example #17
0
 def superell(self,
              name,
              center=(0, 0, 0),
              a=(1, 0, 0),
              b=(0, 1, 0),
              c=(0, 0, 1),
              n=0,
              e=0):
     s = cta.brlcad_new(libwdb.struct_rt_superell_internal)
     s.magic = libwdb.RT_SUPERELL_INTERNAL_MAGIC
     s.v = cta.point(center)
     s.a = cta.point(a)
     s.b = cta.point(b)
     s.c = cta.point(c)
     s.e = e
     s.n = n
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(s),
                       libwdb.ID_SUPERELL, 1)
Example #18
0
 def cone(self,
          name,
          base=(0, 0, 0),
          n=(0, 0, 1),
          h=1,
          r_base=1,
          r_top=0.5):
     libwdb.mk_cone(self.db_fp, name, cta.point(base), cta.direction(n), h,
                    r_base, r_top)
Example #19
0
 def pipe(self, name, points=(((0, 0, 0), 0.5, 0.3, 1), ((0, 0, 1), 0.5, 0.3, 1))):
     """
     The pipe points are: (point, outer_d, inner_d, bend_d)
     """
     seg_list = libwdb.bu_list_new()
     libwdb.mk_pipe_init(seg_list)
     for pipe_point in points:
         libwdb.mk_add_pipe_pt(seg_list, cta.point(pipe_point[0]), *pipe_point[1:])
     libwdb.mk_pipe(self.db_fp, name, seg_list)
Example #20
0
 def revolve(self,
             name,
             sketch=None,
             revolve_center=None,
             revolve_axis=None,
             radius=None,
             angle=None):
     ri = cta.brlcad_new(libwdb.struct_rt_revolve_internal)
     ri.magic = libwdb.RT_REVOLVE_INTERNAL_MAGIC
     ri.v3d = cta.point((0, 0,
                         0) if revolve_center is None else revolve_center)
     ri.axis3d = cta.point((0, 0,
                            1) if revolve_axis is None else revolve_axis)
     ri.r = cta.point((1, 0, 0) if radius is None else radius)
     ri.ang = 180 if angle is None else angle
     ri.sketch_name = cta.str_to_vls(sketch.name)
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(ri),
                       libwdb.ID_REVOLVE, 1)
Example #21
0
 def ehy(self,
         name,
         base=(0, 0, 0),
         height=(0, 0, 1),
         n_major=(0, 1, 0),
         r_major=1,
         r_minor=0.5,
         asymptote=0.1):
     libwdb.mk_ehy(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(n_major), r_major, r_minor, asymptote)
Example #22
0
 def ehy(self, name, base=(0, 0, 0), height=(0, 0, 1), n_major=(0, 1, 0), r_major=1, r_minor=0.5, asymptote=0.1):
     libwdb.mk_ehy(
         self.db_fp,
         name,
         cta.point(base),
         cta.direction(height),
         cta.direction(n_major),
         r_major,
         r_minor,
         asymptote,
     )
Example #23
0
 def tgc(self,
         name,
         base=(0, 0, 0),
         height=(0, 0, 1),
         a=(0, 1, 0),
         b=(0.5, 0, 0),
         c=(0, 0.5, 0),
         d=(1, 0, 0)):
     libwdb.mk_tgc(self.db_fp, name, cta.point(base), cta.direction(height),
                   cta.direction(a), cta.direction(b), cta.direction(c),
                   cta.direction(d))
Example #24
0
 def tgc(self, name, base=(0, 0, 0), height=(0, 0, 1), a=(0, 1, 0), b=(0.5, 0, 0), c=(0, 0.5, 0), d=(1, 0, 0)):
     libwdb.mk_tgc(
         self.db_fp,
         name,
         cta.point(base),
         cta.direction(height),
         cta.direction(a),
         cta.direction(b),
         cta.direction(c),
         cta.direction(d),
     )
Example #25
0
 def wedge(self,
           name,
           vertex=(0, 0, 0),
           x_dir=(1, 0, 0),
           z_dir=(0, 0, 1),
           x_len=1,
           y_len=1,
           z_len=1,
           x_top_len=0.5):
     libwdb.mk_wedge(self.db_fp, name, cta.point(vertex),
                     cta.direction(x_dir), cta.direction(z_dir), x_len,
                     y_len, z_len, x_top_len)
Example #26
0
 def wedge(self, name, vertex=(0, 0, 0), x_dir=(1, 0, 0), z_dir=(0, 0, 1), x_len=1, y_len=1, z_len=1, x_top_len=0.5):
     libwdb.mk_wedge(
         self.db_fp,
         name,
         cta.point(vertex),
         cta.direction(x_dir),
         cta.direction(z_dir),
         x_len,
         y_len,
         z_len,
         x_top_len,
     )
Example #27
0
 def pipe(self,
          name,
          points=(((0, 0, 0), 0.5, 0.3, 1), ((0, 0, 1), 0.5, 0.3, 1))):
     """
     The pipe points are: (point, outer_d, inner_d, bend_d)
     """
     seg_list = libwdb.bu_list_new()
     libwdb.mk_pipe_init(seg_list)
     for pipe_point in points:
         libwdb.mk_add_pipe_pt(seg_list, cta.point(pipe_point[0]),
                               *pipe_point[1:])
     libwdb.mk_pipe(self.db_fp, name, seg_list)
Example #28
0
 def vol(self,
         name,
         file_name,
         x_dim=1,
         y_dim=1,
         z_dim=1,
         low_thresh=0,
         high_thresh=128,
         cell_size=(1, 1, 1),
         mat=Transform.unit()):
     libwdb.mk_vol(self.db_fp, name, file_name, x_dim, y_dim, z_dim,
                   low_thresh, high_thresh, cta.point(cell_size),
                   cta.transform(mat))
Example #29
0
 def vol(
     self,
     name,
     file_name,
     x_dim=1,
     y_dim=1,
     z_dim=1,
     low_thresh=0,
     high_thresh=128,
     cell_size=(1, 1, 1),
     mat=Transform.unit(),
 ):
     libwdb.mk_vol(
         self.db_fp,
         name,
         file_name,
         x_dim,
         y_dim,
         z_dim,
         low_thresh,
         high_thresh,
         cta.point(cell_size),
         cta.transform(mat),
     )
Example #30
0
 def rhc(self, name, base=(0, 0, 0), height=(-1, 0, 0), breadth=(0, 0, 1), half_width=0.5, asymptote=0.1):
     libwdb.mk_rhc(
         self.db_fp, name, cta.point(base), cta.direction(height), cta.direction(breadth), half_width, asymptote
     )
Example #31
0
 def epa(self, name, base=(0, 0, 0), height=(0, 0, 1), n_major=(0, 1, 0), r_major=1, r_minor=0.5):
     libwdb.mk_epa(
         self.db_fp, name, cta.point(base), cta.direction(height), cta.direction(n_major), r_major, r_minor
     )
Example #32
0
 def half(self, name, norm=(1, 0, 0), d=1.0):
     libwdb.mk_half(self.db_fp, name, cta.point(norm), d)
Example #33
0
 def rpc(self, name, base=(0, 0, 0), height=(-1, 0, 0), breadth=(0, 0, 1), half_width=0.5):
     libwdb.mk_rpc(self.db_fp, name, cta.point(base), cta.direction(height), cta.direction(breadth), half_width)
Example #34
0
 def trc(self, name, base=(0, 0, 0), height=(0, 0, 1), r_base=1, r_top=0.5):
     libwdb.mk_trc_h(self.db_fp, name, cta.point(base),
                     cta.direction(height), r_base, r_top)
Example #35
0
 def rcc(self, name, base=(0, 0, 0), height=(0, 0, 1), radius=1):
     libwdb.mk_rcc(self.db_fp, name, cta.point(base), cta.direction(height),
                   radius)
Example #36
0
 def eto(self, name, center=(0, 0, 0), n=(0, 0, 1), s_major=(0, 0.5, 0.5), r_revolution=1, r_minor=0.2):
     libwdb.mk_eto(
         self.db_fp, name, cta.point(center), cta.direction(n), cta.direction(s_major), r_revolution, r_minor
     )
Example #37
0
 def grip(self, name, center=(0, 0, 0), normal=(1, 0, 0), magnitude=1):
     libwdb.mk_grip(self.db_fp, name, cta.point(center, 3), cta.point(normal, 3), magnitude)
Example #38
0
 def half(self, name, norm=(1, 0, 0), d=1.0):
     libwdb.mk_half(self.db_fp, name, cta.point(norm), d)
Example #39
0
 def rcc(self, name, base=(0, 0, 0), height=(0, 0, 1), radius=1):
     libwdb.mk_rcc(self.db_fp, name, cta.point(base), cta.direction(height), radius)
Example #40
0
 def torus(self, name, center=(0, 0, 0), n=(0, 0, 1), r_revolution=1, r_cross=0.2):
     libwdb.mk_tor(self.db_fp, name, cta.point(center), cta.direction(n), r_revolution, r_cross)
Example #41
0
 def ellipsoid(self, name, center=(0, 0, 0), a=(1, 0, 0), b=(0, 1, 0), c=(0, 0, 1)):
     libwdb.mk_ell(self.db_fp, name, cta.point(center), cta.direction(a), cta.direction(b), cta.direction(c))
Example #42
0
 def rpp(self, name, pmin=(-1, -1, -1), pmax=(1, 1, 1)):
     libwdb.mk_rpp(self.db_fp, name, cta.point(pmin), cta.point(pmax))
Example #43
0
 def hyperboloid(self, name, base=(0, 0, 0), height=(0, 0, 1), a_vec=(0, 1, 0), b_mag=0.5, base_neck_ratio=0.2):
     libwdb.mk_hyp(
         self.db_fp, name, cta.point(base), cta.direction(height), cta.direction(a_vec), b_mag, base_neck_ratio
     )
Example #44
0
 def cone(self, name, base=(0, 0, 0), n=(0, 0, 1), h=1, r_base=1, r_top=0.5):
     libwdb.mk_cone(self.db_fp, name, cta.point(base), cta.direction(n), h, r_base, r_top)
Example #45
0
 def particle(self, name, base=(0, 0, 0), height=(0, 0, 1), r_base=0.5, r_end=0.2):
     libwdb.mk_particle(self.db_fp, name, cta.point(base), cta.direction(height), r_base, r_end)
Example #46
0
 def trc(self, name, base=(0, 0, 0), height=(0, 0, 1), r_base=1, r_top=0.5):
     libwdb.mk_trc_h(self.db_fp, name, cta.point(base), cta.direction(height), r_base, r_top)
Example #47
0
 def grip(self, name, center=(0, 0, 0), normal=(1, 0, 0), magnitude=1):
     libwdb.mk_grip(self.db_fp, name, cta.point(center, 3),
                    cta.point(normal, 3), magnitude)
Example #48
0
 def rpp(self, name, pmin=(-1, -1, -1), pmax=(1, 1, 1)):
     libwdb.mk_rpp(self.db_fp, name, cta.point(pmin), cta.point(pmax))
Example #49
0
 def sphere(self, name, center=(0, 0, 0), radius=1):
     libwdb.mk_sph(self.db_fp, name, cta.point(center), radius)
Example #50
0
 def sphere(self, name, center=(0, 0, 0), radius=1):
     libwdb.mk_sph(self.db_fp, name, cta.point(center), radius)