Exemplo n.º 1
0
 def test_empty_db(self):
     db_name = "test_empty_db.g"
     if os.path.isfile(db_name):
         os.remove(db_name)
     # first time the DB is created:
     with wdb.WDB(db_name) as empty_db:
         self.check_empty_db(empty_db)
     # second time the DB exists and it is re-opened:
     with wdb.WDB(db_name) as empty_db:
         self.check_empty_db(empty_db)
Exemplo n.º 2
0
 def setUpClass(cls):
     # create the test DB:
     if os.path.isfile(cls.TEST_FILE_NAME):
         os.remove(cls.TEST_FILE_NAME)
     with wdb.WDB(
             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 = wdb.WDB(cls.TEST_FILE_NAME)
Exemplo n.º 3
0
 def setUpClass(cls):
     # create the test DB:
     if os.path.isfile("test_defaults.g"):
         os.remove("test_defaults.g")
     with wdb.WDB("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 = wdb.WDB("test_defaults.g")
Exemplo n.º 4
0
def main(argv):
    with wdb.WDB(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")