def test_approximate(self): #my_surface = approximate_surface(pts) p1, p2, p3, p4, p5 = Point(0, 0, 0), Point(0, 10, 0), Point( 0, 10, 10), Point(0, 0, 10), Point(5, 5, 5) poly = BRepBuilderAPI_MakePolygon() map(poly.Add, [p1, p2, p3, p4, p1]) poly.Build() my_surf = build_plate([poly], [Point(-1, -1, -1)]) sh = my_surf.Shape() display.DisplayShape(sh)
def make_closed_polygon(*args): poly = BRepBuilderAPI_MakePolygon() for pt in args: if isinstance(pt, list) or isinstance(pt, tuple): for i in pt: poly.Add(i) else: poly.Add(pt) poly.Build() poly.Close() result = poly.Wire() return result
def approximate(self): '''make a boundary representation of a surface that approximates the points''' self.make_bounding_box() #make the bounding box into a polygon poly = BRepBuilderAPI_MakePolygon() map(poly.Add, [ self.bottom_left, self.bottom_right, self.top_left, self.top_right ]) poly.Build() self.polygons = [poly] my_surf = build_plate(self.polygons, self.points) self.shape = my_surf.Shape() display.DisplayShape(self.shape)
def make_closed_polygon(*args): poly = BRepBuilderAPI_MakePolygon() for pt in args: if isinstance(pt, list) or isinstance(pt, tuple): for i in pt: poly.Add(i) else: poly.Add(pt) poly.Build() poly.Close() with assert_isdone(poly, 'failed to produce wire'): result = poly.Wire() return result
def make_polygon(pyptlist): array = [] for pt in pyptlist: array.append(gp_Pnt(pt[0], pt[1], pt[2])) poly = BRepBuilderAPI_MakePolygon() map(poly.Add, array) poly.Build() poly.Close() wire = poly.Wire() occface = BRepBuilderAPI_MakeFace(wire) return occface.Face()
def make_wire(pyptlist): ''' if you want a close wire, make sure the pts the first pts too ''' array = [] for pt in pyptlist: array.append(gp_Pnt(pt[0], pt[1], pt[2])) poly = BRepBuilderAPI_MakePolygon() map(poly.Add, array) poly.Build() wire = poly.Wire() return wire
def make_polygon(args, closed=False): poly = BRepBuilderAPI_MakePolygon() for pt in args: # support nested lists if isinstance(pt, list) or isinstance(pt, tuple): for i in pt: poly.Add(i) else: poly.Add(pt) if closed: poly.Close() poly.Build() with assert_isdone(poly, 'failed to produce wire'): result = poly.Wire() return result