def killSkinny(refineFun = method(:sizeFunc).to_proc)
dput "Starting Kill Skinny"
skiTris = Array.new
@mesh.iterate(2) do |t|
skiTris.push(t) if (isSkinny?(t) || refineFun.call(@mesh, t))
end
trisKilled = 0
ttkillin = 0.0
while (skiTris.length > 0 && trisKilled < @killThresh)
st = skiTris.shift
if @mesh.member? st
p1 = st.controlPoints[0]
p2 = st.controlPoints[2]
p3 = st.controlPoints[6]
cc = Utilities.circumcircle(p1,p2,p3)
location= @mesh.locatePoint(cc,st)
if $CLEANDEBUG
@mesh.drawPoint(cc, col = [0,0.5,0],psize = 10.0, swapBufs = true)
end
ta1 = Time.new.to_f
newTris = []
if (location[0] == 1)
newTris = @mesh.insertClean(location[1],location[2],location[3])
newTris.each {|t|
skiTris.push(t) if (isSkinny?(t) || refineFun.call(@mesh, t))
}
elsif (location[0] == 0)
dput "Inserting mid"
newTris = @mesh.insertCleanMid(location[1],location[2])
newTris.each {|t|
skiTris.push(t) if (isSkinny? (t) || refineFun.call(@mesh, t))
}
else
dput "Locate failed, point insertion fails."
end
trisKilled += 1
dput "Have killed #{trisKilled} triangles" if ((trisKilled)%50 == 0)
ta = Time.new.to_f - ta1
ttkillin += ta
end
end
dput "Average kill time to kill #{trisKilled} triangles = #{ttkillin / trisKilled}"
puts "Triangle killing threshold #{@killThresh} met, no more refinement" if trisKilled >= @killThresh
end