kopia lustrzana https://github.com/vilemduha/blendercam
-pencil strategy improvements
rodzic
f321369818
commit
b9190710e0
|
@ -1025,16 +1025,15 @@ def getOffsetImageEdges(o,i):#for pencil operation mainly
|
|||
#if bpy.app.debug_value==2:
|
||||
|
||||
ar=numpy.logical_or(vertical,horizontal)
|
||||
#dilateAr(ar,0)
|
||||
dilateAr(ar,1)
|
||||
|
||||
iname=getCachePath(o)+'_pencilthres.exr'
|
||||
numpysave(ar,iname)#save for comparison before
|
||||
chunks = crazyStrokeImage(o,ar)
|
||||
iname=getCachePath(o)+'_pencilthres_comp.exr'
|
||||
#iname=getCachePath(o)+'_pencilthres.exr'
|
||||
#numpysave(ar,iname)#save for comparison before
|
||||
#chunks = crazyStrokeImage(o,ar)
|
||||
#iname=getCachePath(o)+'_pencilthres_comp.exr'
|
||||
#numpysave(ar,iname)#and after
|
||||
|
||||
numpysave(ar,iname)#and after
|
||||
|
||||
#chunks=imageToChunks(o,ar)
|
||||
chunks=imageToChunks(o,ar)
|
||||
#chunks=imageToChunksPencil(o,ar)
|
||||
for ch in chunks:#convert 2d chunks to 3d
|
||||
for i,p in enumerate(ch.points):
|
||||
|
@ -1051,10 +1050,35 @@ def getOffsetImageEdges(o,i):#for pencil operation mainly
|
|||
if len(chunk.points)<2:
|
||||
chunks.pop(chi)
|
||||
|
||||
|
||||
#progress(len(polys))
|
||||
#progress(polys[0])
|
||||
return chunks
|
||||
|
||||
def chunksCoherency(chunks):
|
||||
#checks chunks for their stability, for pencil path. it checks if the vectors direction doesn't jump too much too quickly, if this happens it splits the chunk on such places, too much jumps = deletion of the chunk. this is because otherwise the router has to slow down too often, but also means that some parts won't be milled
|
||||
nchunks=[]
|
||||
for chunk in chunks:
|
||||
if len(chunk.points)>2:
|
||||
nchunk=camPathChunk([])
|
||||
|
||||
#doesn't check for 1 point chunks here, they shouldn't get here at all.
|
||||
lastvec=Vector(chunk.points[1])-Vector(chunk.points[0])
|
||||
for i in range(0,len(chunk.points)-1):
|
||||
nchunk.points.append(chunk.points[i])
|
||||
vec=Vector(chunk.points[i+1])-Vector(chunk.points[i])
|
||||
angle=vec.angle(lastvec,vec)
|
||||
#print(angle,i)
|
||||
if angle>1.05:#60 degrees is maximum toleration for pencil paths.
|
||||
if len(nchunk.points)>4:#this is a testing threshold
|
||||
nchunks.append(nchunk)
|
||||
nchunk=camPathChunk([])
|
||||
lastvec=vec
|
||||
if len(nchunk.points)>4:#this is a testing threshold
|
||||
nchunks.append(nchunk)
|
||||
return nchunks
|
||||
|
||||
|
||||
|
||||
def crazyStrokeImage(o,ar):
|
||||
t=time.time()
|
||||
|
@ -1093,7 +1117,7 @@ def crazyStrokeImage(o,ar):
|
|||
itests=0
|
||||
totaltests=0
|
||||
maxtests=500
|
||||
maxtotaltests=300000
|
||||
maxtotaltests=1000000
|
||||
xs=nchunk.points[-1][0]
|
||||
ys=nchunk.points[-1][1]
|
||||
|
||||
|
@ -2709,10 +2733,10 @@ def sortChunks(chunks,o):
|
|||
chunks.remove(ch)
|
||||
|
||||
mergedist=2*o.dist_between_paths
|
||||
if o.strategy=='PENCIL':
|
||||
mergedist=2*o.dist_between_paths
|
||||
if o.strategy=='PENCIL':#this is bigger for pencil path since it goes on the surface to clean up the rests, and can go to close points on the surface without fear of going deep into material.
|
||||
mergedist=10*o.dist_between_paths
|
||||
if o.stay_low and lastch!=None and (ch.dist(pos,o)<mergedist or (o.parallel_step_back and ch.dist(pos,o)<4*o.dist_between_paths)):
|
||||
if o.strategy=='PARALLEL' or o.strategy=='CROSS':# for these paths sorting happens after sampling, thats why they need resample the connection
|
||||
if o.strategy=='PARALLEL' or o.strategy=='CROSS' or o.strategy=='PENCIL':# for these paths sorting happens after sampling, thats why they need resample the connection
|
||||
between=samplePathLow(o,lastch,ch,True)
|
||||
else:
|
||||
between=samplePathLow(o,lastch,ch,False)#other paths either dont use sampling or are sorted before it.
|
||||
|
@ -4235,7 +4259,10 @@ def getPaths(context,operation):#should do all path calculations.
|
|||
layers=[[layerstart,layerend]]
|
||||
|
||||
chunks.extend(sampleChunks(o,pathSamples,layers))
|
||||
if (o.strategy=='PARALLEL' or o.strategy=='CROSS'):# and not o.parallel_step_back:
|
||||
if (o.strategy=='PENCIL'):# and bpy.app.debug_value==-3:
|
||||
chunks=chunksCoherency(chunks)
|
||||
|
||||
if (o.strategy=='PARALLEL' or o.strategy=='CROSS') or o.strategy=='PENCIL':# and not o.parallel_step_back:
|
||||
chunks=sortChunks(chunks,o)
|
||||
#print(chunks)
|
||||
if o.strategy=='CARVE':
|
||||
|
|
Ładowanie…
Reference in New Issue