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)
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 )
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 )
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)
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)
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))
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)
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)
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))
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)
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)
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)
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)
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)
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)
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)
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)
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)
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, )
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))
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), )
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)
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, )
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))
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), )
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 )
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 )
def half(self, name, norm=(1, 0, 0), d=1.0): libwdb.mk_half(self.db_fp, name, cta.point(norm), d)
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)
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)
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 )
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)
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))
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 )
def sphere(self, name, center=(0, 0, 0), radius=1): libwdb.mk_sph(self.db_fp, name, cta.point(center), radius)