def setUp(self): self.pt1 = Point(0, 0, 0) self.pt2 = Point(100, 100, 100) self.boundBox1 = BoundBox(self.pt1, self.pt2) self.pt3 = Point(-100, -100, -100.5) self.pt4 = Point(100, 100, 100) self.boundBox2 = BoundBox(self.pt3, self.pt4)
def boundbox(self): """Return the boundbox for the segmentgroup""" xvalues = [] yvalues = [] zvalues = [] # collect all points from each segment by direction for segment in self.get_segments(): xvalues.extend(segment.get_all_axis_positions('X')) yvalues.extend(segment.get_all_axis_positions('Y')) zvalues.extend(segment.get_all_axis_positions('Z')) x_min = min(xvalues, key=abs) x_max = max(xvalues, key=abs) y_min = min(yvalues, key=abs) y_max = max(yvalues, key=abs) z_min = min(zvalues, key=abs) z_max = max(zvalues, key=abs) pt1 = Point(x_min, y_min, z_min) pt2 = Point(x_max, y_max, z_max) segmentgroupBoundBox = BoundBox(pt1, pt2) return segmentgroupBoundBox
def setUp(self): # Define Part Geometry part_segments = [] PartPt1 = Point(0, 0, 10) PartPt2 = Point(-5, 0, -9) PartPt3 = Point(-9.5, 0, -15.85) PartPt4 = Point(-5.4, 0, -22) PartPt5 = Point(-5.4, 0, -30) PartPt6 = Point(-5.4, 0, -35) PartPt7 = Point(-5.4, 0, -40) PartPt8 = Point(-13, 0, -45) PartPt9 = Point(-13, 0, -48) PartPt10 = Point(0, 0, -48) part_segments.append(Segment(PartPt1, PartPt2, -0.75)) part_segments.append(Segment(PartPt2, PartPt3)) part_segments.append(Segment(PartPt3, PartPt4)) part_segments.append(Segment(PartPt4, PartPt5, 0.25)) part_segments.append(Segment(PartPt5, PartPt6)) part_segments.append(Segment(PartPt6, PartPt8)) part_segments.append(Segment(PartPt7, PartPt8)) part_segments.append(Segment(PartPt8, PartPt9)) part_segments.append(Segment(PartPt9, PartPt10)) # Define stock bounds stockPt1 = Point(0, 0, 15) stockPt2 = Point(-25, 0, -55) stock_boundbox = BoundBox(stockPt1, stockPt2) # set feed rate to test self.hfeed = 10 # Define Operations Properties params = {} params['min_dia'] = 0 params['extra_dia'] = 0 params['start_offset'] = 0 params['end_offset'] = 0 params['allow_grooving'] = True params['step_over'] = 1 params['finish_passes'] = 3 params['stock_to_leave'] = 0 params['hfeed'] = self.hfeed params['vfeed'] = 10 self.op = ProfileOP() self.op.set_params(params) self.op.add_stock(stock_boundbox) self.op.add_part_edges(part_segments) tool = Tool() tool.set_tool_from_string('DCMT070204R') self.op.add_tool(tool)
class test_boundbox(unittest.TestCase): """Test for boundbox.py""" def setUp(self): self.pt1 = Point(0, 0, 0) self.pt2 = Point(100, 100, 100) self.boundBox1 = BoundBox(self.pt1, self.pt2) self.pt3 = Point(-100, -100, -100.5) self.pt4 = Point(100, 100, 100) self.boundBox2 = BoundBox(self.pt3, self.pt4) def test_XLength(self): xlen = self.boundBox1.XLength() self.assertEqual(xlen, 100) xlenNegative = self.boundBox2.XLength() self.assertEqual(xlenNegative, 200) def test_YLength(self): ylen = self.boundBox1.YLength() self.assertEqual(ylen, 100) ylenNegative = self.boundBox2.YLength() self.assertEqual(ylenNegative, 200) def test_ZLength(self): zlen = self.boundBox1.YLength() self.assertEqual(zlen, 100) zlenNegative = self.boundBox2.ZLength() self.assertEqual(zlenNegative, 200.5)
part_segments = [] PartPt1 = Point(0, 0, 0) PartPt2 = Point(-15, 0, -5) PartPt3 = Point(-15, 0, -15) PartPt4 = Point(0, 0, -20) part_segments.append(Segment(PartPt1, PartPt2)) part_segments.append(Segment(PartPt2, PartPt3)) part_segments.append(Segment(PartPt3, PartPt4)) part_segments.append(Segment(PartPt4, PartPt1)) # Define stock bounds stockPt1 = Point(0, 0, 5) stockPt2 = Point(-20, 0, -20) StockBoundingBox = BoundBox(stockPt1, stockPt2) # Define Operations Properties props = {} props['min_dia'] = 0 props['extra_dia'] = 0 props['start_offset'] = 0 props['end_offset'] = 0 props['allow_grooving'] = False props['allow_facing'] = False props['allow_roughing'] = True props['allow_finishing'] = True props['step_over'] = 1 props['finish_passes'] = 2 props['hfeed'] = 10 props['vfeed'] = 10
def getliblatheBoundBox(FcBB): liblatheBoundbox = BoundBox(Point(FcBB.XMin, FcBB.YMin, FcBB.ZMin), Point(FcBB.XMax, FcBB.YMax, FcBB.ZMax)) return liblatheBoundbox