def check_tgc(self, name, expected_points): shape = self.lookup_shape(name) expected = Vector(expected_points) actual = cta.flatten_numbers( [shape.base, shape.height, shape.a, shape.b, shape.c, shape.d]) if not expected.is_same(actual): self.fail("{0} != {1}".format(expected, actual))
def test_curves(curves): ### length of the curves should be more than 3. if len(curves) <=2: return False ### Check that first and last element have three entries i.e a single point if not (len(cta.flatten_numbers(curves[0])) == 3 and len(cta.flatten_numbers(curves[-1])) == 3): return False ### Check that the other curves contain atleast 3 points and each curve contain same number of points index_curve = len(cta.flatten_numbers(curves[1])) if index_curve % 3 != 0 and index_curve/3 >= 3: return False for i in range(2,len(curves)-1): if (len(cta.flatten_numbers(curves[i])) == index_curve): continue else: return False return True
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)
def update_params(self, params): ncurves = len(self.curves) pts_per_curve = len(cta.flatten_numbers(self.curves[1])) / 3 curves = [[None for x in range(pts_per_curve * 3)] for y in range(ncurves)] ## for start for i in range(pts_per_curve): for j in range(3): curves[0][3 * i + j] = self.curves[0][j] ##for other curves for i in range(1, ncurves - 1): for j in range(3 * pts_per_curve): curves[i][j] = self.curves[i][j] ## for end for i in range(pts_per_curve): for j in range(3): curves[ncurves - 1][3 * i + j] = self.curves[ncurves - 1][j] params.update({"curves": curves})
def ars(self, name, curves): ncurves = len(curves) pts_per_curve = len(cta.flatten_numbers(curves[1])) / 3 mod_curves = [[None for x in range(pts_per_curve * 3)] for y in range(ncurves)] ## for start for i in range(pts_per_curve): for j in range(3): mod_curves[0][3 * i + j] = curves[0][j] ##for other curves for i in range(1, ncurves - 1): for j in range(3 * pts_per_curve): mod_curves[i][j] = curves[i][j] ## for end for i in range(pts_per_curve): for j in range(3): mod_curves[ncurves - 1][3 * i + j] = curves[ncurves - 1][j] libwdb.mk_ars(self.db_fp, name, ncurves, pts_per_curve, cta.array2d(mod_curves, use_brlcad_malloc=True))
def check_tgc(self, name, expected_points): shape = self.lookup_shape(name) expected = Vector(expected_points) actual = cta.flatten_numbers([shape.base, shape.height, shape.a, shape.b, shape.c, shape.d]) if not expected.is_same(actual): self.fail("{0} != {1}".format(expected, actual))
def test_arbn_defaults(self): shape = self.lookup_shape("arbn.s") expected = Vector((1, 0, 0, 1, -1, 0, 0, 1, 0, 1, 0, 1, 0, -1, 0, 1, 0, 0, 1, 1, 0, 0, -1, 1)) self.assertTrue(expected.is_same(cta.flatten_numbers(shape.planes)))