def setUpClass(cls): # create the test DB: if os.path.isfile(cls.TEST_FILE_NAME): os.remove(cls.TEST_FILE_NAME) with geometry.Database( cls.TEST_FILE_NAME, "BRL-CAD geometry for testing sketch primitive") as brl_db: brl_db.bot("bot.s") # load the DB and cache it in a class variable: cls.brl_db = geometry.Database(cls.TEST_FILE_NAME)
def main(argv): with geometry.Database(argv[1], "My Database") as brl_db: # All units in the database file are stored in millimeters. This constrains # the arguments to the mk_* routines to also be in millimeters. # make a sphere centered at 1.0, 2.0, 3.0 with radius 0.75 brl_db.sphere("ball.s", center=(1, 2, 3), radius=0.75) # Make an rpp under the sphere (partly overlapping). Note that this really # makes an arb8, but gives us a shortcut for specifying the parameters. brl_db.rpp("box.s", pmin=(0, 0, 0), pmax=(2, 4, 2.5)) # Make a region that is the union of these two objects. To accomplish # this, we don't need anymore to create any linked list of the items ;-). brl_db.combination("box_n_ball.r", is_region=True, tree=union("ball.s", "box.s"), shader="plastic {di=.8 sp=.2}", rgb_color=(64, 180, 96)) # Makes a hole from one corner to the other of the box # Note that you can provide a single combination name or a list in the # obj_list parameter, it will be handled correctly, all the tedious list # building is done under the hood: brl_db.hole(hole_start=(0, 0, 0), hole_depth=(2, 4, 2.5), hole_radius=0.75, obj_list="box_n_ball.r")
def setUpClass(cls): # create the test DB: if os.path.isfile("test_defaults.g"): os.remove("test_defaults.g") with Database("test_defaults.g", "BRL-CAD geometry for testing wdb defaults") as brl_db: brl_db.sphere("sphere.s") brl_db.rpp("rpp.s") brl_db.wedge("wedge.s") brl_db.arb4("arb4.s") brl_db.arb5("arb5.s") brl_db.arb6("arb6.s") brl_db.arb7("arb7.s") brl_db.arb8("arb8.s") brl_db.ellipsoid("ellipsoid.s") brl_db.torus("torus.s") brl_db.rcc("rcc.s") brl_db.tgc("tgc.s") brl_db.cone("cone.s") brl_db.trc("trc.s") brl_db.submodel("submodel.s", "resources/test_submodel.g", "my_bot") brl_db.rpc("rpc.s") brl_db.rhc("rhc.s") brl_db.epa("epa.s") brl_db.ehy("ehy.s") brl_db.hyperboloid("hyperboloid.s") brl_db.eto("eto.s") brl_db.arbn("arbn.s") brl_db.particle("particle.s") brl_db.grip("grip.s") brl_db.pipe("pipe.s") brl_db.vol("vol.s", "resources/voxel.data") brl_db.metaball("metaball.s") brl_db.half("half.s") brl_db.ebm("ebm.s", "resources/Ychar.bw") brl_db.ars( "ars.s", [[0, 0, 3], [1, 1, 3, 1, -1, 3, -1, -1, 3, -1, 1, 3], [1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1], [1, 0, -1, 0, -1, -1, -1, 0, -1, 0, 1, -1], [1, 0, -3, 0, -1, -3, -1, 0, -3, 0, 1, -3], [0, 0, -3]]) brl_db.superell("superell.s") test_comb = primitives.Combination(name="combination.c") for shape_name in brl_db.ls(): test_comb.tree.add_child(shape_name) brl_db.save(test_comb) # load the DB and cache it in a class variable: cls.brl_db = geometry.Database("test_defaults.g")
draw_hyperboloid('hyperbolid.s', [0, 0, 6.75, 0, 0, 0.75, 1, 0, 0, 0.5, 0.3], brl_db) draw_eto('eto.s', [1, 2, 8.5, 0, 0, 1, 0.5, 0, 0.5, 1, 0.25], brl_db) draw_arbn('arbn.s', [ 0, 0, -1, -8, 0, 0, 1, 9, -1, 0, 0, 0.5, 1, 0, 0, 0.5, 0, -1, 0, 0.5, 0, 1, 0, 0.5 ], brl_db) draw_particle('particle.s', [0, -5, 8.5, 0, 0, 0.75, 0.25, 0.5], brl_db) draw_pipe('pips.s', [ 0.55, 4, 5.45, 0.1, 0, 0.45, 0.55, 3.55, 5.4875, 0.1, 0, 0.45, 1.45, 3.55, 5.5625, 0.1, 0, 0.45, 1.45, 4.45, 5.6375, 0.1, 0, 0.45, 0.55, 4.45, 5.7125, 0.1, 0, 0.45, 0.55, 3.55, 5.7875, 0.1, 0, 0.45, 1.45, 3.55, 5.8625, 0.1, 0, 0.45, 1.45, 4.45, 5.9375, 0.1, 0, 0.45, 0.55, 4.45, 6.0125, 0.1, 0, 0.45, 0.55, 4, 6.05, 0.1, 0, 0.45 ], brl_db) draw_half('half.s', [0, 1, 0, 0], brl_db) return if __name__ == '__main__': argv = sys.argv database_name = argv[1] brl_db = geometry.Database(database_name, "SGI.g") main()
"arb5" : draw_arb5, "arb6" : draw_arb6, "arb7" : draw_arb7, "arb8" : draw_arb8, "ell" : draw_ellipsoid, "tor" : draw_torus, "rcc" : draw_rcc, "tgc" : draw_tgc, "cone" : draw_cone, "trc" : draw_trc, "rpc" : draw_rpc, "rhc" : draw_rhc, "epa" : draw_epa, "ehy" : draw_ehy, "hyp" : draw_hyperboloid, "eto" : draw_eto, "arbn" : draw_arbn, "part" : draw_particle, "pipe" : draw_pipe} if __name__ == "__main__": argv = sys.argv commands = read_file(argv[1]) database_name = ' '.join(commands[0].split()[1:]) units = commands[1].split()[1] commands = commands[2:] brl_db = geometry.Database(database_name, "db.g") parse_script(database_name, units, commands)
exit() if rounding_radius > c_length/2: raise ValueError("Rounding Radius cannot be larger than 0.5 * Cylinder Height") exit() def rounder_rcc(c_radius, c_length, rounding_radius): sanity_check(c_radius, c_length, rounding_radius) origin = (0, 0, 0) base = (0, 0, rounding_radius) filler = (0, 0, c_length) top_tor = (0, 0, c_length - rounding_radius) height = (0, 0, c_length - 2 * rounding_radius) neg_z_dir, pos_z_dir = (0, 0, -1), (0, 0, 1) brl_db.rcc("cylinder.rcc", base, height, c_radius) brl_db.rcc("fillend.rcc", origin, filler, c_radius - rounding_radius) brl_db.torus("bottom.tor", base, neg_z_dir, c_radius - rounding_radius, rounding_radius) brl_db.torus("top.tor", top_tor, pos_z_dir, c_radius - rounding_radius, rounding_radius) union_list = ["cylinder.rcc", "fillend.rcc", "top.tor", "bottom.tor"] brl_db.combination( "cylinder3.r", is_region=False, tree=union(union_list) ) if __name__ == "__main__": argv = sys.argv union_list = [] database_name = argv[1] brl_db = geometry.Database(database_name, "fml.g") rounder_rcc(40, 100, 19)