From 8d0d0b77a6099dadea0c02937bc061691ab03eab Mon Sep 17 00:00:00 2001 From: "vilda.novak@gmail.com" Date: Fri, 23 Aug 2013 16:32:34 +0000 Subject: [PATCH] - bridges for cutout operation are now working, I think it's quite comfortable since they are totally automatic. They don't work well with ramp down and ramp out yet... --- scripts/addons/cam/__init__.py | 8 ++- scripts/addons/cam/utils.py | 112 ++++++++++++++++++++++++--------- 2 files changed, 87 insertions(+), 33 deletions(-) diff --git a/scripts/addons/cam/__init__.py b/scripts/addons/cam/__init__.py index d737a4f0..5fee5f4e 100644 --- a/scripts/addons/cam/__init__.py +++ b/scripts/addons/cam/__init__.py @@ -295,9 +295,10 @@ class camOperation(bpy.types.PropertyGroup): #chip_rate #bridges use_bridges = bpy.props.BoolProperty(name="Use bridges",description="use bridges in cutout", default=False, update = updateBridges) - bridges_width = bpy.props.FloatProperty(name = 'width of bridges', default=0.003, unit='LENGTH', precision=PRECISION, update = updateBridges) - bridges_per_curve = bpy.props.IntProperty(name="bridges per curve object", description="", default=3, min=1, max=512, update = updateBridges) - bridges_max_distance = bpy.props.FloatProperty(name = 'Maximum distance between bridges', default=0.1, unit='LENGTH', precision=PRECISION, update = updateBridges) + bridges_width = bpy.props.FloatProperty(name = 'width of bridges', default=0.002, unit='LENGTH', precision=PRECISION, update = updateBridges) + bridges_height = bpy.props.FloatProperty(name = 'height of bridges', description="Height from the bottom of the cutting operation", default=0.0005, unit='LENGTH', precision=PRECISION, update = updateBridges) + bridges_per_curve = bpy.props.IntProperty(name="minimum bridges per curve", description="", default=4, min=1, max=512, update = updateBridges) + bridges_max_distance = bpy.props.FloatProperty(name = 'Maximum distance between bridges', default=0.08, unit='LENGTH', precision=PRECISION, update = updateBridges) #optimisation panel #material settings @@ -1291,6 +1292,7 @@ class CAM_OPERATION_PROPERTIES_Panel(bpy.types.Panel): layout.prop(ao,'use_bridges') if ao.use_bridges: layout.prop(ao,'bridges_width') + layout.prop(ao,'bridges_height') layout.prop(ao,'bridges_per_curve') layout.prop(ao,'bridges_max_distance') diff --git a/scripts/addons/cam/utils.py b/scripts/addons/cam/utils.py index 5e6a71b9..d9973ece 100644 --- a/scripts/addons/cam/utils.py +++ b/scripts/addons/cam/utils.py @@ -1997,33 +1997,7 @@ def doSimulation(name,operations): disp.texture=t ob.hide_render=True -''' -def setupBridges(o): - oname='cam_bridge_'+o.name - - verts=[] - chunks=[] - for ob in o.objects: - #p=curveToPoly(o) - - chunks.extend(curveToChunks(ob)) - - mesh = bpy.data.meshes.new(oname) - mesh.name=oname - mesh.from_pydata(verts, edges, []) - #if o.path!='' and o.path in s.objects: - # s.objects[oname].data=mesh - #el - if oname in s.objects: - s.objects[oname].data=mesh - else: - ob=object_utils.object_data_add(bpy.context, mesh, operator=None) - - ob=s.objects[mesh.name] - ob.location=(0,0,0) - - ob.hide_render=True -''' + def chunksToMesh(chunks,o): ##########convert sampled chunks to path, optimization of paths s=bpy.context.scene @@ -2515,11 +2489,13 @@ class camPathChunk: def getLength(self): self.length=0 + for vi,v1 in enumerate(self.points): + #print(len(self.points),vi) v2=Vector(v1)#this is for case of last point and not closed chunk.. if self.closed and vi==len(self.points)-1: v2=Vector(self.points[0]) - else: + elif vipoint1.z: + point1.z=min(point1.z,bridgeheight) + point2.z=max(point2.z,bridgeheight) + #ch.points.insert(vi-1,point1) + #ch.points.insert(vi,point2) + insertpoints.append([vi+1,point1.to_tuple()]) + insertpoints.append([vi+1,point2.to_tuple()]) + inbridge=True + + if wasinbridge and inbridge:#still in bridge, raise the point up.# + changepoints.append([vi,(v1.x,v1.y,max(v1.z,bridgeheight))]) + #ch.points[vi]=(v1.x,v1.y,max(v1.z,bridgeheight)) + + if inbridge and pos[posi][1]point1.z: + point1.z=max(point1.z,bridgeheight) + point2.z=min(point2.z,bridgeheight) + #ch.points.insert(vi,point1) + #ch.points.insert(vi+1,point2) + #vi+=2 + insertpoints.append([vi+1,point1.to_tuple()]) + insertpoints.append([vi+1,point2.to_tuple()]) + inbridge=False + posi+=1 + vi-=1 + dist-=v.length + vi+=1 + + + + + if posi>=len(pos): + print('added bridges') + break; + for p in changepoints: + ch.points[p[0]]=p[1] + for pi in range(len(insertpoints)-1,-1,-1): + ch.points.insert(insertpoints[pi][0],insertpoints[pi][1]) #this is the main function. def getPaths(context,operation):#should do all path calculations. @@ -3824,7 +3873,10 @@ def getPaths(context,operation):#should do all path calculations. else: for step in steps: chunks.extend(setChunksZ(chunksFromCurve,step[1])) - + if o.use_bridges: + for ch in chunks: + addBridges(ch,o,0) + if bpy.app.debug_value==0 or bpy.app.debug_value==1 or bpy.app.debug_value==3 or bpy.app.debug_value==2:# or bpy.app.debug_value==4: chunksToMesh(chunks,o) '''#bridge stuff from carve strategy: