kopia lustrzana https://github.com/vilemduha/blendercam
more bridges fixing
rodzic
d6f30b13c5
commit
44996564bd
|
|
@ -2141,118 +2141,120 @@ def getBridgesPoly(o):
|
|||
|
||||
def useBridges(ch,o):
|
||||
'''this adds bridges to chunks, takes the bridge-objects group and uses the curves inside it as bridges.'''
|
||||
|
||||
|
||||
bridgegroupname=o.bridges_group_name
|
||||
bridgegroup=bpy.data.groups[bridgegroupname]
|
||||
if len(bridgegroup.objects)>0:
|
||||
|
||||
|
||||
#get bridgepoly
|
||||
getBridgesPoly(o)
|
||||
|
||||
####
|
||||
bridgeheight=min(0,o.min.z+o.bridges_height)
|
||||
vi=0
|
||||
#shapelyToCurve('test',bridgespoly,0)
|
||||
newpoints=[]
|
||||
p1=sgeometry.Point(ch.points[0])
|
||||
startinside = o.bridgespoly.contains(p1)
|
||||
interrupted = False
|
||||
while vi<len(ch.points):
|
||||
i1=vi
|
||||
i2=vi
|
||||
chp1=ch.points[i1]
|
||||
chp2=ch.points[i1]#Vector(v1)#this is for case of last point and not closed chunk..
|
||||
if vi+1<len(ch.points):
|
||||
i2 = vi+1
|
||||
chp2=ch.points[vi+1]#Vector(ch.points[vi+1])
|
||||
v1=Vector(chp1)
|
||||
v2=Vector(chp2)
|
||||
if v1.z<bridgeheight or v2.z<bridgeheight:
|
||||
v=v2-v1
|
||||
#dist+=v.length
|
||||
p2=sgeometry.Point(chp2)
|
||||
|
||||
if interrupted:
|
||||
p1=sgeometry.Point(chp1)
|
||||
startinside = o.bridgespoly.contains(p1)
|
||||
interrupted = False
|
||||
#get bridgepoly
|
||||
getBridgesPoly(o)
|
||||
|
||||
####
|
||||
bridgeheight=min(0,o.min.z+o.bridges_height)
|
||||
vi=0
|
||||
#shapelyToCurve('test',bridgespoly,0)
|
||||
newpoints=[]
|
||||
p1=sgeometry.Point(ch.points[0])
|
||||
startinside = o.bridgespoly.contains(p1)
|
||||
interrupted = False
|
||||
while vi<len(ch.points):
|
||||
i1=vi
|
||||
i2=vi
|
||||
chp1=ch.points[i1]
|
||||
chp2=ch.points[i1]#Vector(v1)#this is for case of last point and not closed chunk..
|
||||
if vi+1<len(ch.points):
|
||||
i2 = vi+1
|
||||
chp2=ch.points[vi+1]#Vector(ch.points[vi+1])
|
||||
v1=Vector(chp1)
|
||||
v2=Vector(chp2)
|
||||
if v1.z<bridgeheight or v2.z<bridgeheight:
|
||||
v=v2-v1
|
||||
#dist+=v.length
|
||||
p2=sgeometry.Point(chp2)
|
||||
|
||||
|
||||
endinside = o.bridgespoly.contains(p2)
|
||||
l=sgeometry.LineString([chp1,chp2])
|
||||
#print(dir(bridgespoly_boundary))
|
||||
if o.bridgespoly_boundary.intersects(l):
|
||||
#print('intersects')
|
||||
intersections = o.bridgespolyorig.boundary.intersection(l)
|
||||
else:
|
||||
intersections = sgeometry.GeometryCollection()
|
||||
|
||||
itempty = intersections.type == 'GeometryCollection'
|
||||
itpoint = intersections.type == 'Point'
|
||||
itmpoint = intersections.type == 'MultiPoint'
|
||||
|
||||
#print(startinside, endinside,intersections, intersections.type)
|
||||
#print(l,bridgespoly)
|
||||
if not startinside:
|
||||
#print('nothing found')
|
||||
|
||||
newpoints.append(chp1)
|
||||
#elif startinside and endinside and itempty:
|
||||
# newpoints.append((chp1[0],chp1[1],max(chp1[2],bridgeheight)))
|
||||
elif startinside:
|
||||
newpoints.append((chp1[0],chp1[1],max(chp1[2],bridgeheight)))
|
||||
#elif not startinside:
|
||||
# newpoints.append(chp1)
|
||||
cpoints=[]
|
||||
if itpoint:
|
||||
cpoints= [Vector((intersections.x,intersections.y,intersections.z))]
|
||||
elif itmpoint:
|
||||
cpoints=[]
|
||||
for p in intersections:
|
||||
cpoints.append(Vector((p.x,p.y,p.z)))
|
||||
#####sort collisions here :(
|
||||
ncpoints=[]
|
||||
while len(cpoints)>0:
|
||||
mind=10000000
|
||||
mini=-1
|
||||
for i,p in enumerate(cpoints):
|
||||
if min(mind, (p-v1).length)<mind:
|
||||
mini=i
|
||||
mind= (p-v1).length
|
||||
ncpoints.append(cpoints.pop(mini))
|
||||
cpoints = ncpoints
|
||||
#endsorting
|
||||
|
||||
|
||||
if startinside:
|
||||
isinside=True
|
||||
else:
|
||||
isinside=False
|
||||
for cp in cpoints:
|
||||
v3= cp
|
||||
#print(v3)
|
||||
if v.length==0:
|
||||
ratio=1
|
||||
else:
|
||||
fractvect = v3 - v1
|
||||
ratio = fractvect.length/v.length
|
||||
if interrupted:
|
||||
p1=sgeometry.Point(chp1)
|
||||
startinside = o.bridgespoly.contains(p1)
|
||||
interrupted = False
|
||||
|
||||
collisionz=v1.z+v.z*ratio
|
||||
np1 = (v3.x, v3.y, collisionz)
|
||||
np2 = (v3.x, v3.y, max(collisionz,bridgeheight))
|
||||
if not isinside:
|
||||
newpoints.extend((np1, np2))
|
||||
|
||||
endinside = o.bridgespoly.contains(p2)
|
||||
l=sgeometry.LineString([chp1,chp2])
|
||||
#print(dir(bridgespoly_boundary))
|
||||
if o.bridgespoly_boundary.intersects(l):
|
||||
#print('intersects')
|
||||
intersections = o.bridgespolyorig.boundary.intersection(l)
|
||||
else:
|
||||
newpoints.extend((np2, np1))
|
||||
isinside = not isinside
|
||||
intersections = sgeometry.GeometryCollection()
|
||||
|
||||
itempty = intersections.type == 'GeometryCollection'
|
||||
itpoint = intersections.type == 'Point'
|
||||
itmpoint = intersections.type == 'MultiPoint'
|
||||
|
||||
startinside = endinside
|
||||
p1=p2
|
||||
|
||||
vi+=1
|
||||
else:
|
||||
newpoints.append(chp1)
|
||||
vi+=1
|
||||
interrupted = True
|
||||
ch.points=newpoints
|
||||
#print(startinside, endinside,intersections, intersections.type)
|
||||
#print(l,bridgespoly)
|
||||
if not startinside:
|
||||
#print('nothing found')
|
||||
|
||||
newpoints.append(chp1)
|
||||
#elif startinside and endinside and itempty:
|
||||
# newpoints.append((chp1[0],chp1[1],max(chp1[2],bridgeheight)))
|
||||
elif startinside:
|
||||
newpoints.append((chp1[0],chp1[1],max(chp1[2],bridgeheight)))
|
||||
#elif not startinside:
|
||||
# newpoints.append(chp1)
|
||||
cpoints=[]
|
||||
if itpoint:
|
||||
cpoints= [Vector((intersections.x,intersections.y,intersections.z))]
|
||||
elif itmpoint:
|
||||
cpoints=[]
|
||||
for p in intersections:
|
||||
cpoints.append(Vector((p.x,p.y,p.z)))
|
||||
#####sort collisions here :(
|
||||
ncpoints=[]
|
||||
while len(cpoints)>0:
|
||||
mind=10000000
|
||||
mini=-1
|
||||
for i,p in enumerate(cpoints):
|
||||
if min(mind, (p-v1).length)<mind:
|
||||
mini=i
|
||||
mind= (p-v1).length
|
||||
ncpoints.append(cpoints.pop(mini))
|
||||
cpoints = ncpoints
|
||||
#endsorting
|
||||
|
||||
|
||||
if startinside:
|
||||
isinside=True
|
||||
else:
|
||||
isinside=False
|
||||
for cp in cpoints:
|
||||
v3= cp
|
||||
#print(v3)
|
||||
if v.length==0:
|
||||
ratio=1
|
||||
else:
|
||||
fractvect = v3 - v1
|
||||
ratio = fractvect.length/v.length
|
||||
|
||||
collisionz=v1.z+v.z*ratio
|
||||
np1 = (v3.x, v3.y, collisionz)
|
||||
np2 = (v3.x, v3.y, max(collisionz,bridgeheight))
|
||||
if not isinside:
|
||||
newpoints.extend((np1, np2))
|
||||
else:
|
||||
newpoints.extend((np2, np1))
|
||||
isinside = not isinside
|
||||
|
||||
startinside = endinside
|
||||
p1=p2
|
||||
|
||||
vi+=1
|
||||
else:
|
||||
newpoints.append(chp1)
|
||||
vi+=1
|
||||
interrupted = True
|
||||
ch.points=newpoints
|
||||
|
||||
|
||||
'''
|
||||
|
|
@ -2438,6 +2440,7 @@ def strategy_cutout( o ):
|
|||
|
||||
if o.use_bridges:#add bridges to chunks
|
||||
#bridges=getBridges(p,o)
|
||||
print('using bridges')
|
||||
bridgeheight=min(0,o.min.z+o.bridges_height)
|
||||
for chl in extendorder:
|
||||
chunk=chl[0]
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue