Ejemplo n.º 1
0
 def combination(
     self,
     name,
     is_region=False,
     tree=None,
     inherit=False,
     shader=None,
     material=None,
     rgb_color=None,
     temperature=0,
     region_id=0,
     air_code=0,
     gift_material=0,
     line_of_sight=0,
     is_fastgen=libwdb.REGION_NON_FASTGEN,
 ):
     if not tree:
         raise ValueError("Empty tree for combination: {0}".format(name))
     tree = primitives.wrap_tree(tree)
     new_comb = cta.brlcad_new(libwdb.struct_rt_comb_internal)
     new_comb.magic = libwdb.RT_COMB_MAGIC
     new_comb.tree = tree.build_tree()
     new_comb.region_flag = cta.bool_to_char(is_region)
     new_comb.is_fastgen = cta.int_to_char(is_fastgen)
     new_comb.region_id = region_id
     new_comb.aircode = air_code
     new_comb.GIFTmater = gift_material
     new_comb.los = line_of_sight
     new_comb.rgb_valid = cta.bool_to_char(rgb_color)
     new_comb.rgb = cta.rgb(rgb_color)
     new_comb.temperature = temperature
     new_comb.shader = cta.str_to_vls(shader)
     new_comb.material = cta.str_to_vls(material)
     new_comb.inherit = cta.bool_to_char(inherit)
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(new_comb), libwdb.ID_COMBINATION, 1)
Ejemplo n.º 2
0
 def dsp(self, name, dsp_name, data_src=1, width=142, length=150, interpolation=False, cut_direction=1, cell_size=1,
         unit_elevation=0.005):
     d = cta.brlcad_new(libwdb.struct_rt_dsp_internal, calloc=True)
     d.magic = libwdb.RT_DSP_INTERNAL_MAGIC
     d.dsp_name = cta.str_to_vls(dsp_name)
     if data_src == 1:
         d.dsp_datasrc = libwdb.RT_DSP_SRC_FILE
     elif data_src == 2:
         d.dsp_datasrc = libwdb.RT_DSP_SRC_OBJ
     d.dsp_xcnt = width
     d.dsp_ycnt = length
     if interpolation:
         d.dsp_smooth = 1
     else:
         d.dsp_smooth = 0
     if cut_direction == 1:
         d.dsp_cuttype = ord(libwdb.DSP_CUT_DIR_ADAPT)
     elif cut_direction == 2:
         d.dsp_cuttype = ord(libwdb.DSP_CUT_DIR_llUR)
     elif cut_direction == 3:
         d.dsp_cuttype = ord(libwdb.DSP_CUT_DIR_ULlr)
     cta.MAT_IDN(d.dsp_stom)
     d.dsp_stom[0] = d.dsp_stom[5] = cell_size
     d.dsp_stom[10] = unit_elevation
     libbn.bn_mat_inv(d.dsp_mtos, d.dsp_stom)
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(d), libwdb.ID_DSP, 1)
Ejemplo n.º 3
0
 def combination(self,
                 name,
                 is_region=False,
                 tree=None,
                 inherit=False,
                 shader=None,
                 material=None,
                 rgb_color=None,
                 temperature=0,
                 region_id=0,
                 air_code=0,
                 gift_material=0,
                 line_of_sight=0,
                 is_fastgen=libwdb.REGION_NON_FASTGEN):
     if not tree:
         raise ValueError("Empty tree for combination: {0}".format(name))
     tree = primitives.wrap_tree(tree)
     new_comb = cta.brlcad_new(libwdb.struct_rt_comb_internal)
     new_comb.magic = libwdb.RT_COMB_MAGIC
     new_comb.tree = tree.build_tree()
     new_comb.region_flag = cta.bool_to_char(is_region)
     new_comb.is_fastgen = cta.int_to_char(is_fastgen)
     new_comb.region_id = region_id
     new_comb.aircode = air_code
     new_comb.GIFTmater = gift_material
     new_comb.los = line_of_sight
     new_comb.rgb_valid = cta.bool_to_char(rgb_color)
     new_comb.rgb = cta.rgb(rgb_color)
     new_comb.temperature = temperature
     new_comb.shader = cta.str_to_vls(shader)
     new_comb.material = cta.str_to_vls(material)
     new_comb.inherit = cta.bool_to_char(inherit)
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(new_comb),
                       libwdb.ID_COMBINATION, 1)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 6
0
 def metaball(self, name, points=(((1, 1, 1), 1, 0), ((0, 0, 1), 2, 0)), threshold=1, method=2):
     """
     ctrl_points: corresponds to metaball control points
            ctrl_point = (point, field_strength, sweat)
     """
     if method < 0 or threshold <= 0:
         raise BRLCADException("Invalid Arguments")
     m = cta.brlcad_new(libwdb.struct_rt_metaball_internal)
     m.magic = libwdb.RT_METABALL_INTERNAL_MAGIC
     m.threshold = threshold
     m.method = method
     cta.list_init(m.metaball_ctrl_head)
     for point in points:
         librt.rt_metaball_add_point(libwdb.byref(m), cta.doubles(cta.flatten_numbers(point[0])), point[1], point[2])
     libwdb.wdb_export(self.db_fp, name, libwdb.byref(m), libwdb.ID_METABALL, 1)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)