"""Compile reviewed finish assemblies and product recipes into editable components. Coordinates are metres, plan X/Y and vertical Z. Sources stay on every component. """ import copy,math from surface_spec import profile,audit from room_geometry import area,clip_rectangle,segments as room_segments from gateways.elevation_index import bind_room_elevations BUILTINS={'@concrete','@ceramic','@metal','@glass','@mirror','@fabric','@dark','@light','@wood','@grout'} def compile_scene(scene): bind_room_elevations(scene) components=[];comparisons=[] def add(code,name,room,center,size,material,kind='fixture',variant='finished',shape='box',source='',verification='',rotation=None,**extra): item=dict(id=code,name=name,room=room,position=[round(float(v),6) for v in center],size=[round(float(v),6) for v in size],material=material,category=kind,variant=variant,shape=shape,source=source or '平面布置与产品参数',verification=verification or '产品外形参数化;未提供的厂家细部须复核') if rotation:item['rotation']=rotation item.update(extra);components.append(item);return item def rod(code,name,room,a,b,r=.008,material='@metal',source='五金选型参数',verification=''): length=math.dist(a,b) return add(code,name,room,[(a[i]+b[i])/2 for i in range(3)],[r*2,r*2,length],material,shape='rod',a=a,b=b,source=source,verification=verification) def rounded(code,name,room,center,size,mat,**kw):return add(code,name,room,center,size,mat,bevel=min(.04,min(size)/5),**kw) def plate(code,name,rid,side,bounds,z,h,thickness,mat,offset=0,**kw): x0,y0,x1,y1=bounds if side in ('west','east'): x=x0+offset+thickness/2 if side=='west' else x1-offset-thickness/2 return add(code,name,rid,[x,(y0+y1)/2,z+h/2],[thickness,y1-y0,h],mat,kind=kw.pop('kind','wall-finish'),**kw) y=y0+offset+thickness/2 if side=='south' else y1-offset-thickness/2 return add(code,name,rid,[(x0+x1)/2,y,z+h/2],[x1-x0,thickness,h],mat,kind=kw.pop('kind','wall-finish'),**kw) for wall in scene['walls']: components.append(dict(id=wall['id'],name='土建墙柱 '+wall['id'],room=wall.get('room',''),shape='polygon',polygon=wall['polygon'],position=[0,0,0],size=[1,1,wall['height']],height=wall['height'],material='@concrete',category='structure',variant='both',source=wall['source'],verification=wall['verification'])) for room in scene['rooms']: rid=room['id'];b=room['structuralBounds'];x0,y0,x1,y1=b assembly=scene['finishAssemblies'][rid];t=assembly['wallThickness'];floor=assembly['floorRise'];height=assembly['finishedHeight'] sideT={side:assembly.get('wallBuildUpSides',{}).get(side,t) for side in ('west','east','south','north')} finished=[x0+sideT['west'],y0+sideT['south'],x1-sideT['east'],y1-sideT['north']];room['bounds']=finished;room['height']=height;room['area']=round((finished[2]-finished[0])*(finished[3]-finished[1]),2) room['verification']='完成面与土建分别建模;尺寸依据及未确认产品参数见尺寸对照' outline=room.get('finishedPolygon') if outline:room['area']=round(area(outline),3) comparisons.append(dict(status='cross_checked_net_only' if rid=='bath' else 'review_required',unit='m',room=rid,name=room['name'],structural=[round(x1-x0,4),round(y1-y0,4),room.get('structuralHeight',2.8)],finished=[round(finished[2]-finished[0],4),round(finished[3]-finished[1],4),height],wallBuildUp=t,wallBuildUpSides=sideT,floorRise=floor,source=assembly['source'])) add('slab-'+rid,room['name']+'土建楼板',rid,[(x0+x1)/2,(y0+y1)/2,-floor-.06],[x1-x0,y1-y0,.12],'@concrete',kind='slab',variant='both',source=assembly['source']) floor_skin=profile(room['material'])['thickness'] add('screed-'+rid,room['name']+'地面找平基层',rid,[(x0+x1)/2,(y0+y1)/2,-(floor+floor_skin)/2],[x1-x0,y1-y0,max(.001,floor-floor_skin)], '@concrete',kind='substrate',source=assembly['source']) fx0,fy0,fx1,fy1=finished # Individual real floor pieces and joints, never a texture-only substitution. finish=profile(room['material']);tile=finish['size'] if room['material'] in ('WF-1001','T-1001') else assembly.get('tileSize',[.8,.8]);joint=assembly.get('joint',.001);z=finish['thickness'] nx=math.ceil((fx1-fx0)/tile[0]);ny=math.ceil((fy1-fy0)/tile[1])+int(finish['pattern']=='369-stagger') for ix in range(nx): for iy in range(ny): a=fx0+ix*tile[0];c=min(a+tile[0],fx1);shift=(ix%3)*tile[1]/3 if finish['pattern']=='369-stagger' else 0;d=max(fy0,fy0+iy*tile[1]-shift);e=min(fy0+(iy+1)*tile[1]-shift,fy1) if e-d<=joint:continue add(f'floor-{rid}-{ix}-{iy}',room['name']+'铺装',rid,[(a+c)/2,(d+e)/2,-z/2],[max(.001,c-a-joint),max(.001,e-d-joint),z],room['material'],kind='floor',source=assembly['source'],verification='材料厚度据物料书;密缝宽度为可调整建模参数') if outline: poly=clip_rectangle(outline,[a,d,c-joint,e-joint]) if len(poly)<3 or area(poly)<1e-7:components.pop();continue components[-1].update(shape='prism',profile=poly,depth=z,position=[0,0,-z/2]) room['floorCode']='floor-'+rid+'-0-0' for side in assembly.get('sidesToFinish',('north','east','south','west')): if outline:continue opening=next((o for o in scene.get('openings',[]) if o['room']==rid and o['side']==side),None) # Door/window holes in finish faces are compiled into separate regions. segments=[(0, (y1-y0 if side in ('east','west') else x1-x0),0,height)] if opening: length=segments[0][1];a=opening['offset'];c=a+opening['width'];bottom=opening.get('bottom',0);top=bottom+opening['height'] segments=[(0,a,0,height),(c,length,0,height),(a,c,top,height)] if bottom>0:segments.append((a,c,0,bottom)) material=assembly.get('sides',{}).get(side,assembly['wallMaterial']) elev=next((e for e in scene.get('elevations',[]) if e['room']==rid and e['direction']==side),None) if elev and elev.get('material'):material=elev['material'] skin=profile(material)['thickness'];substrate=max(.001,sideT[side]-skin) for j,(a,c,z0,z1) in enumerate(segments): if c-a<.001 or z1-z0<.001:continue sub=list(b) if side in ('west','east'):sub[1]=y0+a;sub[3]=y0+c else:sub[0]=x0+a;sub[2]=x0+c # Separate substrate and 9mm/other finish skins preserve physical layering. skin=profile(material)['thickness'] substrate=max(.001,sideT[side]-skin) plate(f'{rid}-{side}-base-{j}',room['name']+'墙面基层',rid,side,sub,z0,z1-z0,substrate,'@concrete',kind='substrate',source=assembly['source'],verification='基层厚度按完成面总偏移反算,节点需复核',elevation=elev['id'] if elev else '') span=c-a;panel=.8 if rid in ('bath','master-bath') else span for k in range(math.ceil(span/panel)): sub2=list(sub);lo=a+k*panel;hi=min(c,lo+panel) if side in ('west','east'):sub2[1]=y0+lo;sub2[3]=y0+hi-joint else:sub2[0]=x0+lo;sub2[2]=x0+hi-joint plate(f'{rid}-{side}-finish-{j}-{k}',room['name']+' '+side+'饰面',rid,side,sub2,z0,z1-z0,skin,material,offset=substrate,source=elev['source'] if elev else assembly['source'],verification='面层实体与分缝;详图未给的基层做法保留核审',elevation=elev['id'] if elev else '') # Tops are present in model; cutaway controls visibility independently. ceiling=add('ceiling-'+rid,room['name']+'吊顶',rid,[(fx0+fx1)/2,(fy0+fy1)/2,height+.025],[fx1-fx0,fy1-fy0,.05],assembly.get('ceiling',{}).get('material','PT-1002' if rid in ('bath','master-bath') else 'PT-1001'),kind='ceiling',source=assembly.get('ceiling',{}).get('source',assembly['source'])) finish=assembly.get('ceilingFinish') if finish and not outline: skin=float(finish['thickness']) if not .0005<=skin<=.01 or finish['material'] not in {m['id'] for m in scene['materials']}: raise ValueError('Invalid reviewed ceiling finish: '+rid) ceiling.update(name=room['name']+'吊顶基层占位(构造待核审)',material='@concrete',verification='50mm占位厚度未经该房间节点确认,不作施工尺寸') add('ceiling-finish-'+rid,room['name']+'天花涂料完成面',rid,[(fx0+fx1)/2,(fy0+fy1)/2,height-skin/2],[fx1-fx0,fy1-fy0,skin],finish['material'],kind='ceiling',source=finish['source'],verification=finish['verification']) if outline: ceiling.update(shape='prism',profile=outline,depth=.002,position=[0,0,height+.001],size=[fx1-fx0,fy1-fy0,.002],verification='吊顶+2400/地面-10据四面立面;2mm涂层为核审构造参数') add('ceiling-base-'+rid,room['name']+'吊顶基层(待核审)',rid,[0,0,height+.008],[fx1-fx0,fy1-fy0,.012],'@concrete',kind='ceiling',shape='prism',profile=outline,depth=.012,source=assembly['source'],verification='12mm基层厚度为核审参数,须对应天花节点确认') for i,(a,b,length,normal) in enumerate(room_segments(room['structuralPolygon'])): side='south' if normal[1]>.5 else 'north' if normal[1]<-.5 else 'west' if normal[0]>.5 else 'east' elev=next((e for e in scene.get('elevations',[]) if e['room']==rid and e['direction']==side),None) mat=assembly.get('sides',{}).get(side,assembly['wallMaterial']);skin=profile(mat)['thickness'];thick=sideT[side];base=thick-skin ranges=[(0,length,0,height)] opening=next((o for o in scene.get('openings',[]) if o['room']==rid and o['side']==side),None) if opening and abs(b[1]-a[1])<1e-6 and abs(a[1]-y0)<1e-6: lo=opening['offset'];hi=lo+opening['width'];ranges=[(0,lo,0,height),(hi,length,0,height),(lo,hi,opening['height'],height)] for j,(lo,hi,z0,z1) in enumerate(ranges): if hi-lo<=.001 or z1-z0<=.001:continue for layer,offset,depth,material,category in [('base',0,base,'@concrete','substrate'),('finish',base,skin,mat,'wall-finish')]: count=1 if layer=='base' else math.ceil((hi-lo)/.8) for k in range(count): l=lo+k*.8 if layer!='base' else lo;h=min(hi,l+.8) if layer!='base' else hi cx=a[0]+(b[0]-a[0])*(l+h)/(2*length)+normal[0]*(offset+depth/2);cy=a[1]+(b[1]-a[1])*(l+h)/(2*length)+normal[1]*(offset+depth/2) size=[h-l-joint,depth,z1-z0] if abs(b[1]-a[1])<1e-6 else [depth,h-l-joint,z1-z0] add(f'{rid}-surface-{i}-{j}-{layer}-{k}',room['name']+' '+side+('柱侧' if i>=3 else '')+('基层' if layer=='base' else '岩板面'),rid,[cx,cy,(z0+z1)/2],size,material,kind=category,source=elev['source'] if elev else assembly['source'],elevation=elev['id'] if elev else '',verification='按实际墙柱折线落位;9mm面层据物料书,其余反算层待核审') for trim in assembly.get('cornerTrims',[]): point=trim['point'];sx,sy=trim['inside'];leg=trim['legDepth'];metal=trim['metalThickness'];top=trim.get('height',height) if not (.0005<=metal<=.005 and metal=3 else 'GL-1002-option-1' if rid in ('bath','master-bath') else 'WD-1001',kind='door',source=opening['source'],verification='按50mm两侧预览框及各3mm预览间隙消除碰撞;实际门套截面/安装间隙待节点核审') normal=1-along handle=list(c);handle[along]+=size[along]/2-.10;handle[2]=bottom+1.0 note='门内外双面五金可见性预览;离边、伸出、型式与安装高度待门节点/产品核审' for sign in (-1,1): inner=sign==(1 if side in ('south','west') else -1) tag=code+'-handle'+('-inner' if inner else '') plate=list(handle);plate[normal]+=sign*(size[normal]/2+.004) plate_size=[.045,.045,.11];plate_size[normal]=.005 add(tag+'-base','门把手安装座(内侧)' if inner else '门把手安装座(外侧)',rid,plate,plate_size,'@metal',source=opening['source'],verification=note) stem_a=list(handle);stem_b=list(handle) stem_a[normal]+=sign*(size[normal]/2) stem_b[normal]+=sign*(size[normal]/2+.038) rod(tag+'-stem','门把手短颈',rid,stem_a,stem_b,.007,source=opening['source'],verification=note) grip_b=list(stem_b);grip_b[along]-=.11 rod(tag,'门把手握柄(内侧)' if inner else '门把手握柄(外侧)',rid,stem_b,grip_b,.009,source=opening['source'],verification=note) else: size[0 if along==1 else 1]=.012 add(code+'-glass','窗玻璃',rid,c,size,'GL-1001',kind='window',variant='both',source=opening['source']) for f in (.33,.66): c=list(center);c[along]+=(f-.5)*span;sz=[.04,.04,height];sz[along]=.025 add(code+'-mullion-'+str(f),'窗竖框',rid,c,sz,'@metal',kind='frame',variant='both',source=opening['source']) refs=[e for e in scene.get('elevations',[]) if e['room']==rid and e['direction']==side] if len(refs)==1: ref=refs[0];opening['elevation']=ref['id'];opening['elevationSheet']=ref.get('sheet') for item in components[opening_start:]: item['elevation']=ref['id'];item['elevationSource']=ref.get('source','') item['indexEvidence']={key:ref.get(key) for key in ('indexHandle','leaderHandle','targetHandle') if ref.get(key)} # Product recipes are separate from structural/finish assemblies. for recipe in scene.get('furniture',[]): start=len(components) rid=recipe['room'];cx,cy=recipe['position'];w,dep=recipe['size'];code=recipe['id'];kind=recipe['type'];src=recipe['source'] if kind=='bed': rounded(code+'-base','床架',rid,[cx,cy,.2],[w,dep,.35],'WD-1001',source=src) rounded(code+'-mattress','床垫',rid,[cx,cy,.48],[w-.06,dep-.04,.23],'@fabric',source=src) rounded(code+'-duvet','床品',rid,[cx,cy-.24,.62],[w-.04,dep*.7,.08],'@fabric',source=src) rounded(code+'-headboard','床头软包',rid,[cx,cy+dep/2,.72],[w+.12,.09,1.35],'UP-1002',source=src) for sign in (-1,1): rounded(code+'-pillow-'+str(sign),'枕头',rid,[cx+sign*w*.24,cy+dep*.3,.66],[w*.4,.42,.12],'@fabric',source=src) rounded(code+'-nightstand-'+str(sign),'床头柜',rid,[cx+sign*(w/2+.3),cy+dep*.32,.28],[.46,.46,.55],'WD-1001',source=src) elif kind=='sofa': rounded(code+'-base','沙发底座',rid,[cx,cy,.22],[w,dep,.35],'@fabric',source=src) rounded(code+'-back','沙发靠背',rid,[cx,cy+dep/2-.1,.65],[w,.2,.75],'@fabric',source=src) for i in range(3):rounded(code+'-seat-'+str(i),'沙发坐垫',rid,[cx-w/3+i*w/3,cy-.06,.47],[w/3-.02,dep-.22,.2],'UP-1002',source=src) for sign in (-1,1):rounded(code+'-arm-'+str(sign),'沙发扶手',rid,[cx+sign*(w/2-.08),cy,.5],[.18,dep,.54],'@fabric',source=src) elif kind in ('table','dining'): rounded(code+'-top','餐桌' if kind=='dining' else '茶几',rid,[cx,cy,.75 if kind=='dining' else .4],[w,dep,.045],'ST-1001',source=src) for ix in (-1,1): for iy in (-1,1):add(f'{code}-leg-{ix}-{iy}','桌腿',rid,[cx+ix*w*.35,cy+iy*dep*.32,.35 if kind=='dining' else .18],[.05,.05,.7 if kind=='dining' else .36],'MT-1001',source=src) if kind=='dining': for k in range(4): a=k*math.pi/2;x=cx+math.cos(a)*(w/2+.32);y=cy+math.sin(a)*(dep/2+.32) rounded(code+'-chair-seat-'+str(k),'餐椅坐垫',rid,[x,y,.45],[.46,.46,.08],'UP-1002',source=src) rounded(code+'-chair-back-'+str(k),'餐椅靠背',rid,[x+math.cos(a)*.2,y+math.sin(a)*.2,.7],[.1 if abs(math.cos(a))>.5 else .46,.46 if abs(math.cos(a))>.5 else .1,.46],'UP-1002',source=src) for dx,dy in [(-.17,-.17),(.17,-.17),(-.17,.17),(.17,.17)]:add(f'{code}-chair-leg-{k}-{dx}-{dy}','椅腿',rid,[x+dx,y+dy,.22],[.025,.025,.44],'MT-1001',source=src) elif kind in ('cabinet','kitchen'): height=recipe.get('height',2.4 if kind=='cabinet' else .84) panel=.018 add(code+'-body','柜体背板',rid,[cx,cy+dep/2-panel/2,height/2],[w,panel,height],'WD-1001',kind='cabinet',source=src,verification='产品外形占位;柜体构造待核审') for side in (-1,1): add(f'{code}-side-{side}','柜体侧板',rid,[cx+side*(w/2-panel/2),cy,height/2],[panel,dep,height],'WD-1001',kind='cabinet',source=src,verification='产品外形占位;柜体构造待核审') for side in (-1,1): add(f'{code}-cap-{side}','柜体顶底板',rid,[cx,cy, (height-panel/2) if side>0 else panel/2],[w,dep,panel],'WD-1001',kind='cabinet',source=src,verification='产品外形占位;柜体构造待核审') count=max(2,round(w/.45)) for i in range(count): x=cx-w/2+(i+.5)*w/count add(code+'-door-'+str(i),'柜门',rid,[x,cy-dep/2-.012,height/2],[w/count-.004,.024,height-.02],'WD-1001',kind='cabinet',source=src) rod(code+'-handle-'+str(i),'柜门拉手',rid,[x+.12,cy-dep/2-.03,.9],[x+.12,cy-dep/2-.03,1.06],.006,source=src) if kind=='kitchen': add(code+'-counter','厨房台面',rid,[cx,cy,height+.018],[w+.02,dep+.02,.036],'ST-1001',source=src) add(code+'-hob','灶具',rid,[cx+.3,cy,height+.045],[.6,.42,.035],'@dark',source=src) for dx in (-.18,.18):add(code+'-burner-'+str(dx),'灶头',rid,[cx+.3+dx,cy,height+.07],[.14,.14,.015],'@metal',shape='cylinder',source=src) angle=math.radians(recipe.get('rotation',0)) if angle: def turn(p):return [cx+(p[0]-cx)*math.cos(angle)-(p[1]-cy)*math.sin(angle),cy+(p[0]-cx)*math.sin(angle)+(p[1]-cy)*math.cos(angle),p[2]] for item in components[start:]: item['position']=turn(item['position']);item['rotation']=[0,0,angle] if item['shape']=='rod':item['a']=turn(item['a']);item['b']=turn(item['b']) for room in scene['rooms']: if room['id'] not in ('bath','master-bath') and not room.get('bathroomRecipe'):continue if scene.get('bathroomDetailVersion',0)>=3: from bathroom_detail import build build(scene,room,add,rod);continue rid=room['id'];b=room['bounds'];x0,y0,x1,y1=b;cx=(x0+x1)/2;h=room['height'];node='06 卫生间大样 / DT-T.02 06、07;立面32' # Local cabinet width runs along the west wall Y; depth runs X. products=scene.get('bathroomProducts',{}).get(rid,{}) width=products.get('vanity_width',.79 if rid=='bath' else .82);depth=products.get('vanity_depth',.55);vy=y0+width/2+.04;vx=x0+depth/2 add(rid+'-vanity-base','洗手柜底板',rid,[vx,vy,.35],[depth,width,.018],'WD-1001',source=node) add(rid+'-vanity-back','洗手柜背板',rid,[x0+.009,vy,.57],[.018,width,.46],'WD-1001',source=node) for sign in (-1,1):add(rid+'-vanity-side-'+str(sign),'洗手柜侧板',rid,[vx,vy+sign*(width/2-.009),.57],[depth,.018,.46],'WD-1001',source=node) for i in range(2): y=vy-width/2+(i+.5)*width/2 add(f'{rid}-vanity-drawer-{i}','洗手柜抽屉',rid,[x0+depth+.01,y,.57],[.02,width/2-.004,.43],'UP-1002',source=node) rod(f'{rid}-vanity-handle-{i}','抽屉金属拉手',rid,[x0+depth+.025,y-.1,.71],[x0+depth+.025,y+.1,.71],.006,source=node) # Counter is four stone solids around the basin opening, not a solid box over a bowl. basinW=.47;basinD=.37;z=.85 for sign in (-1,1): add(rid+'-counter-side-'+str(sign),'台面开孔侧石',rid,[vx,vy+sign*(basinW/2+(width-basinW)/4),z],[depth,(width-basinW)/2,.018],'ST-1002',source=node) add(rid+'-counter-end-'+str(sign),'台面开孔端石',rid,[vx+sign*(basinD/2+(depth-basinD)/4),vy,z],[(depth-basinD)/2,basinW,.018],'ST-1002',source=node) add(rid+'-basin','台下盆',rid,[vx,vy,z-.02],[basinD,basinW,.16],'@ceramic',shape='bowl',source=node) add(rid+'-drain','台盆排水口',rid,[vx,vy,z-.175],[.035,.035,.008],'MT-1001',shape='cylinder',source=node) rod(rid+'-tap-stem','龙头立管',rid,[x0+.09,vy,.86],[x0+.09,vy,1.04],.014,source=node) rod(rid+'-tap-spout','龙头出水嘴',rid,[x0+.09,vy,1.04],[x0+.25,vy,1.04],.012,source=node) # DWG public mirror: 1440 overall, 80 light, 20 frame, 245/245/510 panels, 250 open side rack. mirrorW=products.get('mirror_width',1.44 if rid=='bath' else 1.62);my=y0+mirrorW/2+.04;bottom=1.05;mh=1.0;md=.15 add(rid+'-mirror-back','镜柜背板',rid,[x0+.012,my,bottom+mh/2],[.024,mirrorW,mh],'WD-1001',source='06卫生间大样 / 公卫生镜柜内分隔图') for sign in (-1,1): add(rid+'-mirror-side-'+str(sign),'镜柜侧板',rid,[x0+md/2,my+sign*(mirrorW/2-.01),bottom+mh/2],[md,.02,mh],'WD-1001',source=node) add(rid+'-mirror-cap-'+str(sign),'镜柜顶底板',rid,[x0+md/2,my,bottom+(mh if sign>0 else 0)],[md,mirrorW,.02],'WD-1001',source=node) openWidth=.25;left=y0+.04+.10;panels=[.245,.245,.51] if rid=='bath' else [.42,.42,.42] scale=(mirrorW-(.25+.1+.08))/(sum(panels)) panels=[p*scale for p in panels] for k,w in enumerate(panels): yy=left+w/2 add(f'{rid}-mirror-door-{k}','镜柜门清镜',rid,[x0+md+.002,yy,bottom+mh/2],[.004,w-.003,mh-.04],'MR-1001',source=node,verification='镜面4mm据物料书;门宽据DWG分格') add(f'{rid}-mirror-partition-{k}','镜柜竖隔板',rid,[x0+md/2,left-.01,bottom+mh/2],[md,.02,mh-.04],'WD-1001',source=node) left+=w+.02 rackY=my+mirrorW/2-openWidth/2-.015 for k,zoff in enumerate([.015,.215,.37,.655,.985]):add(f'{rid}-mirror-open-shelf-{k}','侧格搁板',rid,[x0+md/2,rackY,bottom+zoff],[md,openWidth,.005 if k not in (0,4) else .015],'ST-1002',source=node) for k,zoff in enumerate([.20,.48,.77]):add(f'{rid}-mirror-inner-shelf-{k}','镜柜内隔板',rid,[x0+md/2,my-.13,bottom+zoff],[md-.025,mirrorW-openWidth-.10,.02],'WD-1001',source=node) add(rid+'-mirror-light','镜柜灯带',rid,[x0+md+.004,y0+.08,bottom+mh/2],[.006,.025,mh-.06],'@light',source='06卫生间大样 / 成品硬灯条') add(rid+'-mirror-underglow','柜下灯带',rid,[x0+md-.01,my,bottom-.015],[.012,mirrorW-.05,.01],'@light',source=node) # Toilet is separate body, rim, seat/lid, wall mounting and flush plate. ty=min(y1-.95,vy+width/2+.46);tx=x0+.34 rounded(rid+'-wc-body','壁挂坐便器',rid,[tx,ty,.30],[.62,.38,.38],'@ceramic',shape='ellipsoid',source=node) add(rid+'-wc-rim','坐便器座圈',rid,[tx+.035,ty,.465],[.54,.36,.035],'@ceramic',shape='ring',inner=.72,source=node) add(rid+'-wc-opening','坐便器内腔',rid,[tx+.035,ty,.445],[.39,.25,.10],'@dark',shape='ellipsoid',source=node) add(rid+'-wc-flush','冲水面板',rid,[x0+.018,ty,1.0],[.02,.22,.14],'MT-1001',source=node) # Shower zone and 12mm glass panels at the north end. showerY=y1-.78 add(rid+'-shower-glass-fixed','淋浴固定玻璃',rid,[x0+.24,showerY,1.04],[.44,.012,2.08],'GL-1001',source='立面29 / GL-1001 12mm') add(rid+'-shower-glass-door','淋浴玻璃门',rid,[x0+.44+.325,showerY,1.04],[.65,.012,2.08],'GL-1001',source='立面29 / 门宽650') for zhinge in (.3,1.7): add(rid+'-glass-hinge-'+str(zhinge),'玻璃合页',rid,[x0+.44,showerY,zhinge],[.06,.035,.08],'MT-1001',source=node) rod(rid+'-glass-handle','淋浴门拉手',rid,[x0+.92,showerY-.035,.9],[x0+.92,showerY-.035,1.1],.009,source=node) sx=x0+.04;sy=y1-.36 rod(rid+'-shower-riser','淋浴升降杆',rid,[sx,sy,.95],[sx,sy,2.06],.012,source='立面32 / 淋浴五金') rod(rid+'-shower-arm','顶喷横管',rid,[sx,sy,2.06],[sx+.30,sy,2.06],.012,source=node) add(rid+'-shower-head','顶喷花洒',rid,[sx+.3,sy,2.04],[.22,.22,.025],'MT-1001',shape='cylinder',source=node) rod(rid+'-shower-mixer','淋浴混水阀',rid,[sx+.01,sy-.10,1.02],[sx+.01,sy+.10,1.02],.024,source=node) for k in range(16): a=k/16;b=(k+1)/16 p=lambda q:[sx+.035+.08*math.sin(q*math.pi),sy-.12+.23*q,.98-.40*math.sin(q*math.pi)] rod(f'{rid}-shower-hose-{k}','花洒软管',rid,p(a),p(b),.007,source=node) add(rid+'-floor-drain','淋浴地漏',rid,[(x0+x1)/2,y1-.18,.014],[.10,.10,.012],'MT-1001',source=node) for k in range(5):add(f'{rid}-drain-slot-{k}','地漏格栅',rid,[(x0+x1)/2-.036+k*.018,y1-.18,.022],[.004,.08,.004],'@dark',source=node) add(rid+'-shower-threshold','挡水条',rid,[(x0+x1)/2,showerY,.025],[x1-x0,.06,.04],'ST-1002',source='06卫生间大样 / 地面石材收口') # Explicit metal edge trims and waterproof/substrate attribution. for side,x in [('west',x0+.002),('east',x1-.002)]:add(rid+'-edge-'+side,'金属收边',rid,[x,showerY,h/2],[.001,.02,h],'MT-1001',source='MT-1001 1mm / 立面31、32') if scene.get('bathroomDetailVersion',0)>=3: for component in components: room=next((r for r in scene['rooms'] if r['id']==component['room']),None) shift=room.get('finishedFloorElevation',-.01 if component['room']=='bath' else 0) if room else 0 if shift: component['position'][2]=round(component['position'][2]+shift,6) if component['shape']=='rod': for endpoint in ('a','b'):component[endpoint][2]=round(component[endpoint][2]+shift,6) next(r for r in scene['rooms'] if r['id']=='bath')['finishedFloorElevation']=-.01 # User-confirmed overrides apply to registered components only. by_id={c['id']:c for c in components} for code,values in scene.get('overrides',{}).items(): if code not in by_id:raise ValueError('微调目标不存在:'+code) c=by_id[code] for field,value in values.items(): if field in ('material','elevation'):c[field]=value elif field in ('width','depth','height'):c['size'][('width','depth','height').index(field)]=float(value) elif field in ('position_x','position_y','position_z'):c['position'][('position_x','position_y','position_z').index(field)]=float(value) else:raise ValueError('不支持的微调字段') c['verification']='经用户确认的微调方案;保留原始图纸依据' for component in components: if component['room'] in ('bath','master-bath') and not component.get('elevation'): code=component['id'] refs={e['direction']:e['id'] for e in scene.get('elevations',[]) if e['room']==component['room']} if any(token in code for token in ('-glass-','-shower-glass','-shower-fixed','-shower-door','-shower-return')):component['elevation']=refs.get('north','') elif any(token in code for token in ('-mirror-','-vanity-','-counter-','-basin','-wc-','-tap-','-shower-','-telephone')):component['elevation']=refs.get('west','') elif '-towel-' in code:component['elevation']=refs.get('east','') scene['components']=components;scene['dimensionComparison']=comparisons scene['materialProfiles']={m['id']:profile(m['id']) for m in scene['materials']} scene['designAudit']=audit(scene) return scene