def _geo(self): w,ww,bh = self.w,self.wall.w,self.wall.h-self.h-self.z bottom = dcu.cube().translate_z(0.5) bottom.scale_x(w).scale_y(ww).scale_z(bh) bottom.rotate(dpq.q_from_uu(dpv.x(),self.wall.tangent)) bottom._project_uv_flat() th = self.wall.h-self.h-bh top = dcu.cube().translate_z(0.5) top.scale_x(w).scale_y(ww).scale_z(th) top.translate_z(bh+self.h) top.rotate(dpq.q_from_uu(dpv.x(),self.wall.tangent)) top._project_uv_flat() self._consume(bottom)._consume(top)
def prot_to_xy(py): eb,ibs = py ebn = dpr.polygon_normal(eb) if ebn.near(dpv.nz()):prot = dpq.q_from_av(dpr.PI,dpv.x()) elif not ebn.near(dpv.z() ):prot = dpq.q_from_uu(ebn,dpv.z()) else: prot = dpq.zero() return prot
def prot_to_xy(py): eb, ibs = py ebn = dpr.polygon_normal(eb) if ebn.near(dpv.nz()): prot = dpq.q_from_av(dpr.PI, dpv.x()) elif not ebn.near(dpv.z()): prot = dpq.q_from_uu(ebn, dpv.z()) else: prot = dpq.zero() return prot
def grow(self,plans,length = None,side = None,force = False): side = self.grow_side(plans,side) if side is None:return False gleng = self.grow_length(plans,length,side) if gleng is None:return False self.face_away(side) v1,v2 = side[0] c1 = v2.copy() c2 = v1.copy() c3,c4 = dpr.extrude_edge(c1,c2,gleng,side[1]['normal']) newcorners = [c1,c2,c3,c4] x,y,z = dpv.center_of_mass(newcorners) xpj = dpv.project_coords(newcorners,dpv.x()) ypj = dpv.project_coords(newcorners,dpv.y()) l,w = xpj.y-xpj.x,ypj.y-ypj.x margs = ((),{'x':x,'y':y,'l':l,'w':w,'shafted':False}) self.create_bbox(margs) if not self.verify_growth(plans,margs):return False splan = self.should_shaft(plans,margs) cpairs = [(c2,c3),(c3,c4),(c4,c1)] iwargs = [] ewargs = [[cp, {'h':4.0,'w':0.5,'walltype':'exterior','room':margs}] for cp in cpairs] self.switch_walltype(plans,side) if self.resolve_walls(plans,ewargs,iwargs,margs): rps,eps,ips,sps = plans rps.append(margs) eps.extend(ewargs) ips.extend(iwargs) if splan:sps.append(splan) return True else:return False
def _geo(self): w, ww, th = self.w, self.wall.w, self.wall.h - self.h - self.z top = dcu.cube().translate_z(0.5) top.scale_x(w).scale_y(ww).scale_z(th) top.translate_z(self.z + self.h) top.rotate(dpq.q_from_uu(dpv.x(), self.wall.tangent)) top._project_uv_flat() self._consume(top)
def _geo(self): w,ww,th = self.w,self.wall.w,self.wall.h-self.h-self.z top = dcu.cube().translate_z(0.5) top.scale_x(w).scale_y(ww).scale_z(th) top.translate_z(self.z+self.h) top.rotate(dpq.q_from_uu(dpv.x(),self.wall.tangent)) top._project_uv_flat() self._consume(top)
def create_bbox(self, roomplan): x, y = roomplan[1]['x'], roomplan[1]['y'] l, w = roomplan[1]['l'] - 0.01, roomplan[1]['w'] - 0.01 cns = dpr.square(l, w, dpv.vector(x, y, 0)) xpj = dpv.project_coords(cns, dpv.x()) ypj = dpv.project_coords(cns, dpv.y()) zpj = dpv.project_coords(cns, dpv.z()) bb = dbb.bbox(xpj, ypj, zpj) roomplan[1]['bbox'] = bb
def create_bbox(self,roomplan): x,y = roomplan[1]['x'],roomplan[1]['y'] l,w = roomplan[1]['l']-0.01,roomplan[1]['w']-0.01 cns = dpr.square(l,w,dpv.vector(x,y,0)) xpj = dpv.project_coords(cns,dpv.x()) ypj = dpv.project_coords(cns,dpv.y()) zpj = dpv.project_coords(cns,dpv.z()) bb = dbb.bbox(xpj,ypj,zpj) roomplan[1]['bbox'] = bb
def _project_uv_flat(self,rng = None): if rng is None:rng = range(len(self.faces)) for nf in rng: face = self.faces[nf] for fdx in face: p = self.pcoords[fdx] n = self.ncoords[fdx] if dpv.near(n,dpv.nx()) or dpv.near(n,dpv.x()): nu = p.copy().yz2d() elif dpv.near(n,dpv.ny()) or dpv.near(n,dpv.y()): nu = p.copy().xz2d() elif dpv.near(n,dpv.nz()) or dpv.near(n,dpv.z()): nu = p.copy().xy2d() else:continue self.ucoords[fdx] = nu
def valid_pair(py1,py2): eb1,eb2 = py1[0],py2[0] for x in range(len(eb2)): one,two = eb2[x-1],eb2[x] if one.near(two): print('invalid!!!') pdb.set_trace() ebn1 = dpr.polygon_normal(eb1) pj1 = dpv.project_coords(list(eb1),ebn1) pj2 = dpv.project_coords(list(eb2),ebn1) if not (dpr.isnear(pj2.x,pj2.y) and dpr.isnear(pj1.x,pj2.x)):return if ebn1.near(dpv.nz()):prot = dpq.q_from_av(dpr.PI,dpv.x()) elif not ebn1.near(dpv.z() ):prot = dpq.q_from_uu(ebn1,dpv.z()) else: prot = dpq.zero() return prot
def valid_pair(py1, py2): eb1, eb2 = py1[0], py2[0] for x in range(len(eb2)): one, two = eb2[x - 1], eb2[x] if one.near(two): print('invalid!!!') pdb.set_trace() ebn1 = dpr.polygon_normal(eb1) pj1 = dpv.project_coords(list(eb1), ebn1) pj2 = dpv.project_coords(list(eb2), ebn1) if not (dpr.isnear(pj2.x, pj2.y) and dpr.isnear(pj1.x, pj2.x)): return if ebn1.near(dpv.nz()): prot = dpq.q_from_av(dpr.PI, dpv.x()) elif not ebn1.near(dpv.z()): prot = dpq.q_from_uu(ebn1, dpv.z()) else: prot = dpq.zero() return prot
def grow(self, plans, length=None, side=None, force=False): side = self.grow_side(plans, side) if side is None: return False gleng = self.grow_length(plans, length, side) if gleng is None: return False self.face_away(side) v1, v2 = side[0] c1 = v2.copy() c2 = v1.copy() c3, c4 = dpr.extrude_edge(c1, c2, gleng, side[1]['normal']) newcorners = [c1, c2, c3, c4] x, y, z = dpv.center_of_mass(newcorners) xpj = dpv.project_coords(newcorners, dpv.x()) ypj = dpv.project_coords(newcorners, dpv.y()) l, w = xpj.y - xpj.x, ypj.y - ypj.x margs = ((), {'x': x, 'y': y, 'l': l, 'w': w, 'shafted': False}) self.create_bbox(margs) if not self.verify_growth(plans, margs): return False splan = self.should_shaft(plans, margs) cpairs = [(c2, c3), (c3, c4), (c4, c1)] iwargs = [] ewargs = [[ cp, { 'h': 4.0, 'w': 0.5, 'walltype': 'exterior', 'room': margs } ] for cp in cpairs] self.switch_walltype(plans, side) if self.resolve_walls(plans, ewargs, iwargs, margs): rps, eps, ips, sps = plans rps.append(margs) eps.extend(ewargs) ips.extend(iwargs) if splan: sps.append(splan) return True else: return False
def inpolyhedron(point,triangles): pray = dry.ray(point,dpv.x()) isects = [] isects = dry.intersect_hits(pray,triangles) #print('inininin',len(triangles),isects) '''# for x in range(len(triangles)): t1,t2,t3 = triangles[x] isct = pray.intersect_tri(t1,t2,t3) if isct == 1: t = pray.cast.x print('t',t) isects.append(t) else:print('noinsct',x) '''# ins = len(isects) % 2 > 0 pray = dry.ray(point,dpv.y()) isects = [] isects = dry.intersect_hits(pray,triangles) ins = ins or len(isects) % 2 > 0 #print('insideeee',ins,len(isects)) '''# ax = dtl.plot_axes() for x in range(len(triangles)): ax = dtl.plot_polygon(list(triangles[x]),ax) ax = dtl.plot_edges([ pray.origin,pray.origin.copy().translate( pray.direction.copy().scale_u(100))],ax) plt.show() '''# return ins
def pitch_up(self,p,d):d.rotate(dpq.q_from_av(self.angle,dpv.x())) def pitch_down(self,p,d):d.rotate(dpq.q_from_av(self.angle,dpv.nx()))