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()
|
obj.Placement = App.Placement()
|
||||||
|
|
||||||
if bExposing:
|
if bExposing:
|
||||||
obj.Shape = marker.copy()
|
obj.Shape = shallow_copy(marker)
|
||||||
obj.Placement = plms[0]
|
obj.Placement = plms[0]
|
||||||
else:
|
else:
|
||||||
for plm in plms:
|
for plm in plms:
|
||||||
sh = marker.copy()
|
sh = shallow_copy(marker)
|
||||||
sh.Placement = plm
|
sh.Placement = plm
|
||||||
shapes.append(sh)
|
shapes.append(sh)
|
||||||
|
|
||||||
if len(shapes) == 0:
|
if len(shapes) == 0:
|
||||||
obj.Shape = lattice2Markers.getNullShapeShape(markerSize)
|
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)
|
sh = Part.makeCompound(shapes)
|
||||||
obj.Shape = sh
|
obj.Shape = sh
|
||||||
|
|
|
@ -81,6 +81,23 @@ def deselect(sel):
|
||||||
for selobj in sel:
|
for selobj in sel:
|
||||||
FreeCADGui.Selection.removeSelection(selobj.Object)
|
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.
|
# OCC's Precision::Confusion; should have taken this from FreeCAD but haven't found; unlikely to ever change.
|
||||||
DistConfusion = 1e-7
|
DistConfusion = 1e-7
|
||||||
ParaConfusion = 1e-8
|
ParaConfusion = 1e-8
|
||||||
|
|
|
@ -106,7 +106,7 @@ class LatticePopulateChildren(lattice2BaseFeature.LatticeFeature):
|
||||||
objectPlm = objectPlms[iChild]
|
objectPlm = objectPlms[iChild]
|
||||||
outputPlms.append(plm.multiply(objectPlm))
|
outputPlms.append(plm.multiply(objectPlm))
|
||||||
else:
|
else:
|
||||||
outputShape = objectShapes[iChild].copy()
|
outputShape = shallow_copy(objectShapes[iChild])
|
||||||
outputShape.Placement = plm.multiply(outputShape.Placement)
|
outputShape.Placement = plm.multiply(outputShape.Placement)
|
||||||
outputShapes.append(outputShape)
|
outputShapes.append(outputShape)
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ class LatticePopulateCopies(lattice2BaseFeature.LatticeFeature):
|
||||||
for objectPlm in objectPlms:
|
for objectPlm in objectPlms:
|
||||||
outputPlms.append(plm.multiply(objectPlm))
|
outputPlms.append(plm.multiply(objectPlm))
|
||||||
else:
|
else:
|
||||||
outputShape = objectShape.copy()
|
outputShape = shallow_copy(objectShape)
|
||||||
outputShape.Placement = plm.multiply(outputShape.Placement)
|
outputShape.Placement = plm.multiply(outputShape.Placement)
|
||||||
outputShapes.append(outputShape)
|
outputShapes.append(outputShape)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user