Use shallow copy for arraying
Boost performance. Experimental.
This commit is contained in:
parent
a83d441f79
commit
b0ff5547a4
|
@ -141,17 +141,17 @@ class LatticeFeature():
|
|||
obj.Placement = App.Placement()
|
||||
|
||||
if bExposing:
|
||||
obj.Shape = marker.copy()
|
||||
obj.Shape = shallow_copy(marker)
|
||||
obj.Placement = plms[0]
|
||||
else:
|
||||
for plm in plms:
|
||||
sh = marker.copy()
|
||||
sh = shallow_copy(marker)
|
||||
sh.Placement = plm
|
||||
shapes.append(sh)
|
||||
|
||||
if len(shapes) == 0:
|
||||
obj.Shape = lattice2Markers.getNullShapeShape(markerSize)
|
||||
raise ValueError('Lattice object is null') #Feeding empty compounds to FreeCAD seems to cause rendering issues, otherwise it would have been a good idea to output nothing.
|
||||
raise ValueError('Lattice object is null')
|
||||
|
||||
sh = Part.makeCompound(shapes)
|
||||
obj.Shape = sh
|
||||
|
|
|
@ -81,6 +81,23 @@ def deselect(sel):
|
|||
for selobj in sel:
|
||||
FreeCADGui.Selection.removeSelection(selobj.Object)
|
||||
|
||||
def shallow_copy(shape):
|
||||
copiers = {
|
||||
"Vertex": lambda(sh): sh.Vertexes[0],
|
||||
"Edge": lambda(sh): sh.Edges[0],
|
||||
"Wire": lambda(sh): sh.Wires[0],
|
||||
"Face": lambda(sh): sh.Faces[0],
|
||||
"Shell": lambda(sh): sh.Shells[0],
|
||||
"Solid": lambda(sh): sh.Solids[0],
|
||||
"CompSolid": lambda(sh): sh.CompSolids[0],
|
||||
"Compound": lambda(sh): sh.Compounds[0],
|
||||
}
|
||||
copier = copiers.get(shape.ShapeType)
|
||||
if copier is None:
|
||||
copier = lambda(sh): sh.copy()
|
||||
FreeCAD.Console.PrintWarning("Lattice2: shallow_copy: unexpected shape type '{typ}'. Using deep copy instead.\n".format(typ= shape.ShapeType))
|
||||
return copier(shape)
|
||||
|
||||
# OCC's Precision::Confusion; should have taken this from FreeCAD but haven't found; unlikely to ever change.
|
||||
DistConfusion = 1e-7
|
||||
ParaConfusion = 1e-8
|
||||
|
|
|
@ -106,7 +106,7 @@ class LatticePopulateChildren(lattice2BaseFeature.LatticeFeature):
|
|||
objectPlm = objectPlms[iChild]
|
||||
outputPlms.append(plm.multiply(objectPlm))
|
||||
else:
|
||||
outputShape = objectShapes[iChild].copy()
|
||||
outputShape = shallow_copy(objectShapes[iChild])
|
||||
outputShape.Placement = plm.multiply(outputShape.Placement)
|
||||
outputShapes.append(outputShape)
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
|
|||
for objectPlm in objectPlms:
|
||||
outputPlms.append(plm.multiply(objectPlm))
|
||||
else:
|
||||
outputShape = objectShape.copy()
|
||||
outputShape = shallow_copy(objectShape)
|
||||
outputShape.Placement = plm.multiply(outputShape.Placement)
|
||||
outputShapes.append(outputShape)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user