def segments_to_polyline(array, istart=0, tol=1.e-10): from youbastard.geometry.Polyline3D import Polyline3D first = array[0] init = len(array) ordered = [array.pop(istart)] cont = True while len(ordered) <= len(array): for i, s in enumerate(array): p0 = s[0] p1 = s[1] last = ordered[-1][1] if distance(last, p0) < tol: ordered.append(array.pop(i)) continue if distance(last, p1) < tol: ordered.append(array.pop(i)[::-1]) continue ordered = [s[::-1] for s in ordered[::-1]] if ordered[0] == first: ordered = ordered else: ordered = ordered[::-1] pol = [ordered[0][0], ordered[0][1]] for s in ordered[1:]: pol.append(s[1]) return Polyline3D(pol)
def create_window(i1, i2, dist=None, width=1., height=1.2, bottom_height=1., close=True): create = False pts = data['points'] for w in data['walls']: if (i1 in w) and (i2 in w): create = True break if create: if not dist: dist = 0.5 * distance(pts[i1], pts[i2]) window = rectangle(width, height) op = Opening(pts[i1], pts[i2], thick, dist, bottom_height + 0.5 * height, vertical, window, close=close) all_openings.append(op.ex) if op.close: all_closings.append(op.close)
def create_heat(i1, i2, dist=None, width=0.8, height=0.6, offset=0.05, box_thickness=0.05, bottom_height=0.2): create = False pts = data['points'] for w in data['walls']: if (i1 in w) and (i2 in w): create = True break if create: if not dist: dist = 0.5 * distance(pts[i1], pts[i2]) heat = rectangle(width, height) op = BoxOnWall(pts[i1], pts[i2], thick, box_thickness, offset, dist, 0.2 + 0.5 * height, vertical, heat) all_heats.append(op.ex)
} test_sec = None all_tree_nodes = [] all_thicknesses = [] for ipoint, point in enumerate(data['points']): sector = [point] for iwall, wall in enumerate(data['walls']): if ipoint in wall[:2]: nex = None if wall[0] == ipoint: nex = data['points'][wall[1]] else: nex = data['points'][wall[0]] length = distance(point, nex) vec = Vector([nex[i] - point[i] for i in range(3)]).unit() half = Point([point[i] + 0.5 * length * vec[i] for i in range(3)]) thick = float(wall[2]) sector.append([half, thick]) all_tree_nodes.append( TreeNode([sector[0]] + [secp[0] for secp in sector[1:]])) all_thicknesses.append([secp[1] for secp in sector[1:]]) polylines = [] for itreenode, treenode in enumerate(all_tree_nodes): thck = all_thicknesses[itreenode] treenode.set_thicknesses(thck) pl = treenode.offset() polylines.append(pl)
def dst2(pt): return distance(pt, self.l2[0])
def dst1(pt): return distance(pt, self.l1[0])
generator = Spline3D(a_point) fa = generator.frame_array(mode=Vector([0., 0., 1.]), n=ndisc) #fa = [Frame([[0.,0.,0.], [[0.,0.,1.],[1.,0.,0.],[0.,1.,0.]]])] + fa shapes = [] generator_extrados = BRepOffsetAPI_ThruSections(False, True) generator_intrados = BRepOffsetAPI_ThruSections(False, True) generator_trailing_edge = BRepOffsetAPI_ThruSections(False, True) generator = BRepOffsetAPI_ThruSections(False, True) print dir(generator) chord = lambda x: max_chord * chordf(x) for i, f in enumerate(fa): # adimensioned position along span xspan = distance(fa[0][0], f[0]) / span # dimesioned chord value at xspan local_chord = chord(xspan) # the profile at this position pf = Profile(typ='fon', par=[ 0.89 - 0.2 * xspan, 0.15 - 0.05 * xspan, 0.05, 0.05 * (1. - xspan), 0.015 ], npt=59) # creation of the 2d profile pol = pf.polyline( closed=True) # TODO : Profile should herit of Polyline_2D pp = pol.to_frame(f, scale=local_chord)